1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
14 #include <sys/socket.h>
15 #include <netinet/in.h>
17 #include <sys/queue.h>
19 #include <rte_common.h>
20 #include <rte_byteorder.h>
22 #include <rte_debug.h>
23 #include <rte_cycles.h>
24 #include <rte_memory.h>
25 #include <rte_memzone.h>
26 #include <rte_malloc.h>
27 #include <rte_launch.h>
29 #include <rte_per_lcore.h>
30 #include <rte_lcore.h>
31 #include <rte_atomic.h>
32 #include <rte_branch_prediction.h>
34 #include <rte_mempool.h>
35 #include <rte_interrupts.h>
37 #include <rte_ether.h>
38 #include <rte_ethdev.h>
39 #include <rte_string_fns.h>
40 #include <rte_devargs.h>
43 #include <rte_mbuf_dyn.h>
45 #include <cmdline_rdline.h>
46 #include <cmdline_parse.h>
47 #include <cmdline_parse_num.h>
48 #include <cmdline_parse_string.h>
49 #include <cmdline_parse_ipaddr.h>
50 #include <cmdline_parse_etheraddr.h>
51 #include <cmdline_socket.h>
53 #ifdef RTE_LIBRTE_PMD_BOND
54 #include <rte_eth_bond.h>
55 #include <rte_eth_bond_8023ad.h>
57 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
58 #include <rte_pmd_dpaa.h>
60 #ifdef RTE_LIBRTE_IXGBE_PMD
61 #include <rte_pmd_ixgbe.h>
63 #ifdef RTE_LIBRTE_I40E_PMD
64 #include <rte_pmd_i40e.h>
66 #ifdef RTE_LIBRTE_BNXT_PMD
67 #include <rte_pmd_bnxt.h>
70 #include "cmdline_mtr.h"
71 #include "cmdline_tm.h"
74 static struct cmdline *testpmd_cl;
76 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
78 /* *** Help command with introduction. *** */
79 struct cmd_help_brief_result {
80 cmdline_fixed_string_t help;
83 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
85 __rte_unused void *data)
90 "Help is available for the following sections:\n\n"
91 " help control : Start and stop forwarding.\n"
92 " help display : Displaying port, stats and config "
94 " help config : Configuration information.\n"
95 " help ports : Configuring ports.\n"
96 " help registers : Reading and setting port registers.\n"
97 " help filters : Filters configuration help.\n"
98 " help traffic_management : Traffic Management commands.\n"
99 " help devices : Device related cmds.\n"
100 " help all : All of the above sections.\n\n"
105 cmdline_parse_token_string_t cmd_help_brief_help =
106 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
108 cmdline_parse_inst_t cmd_help_brief = {
109 .f = cmd_help_brief_parsed,
111 .help_str = "help: Show help",
113 (void *)&cmd_help_brief_help,
118 /* *** Help command with help sections. *** */
119 struct cmd_help_long_result {
120 cmdline_fixed_string_t help;
121 cmdline_fixed_string_t section;
124 static void cmd_help_long_parsed(void *parsed_result,
126 __rte_unused void *data)
129 struct cmd_help_long_result *res = parsed_result;
131 if (!strcmp(res->section, "all"))
134 if (show_all || !strcmp(res->section, "control")) {
139 "Control forwarding:\n"
140 "-------------------\n\n"
143 " Start packet forwarding with current configuration.\n\n"
146 " Start packet forwarding with current config"
147 " after sending one burst of packets.\n\n"
150 " Stop packet forwarding, and display accumulated"
154 " Quit to prompt.\n\n"
158 if (show_all || !strcmp(res->section, "display")) {
166 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
167 " Display information for port_id, or all.\n\n"
169 "show port X rss reta (size) (mask0,mask1,...)\n"
170 " Display the rss redirection table entry indicated"
171 " by masks on port X. size is used to indicate the"
172 " hardware supported reta size\n\n"
174 "show port (port_id) rss-hash [key]\n"
175 " Display the RSS hash functions and RSS hash key of port\n\n"
177 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
178 " Clear information for port_id, or all.\n\n"
180 "show (rxq|txq) info (port_id) (queue_id)\n"
181 " Display information for configured RX/TX queue.\n\n"
183 "show config (rxtx|cores|fwd|txpkts)\n"
184 " Display the given configuration.\n\n"
186 "read rxd (port_id) (queue_id) (rxd_id)\n"
187 " Display an RX descriptor of a port RX queue.\n\n"
189 "read txd (port_id) (queue_id) (txd_id)\n"
190 " Display a TX descriptor of a port TX queue.\n\n"
192 "ddp get list (port_id)\n"
193 " Get ddp profile info list\n\n"
195 "ddp get info (profile_path)\n"
196 " Get ddp profile information.\n\n"
198 "show vf stats (port_id) (vf_id)\n"
199 " Display a VF's statistics.\n\n"
201 "clear vf stats (port_id) (vf_id)\n"
202 " Reset a VF's statistics.\n\n"
204 "show port (port_id) pctype mapping\n"
205 " Get flow ptype to pctype mapping on a port\n\n"
207 "show port meter stats (port_id) (meter_id) (clear)\n"
208 " Get meter stats on a port\n\n"
210 "show fwd stats all\n"
211 " Display statistics for all fwd engines.\n\n"
213 "clear fwd stats all\n"
214 " Clear statistics for all fwd engines.\n\n"
216 "show port (port_id) rx_offload capabilities\n"
217 " List all per queue and per port Rx offloading"
218 " capabilities of a port\n\n"
220 "show port (port_id) rx_offload configuration\n"
221 " List port level and all queue level"
222 " Rx offloading configuration\n\n"
224 "show port (port_id) tx_offload capabilities\n"
225 " List all per queue and per port"
226 " Tx offloading capabilities of a port\n\n"
228 "show port (port_id) tx_offload configuration\n"
229 " List port level and all queue level"
230 " Tx offloading configuration\n\n"
232 "show port (port_id) tx_metadata\n"
233 " Show Tx metadata value set"
234 " for a specific port\n\n"
236 "show port (port_id) ptypes\n"
237 " Show port supported ptypes"
238 " for a specific port\n\n"
240 "show device info (<identifier>|all)"
241 " Show general information about devices probed.\n\n"
243 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
244 " Show status of rx|tx descriptor.\n\n"
246 "show port (port_id) macs|mcast_macs"
247 " Display list of mac addresses added to port.\n\n"
251 if (show_all || !strcmp(res->section, "config")) {
257 "Configuration changes only become active when"
258 " forwarding is started/restarted.\n\n"
261 " Reset forwarding to the default configuration.\n\n"
263 "set verbose (level)\n"
264 " Set the debug verbosity level X.\n\n"
266 "set log global|(type) (level)\n"
267 " Set the log level.\n\n"
270 " Set number of ports.\n\n"
273 " Set number of cores.\n\n"
275 "set coremask (mask)\n"
276 " Set the forwarding cores hexadecimal mask.\n\n"
278 "set portmask (mask)\n"
279 " Set the forwarding ports hexadecimal mask.\n\n"
282 " Set number of packets per burst.\n\n"
284 "set burst tx delay (microseconds) retry (num)\n"
285 " Set the transmit delay time and number of retries,"
286 " effective when retry is enabled.\n\n"
288 "set txpkts (x[,y]*)\n"
289 " Set the length of each segment of TXONLY"
290 " and optionally CSUM packets.\n\n"
292 "set txsplit (off|on|rand)\n"
293 " Set the split policy for the TX packets."
294 " Right now only applicable for CSUM and TXONLY"
297 "set txtimes (x, y)\n"
298 " Set the scheduling on timestamps"
299 " timings for the TXONLY mode\n\n"
301 "set corelist (x[,y]*)\n"
302 " Set the list of forwarding cores.\n\n"
304 "set portlist (x[,y]*)\n"
305 " Set the list of forwarding ports.\n\n"
307 "set port setup on (iterator|event)\n"
308 " Select how attached port is retrieved for setup.\n\n"
310 "set tx loopback (port_id) (on|off)\n"
311 " Enable or disable tx loopback.\n\n"
313 "set all queues drop (port_id) (on|off)\n"
314 " Set drop enable bit for all queues.\n\n"
316 "set vf split drop (port_id) (vf_id) (on|off)\n"
317 " Set split drop enable bit for a VF from the PF.\n\n"
319 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
320 " Set MAC antispoof for a VF from the PF.\n\n"
322 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
323 " Enable MACsec offload.\n\n"
325 "set macsec offload (port_id) off\n"
326 " Disable MACsec offload.\n\n"
328 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
329 " Configure MACsec secure connection (SC).\n\n"
331 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
332 " Configure MACsec secure association (SA).\n\n"
334 "set vf broadcast (port_id) (vf_id) (on|off)\n"
335 " Set VF broadcast for a VF from the PF.\n\n"
337 "vlan set stripq (on|off) (port_id,queue_id)\n"
338 " Set the VLAN strip for a queue on a port.\n\n"
340 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
341 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
343 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
344 " Set VLAN insert for a VF from the PF.\n\n"
346 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
347 " Set VLAN antispoof for a VF from the PF.\n\n"
349 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
350 " Set VLAN tag for a VF from the PF.\n\n"
352 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
353 " Set a VF's max bandwidth(Mbps).\n\n"
355 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
356 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
358 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
359 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
361 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
362 " Set some TCs' strict link priority mode on a physical port.\n\n"
364 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
365 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
367 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
368 " Set the VLAN strip or filter or qinq strip or extend\n\n"
370 "vlan set (inner|outer) tpid (value) (port_id)\n"
371 " Set the VLAN TPID for Packet Filtering on"
374 "rx_vlan add (vlan_id|all) (port_id)\n"
375 " Add a vlan_id, or all identifiers, to the set"
376 " of VLAN identifiers filtered by port_id.\n\n"
378 "rx_vlan rm (vlan_id|all) (port_id)\n"
379 " Remove a vlan_id, or all identifiers, from the set"
380 " of VLAN identifiers filtered by port_id.\n\n"
382 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
383 " Add a vlan_id, to the set of VLAN identifiers"
384 "filtered for VF(s) from port_id.\n\n"
386 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
387 " Remove a vlan_id, to the set of VLAN identifiers"
388 "filtered for VF(s) from port_id.\n\n"
390 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
391 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
392 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
393 " add a tunnel filter of a port.\n\n"
395 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
396 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
397 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
398 " remove a tunnel filter of a port.\n\n"
400 "rx_vxlan_port add (udp_port) (port_id)\n"
401 " Add an UDP port for VXLAN packet filter on a port\n\n"
403 "rx_vxlan_port rm (udp_port) (port_id)\n"
404 " Remove an UDP port for VXLAN packet filter on a port\n\n"
406 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
407 " Set hardware insertion of VLAN IDs (single or double VLAN "
408 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
410 "tx_vlan set pvid port_id vlan_id (on|off)\n"
411 " Set port based TX VLAN insertion.\n\n"
413 "tx_vlan reset (port_id)\n"
414 " Disable hardware insertion of a VLAN header in"
415 " packets sent on a port.\n\n"
417 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
418 " Select hardware or software calculation of the"
419 " checksum when transmitting a packet using the"
420 " csum forward engine.\n"
421 " ip|udp|tcp|sctp always concern the inner layer.\n"
422 " outer-ip concerns the outer IP layer in"
423 " outer-udp concerns the outer UDP layer in"
424 " case the packet is recognized as a tunnel packet by"
425 " the forward engine (vxlan, gre and ipip are supported)\n"
426 " Please check the NIC datasheet for HW limits.\n\n"
428 "csum parse-tunnel (on|off) (tx_port_id)\n"
429 " If disabled, treat tunnel packets as non-tunneled"
430 " packets (treat inner headers as payload). The port\n"
431 " argument is the port used for TX in csum forward"
434 "csum show (port_id)\n"
435 " Display tx checksum offload configuration\n\n"
437 "tso set (segsize) (portid)\n"
438 " Enable TCP Segmentation Offload in csum forward"
440 " Please check the NIC datasheet for HW limits.\n\n"
443 " Display the status of TCP Segmentation Offload.\n\n"
445 "set port (port_id) gro on|off\n"
446 " Enable or disable Generic Receive Offload in"
447 " csum forwarding engine.\n\n"
449 "show port (port_id) gro\n"
450 " Display GRO configuration.\n\n"
452 "set gro flush (cycles)\n"
453 " Set the cycle to flush GROed packets from"
454 " reassembly tables.\n\n"
456 "set port (port_id) gso (on|off)"
457 " Enable or disable Generic Segmentation Offload in"
458 " csum forwarding engine.\n\n"
460 "set gso segsz (length)\n"
461 " Set max packet length for output GSO segments,"
462 " including packet header and payload.\n\n"
464 "show port (port_id) gso\n"
465 " Show GSO configuration.\n\n"
468 " Set packet forwarding mode.\n\n"
470 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
471 " Add a MAC address on port_id.\n\n"
473 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
474 " Remove a MAC address from port_id.\n\n"
476 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
477 " Set the default MAC address for port_id.\n\n"
479 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
480 " Add a MAC address for a VF on the port.\n\n"
482 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
483 " Set the MAC address for a VF from the PF.\n\n"
485 "set eth-peer (port_id) (peer_addr)\n"
486 " set the peer address for certain port.\n\n"
488 "set port (port_id) uta (mac_address|all) (on|off)\n"
489 " Add/Remove a or all unicast hash filter(s)"
492 "set promisc (port_id|all) (on|off)\n"
493 " Set the promiscuous mode on port_id, or all.\n\n"
495 "set allmulti (port_id|all) (on|off)\n"
496 " Set the allmulti mode on port_id, or all.\n\n"
498 "set vf promisc (port_id) (vf_id) (on|off)\n"
499 " Set unicast promiscuous mode for a VF from the PF.\n\n"
501 "set vf allmulti (port_id) (vf_id) (on|off)\n"
502 " Set multicast promiscuous mode for a VF from the PF.\n\n"
504 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
505 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
506 " (on|off) autoneg (on|off) (port_id)\n"
507 "set flow_ctrl rx (on|off) (portid)\n"
508 "set flow_ctrl tx (on|off) (portid)\n"
509 "set flow_ctrl high_water (high_water) (portid)\n"
510 "set flow_ctrl low_water (low_water) (portid)\n"
511 "set flow_ctrl pause_time (pause_time) (portid)\n"
512 "set flow_ctrl send_xon (send_xon) (portid)\n"
513 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
514 "set flow_ctrl autoneg (on|off) (port_id)\n"
515 " Set the link flow control parameter on a port.\n\n"
517 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
518 " (low_water) (pause_time) (priority) (port_id)\n"
519 " Set the priority flow control parameter on a"
522 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
523 " Set statistics mapping (qmapping 0..15) for RX/TX"
525 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
526 " on port 0 to mapping 5.\n\n"
528 "set xstats-hide-zero on|off\n"
529 " Set the option to hide the zero values"
530 " for xstats display.\n"
532 "set record-core-cycles on|off\n"
533 " Set the option to enable measurement of CPU cycles.\n"
535 "set port (port_id) vf (vf_id) rx|tx on|off\n"
536 " Enable/Disable a VF receive/tranmit from a port\n\n"
538 "set port (port_id) vf (vf_id) (mac_addr)"
539 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
540 " Add/Remove unicast or multicast MAC addr filter"
543 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
545 " AUPE:accepts untagged VLAN;"
546 "ROPE:accept unicast hash\n\n"
547 " BAM:accepts broadcast packets;"
548 "MPE:accepts all multicast packets\n\n"
549 " Enable/Disable a VF receive mode of a port\n\n"
551 "set port (port_id) queue (queue_id) rate (rate_num)\n"
552 " Set rate limit for a queue of a port\n\n"
554 "set port (port_id) vf (vf_id) rate (rate_num) "
555 "queue_mask (queue_mask_value)\n"
556 " Set rate limit for queues in VF of a port\n\n"
558 "set port (port_id) mirror-rule (rule_id)"
559 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
560 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
561 " Set pool or vlan type mirror rule on a port.\n"
562 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
563 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
566 "set port (port_id) mirror-rule (rule_id)"
567 " (uplink-mirror|downlink-mirror) dst-pool"
568 " (pool_id) (on|off)\n"
569 " Set uplink or downlink type mirror rule on a port.\n"
570 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
571 " 0 on' enable mirror income traffic to pool 0.\n\n"
573 "reset port (port_id) mirror-rule (rule_id)\n"
574 " Reset a mirror rule.\n\n"
576 "set flush_rx (on|off)\n"
577 " Flush (default) or don't flush RX streams before"
578 " forwarding. Mainly used with PCAP drivers.\n\n"
580 "set bypass mode (normal|bypass|isolate) (port_id)\n"
581 " Set the bypass mode for the lowest port on bypass enabled"
584 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
585 "mode (normal|bypass|isolate) (port_id)\n"
586 " Set the event required to initiate specified bypass mode for"
587 " the lowest port on a bypass enabled NIC where:\n"
588 " timeout = enable bypass after watchdog timeout.\n"
589 " os_on = enable bypass when OS/board is powered on.\n"
590 " os_off = enable bypass when OS/board is powered off.\n"
591 " power_on = enable bypass when power supply is turned on.\n"
592 " power_off = enable bypass when power supply is turned off."
595 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
596 " Set the bypass watchdog timeout to 'n' seconds"
597 " where 0 = instant.\n\n"
599 "show bypass config (port_id)\n"
600 " Show the bypass configuration for a bypass enabled NIC"
601 " using the lowest port on the NIC.\n\n"
603 #ifdef RTE_LIBRTE_PMD_BOND
604 "create bonded device (mode) (socket)\n"
605 " Create a new bonded device with specific bonding mode and socket.\n\n"
607 "add bonding slave (slave_id) (port_id)\n"
608 " Add a slave device to a bonded device.\n\n"
610 "remove bonding slave (slave_id) (port_id)\n"
611 " Remove a slave device from a bonded device.\n\n"
613 "set bonding mode (value) (port_id)\n"
614 " Set the bonding mode on a bonded device.\n\n"
616 "set bonding primary (slave_id) (port_id)\n"
617 " Set the primary slave for a bonded device.\n\n"
619 "show bonding config (port_id)\n"
620 " Show the bonding config for port_id.\n\n"
622 "set bonding mac_addr (port_id) (address)\n"
623 " Set the MAC address of a bonded device.\n\n"
625 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
626 " Set Aggregation mode for IEEE802.3AD (mode 4)"
628 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
629 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
631 "set bonding mon_period (port_id) (value)\n"
632 " Set the bonding link status monitoring polling period in ms.\n\n"
634 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
635 " Enable/disable dedicated queues for LACP control traffic.\n\n"
638 "set link-up port (port_id)\n"
639 " Set link up for a port.\n\n"
641 "set link-down port (port_id)\n"
642 " Set link down for a port.\n\n"
644 "E-tag set insertion on port-tag-id (value)"
645 " port (port_id) vf (vf_id)\n"
646 " Enable E-tag insertion for a VF on a port\n\n"
648 "E-tag set insertion off port (port_id) vf (vf_id)\n"
649 " Disable E-tag insertion for a VF on a port\n\n"
651 "E-tag set stripping (on|off) port (port_id)\n"
652 " Enable/disable E-tag stripping on a port\n\n"
654 "E-tag set forwarding (on|off) port (port_id)\n"
655 " Enable/disable E-tag based forwarding"
658 "E-tag set filter add e-tag-id (value) dst-pool"
659 " (pool_id) port (port_id)\n"
660 " Add an E-tag forwarding filter on a port\n\n"
662 "E-tag set filter del e-tag-id (value) port (port_id)\n"
663 " Delete an E-tag forwarding filter on a port\n\n"
665 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
666 " Load a profile package on a port\n\n"
668 "ddp del (port_id) (backup_profile_path)\n"
669 " Delete a profile package from a port\n\n"
671 "ptype mapping get (port_id) (valid_only)\n"
672 " Get ptype mapping on a port\n\n"
674 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
675 " Replace target with the pkt_type in ptype mapping\n\n"
677 "ptype mapping reset (port_id)\n"
678 " Reset ptype mapping on a port\n\n"
680 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
681 " Update a ptype mapping item on a port\n\n"
683 "set port (port_id) ptype_mask (ptype_mask)\n"
684 " set packet types classification for a specific 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 , list_pkt_forwarding_modes()
752 if (show_all || !strcmp(res->section, "ports")) {
758 "----------------\n\n"
760 "port start (port_id|all)\n"
761 " Start all ports or port_id.\n\n"
763 "port stop (port_id|all)\n"
764 " Stop all ports or port_id.\n\n"
766 "port close (port_id|all)\n"
767 " Close all ports or port_id.\n\n"
769 "port reset (port_id|all)\n"
770 " Reset all ports or port_id.\n\n"
772 "port attach (ident)\n"
773 " Attach physical or virtual dev by pci address or virtual device name\n\n"
775 "port detach (port_id)\n"
776 " Detach physical or virtual dev by port_id\n\n"
778 "port config (port_id|all)"
779 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
780 " duplex (half|full|auto)\n"
781 " Set speed and duplex for all ports or port_id\n\n"
783 "port config (port_id|all) loopback (mode)\n"
784 " Set loopback mode for all ports or port_id\n\n"
786 "port config all (rxq|txq|rxd|txd) (value)\n"
787 " Set number for rxq/txq/rxd/txd.\n\n"
789 "port config all max-pkt-len (value)\n"
790 " Set the max packet length.\n\n"
792 "port config all max-lro-pkt-size (value)\n"
793 " Set the max LRO aggregated packet size.\n\n"
795 "port config all drop-en (on|off)\n"
796 " Enable or disable packet drop on all RX queues of all ports when no "
797 "receive buffers available.\n\n"
799 "port config all rss (all|default|ip|tcp|udp|sctp|"
800 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
801 " Set the RSS mode.\n\n"
803 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
804 " Set the RSS redirection table.\n\n"
806 "port config (port_id) dcb vt (on|off) (traffic_class)"
808 " Set the DCB mode.\n\n"
810 "port config all burst (value)\n"
811 " Set the number of packets per burst.\n\n"
813 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
815 " Set the ring prefetch/host/writeback threshold"
816 " for tx/rx queue.\n\n"
818 "port config all (txfreet|txrst|rxfreet) (value)\n"
819 " Set free threshold for rx/tx, or set"
820 " tx rs bit threshold.\n\n"
821 "port config mtu X value\n"
822 " Set the MTU of port X to a given value\n\n"
824 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
825 " Set a rx/tx queue's ring size configuration, the new"
826 " value will take effect after command that (re-)start the port"
827 " or command that setup the specific queue\n\n"
829 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
830 " Start/stop a rx/tx queue of port X. Only take effect"
831 " when port X is started\n\n"
833 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
834 " Switch on/off a deferred start of port X rx/tx queue. Only"
835 " take effect when port X is stopped.\n\n"
837 "port (port_id) (rxq|txq) (queue_id) setup\n"
838 " Setup a rx/tx queue of port X.\n\n"
840 "port config (port_id|all) l2-tunnel E-tag ether-type"
842 " Set the value of E-tag ether-type.\n\n"
844 "port config (port_id|all) l2-tunnel E-tag"
845 " (enable|disable)\n"
846 " Enable/disable the E-tag support.\n\n"
848 "port config (port_id) pctype mapping reset\n"
849 " Reset flow type to pctype mapping on a port\n\n"
851 "port config (port_id) pctype mapping update"
852 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
853 " Update a flow type to pctype mapping item on a port\n\n"
855 "port config (port_id) pctype (pctype_id) hash_inset|"
856 "fdir_inset|fdir_flx_inset get|set|clear field\n"
858 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
860 "port config (port_id) pctype (pctype_id) hash_inset|"
861 "fdir_inset|fdir_flx_inset clear all"
862 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
864 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
865 " Add/remove UDP tunnel port for tunneling offload\n\n"
867 "port config <port_id> rx_offload vlan_strip|"
868 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
869 "outer_ipv4_cksum|macsec_strip|header_split|"
870 "vlan_filter|vlan_extend|jumbo_frame|"
871 "scatter|timestamp|security|keep_crc on|off\n"
872 " Enable or disable a per port Rx offloading"
873 " on all Rx queues of a port\n\n"
875 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
876 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
877 "outer_ipv4_cksum|macsec_strip|header_split|"
878 "vlan_filter|vlan_extend|jumbo_frame|"
879 "scatter|timestamp|security|keep_crc on|off\n"
880 " Enable or disable a per queue Rx offloading"
881 " only on a specific Rx queue\n\n"
883 "port config (port_id) tx_offload vlan_insert|"
884 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
885 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
886 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
887 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
889 " Enable or disable a per port Tx offloading"
890 " on all Tx queues of a port\n\n"
892 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
893 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
894 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
895 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
896 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
898 " Enable or disable a per queue Tx offloading"
899 " only on a specific Tx queue\n\n"
901 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
902 " Load an eBPF program as a callback"
903 " for particular RX/TX queue\n\n"
905 "bpf-unload rx|tx (port) (queue)\n"
906 " Unload previously loaded eBPF program"
907 " for particular RX/TX queue\n\n"
909 "port config (port_id) tx_metadata (value)\n"
910 " Set Tx metadata value per port. Testpmd will add this value"
911 " to any Tx packet sent from this port\n\n"
913 "port config (port_id) dynf (name) set|clear\n"
914 " Register a dynf and Set/clear this flag on Tx. "
915 "Testpmd will set this value to any Tx packet "
916 "sent from this port\n\n"
920 if (show_all || !strcmp(res->section, "registers")) {
928 "read reg (port_id) (address)\n"
929 " Display value of a port register.\n\n"
931 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
932 " Display a port register bit field.\n\n"
934 "read regbit (port_id) (address) (bit_x)\n"
935 " Display a single port register bit.\n\n"
937 "write reg (port_id) (address) (value)\n"
938 " Set value of a port register.\n\n"
940 "write regfield (port_id) (address) (bit_x) (bit_y)"
942 " Set bit field of a port register.\n\n"
944 "write regbit (port_id) (address) (bit_x) (value)\n"
945 " Set single bit value of a port register.\n\n"
948 if (show_all || !strcmp(res->section, "filters")) {
956 "ethertype_filter (port_id) (add|del)"
957 " (mac_addr|mac_ignr) (mac_address) ethertype"
958 " (ether_type) (drop|fwd) queue (queue_id)\n"
959 " Add/Del an ethertype filter.\n\n"
961 "2tuple_filter (port_id) (add|del)"
962 " dst_port (dst_port_value) protocol (protocol_value)"
963 " mask (mask_value) tcp_flags (tcp_flags_value)"
964 " priority (prio_value) queue (queue_id)\n"
965 " Add/Del a 2tuple filter.\n\n"
967 "5tuple_filter (port_id) (add|del)"
968 " dst_ip (dst_address) src_ip (src_address)"
969 " dst_port (dst_port_value) src_port (src_port_value)"
970 " protocol (protocol_value)"
971 " mask (mask_value) tcp_flags (tcp_flags_value)"
972 " priority (prio_value) queue (queue_id)\n"
973 " Add/Del a 5tuple filter.\n\n"
975 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
976 " Add/Del syn filter.\n\n"
978 "flex_filter (port_id) (add|del) len (len_value)"
979 " bytes (bytes_value) mask (mask_value)"
980 " priority (prio_value) queue (queue_id)\n"
981 " Add/Del a flex filter.\n\n"
983 "flow_director_filter (port_id) mode IP (add|del|update)"
984 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
985 " src (src_ip_address) dst (dst_ip_address)"
986 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
987 " vlan (vlan_value) flexbytes (flexbytes_value)"
988 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
989 " fd_id (fd_id_value)\n"
990 " Add/Del an IP type flow director filter.\n\n"
992 "flow_director_filter (port_id) mode IP (add|del|update)"
993 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
994 " src (src_ip_address) (src_port)"
995 " dst (dst_ip_address) (dst_port)"
996 " tos (tos_value) ttl (ttl_value)"
997 " vlan (vlan_value) flexbytes (flexbytes_value)"
998 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
999 " fd_id (fd_id_value)\n"
1000 " Add/Del an UDP/TCP type flow director filter.\n\n"
1002 "flow_director_filter (port_id) mode IP (add|del|update)"
1003 " flow (ipv4-sctp|ipv6-sctp)"
1004 " src (src_ip_address) (src_port)"
1005 " dst (dst_ip_address) (dst_port)"
1006 " tag (verification_tag) "
1007 " tos (tos_value) ttl (ttl_value)"
1008 " vlan (vlan_value)"
1009 " flexbytes (flexbytes_value) (drop|fwd)"
1010 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1011 " Add/Del a SCTP type flow director filter.\n\n"
1013 "flow_director_filter (port_id) mode IP (add|del|update)"
1014 " flow l2_payload ether (ethertype)"
1015 " flexbytes (flexbytes_value) (drop|fwd)"
1016 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1017 " Add/Del a l2 payload type flow director filter.\n\n"
1019 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1020 " mac (mac_address) vlan (vlan_value)"
1021 " flexbytes (flexbytes_value) (drop|fwd)"
1022 " queue (queue_id) fd_id (fd_id_value)\n"
1023 " Add/Del a MAC-VLAN flow director filter.\n\n"
1025 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1026 " mac (mac_address) vlan (vlan_value)"
1027 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1028 " flexbytes (flexbytes_value) (drop|fwd)"
1029 " queue (queue_id) fd_id (fd_id_value)\n"
1030 " Add/Del a Tunnel flow director filter.\n\n"
1032 "flow_director_filter (port_id) mode raw (add|del|update)"
1033 " flow (flow_id) (drop|fwd) queue (queue_id)"
1034 " fd_id (fd_id_value) packet (packet file name)\n"
1035 " Add/Del a raw type flow director filter.\n\n"
1037 "flush_flow_director (port_id)\n"
1038 " Flush all flow director entries of a device.\n\n"
1040 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1041 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1042 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1043 " Set flow director IP mask.\n\n"
1045 "flow_director_mask (port_id) mode MAC-VLAN"
1046 " vlan (vlan_value)\n"
1047 " Set flow director MAC-VLAN mask.\n\n"
1049 "flow_director_mask (port_id) mode Tunnel"
1050 " vlan (vlan_value) mac (mac_value)"
1051 " tunnel-type (tunnel_type_value)"
1052 " tunnel-id (tunnel_id_value)\n"
1053 " Set flow director Tunnel mask.\n\n"
1055 "flow_director_flex_mask (port_id)"
1056 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1057 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1059 " Configure mask of flex payload.\n\n"
1061 "flow_director_flex_payload (port_id)"
1062 " (raw|l2|l3|l4) (config)\n"
1063 " Configure flex payload selection.\n\n"
1065 "get_sym_hash_ena_per_port (port_id)\n"
1066 " get symmetric hash enable configuration per port.\n\n"
1068 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1069 " set symmetric hash enable configuration per port"
1070 " to enable or disable.\n\n"
1072 "get_hash_global_config (port_id)\n"
1073 " Get the global configurations of hash filters.\n\n"
1075 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1076 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1077 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1078 " (enable|disable)\n"
1079 " Set the global configurations of hash filters.\n\n"
1081 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1082 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1083 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1084 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1085 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1086 "ipv6-next-header|udp-src-port|udp-dst-port|"
1087 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1088 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1089 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1090 "fld-8th|none) (select|add)\n"
1091 " Set the input set for hash.\n\n"
1093 "set_fdir_input_set (port_id) "
1094 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1095 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1096 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1097 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1098 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1099 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1100 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1102 " Set the input set for FDir.\n\n"
1104 "flow validate {port_id}"
1105 " [group {group_id}] [priority {level}]"
1106 " [ingress] [egress]"
1107 " pattern {item} [/ {item} [...]] / end"
1108 " actions {action} [/ {action} [...]] / end\n"
1109 " Check whether a flow rule can be created.\n\n"
1111 "flow create {port_id}"
1112 " [group {group_id}] [priority {level}]"
1113 " [ingress] [egress]"
1114 " pattern {item} [/ {item} [...]] / end"
1115 " actions {action} [/ {action} [...]] / end\n"
1116 " Create a flow rule.\n\n"
1118 "flow destroy {port_id} rule {rule_id} [...]\n"
1119 " Destroy specific flow rules.\n\n"
1121 "flow flush {port_id}\n"
1122 " Destroy all flow rules.\n\n"
1124 "flow query {port_id} {rule_id} {action}\n"
1125 " Query an existing flow rule.\n\n"
1127 "flow list {port_id} [group {group_id}] [...]\n"
1128 " List existing flow rules sorted by priority,"
1129 " filtered by group identifiers.\n\n"
1131 "flow isolate {port_id} {boolean}\n"
1132 " Restrict ingress traffic to the defined"
1135 "flow aged {port_id} [destroy]\n"
1136 " List and destroy aged flows"
1139 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1140 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1141 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1142 " Configure the VXLAN encapsulation for flows.\n\n"
1144 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1145 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1146 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1147 " eth-dst (eth-dst)\n"
1148 " Configure the VXLAN encapsulation for flows.\n\n"
1150 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1151 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1152 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1153 " eth-dst (eth-dst)\n"
1154 " Configure the VXLAN encapsulation for flows.\n\n"
1156 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1157 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1159 " Configure the NVGRE encapsulation for flows.\n\n"
1161 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1162 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1163 " eth-src (eth-src) eth-dst (eth-dst)\n"
1164 " Configure the NVGRE encapsulation for flows.\n\n"
1166 "set raw_encap {flow items}\n"
1167 " Configure the encapsulation with raw data.\n\n"
1169 "set raw_decap {flow items}\n"
1170 " Configure the decapsulation with raw data.\n\n"
1175 if (show_all || !strcmp(res->section, "traffic_management")) {
1179 "Traffic Management:\n"
1181 "show port tm cap (port_id)\n"
1182 " Display the port TM capability.\n\n"
1184 "show port tm level cap (port_id) (level_id)\n"
1185 " Display the port TM hierarchical level capability.\n\n"
1187 "show port tm node cap (port_id) (node_id)\n"
1188 " Display the port TM node capability.\n\n"
1190 "show port tm node type (port_id) (node_id)\n"
1191 " Display the port TM node type.\n\n"
1193 "show port tm node stats (port_id) (node_id) (clear)\n"
1194 " Display the port TM node stats.\n\n"
1196 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1197 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1198 " (packet_length_adjust)\n"
1199 " Add port tm node private shaper profile.\n\n"
1201 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1202 " Delete port tm node private shaper profile.\n\n"
1204 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1205 " (shaper_profile_id)\n"
1206 " Add/update port tm node shared shaper.\n\n"
1208 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1209 " Delete port tm node shared shaper.\n\n"
1211 "set port tm node shaper profile (port_id) (node_id)"
1212 " (shaper_profile_id)\n"
1213 " Set port tm node shaper profile.\n\n"
1215 "add port tm node wred profile (port_id) (wred_profile_id)"
1216 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1217 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1218 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1219 " Add port tm node wred profile.\n\n"
1221 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1222 " Delete port tm node wred profile.\n\n"
1224 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1225 " (priority) (weight) (level_id) (shaper_profile_id)"
1226 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1227 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1228 " Add port tm nonleaf node.\n\n"
1230 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1231 " (priority) (weight) (level_id) (shaper_profile_id)"
1232 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1233 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1234 " Add port tm leaf node.\n\n"
1236 "del port tm node (port_id) (node_id)\n"
1237 " Delete port tm node.\n\n"
1239 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1240 " (priority) (weight)\n"
1241 " Set port tm node parent.\n\n"
1243 "suspend port tm node (port_id) (node_id)"
1244 " Suspend tm node.\n\n"
1246 "resume port tm node (port_id) (node_id)"
1247 " Resume tm node.\n\n"
1249 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1250 " Commit tm hierarchy.\n\n"
1252 "set port tm mark ip_ecn (port) (green) (yellow)"
1254 " Enables/Disables the traffic management marking"
1255 " for IP ECN (Explicit Congestion Notification)"
1256 " packets on a given port\n\n"
1258 "set port tm mark ip_dscp (port) (green) (yellow)"
1260 " Enables/Disables the traffic management marking"
1261 " on the port for IP dscp packets\n\n"
1263 "set port tm mark vlan_dei (port) (green) (yellow)"
1265 " Enables/Disables the traffic management marking"
1266 " on the port for VLAN packets with DEI enabled\n\n"
1270 if (show_all || !strcmp(res->section, "devices")) {
1274 "Device Operations:\n"
1276 "device detach (identifier)\n"
1277 " Detach device by identifier.\n\n"
1283 cmdline_parse_token_string_t cmd_help_long_help =
1284 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1286 cmdline_parse_token_string_t cmd_help_long_section =
1287 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1288 "all#control#display#config#"
1289 "ports#registers#filters#traffic_management#devices");
1291 cmdline_parse_inst_t cmd_help_long = {
1292 .f = cmd_help_long_parsed,
1294 .help_str = "help all|control|display|config|ports|register|"
1295 "filters|traffic_management|devices: "
1298 (void *)&cmd_help_long_help,
1299 (void *)&cmd_help_long_section,
1305 /* *** start/stop/close all ports *** */
1306 struct cmd_operate_port_result {
1307 cmdline_fixed_string_t keyword;
1308 cmdline_fixed_string_t name;
1309 cmdline_fixed_string_t value;
1312 static void cmd_operate_port_parsed(void *parsed_result,
1313 __rte_unused struct cmdline *cl,
1314 __rte_unused void *data)
1316 struct cmd_operate_port_result *res = parsed_result;
1318 if (!strcmp(res->name, "start"))
1319 start_port(RTE_PORT_ALL);
1320 else if (!strcmp(res->name, "stop"))
1321 stop_port(RTE_PORT_ALL);
1322 else if (!strcmp(res->name, "close"))
1323 close_port(RTE_PORT_ALL);
1324 else if (!strcmp(res->name, "reset"))
1325 reset_port(RTE_PORT_ALL);
1327 printf("Unknown parameter\n");
1330 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1331 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1333 cmdline_parse_token_string_t cmd_operate_port_all_port =
1334 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1335 "start#stop#close#reset");
1336 cmdline_parse_token_string_t cmd_operate_port_all_all =
1337 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1339 cmdline_parse_inst_t cmd_operate_port = {
1340 .f = cmd_operate_port_parsed,
1342 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1344 (void *)&cmd_operate_port_all_cmd,
1345 (void *)&cmd_operate_port_all_port,
1346 (void *)&cmd_operate_port_all_all,
1351 /* *** start/stop/close specific port *** */
1352 struct cmd_operate_specific_port_result {
1353 cmdline_fixed_string_t keyword;
1354 cmdline_fixed_string_t name;
1358 static void cmd_operate_specific_port_parsed(void *parsed_result,
1359 __rte_unused struct cmdline *cl,
1360 __rte_unused void *data)
1362 struct cmd_operate_specific_port_result *res = parsed_result;
1364 if (!strcmp(res->name, "start"))
1365 start_port(res->value);
1366 else if (!strcmp(res->name, "stop"))
1367 stop_port(res->value);
1368 else if (!strcmp(res->name, "close"))
1369 close_port(res->value);
1370 else if (!strcmp(res->name, "reset"))
1371 reset_port(res->value);
1373 printf("Unknown parameter\n");
1376 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1377 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1379 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1380 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1381 name, "start#stop#close#reset");
1382 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1383 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1386 cmdline_parse_inst_t cmd_operate_specific_port = {
1387 .f = cmd_operate_specific_port_parsed,
1389 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1391 (void *)&cmd_operate_specific_port_cmd,
1392 (void *)&cmd_operate_specific_port_port,
1393 (void *)&cmd_operate_specific_port_id,
1398 /* *** enable port setup (after attach) via iterator or event *** */
1399 struct cmd_set_port_setup_on_result {
1400 cmdline_fixed_string_t set;
1401 cmdline_fixed_string_t port;
1402 cmdline_fixed_string_t setup;
1403 cmdline_fixed_string_t on;
1404 cmdline_fixed_string_t mode;
1407 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1408 __rte_unused struct cmdline *cl,
1409 __rte_unused void *data)
1411 struct cmd_set_port_setup_on_result *res = parsed_result;
1413 if (strcmp(res->mode, "event") == 0)
1414 setup_on_probe_event = true;
1415 else if (strcmp(res->mode, "iterator") == 0)
1416 setup_on_probe_event = false;
1418 printf("Unknown mode\n");
1421 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1422 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1424 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1425 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1427 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1428 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1430 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1431 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1433 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1434 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1435 mode, "iterator#event");
1437 cmdline_parse_inst_t cmd_set_port_setup_on = {
1438 .f = cmd_set_port_setup_on_parsed,
1440 .help_str = "set port setup on iterator|event",
1442 (void *)&cmd_set_port_setup_on_set,
1443 (void *)&cmd_set_port_setup_on_port,
1444 (void *)&cmd_set_port_setup_on_setup,
1445 (void *)&cmd_set_port_setup_on_on,
1446 (void *)&cmd_set_port_setup_on_mode,
1451 /* *** attach a specified port *** */
1452 struct cmd_operate_attach_port_result {
1453 cmdline_fixed_string_t port;
1454 cmdline_fixed_string_t keyword;
1455 cmdline_multi_string_t identifier;
1458 static void cmd_operate_attach_port_parsed(void *parsed_result,
1459 __rte_unused struct cmdline *cl,
1460 __rte_unused void *data)
1462 struct cmd_operate_attach_port_result *res = parsed_result;
1464 if (!strcmp(res->keyword, "attach"))
1465 attach_port(res->identifier);
1467 printf("Unknown parameter\n");
1470 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1471 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1473 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1474 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1476 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1477 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1478 identifier, TOKEN_STRING_MULTI);
1480 cmdline_parse_inst_t cmd_operate_attach_port = {
1481 .f = cmd_operate_attach_port_parsed,
1483 .help_str = "port attach <identifier>: "
1484 "(identifier: pci address or virtual dev name)",
1486 (void *)&cmd_operate_attach_port_port,
1487 (void *)&cmd_operate_attach_port_keyword,
1488 (void *)&cmd_operate_attach_port_identifier,
1493 /* *** detach a specified port *** */
1494 struct cmd_operate_detach_port_result {
1495 cmdline_fixed_string_t port;
1496 cmdline_fixed_string_t keyword;
1500 static void cmd_operate_detach_port_parsed(void *parsed_result,
1501 __rte_unused struct cmdline *cl,
1502 __rte_unused void *data)
1504 struct cmd_operate_detach_port_result *res = parsed_result;
1506 if (!strcmp(res->keyword, "detach")) {
1507 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1508 detach_port_device(res->port_id);
1510 printf("Unknown parameter\n");
1514 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1515 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1517 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1518 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1520 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1521 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1524 cmdline_parse_inst_t cmd_operate_detach_port = {
1525 .f = cmd_operate_detach_port_parsed,
1527 .help_str = "port detach <port_id>",
1529 (void *)&cmd_operate_detach_port_port,
1530 (void *)&cmd_operate_detach_port_keyword,
1531 (void *)&cmd_operate_detach_port_port_id,
1536 /* *** detach device by identifier *** */
1537 struct cmd_operate_detach_device_result {
1538 cmdline_fixed_string_t device;
1539 cmdline_fixed_string_t keyword;
1540 cmdline_fixed_string_t identifier;
1543 static void cmd_operate_detach_device_parsed(void *parsed_result,
1544 __rte_unused struct cmdline *cl,
1545 __rte_unused void *data)
1547 struct cmd_operate_detach_device_result *res = parsed_result;
1549 if (!strcmp(res->keyword, "detach"))
1550 detach_devargs(res->identifier);
1552 printf("Unknown parameter\n");
1555 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1556 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1558 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1559 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1561 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1562 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1565 cmdline_parse_inst_t cmd_operate_detach_device = {
1566 .f = cmd_operate_detach_device_parsed,
1568 .help_str = "device detach <identifier>:"
1569 "(identifier: pci address or virtual dev name)",
1571 (void *)&cmd_operate_detach_device_device,
1572 (void *)&cmd_operate_detach_device_keyword,
1573 (void *)&cmd_operate_detach_device_identifier,
1577 /* *** configure speed for all ports *** */
1578 struct cmd_config_speed_all {
1579 cmdline_fixed_string_t port;
1580 cmdline_fixed_string_t keyword;
1581 cmdline_fixed_string_t all;
1582 cmdline_fixed_string_t item1;
1583 cmdline_fixed_string_t item2;
1584 cmdline_fixed_string_t value1;
1585 cmdline_fixed_string_t value2;
1589 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1594 if (!strcmp(duplexstr, "half")) {
1595 duplex = ETH_LINK_HALF_DUPLEX;
1596 } else if (!strcmp(duplexstr, "full")) {
1597 duplex = ETH_LINK_FULL_DUPLEX;
1598 } else if (!strcmp(duplexstr, "auto")) {
1599 duplex = ETH_LINK_FULL_DUPLEX;
1601 printf("Unknown duplex parameter\n");
1605 if (!strcmp(speedstr, "10")) {
1606 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1607 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1608 } else if (!strcmp(speedstr, "100")) {
1609 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1610 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1612 if (duplex != ETH_LINK_FULL_DUPLEX) {
1613 printf("Invalid speed/duplex parameters\n");
1616 if (!strcmp(speedstr, "1000")) {
1617 *speed = ETH_LINK_SPEED_1G;
1618 } else if (!strcmp(speedstr, "10000")) {
1619 *speed = ETH_LINK_SPEED_10G;
1620 } else if (!strcmp(speedstr, "25000")) {
1621 *speed = ETH_LINK_SPEED_25G;
1622 } else if (!strcmp(speedstr, "40000")) {
1623 *speed = ETH_LINK_SPEED_40G;
1624 } else if (!strcmp(speedstr, "50000")) {
1625 *speed = ETH_LINK_SPEED_50G;
1626 } else if (!strcmp(speedstr, "100000")) {
1627 *speed = ETH_LINK_SPEED_100G;
1628 } else if (!strcmp(speedstr, "200000")) {
1629 *speed = ETH_LINK_SPEED_200G;
1630 } else if (!strcmp(speedstr, "auto")) {
1631 *speed = ETH_LINK_SPEED_AUTONEG;
1633 printf("Unknown speed parameter\n");
1642 cmd_config_speed_all_parsed(void *parsed_result,
1643 __rte_unused struct cmdline *cl,
1644 __rte_unused void *data)
1646 struct cmd_config_speed_all *res = parsed_result;
1647 uint32_t link_speed;
1650 if (!all_ports_stopped()) {
1651 printf("Please stop all ports first\n");
1655 if (parse_and_check_speed_duplex(res->value1, res->value2,
1659 RTE_ETH_FOREACH_DEV(pid) {
1660 ports[pid].dev_conf.link_speeds = link_speed;
1663 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1666 cmdline_parse_token_string_t cmd_config_speed_all_port =
1667 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1668 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1669 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1671 cmdline_parse_token_string_t cmd_config_speed_all_all =
1672 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1673 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1674 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1675 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1676 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1677 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1678 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1679 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1680 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1681 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1684 cmdline_parse_inst_t cmd_config_speed_all = {
1685 .f = cmd_config_speed_all_parsed,
1687 .help_str = "port config all speed "
1688 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1691 (void *)&cmd_config_speed_all_port,
1692 (void *)&cmd_config_speed_all_keyword,
1693 (void *)&cmd_config_speed_all_all,
1694 (void *)&cmd_config_speed_all_item1,
1695 (void *)&cmd_config_speed_all_value1,
1696 (void *)&cmd_config_speed_all_item2,
1697 (void *)&cmd_config_speed_all_value2,
1702 /* *** configure speed for specific port *** */
1703 struct cmd_config_speed_specific {
1704 cmdline_fixed_string_t port;
1705 cmdline_fixed_string_t keyword;
1707 cmdline_fixed_string_t item1;
1708 cmdline_fixed_string_t item2;
1709 cmdline_fixed_string_t value1;
1710 cmdline_fixed_string_t value2;
1714 cmd_config_speed_specific_parsed(void *parsed_result,
1715 __rte_unused struct cmdline *cl,
1716 __rte_unused void *data)
1718 struct cmd_config_speed_specific *res = parsed_result;
1719 uint32_t link_speed;
1721 if (!all_ports_stopped()) {
1722 printf("Please stop all ports first\n");
1726 if (port_id_is_invalid(res->id, ENABLED_WARN))
1729 if (parse_and_check_speed_duplex(res->value1, res->value2,
1733 ports[res->id].dev_conf.link_speeds = link_speed;
1735 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1739 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1740 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1742 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1743 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1745 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1746 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1747 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1748 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1750 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1751 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1752 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1753 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1754 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1756 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1757 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1760 cmdline_parse_inst_t cmd_config_speed_specific = {
1761 .f = cmd_config_speed_specific_parsed,
1763 .help_str = "port config <port_id> speed "
1764 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1767 (void *)&cmd_config_speed_specific_port,
1768 (void *)&cmd_config_speed_specific_keyword,
1769 (void *)&cmd_config_speed_specific_id,
1770 (void *)&cmd_config_speed_specific_item1,
1771 (void *)&cmd_config_speed_specific_value1,
1772 (void *)&cmd_config_speed_specific_item2,
1773 (void *)&cmd_config_speed_specific_value2,
1778 /* *** configure loopback for all ports *** */
1779 struct cmd_config_loopback_all {
1780 cmdline_fixed_string_t port;
1781 cmdline_fixed_string_t keyword;
1782 cmdline_fixed_string_t all;
1783 cmdline_fixed_string_t item;
1788 cmd_config_loopback_all_parsed(void *parsed_result,
1789 __rte_unused struct cmdline *cl,
1790 __rte_unused void *data)
1792 struct cmd_config_loopback_all *res = parsed_result;
1795 if (!all_ports_stopped()) {
1796 printf("Please stop all ports first\n");
1800 RTE_ETH_FOREACH_DEV(pid) {
1801 ports[pid].dev_conf.lpbk_mode = res->mode;
1804 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1807 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1808 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1809 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1810 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1812 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1813 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1814 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1815 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1817 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1818 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1820 cmdline_parse_inst_t cmd_config_loopback_all = {
1821 .f = cmd_config_loopback_all_parsed,
1823 .help_str = "port config all loopback <mode>",
1825 (void *)&cmd_config_loopback_all_port,
1826 (void *)&cmd_config_loopback_all_keyword,
1827 (void *)&cmd_config_loopback_all_all,
1828 (void *)&cmd_config_loopback_all_item,
1829 (void *)&cmd_config_loopback_all_mode,
1834 /* *** configure loopback for specific port *** */
1835 struct cmd_config_loopback_specific {
1836 cmdline_fixed_string_t port;
1837 cmdline_fixed_string_t keyword;
1839 cmdline_fixed_string_t item;
1844 cmd_config_loopback_specific_parsed(void *parsed_result,
1845 __rte_unused struct cmdline *cl,
1846 __rte_unused void *data)
1848 struct cmd_config_loopback_specific *res = parsed_result;
1850 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1853 if (!port_is_stopped(res->port_id)) {
1854 printf("Please stop port %u first\n", res->port_id);
1858 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1860 cmd_reconfig_device_queue(res->port_id, 1, 1);
1864 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1865 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1867 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1868 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1870 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1871 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1873 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1874 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1876 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1877 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1880 cmdline_parse_inst_t cmd_config_loopback_specific = {
1881 .f = cmd_config_loopback_specific_parsed,
1883 .help_str = "port config <port_id> loopback <mode>",
1885 (void *)&cmd_config_loopback_specific_port,
1886 (void *)&cmd_config_loopback_specific_keyword,
1887 (void *)&cmd_config_loopback_specific_id,
1888 (void *)&cmd_config_loopback_specific_item,
1889 (void *)&cmd_config_loopback_specific_mode,
1894 /* *** configure txq/rxq, txd/rxd *** */
1895 struct cmd_config_rx_tx {
1896 cmdline_fixed_string_t port;
1897 cmdline_fixed_string_t keyword;
1898 cmdline_fixed_string_t all;
1899 cmdline_fixed_string_t name;
1904 cmd_config_rx_tx_parsed(void *parsed_result,
1905 __rte_unused struct cmdline *cl,
1906 __rte_unused void *data)
1908 struct cmd_config_rx_tx *res = parsed_result;
1910 if (!all_ports_stopped()) {
1911 printf("Please stop all ports first\n");
1914 if (!strcmp(res->name, "rxq")) {
1915 if (!res->value && !nb_txq) {
1916 printf("Warning: Either rx or tx queues should be non zero\n");
1919 if (check_nb_rxq(res->value) != 0)
1921 nb_rxq = res->value;
1923 else if (!strcmp(res->name, "txq")) {
1924 if (!res->value && !nb_rxq) {
1925 printf("Warning: Either rx or tx queues should be non zero\n");
1928 if (check_nb_txq(res->value) != 0)
1930 nb_txq = res->value;
1932 else if (!strcmp(res->name, "rxd")) {
1933 if (check_nb_rxd(res->value) != 0)
1935 nb_rxd = res->value;
1936 } else if (!strcmp(res->name, "txd")) {
1937 if (check_nb_txd(res->value) != 0)
1940 nb_txd = res->value;
1942 printf("Unknown parameter\n");
1950 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1953 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1954 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1955 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1956 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1957 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1958 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1959 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1960 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1962 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1963 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1965 cmdline_parse_inst_t cmd_config_rx_tx = {
1966 .f = cmd_config_rx_tx_parsed,
1968 .help_str = "port config all rxq|txq|rxd|txd <value>",
1970 (void *)&cmd_config_rx_tx_port,
1971 (void *)&cmd_config_rx_tx_keyword,
1972 (void *)&cmd_config_rx_tx_all,
1973 (void *)&cmd_config_rx_tx_name,
1974 (void *)&cmd_config_rx_tx_value,
1979 /* *** config max packet length *** */
1980 struct cmd_config_max_pkt_len_result {
1981 cmdline_fixed_string_t port;
1982 cmdline_fixed_string_t keyword;
1983 cmdline_fixed_string_t all;
1984 cmdline_fixed_string_t name;
1989 cmd_config_max_pkt_len_parsed(void *parsed_result,
1990 __rte_unused struct cmdline *cl,
1991 __rte_unused void *data)
1993 struct cmd_config_max_pkt_len_result *res = parsed_result;
1996 if (!all_ports_stopped()) {
1997 printf("Please stop all ports first\n");
2001 RTE_ETH_FOREACH_DEV(pid) {
2002 struct rte_port *port = &ports[pid];
2003 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
2005 if (!strcmp(res->name, "max-pkt-len")) {
2006 if (res->value < RTE_ETHER_MIN_LEN) {
2007 printf("max-pkt-len can not be less than %d\n",
2011 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2014 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2015 if (res->value > RTE_ETHER_MAX_LEN)
2016 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2018 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2019 port->dev_conf.rxmode.offloads = rx_offloads;
2021 printf("Unknown parameter\n");
2028 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2031 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2032 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2034 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2035 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2037 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2038 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2040 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2041 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2043 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2044 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2047 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2048 .f = cmd_config_max_pkt_len_parsed,
2050 .help_str = "port config all max-pkt-len <value>",
2052 (void *)&cmd_config_max_pkt_len_port,
2053 (void *)&cmd_config_max_pkt_len_keyword,
2054 (void *)&cmd_config_max_pkt_len_all,
2055 (void *)&cmd_config_max_pkt_len_name,
2056 (void *)&cmd_config_max_pkt_len_value,
2061 /* *** config max LRO aggregated packet size *** */
2062 struct cmd_config_max_lro_pkt_size_result {
2063 cmdline_fixed_string_t port;
2064 cmdline_fixed_string_t keyword;
2065 cmdline_fixed_string_t all;
2066 cmdline_fixed_string_t name;
2071 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2072 __rte_unused struct cmdline *cl,
2073 __rte_unused void *data)
2075 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2078 if (!all_ports_stopped()) {
2079 printf("Please stop all ports first\n");
2083 RTE_ETH_FOREACH_DEV(pid) {
2084 struct rte_port *port = &ports[pid];
2086 if (!strcmp(res->name, "max-lro-pkt-size")) {
2088 port->dev_conf.rxmode.max_lro_pkt_size)
2091 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2093 printf("Unknown parameter\n");
2100 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2103 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2104 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2106 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2107 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2109 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2110 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2112 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2113 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2114 name, "max-lro-pkt-size");
2115 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2116 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2119 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2120 .f = cmd_config_max_lro_pkt_size_parsed,
2122 .help_str = "port config all max-lro-pkt-size <value>",
2124 (void *)&cmd_config_max_lro_pkt_size_port,
2125 (void *)&cmd_config_max_lro_pkt_size_keyword,
2126 (void *)&cmd_config_max_lro_pkt_size_all,
2127 (void *)&cmd_config_max_lro_pkt_size_name,
2128 (void *)&cmd_config_max_lro_pkt_size_value,
2133 /* *** configure port MTU *** */
2134 struct cmd_config_mtu_result {
2135 cmdline_fixed_string_t port;
2136 cmdline_fixed_string_t keyword;
2137 cmdline_fixed_string_t mtu;
2143 cmd_config_mtu_parsed(void *parsed_result,
2144 __rte_unused struct cmdline *cl,
2145 __rte_unused void *data)
2147 struct cmd_config_mtu_result *res = parsed_result;
2149 if (res->value < RTE_ETHER_MIN_LEN) {
2150 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2153 port_mtu_set(res->port_id, res->value);
2156 cmdline_parse_token_string_t cmd_config_mtu_port =
2157 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2159 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2160 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2162 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2163 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2165 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2166 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2167 cmdline_parse_token_num_t cmd_config_mtu_value =
2168 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2170 cmdline_parse_inst_t cmd_config_mtu = {
2171 .f = cmd_config_mtu_parsed,
2173 .help_str = "port config mtu <port_id> <value>",
2175 (void *)&cmd_config_mtu_port,
2176 (void *)&cmd_config_mtu_keyword,
2177 (void *)&cmd_config_mtu_mtu,
2178 (void *)&cmd_config_mtu_port_id,
2179 (void *)&cmd_config_mtu_value,
2184 /* *** configure rx mode *** */
2185 struct cmd_config_rx_mode_flag {
2186 cmdline_fixed_string_t port;
2187 cmdline_fixed_string_t keyword;
2188 cmdline_fixed_string_t all;
2189 cmdline_fixed_string_t name;
2190 cmdline_fixed_string_t value;
2194 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2195 __rte_unused struct cmdline *cl,
2196 __rte_unused void *data)
2198 struct cmd_config_rx_mode_flag *res = parsed_result;
2200 if (!all_ports_stopped()) {
2201 printf("Please stop all ports first\n");
2205 if (!strcmp(res->name, "drop-en")) {
2206 if (!strcmp(res->value, "on"))
2208 else if (!strcmp(res->value, "off"))
2211 printf("Unknown parameter\n");
2215 printf("Unknown parameter\n");
2221 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2224 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2225 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2226 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2227 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2229 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2230 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2231 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2232 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2234 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2235 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2238 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2239 .f = cmd_config_rx_mode_flag_parsed,
2241 .help_str = "port config all drop-en on|off",
2243 (void *)&cmd_config_rx_mode_flag_port,
2244 (void *)&cmd_config_rx_mode_flag_keyword,
2245 (void *)&cmd_config_rx_mode_flag_all,
2246 (void *)&cmd_config_rx_mode_flag_name,
2247 (void *)&cmd_config_rx_mode_flag_value,
2252 /* *** configure rss *** */
2253 struct cmd_config_rss {
2254 cmdline_fixed_string_t port;
2255 cmdline_fixed_string_t keyword;
2256 cmdline_fixed_string_t all;
2257 cmdline_fixed_string_t name;
2258 cmdline_fixed_string_t value;
2262 cmd_config_rss_parsed(void *parsed_result,
2263 __rte_unused struct cmdline *cl,
2264 __rte_unused void *data)
2266 struct cmd_config_rss *res = parsed_result;
2267 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2268 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2269 int use_default = 0;
2270 int all_updated = 1;
2275 if (!strcmp(res->value, "all"))
2276 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2277 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2278 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2279 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU;
2280 else if (!strcmp(res->value, "eth"))
2281 rss_conf.rss_hf = ETH_RSS_ETH;
2282 else if (!strcmp(res->value, "vlan"))
2283 rss_conf.rss_hf = ETH_RSS_VLAN;
2284 else if (!strcmp(res->value, "ip"))
2285 rss_conf.rss_hf = ETH_RSS_IP;
2286 else if (!strcmp(res->value, "udp"))
2287 rss_conf.rss_hf = ETH_RSS_UDP;
2288 else if (!strcmp(res->value, "tcp"))
2289 rss_conf.rss_hf = ETH_RSS_TCP;
2290 else if (!strcmp(res->value, "sctp"))
2291 rss_conf.rss_hf = ETH_RSS_SCTP;
2292 else if (!strcmp(res->value, "ether"))
2293 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2294 else if (!strcmp(res->value, "port"))
2295 rss_conf.rss_hf = ETH_RSS_PORT;
2296 else if (!strcmp(res->value, "vxlan"))
2297 rss_conf.rss_hf = ETH_RSS_VXLAN;
2298 else if (!strcmp(res->value, "geneve"))
2299 rss_conf.rss_hf = ETH_RSS_GENEVE;
2300 else if (!strcmp(res->value, "nvgre"))
2301 rss_conf.rss_hf = ETH_RSS_NVGRE;
2302 else if (!strcmp(res->value, "l3-pre32"))
2303 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2304 else if (!strcmp(res->value, "l3-pre40"))
2305 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2306 else if (!strcmp(res->value, "l3-pre48"))
2307 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2308 else if (!strcmp(res->value, "l3-pre56"))
2309 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2310 else if (!strcmp(res->value, "l3-pre64"))
2311 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2312 else if (!strcmp(res->value, "l3-pre96"))
2313 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2314 else if (!strcmp(res->value, "l3-src-only"))
2315 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2316 else if (!strcmp(res->value, "l3-dst-only"))
2317 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2318 else if (!strcmp(res->value, "l4-src-only"))
2319 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2320 else if (!strcmp(res->value, "l4-dst-only"))
2321 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2322 else if (!strcmp(res->value, "l2-src-only"))
2323 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2324 else if (!strcmp(res->value, "l2-dst-only"))
2325 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2326 else if (!strcmp(res->value, "l2tpv3"))
2327 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2328 else if (!strcmp(res->value, "esp"))
2329 rss_conf.rss_hf = ETH_RSS_ESP;
2330 else if (!strcmp(res->value, "ah"))
2331 rss_conf.rss_hf = ETH_RSS_AH;
2332 else if (!strcmp(res->value, "pfcp"))
2333 rss_conf.rss_hf = ETH_RSS_PFCP;
2334 else if (!strcmp(res->value, "pppoe"))
2335 rss_conf.rss_hf = ETH_RSS_PPPOE;
2336 else if (!strcmp(res->value, "gtpu"))
2337 rss_conf.rss_hf = ETH_RSS_GTPU;
2338 else if (!strcmp(res->value, "none"))
2339 rss_conf.rss_hf = 0;
2340 else if (!strcmp(res->value, "default"))
2342 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2343 atoi(res->value) < 64)
2344 rss_conf.rss_hf = 1ULL << atoi(res->value);
2346 printf("Unknown parameter\n");
2349 rss_conf.rss_key = NULL;
2350 /* Update global configuration for RSS types. */
2351 RTE_ETH_FOREACH_DEV(i) {
2352 struct rte_eth_rss_conf local_rss_conf;
2354 ret = eth_dev_info_get_print_err(i, &dev_info);
2359 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2361 local_rss_conf = rss_conf;
2362 local_rss_conf.rss_hf = rss_conf.rss_hf &
2363 dev_info.flow_type_rss_offloads;
2364 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2365 printf("Port %u modified RSS hash function based on hardware support,"
2366 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2367 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2369 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2372 printf("Configuration of RSS hash at ethernet port %d "
2373 "failed with error (%d): %s.\n",
2374 i, -diag, strerror(-diag));
2377 if (all_updated && !use_default) {
2378 rss_hf = rss_conf.rss_hf;
2379 printf("rss_hf %#"PRIx64"\n", rss_hf);
2383 cmdline_parse_token_string_t cmd_config_rss_port =
2384 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2385 cmdline_parse_token_string_t cmd_config_rss_keyword =
2386 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2387 cmdline_parse_token_string_t cmd_config_rss_all =
2388 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2389 cmdline_parse_token_string_t cmd_config_rss_name =
2390 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2391 cmdline_parse_token_string_t cmd_config_rss_value =
2392 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2394 cmdline_parse_inst_t cmd_config_rss = {
2395 .f = cmd_config_rss_parsed,
2397 .help_str = "port config all rss "
2398 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2399 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|<flowtype_id>",
2401 (void *)&cmd_config_rss_port,
2402 (void *)&cmd_config_rss_keyword,
2403 (void *)&cmd_config_rss_all,
2404 (void *)&cmd_config_rss_name,
2405 (void *)&cmd_config_rss_value,
2410 /* *** configure rss hash key *** */
2411 struct cmd_config_rss_hash_key {
2412 cmdline_fixed_string_t port;
2413 cmdline_fixed_string_t config;
2415 cmdline_fixed_string_t rss_hash_key;
2416 cmdline_fixed_string_t rss_type;
2417 cmdline_fixed_string_t key;
2421 hexa_digit_to_value(char hexa_digit)
2423 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2424 return (uint8_t) (hexa_digit - '0');
2425 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2426 return (uint8_t) ((hexa_digit - 'a') + 10);
2427 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2428 return (uint8_t) ((hexa_digit - 'A') + 10);
2429 /* Invalid hexa digit */
2434 parse_and_check_key_hexa_digit(char *key, int idx)
2438 hexa_v = hexa_digit_to_value(key[idx]);
2440 printf("invalid key: character %c at position %d is not a "
2441 "valid hexa digit\n", key[idx], idx);
2446 cmd_config_rss_hash_key_parsed(void *parsed_result,
2447 __rte_unused struct cmdline *cl,
2448 __rte_unused void *data)
2450 struct cmd_config_rss_hash_key *res = parsed_result;
2451 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2455 struct rte_eth_dev_info dev_info;
2456 uint8_t hash_key_size;
2460 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2464 if (dev_info.hash_key_size > 0 &&
2465 dev_info.hash_key_size <= sizeof(hash_key))
2466 hash_key_size = dev_info.hash_key_size;
2468 printf("dev_info did not provide a valid hash key size\n");
2471 /* Check the length of the RSS hash key */
2472 key_len = strlen(res->key);
2473 if (key_len != (hash_key_size * 2)) {
2474 printf("key length: %d invalid - key must be a string of %d"
2475 " hexa-decimal numbers\n",
2476 (int) key_len, hash_key_size * 2);
2479 /* Translate RSS hash key into binary representation */
2480 for (i = 0; i < hash_key_size; i++) {
2481 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2484 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2487 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2489 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2493 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2494 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2495 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2496 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2498 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2499 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2500 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2501 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2502 rss_hash_key, "rss-hash-key");
2503 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2504 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2505 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2506 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2507 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2508 "ipv6-tcp-ex#ipv6-udp-ex#"
2509 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2510 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2511 "l2tpv3#esp#ah#pfcp#pppoe#gtpu");
2512 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2513 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2515 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2516 .f = cmd_config_rss_hash_key_parsed,
2518 .help_str = "port config <port_id> rss-hash-key "
2519 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2520 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2521 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2522 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2523 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2524 "l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2525 "<string of hex digits (variable length, NIC dependent)>",
2527 (void *)&cmd_config_rss_hash_key_port,
2528 (void *)&cmd_config_rss_hash_key_config,
2529 (void *)&cmd_config_rss_hash_key_port_id,
2530 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2531 (void *)&cmd_config_rss_hash_key_rss_type,
2532 (void *)&cmd_config_rss_hash_key_value,
2537 /* *** configure port rxq/txq ring size *** */
2538 struct cmd_config_rxtx_ring_size {
2539 cmdline_fixed_string_t port;
2540 cmdline_fixed_string_t config;
2542 cmdline_fixed_string_t rxtxq;
2544 cmdline_fixed_string_t rsize;
2549 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2550 __rte_unused struct cmdline *cl,
2551 __rte_unused void *data)
2553 struct cmd_config_rxtx_ring_size *res = parsed_result;
2554 struct rte_port *port;
2557 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2560 if (res->portid == (portid_t)RTE_PORT_ALL) {
2561 printf("Invalid port id\n");
2565 port = &ports[res->portid];
2567 if (!strcmp(res->rxtxq, "rxq"))
2569 else if (!strcmp(res->rxtxq, "txq"))
2572 printf("Unknown parameter\n");
2576 if (isrx && rx_queue_id_is_invalid(res->qid))
2578 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2581 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2582 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2588 port->nb_rx_desc[res->qid] = res->size;
2590 port->nb_tx_desc[res->qid] = res->size;
2592 cmd_reconfig_device_queue(res->portid, 0, 1);
2595 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2596 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2598 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2599 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2601 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2602 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2604 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2605 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2607 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2608 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2610 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2611 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2612 rsize, "ring_size");
2613 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2614 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2617 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2618 .f = cmd_config_rxtx_ring_size_parsed,
2620 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2622 (void *)&cmd_config_rxtx_ring_size_port,
2623 (void *)&cmd_config_rxtx_ring_size_config,
2624 (void *)&cmd_config_rxtx_ring_size_portid,
2625 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2626 (void *)&cmd_config_rxtx_ring_size_qid,
2627 (void *)&cmd_config_rxtx_ring_size_rsize,
2628 (void *)&cmd_config_rxtx_ring_size_size,
2633 /* *** configure port rxq/txq start/stop *** */
2634 struct cmd_config_rxtx_queue {
2635 cmdline_fixed_string_t port;
2637 cmdline_fixed_string_t rxtxq;
2639 cmdline_fixed_string_t opname;
2643 cmd_config_rxtx_queue_parsed(void *parsed_result,
2644 __rte_unused struct cmdline *cl,
2645 __rte_unused void *data)
2647 struct cmd_config_rxtx_queue *res = parsed_result;
2652 if (test_done == 0) {
2653 printf("Please stop forwarding first\n");
2657 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2660 if (port_is_started(res->portid) != 1) {
2661 printf("Please start port %u first\n", res->portid);
2665 if (!strcmp(res->rxtxq, "rxq"))
2667 else if (!strcmp(res->rxtxq, "txq"))
2670 printf("Unknown parameter\n");
2674 if (isrx && rx_queue_id_is_invalid(res->qid))
2676 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2679 if (!strcmp(res->opname, "start"))
2681 else if (!strcmp(res->opname, "stop"))
2684 printf("Unknown parameter\n");
2688 if (isstart && isrx)
2689 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2690 else if (!isstart && isrx)
2691 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2692 else if (isstart && !isrx)
2693 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2695 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2697 if (ret == -ENOTSUP)
2698 printf("Function not supported in PMD driver\n");
2701 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2702 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2703 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2704 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2705 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2706 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2707 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2708 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2709 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2710 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2713 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2714 .f = cmd_config_rxtx_queue_parsed,
2716 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2718 (void *)&cmd_config_rxtx_queue_port,
2719 (void *)&cmd_config_rxtx_queue_portid,
2720 (void *)&cmd_config_rxtx_queue_rxtxq,
2721 (void *)&cmd_config_rxtx_queue_qid,
2722 (void *)&cmd_config_rxtx_queue_opname,
2727 /* *** configure port rxq/txq deferred start on/off *** */
2728 struct cmd_config_deferred_start_rxtx_queue {
2729 cmdline_fixed_string_t port;
2731 cmdline_fixed_string_t rxtxq;
2733 cmdline_fixed_string_t opname;
2734 cmdline_fixed_string_t state;
2738 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2739 __rte_unused struct cmdline *cl,
2740 __rte_unused void *data)
2742 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2743 struct rte_port *port;
2746 uint8_t needreconfig = 0;
2748 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2751 if (port_is_started(res->port_id) != 0) {
2752 printf("Please stop port %u first\n", res->port_id);
2756 port = &ports[res->port_id];
2758 isrx = !strcmp(res->rxtxq, "rxq");
2760 if (isrx && rx_queue_id_is_invalid(res->qid))
2762 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2765 ison = !strcmp(res->state, "on");
2767 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2768 port->rx_conf[res->qid].rx_deferred_start = ison;
2770 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2771 port->tx_conf[res->qid].tx_deferred_start = ison;
2776 cmd_reconfig_device_queue(res->port_id, 0, 1);
2779 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2780 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2782 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2783 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2785 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2786 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2788 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2789 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2791 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2792 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2793 opname, "deferred_start");
2794 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2795 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2798 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2799 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2801 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2803 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2804 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2805 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2806 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2807 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2808 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2813 /* *** configure port rxq/txq setup *** */
2814 struct cmd_setup_rxtx_queue {
2815 cmdline_fixed_string_t port;
2817 cmdline_fixed_string_t rxtxq;
2819 cmdline_fixed_string_t setup;
2822 /* Common CLI fields for queue setup */
2823 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2824 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2825 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2826 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2827 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2828 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2829 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2830 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2831 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2832 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2835 cmd_setup_rxtx_queue_parsed(
2836 void *parsed_result,
2837 __rte_unused struct cmdline *cl,
2838 __rte_unused void *data)
2840 struct cmd_setup_rxtx_queue *res = parsed_result;
2841 struct rte_port *port;
2842 struct rte_mempool *mp;
2843 unsigned int socket_id;
2847 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2850 if (res->portid == (portid_t)RTE_PORT_ALL) {
2851 printf("Invalid port id\n");
2855 if (!strcmp(res->rxtxq, "rxq"))
2857 else if (!strcmp(res->rxtxq, "txq"))
2860 printf("Unknown parameter\n");
2864 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2865 printf("Invalid rx queue\n");
2867 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2868 printf("Invalid tx queue\n");
2872 port = &ports[res->portid];
2874 socket_id = rxring_numa[res->portid];
2875 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2876 socket_id = port->socket_id;
2878 mp = mbuf_pool_find(socket_id);
2880 printf("Failed to setup RX queue: "
2881 "No mempool allocation"
2882 " on the socket %d\n",
2883 rxring_numa[res->portid]);
2886 ret = rte_eth_rx_queue_setup(res->portid,
2888 port->nb_rx_desc[res->qid],
2890 &port->rx_conf[res->qid],
2893 printf("Failed to setup RX queue\n");
2895 socket_id = txring_numa[res->portid];
2896 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2897 socket_id = port->socket_id;
2899 ret = rte_eth_tx_queue_setup(res->portid,
2901 port->nb_tx_desc[res->qid],
2903 &port->tx_conf[res->qid]);
2905 printf("Failed to setup TX queue\n");
2909 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2910 .f = cmd_setup_rxtx_queue_parsed,
2912 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2914 (void *)&cmd_setup_rxtx_queue_port,
2915 (void *)&cmd_setup_rxtx_queue_portid,
2916 (void *)&cmd_setup_rxtx_queue_rxtxq,
2917 (void *)&cmd_setup_rxtx_queue_qid,
2918 (void *)&cmd_setup_rxtx_queue_setup,
2924 /* *** Configure RSS RETA *** */
2925 struct cmd_config_rss_reta {
2926 cmdline_fixed_string_t port;
2927 cmdline_fixed_string_t keyword;
2929 cmdline_fixed_string_t name;
2930 cmdline_fixed_string_t list_name;
2931 cmdline_fixed_string_t list_of_items;
2935 parse_reta_config(const char *str,
2936 struct rte_eth_rss_reta_entry64 *reta_conf,
2937 uint16_t nb_entries)
2941 uint16_t hash_index, idx, shift;
2944 const char *p, *p0 = str;
2951 unsigned long int_fld[_NUM_FLD];
2952 char *str_fld[_NUM_FLD];
2954 while ((p = strchr(p0,'(')) != NULL) {
2956 if((p0 = strchr(p,')')) == NULL)
2960 if(size >= sizeof(s))
2963 snprintf(s, sizeof(s), "%.*s", size, p);
2964 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2966 for (i = 0; i < _NUM_FLD; i++) {
2968 int_fld[i] = strtoul(str_fld[i], &end, 0);
2969 if (errno != 0 || end == str_fld[i] ||
2974 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2975 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2977 if (hash_index >= nb_entries) {
2978 printf("Invalid RETA hash index=%d\n", hash_index);
2982 idx = hash_index / RTE_RETA_GROUP_SIZE;
2983 shift = hash_index % RTE_RETA_GROUP_SIZE;
2984 reta_conf[idx].mask |= (1ULL << shift);
2985 reta_conf[idx].reta[shift] = nb_queue;
2992 cmd_set_rss_reta_parsed(void *parsed_result,
2993 __rte_unused struct cmdline *cl,
2994 __rte_unused void *data)
2997 struct rte_eth_dev_info dev_info;
2998 struct rte_eth_rss_reta_entry64 reta_conf[8];
2999 struct cmd_config_rss_reta *res = parsed_result;
3001 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3005 if (dev_info.reta_size == 0) {
3006 printf("Redirection table size is 0 which is "
3007 "invalid for RSS\n");
3010 printf("The reta size of port %d is %u\n",
3011 res->port_id, dev_info.reta_size);
3012 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3013 printf("Currently do not support more than %u entries of "
3014 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3018 memset(reta_conf, 0, sizeof(reta_conf));
3019 if (!strcmp(res->list_name, "reta")) {
3020 if (parse_reta_config(res->list_of_items, reta_conf,
3021 dev_info.reta_size)) {
3022 printf("Invalid RSS Redirection Table "
3023 "config entered\n");
3026 ret = rte_eth_dev_rss_reta_update(res->port_id,
3027 reta_conf, dev_info.reta_size);
3029 printf("Bad redirection table parameter, "
3030 "return code = %d \n", ret);
3034 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3035 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3036 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3037 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3038 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3039 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3040 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3041 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3042 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3043 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3044 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3045 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3047 cmdline_parse_inst_t cmd_config_rss_reta = {
3048 .f = cmd_set_rss_reta_parsed,
3050 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3052 (void *)&cmd_config_rss_reta_port,
3053 (void *)&cmd_config_rss_reta_keyword,
3054 (void *)&cmd_config_rss_reta_port_id,
3055 (void *)&cmd_config_rss_reta_name,
3056 (void *)&cmd_config_rss_reta_list_name,
3057 (void *)&cmd_config_rss_reta_list_of_items,
3062 /* *** SHOW PORT RETA INFO *** */
3063 struct cmd_showport_reta {
3064 cmdline_fixed_string_t show;
3065 cmdline_fixed_string_t port;
3067 cmdline_fixed_string_t rss;
3068 cmdline_fixed_string_t reta;
3070 cmdline_fixed_string_t list_of_items;
3074 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3075 uint16_t nb_entries,
3079 const char *p, *p0 = str;
3084 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3085 RTE_RETA_GROUP_SIZE;
3088 p = strchr(p0, '(');
3092 p0 = strchr(p, ')');
3096 if (size >= sizeof(s)) {
3097 printf("The string size exceeds the internal buffer size\n");
3100 snprintf(s, sizeof(s), "%.*s", size, p);
3101 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3102 if (ret <= 0 || ret != num) {
3103 printf("The bits of masks do not match the number of "
3104 "reta entries: %u\n", num);
3107 for (i = 0; i < ret; i++)
3108 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3114 cmd_showport_reta_parsed(void *parsed_result,
3115 __rte_unused struct cmdline *cl,
3116 __rte_unused void *data)
3118 struct cmd_showport_reta *res = parsed_result;
3119 struct rte_eth_rss_reta_entry64 reta_conf[8];
3120 struct rte_eth_dev_info dev_info;
3121 uint16_t max_reta_size;
3124 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3128 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3129 if (res->size == 0 || res->size > max_reta_size) {
3130 printf("Invalid redirection table size: %u (1-%u)\n",
3131 res->size, max_reta_size);
3135 memset(reta_conf, 0, sizeof(reta_conf));
3136 if (showport_parse_reta_config(reta_conf, res->size,
3137 res->list_of_items) < 0) {
3138 printf("Invalid string: %s for reta masks\n",
3139 res->list_of_items);
3142 port_rss_reta_info(res->port_id, reta_conf, res->size);
3145 cmdline_parse_token_string_t cmd_showport_reta_show =
3146 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3147 cmdline_parse_token_string_t cmd_showport_reta_port =
3148 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3149 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3150 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3151 cmdline_parse_token_string_t cmd_showport_reta_rss =
3152 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3153 cmdline_parse_token_string_t cmd_showport_reta_reta =
3154 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3155 cmdline_parse_token_num_t cmd_showport_reta_size =
3156 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3157 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3158 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3159 list_of_items, NULL);
3161 cmdline_parse_inst_t cmd_showport_reta = {
3162 .f = cmd_showport_reta_parsed,
3164 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3166 (void *)&cmd_showport_reta_show,
3167 (void *)&cmd_showport_reta_port,
3168 (void *)&cmd_showport_reta_port_id,
3169 (void *)&cmd_showport_reta_rss,
3170 (void *)&cmd_showport_reta_reta,
3171 (void *)&cmd_showport_reta_size,
3172 (void *)&cmd_showport_reta_list_of_items,
3177 /* *** Show RSS hash configuration *** */
3178 struct cmd_showport_rss_hash {
3179 cmdline_fixed_string_t show;
3180 cmdline_fixed_string_t port;
3182 cmdline_fixed_string_t rss_hash;
3183 cmdline_fixed_string_t rss_type;
3184 cmdline_fixed_string_t key; /* optional argument */
3187 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3188 __rte_unused struct cmdline *cl,
3191 struct cmd_showport_rss_hash *res = parsed_result;
3193 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3196 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3197 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3198 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3199 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3200 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3201 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3202 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3203 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3205 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3206 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3208 cmdline_parse_inst_t cmd_showport_rss_hash = {
3209 .f = cmd_showport_rss_hash_parsed,
3211 .help_str = "show port <port_id> rss-hash",
3213 (void *)&cmd_showport_rss_hash_show,
3214 (void *)&cmd_showport_rss_hash_port,
3215 (void *)&cmd_showport_rss_hash_port_id,
3216 (void *)&cmd_showport_rss_hash_rss_hash,
3221 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3222 .f = cmd_showport_rss_hash_parsed,
3224 .help_str = "show port <port_id> rss-hash key",
3226 (void *)&cmd_showport_rss_hash_show,
3227 (void *)&cmd_showport_rss_hash_port,
3228 (void *)&cmd_showport_rss_hash_port_id,
3229 (void *)&cmd_showport_rss_hash_rss_hash,
3230 (void *)&cmd_showport_rss_hash_rss_key,
3235 /* *** Configure DCB *** */
3236 struct cmd_config_dcb {
3237 cmdline_fixed_string_t port;
3238 cmdline_fixed_string_t config;
3240 cmdline_fixed_string_t dcb;
3241 cmdline_fixed_string_t vt;
3242 cmdline_fixed_string_t vt_en;
3244 cmdline_fixed_string_t pfc;
3245 cmdline_fixed_string_t pfc_en;
3249 cmd_config_dcb_parsed(void *parsed_result,
3250 __rte_unused struct cmdline *cl,
3251 __rte_unused void *data)
3253 struct cmd_config_dcb *res = parsed_result;
3254 portid_t port_id = res->port_id;
3255 struct rte_port *port;
3259 port = &ports[port_id];
3260 /** Check if the port is not started **/
3261 if (port->port_status != RTE_PORT_STOPPED) {
3262 printf("Please stop port %d first\n", port_id);
3266 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3267 printf("The invalid number of traffic class,"
3268 " only 4 or 8 allowed.\n");
3272 if (nb_fwd_lcores < res->num_tcs) {
3273 printf("nb_cores shouldn't be less than number of TCs.\n");
3276 if (!strncmp(res->pfc_en, "on", 2))
3281 /* DCB in VT mode */
3282 if (!strncmp(res->vt_en, "on", 2))
3283 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3284 (enum rte_eth_nb_tcs)res->num_tcs,
3287 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3288 (enum rte_eth_nb_tcs)res->num_tcs,
3293 printf("Cannot initialize network ports.\n");
3297 cmd_reconfig_device_queue(port_id, 1, 1);
3300 cmdline_parse_token_string_t cmd_config_dcb_port =
3301 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3302 cmdline_parse_token_string_t cmd_config_dcb_config =
3303 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3304 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3305 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3306 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3307 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3308 cmdline_parse_token_string_t cmd_config_dcb_vt =
3309 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3310 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3311 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3312 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3313 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3314 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3315 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3316 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3317 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3319 cmdline_parse_inst_t cmd_config_dcb = {
3320 .f = cmd_config_dcb_parsed,
3322 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3324 (void *)&cmd_config_dcb_port,
3325 (void *)&cmd_config_dcb_config,
3326 (void *)&cmd_config_dcb_port_id,
3327 (void *)&cmd_config_dcb_dcb,
3328 (void *)&cmd_config_dcb_vt,
3329 (void *)&cmd_config_dcb_vt_en,
3330 (void *)&cmd_config_dcb_num_tcs,
3331 (void *)&cmd_config_dcb_pfc,
3332 (void *)&cmd_config_dcb_pfc_en,
3337 /* *** configure number of packets per burst *** */
3338 struct cmd_config_burst {
3339 cmdline_fixed_string_t port;
3340 cmdline_fixed_string_t keyword;
3341 cmdline_fixed_string_t all;
3342 cmdline_fixed_string_t name;
3347 cmd_config_burst_parsed(void *parsed_result,
3348 __rte_unused struct cmdline *cl,
3349 __rte_unused void *data)
3351 struct cmd_config_burst *res = parsed_result;
3352 struct rte_eth_dev_info dev_info;
3353 uint16_t rec_nb_pkts;
3356 if (!all_ports_stopped()) {
3357 printf("Please stop all ports first\n");
3361 if (!strcmp(res->name, "burst")) {
3362 if (res->value == 0) {
3363 /* If user gives a value of zero, query the PMD for
3364 * its recommended Rx burst size. Testpmd uses a single
3365 * size for all ports, so assume all ports are the same
3366 * NIC model and use the values from Port 0.
3368 ret = eth_dev_info_get_print_err(0, &dev_info);
3372 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3374 if (rec_nb_pkts == 0) {
3375 printf("PMD does not recommend a burst size.\n"
3376 "User provided value must be between"
3377 " 1 and %d\n", MAX_PKT_BURST);
3379 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3380 printf("PMD recommended burst size of %d"
3381 " exceeds maximum value of %d\n",
3382 rec_nb_pkts, MAX_PKT_BURST);
3385 printf("Using PMD-provided burst value of %d\n",
3387 nb_pkt_per_burst = rec_nb_pkts;
3388 } else if (res->value > MAX_PKT_BURST) {
3389 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3392 nb_pkt_per_burst = res->value;
3394 printf("Unknown parameter\n");
3400 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3403 cmdline_parse_token_string_t cmd_config_burst_port =
3404 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3405 cmdline_parse_token_string_t cmd_config_burst_keyword =
3406 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3407 cmdline_parse_token_string_t cmd_config_burst_all =
3408 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3409 cmdline_parse_token_string_t cmd_config_burst_name =
3410 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3411 cmdline_parse_token_num_t cmd_config_burst_value =
3412 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3414 cmdline_parse_inst_t cmd_config_burst = {
3415 .f = cmd_config_burst_parsed,
3417 .help_str = "port config all burst <value>",
3419 (void *)&cmd_config_burst_port,
3420 (void *)&cmd_config_burst_keyword,
3421 (void *)&cmd_config_burst_all,
3422 (void *)&cmd_config_burst_name,
3423 (void *)&cmd_config_burst_value,
3428 /* *** configure rx/tx queues *** */
3429 struct cmd_config_thresh {
3430 cmdline_fixed_string_t port;
3431 cmdline_fixed_string_t keyword;
3432 cmdline_fixed_string_t all;
3433 cmdline_fixed_string_t name;
3438 cmd_config_thresh_parsed(void *parsed_result,
3439 __rte_unused struct cmdline *cl,
3440 __rte_unused void *data)
3442 struct cmd_config_thresh *res = parsed_result;
3444 if (!all_ports_stopped()) {
3445 printf("Please stop all ports first\n");
3449 if (!strcmp(res->name, "txpt"))
3450 tx_pthresh = res->value;
3451 else if(!strcmp(res->name, "txht"))
3452 tx_hthresh = res->value;
3453 else if(!strcmp(res->name, "txwt"))
3454 tx_wthresh = res->value;
3455 else if(!strcmp(res->name, "rxpt"))
3456 rx_pthresh = res->value;
3457 else if(!strcmp(res->name, "rxht"))
3458 rx_hthresh = res->value;
3459 else if(!strcmp(res->name, "rxwt"))
3460 rx_wthresh = res->value;
3462 printf("Unknown parameter\n");
3468 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3471 cmdline_parse_token_string_t cmd_config_thresh_port =
3472 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3473 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3474 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3475 cmdline_parse_token_string_t cmd_config_thresh_all =
3476 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3477 cmdline_parse_token_string_t cmd_config_thresh_name =
3478 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3479 "txpt#txht#txwt#rxpt#rxht#rxwt");
3480 cmdline_parse_token_num_t cmd_config_thresh_value =
3481 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3483 cmdline_parse_inst_t cmd_config_thresh = {
3484 .f = cmd_config_thresh_parsed,
3486 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3488 (void *)&cmd_config_thresh_port,
3489 (void *)&cmd_config_thresh_keyword,
3490 (void *)&cmd_config_thresh_all,
3491 (void *)&cmd_config_thresh_name,
3492 (void *)&cmd_config_thresh_value,
3497 /* *** configure free/rs threshold *** */
3498 struct cmd_config_threshold {
3499 cmdline_fixed_string_t port;
3500 cmdline_fixed_string_t keyword;
3501 cmdline_fixed_string_t all;
3502 cmdline_fixed_string_t name;
3507 cmd_config_threshold_parsed(void *parsed_result,
3508 __rte_unused struct cmdline *cl,
3509 __rte_unused void *data)
3511 struct cmd_config_threshold *res = parsed_result;
3513 if (!all_ports_stopped()) {
3514 printf("Please stop all ports first\n");
3518 if (!strcmp(res->name, "txfreet"))
3519 tx_free_thresh = res->value;
3520 else if (!strcmp(res->name, "txrst"))
3521 tx_rs_thresh = res->value;
3522 else if (!strcmp(res->name, "rxfreet"))
3523 rx_free_thresh = res->value;
3525 printf("Unknown parameter\n");
3531 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3534 cmdline_parse_token_string_t cmd_config_threshold_port =
3535 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3536 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3537 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3539 cmdline_parse_token_string_t cmd_config_threshold_all =
3540 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3541 cmdline_parse_token_string_t cmd_config_threshold_name =
3542 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3543 "txfreet#txrst#rxfreet");
3544 cmdline_parse_token_num_t cmd_config_threshold_value =
3545 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3547 cmdline_parse_inst_t cmd_config_threshold = {
3548 .f = cmd_config_threshold_parsed,
3550 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3552 (void *)&cmd_config_threshold_port,
3553 (void *)&cmd_config_threshold_keyword,
3554 (void *)&cmd_config_threshold_all,
3555 (void *)&cmd_config_threshold_name,
3556 (void *)&cmd_config_threshold_value,
3562 struct cmd_stop_result {
3563 cmdline_fixed_string_t stop;
3566 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3567 __rte_unused struct cmdline *cl,
3568 __rte_unused void *data)
3570 stop_packet_forwarding();
3573 cmdline_parse_token_string_t cmd_stop_stop =
3574 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3576 cmdline_parse_inst_t cmd_stop = {
3577 .f = cmd_stop_parsed,
3579 .help_str = "stop: Stop packet forwarding",
3581 (void *)&cmd_stop_stop,
3586 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3589 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3590 unsigned int *parsed_items, int check_unique_values)
3592 unsigned int nb_item;
3600 * First parse all items in the list and store their value.
3605 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3607 if ((c >= '0') && (c <= '9')) {
3608 value = (unsigned int) (value * 10 + (c - '0'));
3613 printf("character %c is not a decimal digit\n", c);
3617 printf("No valid value before comma\n");
3620 if (nb_item < max_items) {
3621 parsed_items[nb_item] = value;
3627 if (nb_item >= max_items) {
3628 printf("Number of %s = %u > %u (maximum items)\n",
3629 item_name, nb_item + 1, max_items);
3632 parsed_items[nb_item++] = value;
3633 if (! check_unique_values)
3637 * Then, check that all values in the list are differents.
3638 * No optimization here...
3640 for (i = 0; i < nb_item; i++) {
3641 for (j = i + 1; j < nb_item; j++) {
3642 if (parsed_items[j] == parsed_items[i]) {
3643 printf("duplicated %s %u at index %u and %u\n",
3644 item_name, parsed_items[i], i, j);
3652 struct cmd_set_list_result {
3653 cmdline_fixed_string_t cmd_keyword;
3654 cmdline_fixed_string_t list_name;
3655 cmdline_fixed_string_t list_of_items;
3658 static void cmd_set_list_parsed(void *parsed_result,
3659 __rte_unused struct cmdline *cl,
3660 __rte_unused void *data)
3662 struct cmd_set_list_result *res;
3664 unsigned int lcorelist[RTE_MAX_LCORE];
3665 unsigned int portlist[RTE_MAX_ETHPORTS];
3667 unsigned int nb_item;
3669 if (test_done == 0) {
3670 printf("Please stop forwarding first\n");
3674 res = parsed_result;
3675 if (!strcmp(res->list_name, "corelist")) {
3676 nb_item = parse_item_list(res->list_of_items, "core",
3678 parsed_items.lcorelist, 1);
3680 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3685 if (!strcmp(res->list_name, "portlist")) {
3686 nb_item = parse_item_list(res->list_of_items, "port",
3688 parsed_items.portlist, 1);
3690 set_fwd_ports_list(parsed_items.portlist, nb_item);
3696 cmdline_parse_token_string_t cmd_set_list_keyword =
3697 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3699 cmdline_parse_token_string_t cmd_set_list_name =
3700 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3701 "corelist#portlist");
3702 cmdline_parse_token_string_t cmd_set_list_of_items =
3703 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3706 cmdline_parse_inst_t cmd_set_fwd_list = {
3707 .f = cmd_set_list_parsed,
3709 .help_str = "set corelist|portlist <list0[,list1]*>",
3711 (void *)&cmd_set_list_keyword,
3712 (void *)&cmd_set_list_name,
3713 (void *)&cmd_set_list_of_items,
3718 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3720 struct cmd_setmask_result {
3721 cmdline_fixed_string_t set;
3722 cmdline_fixed_string_t mask;
3726 static void cmd_set_mask_parsed(void *parsed_result,
3727 __rte_unused struct cmdline *cl,
3728 __rte_unused void *data)
3730 struct cmd_setmask_result *res = parsed_result;
3732 if (test_done == 0) {
3733 printf("Please stop forwarding first\n");
3736 if (!strcmp(res->mask, "coremask")) {
3737 set_fwd_lcores_mask(res->hexavalue);
3739 } else if (!strcmp(res->mask, "portmask")) {
3740 set_fwd_ports_mask(res->hexavalue);
3745 cmdline_parse_token_string_t cmd_setmask_set =
3746 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3747 cmdline_parse_token_string_t cmd_setmask_mask =
3748 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3749 "coremask#portmask");
3750 cmdline_parse_token_num_t cmd_setmask_value =
3751 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3753 cmdline_parse_inst_t cmd_set_fwd_mask = {
3754 .f = cmd_set_mask_parsed,
3756 .help_str = "set coremask|portmask <hexadecimal value>",
3758 (void *)&cmd_setmask_set,
3759 (void *)&cmd_setmask_mask,
3760 (void *)&cmd_setmask_value,
3766 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3768 struct cmd_set_result {
3769 cmdline_fixed_string_t set;
3770 cmdline_fixed_string_t what;
3774 static void cmd_set_parsed(void *parsed_result,
3775 __rte_unused struct cmdline *cl,
3776 __rte_unused void *data)
3778 struct cmd_set_result *res = parsed_result;
3779 if (!strcmp(res->what, "nbport")) {
3780 set_fwd_ports_number(res->value);
3782 } else if (!strcmp(res->what, "nbcore")) {
3783 set_fwd_lcores_number(res->value);
3785 } else if (!strcmp(res->what, "burst"))
3786 set_nb_pkt_per_burst(res->value);
3787 else if (!strcmp(res->what, "verbose"))
3788 set_verbose_level(res->value);
3791 cmdline_parse_token_string_t cmd_set_set =
3792 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3793 cmdline_parse_token_string_t cmd_set_what =
3794 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3795 "nbport#nbcore#burst#verbose");
3796 cmdline_parse_token_num_t cmd_set_value =
3797 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3799 cmdline_parse_inst_t cmd_set_numbers = {
3800 .f = cmd_set_parsed,
3802 .help_str = "set nbport|nbcore|burst|verbose <value>",
3804 (void *)&cmd_set_set,
3805 (void *)&cmd_set_what,
3806 (void *)&cmd_set_value,
3811 /* *** SET LOG LEVEL CONFIGURATION *** */
3813 struct cmd_set_log_result {
3814 cmdline_fixed_string_t set;
3815 cmdline_fixed_string_t log;
3816 cmdline_fixed_string_t type;
3821 cmd_set_log_parsed(void *parsed_result,
3822 __rte_unused struct cmdline *cl,
3823 __rte_unused void *data)
3825 struct cmd_set_log_result *res;
3828 res = parsed_result;
3829 if (!strcmp(res->type, "global"))
3830 rte_log_set_global_level(res->level);
3832 ret = rte_log_set_level_regexp(res->type, res->level);
3834 printf("Unable to set log level\n");
3838 cmdline_parse_token_string_t cmd_set_log_set =
3839 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3840 cmdline_parse_token_string_t cmd_set_log_log =
3841 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3842 cmdline_parse_token_string_t cmd_set_log_type =
3843 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3844 cmdline_parse_token_num_t cmd_set_log_level =
3845 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3847 cmdline_parse_inst_t cmd_set_log = {
3848 .f = cmd_set_log_parsed,
3850 .help_str = "set log global|<type> <level>",
3852 (void *)&cmd_set_log_set,
3853 (void *)&cmd_set_log_log,
3854 (void *)&cmd_set_log_type,
3855 (void *)&cmd_set_log_level,
3860 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3862 struct cmd_set_txpkts_result {
3863 cmdline_fixed_string_t cmd_keyword;
3864 cmdline_fixed_string_t txpkts;
3865 cmdline_fixed_string_t seg_lengths;
3869 cmd_set_txpkts_parsed(void *parsed_result,
3870 __rte_unused struct cmdline *cl,
3871 __rte_unused void *data)
3873 struct cmd_set_txpkts_result *res;
3874 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3875 unsigned int nb_segs;
3877 res = parsed_result;
3878 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3879 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3881 set_tx_pkt_segments(seg_lengths, nb_segs);
3884 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3885 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3886 cmd_keyword, "set");
3887 cmdline_parse_token_string_t cmd_set_txpkts_name =
3888 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3890 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3891 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3894 cmdline_parse_inst_t cmd_set_txpkts = {
3895 .f = cmd_set_txpkts_parsed,
3897 .help_str = "set txpkts <len0[,len1]*>",
3899 (void *)&cmd_set_txpkts_keyword,
3900 (void *)&cmd_set_txpkts_name,
3901 (void *)&cmd_set_txpkts_lengths,
3906 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3908 struct cmd_set_txsplit_result {
3909 cmdline_fixed_string_t cmd_keyword;
3910 cmdline_fixed_string_t txsplit;
3911 cmdline_fixed_string_t mode;
3915 cmd_set_txsplit_parsed(void *parsed_result,
3916 __rte_unused struct cmdline *cl,
3917 __rte_unused void *data)
3919 struct cmd_set_txsplit_result *res;
3921 res = parsed_result;
3922 set_tx_pkt_split(res->mode);
3925 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3926 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3927 cmd_keyword, "set");
3928 cmdline_parse_token_string_t cmd_set_txsplit_name =
3929 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3930 txsplit, "txsplit");
3931 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3932 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3935 cmdline_parse_inst_t cmd_set_txsplit = {
3936 .f = cmd_set_txsplit_parsed,
3938 .help_str = "set txsplit on|off|rand",
3940 (void *)&cmd_set_txsplit_keyword,
3941 (void *)&cmd_set_txsplit_name,
3942 (void *)&cmd_set_txsplit_mode,
3947 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
3949 struct cmd_set_txtimes_result {
3950 cmdline_fixed_string_t cmd_keyword;
3951 cmdline_fixed_string_t txtimes;
3952 cmdline_fixed_string_t tx_times;
3956 cmd_set_txtimes_parsed(void *parsed_result,
3957 __rte_unused struct cmdline *cl,
3958 __rte_unused void *data)
3960 struct cmd_set_txtimes_result *res;
3961 unsigned int tx_times[2] = {0, 0};
3962 unsigned int n_times;
3964 res = parsed_result;
3965 n_times = parse_item_list(res->tx_times, "tx times",
3968 set_tx_pkt_times(tx_times);
3971 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
3972 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3973 cmd_keyword, "set");
3974 cmdline_parse_token_string_t cmd_set_txtimes_name =
3975 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3976 txtimes, "txtimes");
3977 cmdline_parse_token_string_t cmd_set_txtimes_value =
3978 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3981 cmdline_parse_inst_t cmd_set_txtimes = {
3982 .f = cmd_set_txtimes_parsed,
3984 .help_str = "set txtimes <inter_burst>,<intra_burst>",
3986 (void *)&cmd_set_txtimes_keyword,
3987 (void *)&cmd_set_txtimes_name,
3988 (void *)&cmd_set_txtimes_value,
3993 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3994 struct cmd_rx_vlan_filter_all_result {
3995 cmdline_fixed_string_t rx_vlan;
3996 cmdline_fixed_string_t what;
3997 cmdline_fixed_string_t all;
4002 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4003 __rte_unused struct cmdline *cl,
4004 __rte_unused void *data)
4006 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4008 if (!strcmp(res->what, "add"))
4009 rx_vlan_all_filter_set(res->port_id, 1);
4011 rx_vlan_all_filter_set(res->port_id, 0);
4014 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4015 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4016 rx_vlan, "rx_vlan");
4017 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4018 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4020 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4021 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4023 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4024 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4027 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4028 .f = cmd_rx_vlan_filter_all_parsed,
4030 .help_str = "rx_vlan add|rm all <port_id>: "
4031 "Add/Remove all identifiers to/from the set of VLAN "
4032 "identifiers filtered by a port",
4034 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4035 (void *)&cmd_rx_vlan_filter_all_what,
4036 (void *)&cmd_rx_vlan_filter_all_all,
4037 (void *)&cmd_rx_vlan_filter_all_portid,
4042 /* *** VLAN OFFLOAD SET ON A PORT *** */
4043 struct cmd_vlan_offload_result {
4044 cmdline_fixed_string_t vlan;
4045 cmdline_fixed_string_t set;
4046 cmdline_fixed_string_t vlan_type;
4047 cmdline_fixed_string_t what;
4048 cmdline_fixed_string_t on;
4049 cmdline_fixed_string_t port_id;
4053 cmd_vlan_offload_parsed(void *parsed_result,
4054 __rte_unused struct cmdline *cl,
4055 __rte_unused void *data)
4058 struct cmd_vlan_offload_result *res = parsed_result;
4061 portid_t port_id = 0;
4065 len = strnlen(str, STR_TOKEN_SIZE);
4067 /* Get port_id first */
4075 tmp = strtoul(str, NULL, 0);
4076 /* If port_id greater that what portid_t can represent, return */
4077 if(tmp >= RTE_MAX_ETHPORTS)
4079 port_id = (portid_t)tmp;
4081 if (!strcmp(res->on, "on"))
4086 if (!strcmp(res->what, "strip"))
4087 rx_vlan_strip_set(port_id, on);
4088 else if(!strcmp(res->what, "stripq")){
4089 uint16_t queue_id = 0;
4091 /* No queue_id, return */
4093 printf("must specify (port,queue_id)\n");
4096 tmp = strtoul(str + i + 1, NULL, 0);
4097 /* If queue_id greater that what 16-bits can represent, return */
4101 queue_id = (uint16_t)tmp;
4102 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4104 else if (!strcmp(res->what, "filter"))
4105 rx_vlan_filter_set(port_id, on);
4106 else if (!strcmp(res->what, "qinq_strip"))
4107 rx_vlan_qinq_strip_set(port_id, on);
4109 vlan_extend_set(port_id, on);
4114 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4115 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4117 cmdline_parse_token_string_t cmd_vlan_offload_set =
4118 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4120 cmdline_parse_token_string_t cmd_vlan_offload_what =
4121 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4122 what, "strip#filter#qinq_strip#extend#stripq");
4123 cmdline_parse_token_string_t cmd_vlan_offload_on =
4124 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4126 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4127 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4130 cmdline_parse_inst_t cmd_vlan_offload = {
4131 .f = cmd_vlan_offload_parsed,
4133 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4134 "<port_id[,queue_id]>: "
4135 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4137 (void *)&cmd_vlan_offload_vlan,
4138 (void *)&cmd_vlan_offload_set,
4139 (void *)&cmd_vlan_offload_what,
4140 (void *)&cmd_vlan_offload_on,
4141 (void *)&cmd_vlan_offload_portid,
4146 /* *** VLAN TPID SET ON A PORT *** */
4147 struct cmd_vlan_tpid_result {
4148 cmdline_fixed_string_t vlan;
4149 cmdline_fixed_string_t set;
4150 cmdline_fixed_string_t vlan_type;
4151 cmdline_fixed_string_t what;
4157 cmd_vlan_tpid_parsed(void *parsed_result,
4158 __rte_unused struct cmdline *cl,
4159 __rte_unused void *data)
4161 struct cmd_vlan_tpid_result *res = parsed_result;
4162 enum rte_vlan_type vlan_type;
4164 if (!strcmp(res->vlan_type, "inner"))
4165 vlan_type = ETH_VLAN_TYPE_INNER;
4166 else if (!strcmp(res->vlan_type, "outer"))
4167 vlan_type = ETH_VLAN_TYPE_OUTER;
4169 printf("Unknown vlan type\n");
4172 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4175 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4176 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4178 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4179 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4181 cmdline_parse_token_string_t cmd_vlan_type =
4182 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4183 vlan_type, "inner#outer");
4184 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4185 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4187 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4188 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4190 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4191 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4194 cmdline_parse_inst_t cmd_vlan_tpid = {
4195 .f = cmd_vlan_tpid_parsed,
4197 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4198 "Set the VLAN Ether type",
4200 (void *)&cmd_vlan_tpid_vlan,
4201 (void *)&cmd_vlan_tpid_set,
4202 (void *)&cmd_vlan_type,
4203 (void *)&cmd_vlan_tpid_what,
4204 (void *)&cmd_vlan_tpid_tpid,
4205 (void *)&cmd_vlan_tpid_portid,
4210 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4211 struct cmd_rx_vlan_filter_result {
4212 cmdline_fixed_string_t rx_vlan;
4213 cmdline_fixed_string_t what;
4219 cmd_rx_vlan_filter_parsed(void *parsed_result,
4220 __rte_unused struct cmdline *cl,
4221 __rte_unused void *data)
4223 struct cmd_rx_vlan_filter_result *res = parsed_result;
4225 if (!strcmp(res->what, "add"))
4226 rx_vft_set(res->port_id, res->vlan_id, 1);
4228 rx_vft_set(res->port_id, res->vlan_id, 0);
4231 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4232 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4233 rx_vlan, "rx_vlan");
4234 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4235 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4237 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4238 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4240 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4241 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4244 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4245 .f = cmd_rx_vlan_filter_parsed,
4247 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4248 "Add/Remove a VLAN identifier to/from the set of VLAN "
4249 "identifiers filtered by a port",
4251 (void *)&cmd_rx_vlan_filter_rx_vlan,
4252 (void *)&cmd_rx_vlan_filter_what,
4253 (void *)&cmd_rx_vlan_filter_vlanid,
4254 (void *)&cmd_rx_vlan_filter_portid,
4259 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4260 struct cmd_tx_vlan_set_result {
4261 cmdline_fixed_string_t tx_vlan;
4262 cmdline_fixed_string_t set;
4268 cmd_tx_vlan_set_parsed(void *parsed_result,
4269 __rte_unused struct cmdline *cl,
4270 __rte_unused void *data)
4272 struct cmd_tx_vlan_set_result *res = parsed_result;
4274 if (!port_is_stopped(res->port_id)) {
4275 printf("Please stop port %d first\n", res->port_id);
4279 tx_vlan_set(res->port_id, res->vlan_id);
4281 cmd_reconfig_device_queue(res->port_id, 1, 1);
4284 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4285 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4286 tx_vlan, "tx_vlan");
4287 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4288 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4290 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4291 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4293 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4294 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4297 cmdline_parse_inst_t cmd_tx_vlan_set = {
4298 .f = cmd_tx_vlan_set_parsed,
4300 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4301 "Enable hardware insertion of a single VLAN header "
4302 "with a given TAG Identifier in packets sent on a port",
4304 (void *)&cmd_tx_vlan_set_tx_vlan,
4305 (void *)&cmd_tx_vlan_set_set,
4306 (void *)&cmd_tx_vlan_set_portid,
4307 (void *)&cmd_tx_vlan_set_vlanid,
4312 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4313 struct cmd_tx_vlan_set_qinq_result {
4314 cmdline_fixed_string_t tx_vlan;
4315 cmdline_fixed_string_t set;
4318 uint16_t vlan_id_outer;
4322 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4323 __rte_unused struct cmdline *cl,
4324 __rte_unused void *data)
4326 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4328 if (!port_is_stopped(res->port_id)) {
4329 printf("Please stop port %d first\n", res->port_id);
4333 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4335 cmd_reconfig_device_queue(res->port_id, 1, 1);
4338 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4339 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4340 tx_vlan, "tx_vlan");
4341 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4342 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4344 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4345 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4347 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4348 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4350 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4351 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4352 vlan_id_outer, UINT16);
4354 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4355 .f = cmd_tx_vlan_set_qinq_parsed,
4357 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4358 "Enable hardware insertion of double VLAN header "
4359 "with given TAG Identifiers in packets sent on a port",
4361 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4362 (void *)&cmd_tx_vlan_set_qinq_set,
4363 (void *)&cmd_tx_vlan_set_qinq_portid,
4364 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4365 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4370 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4371 struct cmd_tx_vlan_set_pvid_result {
4372 cmdline_fixed_string_t tx_vlan;
4373 cmdline_fixed_string_t set;
4374 cmdline_fixed_string_t pvid;
4377 cmdline_fixed_string_t mode;
4381 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4382 __rte_unused struct cmdline *cl,
4383 __rte_unused void *data)
4385 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4387 if (strcmp(res->mode, "on") == 0)
4388 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4390 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4393 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4394 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4395 tx_vlan, "tx_vlan");
4396 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4397 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4399 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4400 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4402 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4403 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4405 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4406 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4408 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4409 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4412 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4413 .f = cmd_tx_vlan_set_pvid_parsed,
4415 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4417 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4418 (void *)&cmd_tx_vlan_set_pvid_set,
4419 (void *)&cmd_tx_vlan_set_pvid_pvid,
4420 (void *)&cmd_tx_vlan_set_pvid_port_id,
4421 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4422 (void *)&cmd_tx_vlan_set_pvid_mode,
4427 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4428 struct cmd_tx_vlan_reset_result {
4429 cmdline_fixed_string_t tx_vlan;
4430 cmdline_fixed_string_t reset;
4435 cmd_tx_vlan_reset_parsed(void *parsed_result,
4436 __rte_unused struct cmdline *cl,
4437 __rte_unused void *data)
4439 struct cmd_tx_vlan_reset_result *res = parsed_result;
4441 if (!port_is_stopped(res->port_id)) {
4442 printf("Please stop port %d first\n", res->port_id);
4446 tx_vlan_reset(res->port_id);
4448 cmd_reconfig_device_queue(res->port_id, 1, 1);
4451 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4452 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4453 tx_vlan, "tx_vlan");
4454 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4455 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4457 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4458 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4461 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4462 .f = cmd_tx_vlan_reset_parsed,
4464 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4465 "VLAN header in packets sent on a port",
4467 (void *)&cmd_tx_vlan_reset_tx_vlan,
4468 (void *)&cmd_tx_vlan_reset_reset,
4469 (void *)&cmd_tx_vlan_reset_portid,
4475 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4476 struct cmd_csum_result {
4477 cmdline_fixed_string_t csum;
4478 cmdline_fixed_string_t mode;
4479 cmdline_fixed_string_t proto;
4480 cmdline_fixed_string_t hwsw;
4485 csum_show(int port_id)
4487 struct rte_eth_dev_info dev_info;
4488 uint64_t tx_offloads;
4491 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4492 printf("Parse tunnel is %s\n",
4493 (ports[port_id].parse_tunnel) ? "on" : "off");
4494 printf("IP checksum offload is %s\n",
4495 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4496 printf("UDP checksum offload is %s\n",
4497 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4498 printf("TCP checksum offload is %s\n",
4499 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4500 printf("SCTP checksum offload is %s\n",
4501 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4502 printf("Outer-Ip checksum offload is %s\n",
4503 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4504 printf("Outer-Udp checksum offload is %s\n",
4505 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4507 /* display warnings if configuration is not supported by the NIC */
4508 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4512 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4513 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4514 printf("Warning: hardware IP checksum enabled but not "
4515 "supported by port %d\n", port_id);
4517 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4518 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4519 printf("Warning: hardware UDP checksum enabled but not "
4520 "supported by port %d\n", port_id);
4522 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4523 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4524 printf("Warning: hardware TCP checksum enabled but not "
4525 "supported by port %d\n", port_id);
4527 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4528 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4529 printf("Warning: hardware SCTP checksum enabled but not "
4530 "supported by port %d\n", port_id);
4532 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4533 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4534 printf("Warning: hardware outer IP checksum enabled but not "
4535 "supported by port %d\n", port_id);
4537 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4538 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4540 printf("Warning: hardware outer UDP checksum enabled but not "
4541 "supported by port %d\n", port_id);
4546 cmd_config_queue_tx_offloads(struct rte_port *port)
4550 /* Apply queue tx offloads configuration */
4551 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4552 port->tx_conf[k].offloads =
4553 port->dev_conf.txmode.offloads;
4557 cmd_csum_parsed(void *parsed_result,
4558 __rte_unused struct cmdline *cl,
4559 __rte_unused void *data)
4561 struct cmd_csum_result *res = parsed_result;
4563 uint64_t csum_offloads = 0;
4564 struct rte_eth_dev_info dev_info;
4567 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4568 printf("invalid port %d\n", res->port_id);
4571 if (!port_is_stopped(res->port_id)) {
4572 printf("Please stop port %d first\n", res->port_id);
4576 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4580 if (!strcmp(res->mode, "set")) {
4582 if (!strcmp(res->hwsw, "hw"))
4585 if (!strcmp(res->proto, "ip")) {
4586 if (hw == 0 || (dev_info.tx_offload_capa &
4587 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4588 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4590 printf("IP checksum offload is not supported "
4591 "by port %u\n", res->port_id);
4593 } else if (!strcmp(res->proto, "udp")) {
4594 if (hw == 0 || (dev_info.tx_offload_capa &
4595 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4596 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4598 printf("UDP checksum offload is not supported "
4599 "by port %u\n", res->port_id);
4601 } else if (!strcmp(res->proto, "tcp")) {
4602 if (hw == 0 || (dev_info.tx_offload_capa &
4603 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4604 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4606 printf("TCP checksum offload is not supported "
4607 "by port %u\n", res->port_id);
4609 } else if (!strcmp(res->proto, "sctp")) {
4610 if (hw == 0 || (dev_info.tx_offload_capa &
4611 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4612 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4614 printf("SCTP checksum offload is not supported "
4615 "by port %u\n", res->port_id);
4617 } else if (!strcmp(res->proto, "outer-ip")) {
4618 if (hw == 0 || (dev_info.tx_offload_capa &
4619 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4621 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4623 printf("Outer IP checksum offload is not "
4624 "supported by port %u\n", res->port_id);
4626 } else if (!strcmp(res->proto, "outer-udp")) {
4627 if (hw == 0 || (dev_info.tx_offload_capa &
4628 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4630 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4632 printf("Outer UDP checksum offload is not "
4633 "supported by port %u\n", res->port_id);
4638 ports[res->port_id].dev_conf.txmode.offloads |=
4641 ports[res->port_id].dev_conf.txmode.offloads &=
4644 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4646 csum_show(res->port_id);
4648 cmd_reconfig_device_queue(res->port_id, 1, 1);
4651 cmdline_parse_token_string_t cmd_csum_csum =
4652 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4654 cmdline_parse_token_string_t cmd_csum_mode =
4655 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4657 cmdline_parse_token_string_t cmd_csum_proto =
4658 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4659 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4660 cmdline_parse_token_string_t cmd_csum_hwsw =
4661 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4663 cmdline_parse_token_num_t cmd_csum_portid =
4664 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4667 cmdline_parse_inst_t cmd_csum_set = {
4668 .f = cmd_csum_parsed,
4670 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4671 "Enable/Disable hardware calculation of L3/L4 checksum when "
4672 "using csum forward engine",
4674 (void *)&cmd_csum_csum,
4675 (void *)&cmd_csum_mode,
4676 (void *)&cmd_csum_proto,
4677 (void *)&cmd_csum_hwsw,
4678 (void *)&cmd_csum_portid,
4683 cmdline_parse_token_string_t cmd_csum_mode_show =
4684 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4687 cmdline_parse_inst_t cmd_csum_show = {
4688 .f = cmd_csum_parsed,
4690 .help_str = "csum show <port_id>: Show checksum offload configuration",
4692 (void *)&cmd_csum_csum,
4693 (void *)&cmd_csum_mode_show,
4694 (void *)&cmd_csum_portid,
4699 /* Enable/disable tunnel parsing */
4700 struct cmd_csum_tunnel_result {
4701 cmdline_fixed_string_t csum;
4702 cmdline_fixed_string_t parse;
4703 cmdline_fixed_string_t onoff;
4708 cmd_csum_tunnel_parsed(void *parsed_result,
4709 __rte_unused struct cmdline *cl,
4710 __rte_unused void *data)
4712 struct cmd_csum_tunnel_result *res = parsed_result;
4714 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4717 if (!strcmp(res->onoff, "on"))
4718 ports[res->port_id].parse_tunnel = 1;
4720 ports[res->port_id].parse_tunnel = 0;
4722 csum_show(res->port_id);
4725 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4726 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4728 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4729 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4730 parse, "parse-tunnel");
4731 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4732 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4734 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4735 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4738 cmdline_parse_inst_t cmd_csum_tunnel = {
4739 .f = cmd_csum_tunnel_parsed,
4741 .help_str = "csum parse-tunnel on|off <port_id>: "
4742 "Enable/Disable parsing of tunnels for csum engine",
4744 (void *)&cmd_csum_tunnel_csum,
4745 (void *)&cmd_csum_tunnel_parse,
4746 (void *)&cmd_csum_tunnel_onoff,
4747 (void *)&cmd_csum_tunnel_portid,
4752 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4753 struct cmd_tso_set_result {
4754 cmdline_fixed_string_t tso;
4755 cmdline_fixed_string_t mode;
4761 cmd_tso_set_parsed(void *parsed_result,
4762 __rte_unused struct cmdline *cl,
4763 __rte_unused void *data)
4765 struct cmd_tso_set_result *res = parsed_result;
4766 struct rte_eth_dev_info dev_info;
4769 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4771 if (!port_is_stopped(res->port_id)) {
4772 printf("Please stop port %d first\n", res->port_id);
4776 if (!strcmp(res->mode, "set"))
4777 ports[res->port_id].tso_segsz = res->tso_segsz;
4779 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4783 if ((ports[res->port_id].tso_segsz != 0) &&
4784 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4785 printf("Error: TSO is not supported by port %d\n",
4790 if (ports[res->port_id].tso_segsz == 0) {
4791 ports[res->port_id].dev_conf.txmode.offloads &=
4792 ~DEV_TX_OFFLOAD_TCP_TSO;
4793 printf("TSO for non-tunneled packets is disabled\n");
4795 ports[res->port_id].dev_conf.txmode.offloads |=
4796 DEV_TX_OFFLOAD_TCP_TSO;
4797 printf("TSO segment size for non-tunneled packets is %d\n",
4798 ports[res->port_id].tso_segsz);
4800 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4802 /* display warnings if configuration is not supported by the NIC */
4803 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4807 if ((ports[res->port_id].tso_segsz != 0) &&
4808 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4809 printf("Warning: TSO enabled but not "
4810 "supported by port %d\n", res->port_id);
4813 cmd_reconfig_device_queue(res->port_id, 1, 1);
4816 cmdline_parse_token_string_t cmd_tso_set_tso =
4817 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4819 cmdline_parse_token_string_t cmd_tso_set_mode =
4820 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4822 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4823 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4825 cmdline_parse_token_num_t cmd_tso_set_portid =
4826 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4829 cmdline_parse_inst_t cmd_tso_set = {
4830 .f = cmd_tso_set_parsed,
4832 .help_str = "tso set <tso_segsz> <port_id>: "
4833 "Set TSO segment size of non-tunneled packets for csum engine "
4836 (void *)&cmd_tso_set_tso,
4837 (void *)&cmd_tso_set_mode,
4838 (void *)&cmd_tso_set_tso_segsz,
4839 (void *)&cmd_tso_set_portid,
4844 cmdline_parse_token_string_t cmd_tso_show_mode =
4845 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4849 cmdline_parse_inst_t cmd_tso_show = {
4850 .f = cmd_tso_set_parsed,
4852 .help_str = "tso show <port_id>: "
4853 "Show TSO segment size of non-tunneled packets for csum engine",
4855 (void *)&cmd_tso_set_tso,
4856 (void *)&cmd_tso_show_mode,
4857 (void *)&cmd_tso_set_portid,
4862 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4863 struct cmd_tunnel_tso_set_result {
4864 cmdline_fixed_string_t tso;
4865 cmdline_fixed_string_t mode;
4870 static struct rte_eth_dev_info
4871 check_tunnel_tso_nic_support(portid_t port_id)
4873 struct rte_eth_dev_info dev_info;
4875 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4878 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4879 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4880 "not enabled for port %d\n", port_id);
4881 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4882 printf("Warning: GRE TUNNEL TSO not supported therefore "
4883 "not enabled for port %d\n", port_id);
4884 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4885 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4886 "not enabled for port %d\n", port_id);
4887 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4888 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4889 "not enabled for port %d\n", port_id);
4890 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4891 printf("Warning: IP TUNNEL TSO not supported therefore "
4892 "not enabled for port %d\n", port_id);
4893 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4894 printf("Warning: UDP TUNNEL TSO not supported therefore "
4895 "not enabled for port %d\n", port_id);
4900 cmd_tunnel_tso_set_parsed(void *parsed_result,
4901 __rte_unused struct cmdline *cl,
4902 __rte_unused void *data)
4904 struct cmd_tunnel_tso_set_result *res = parsed_result;
4905 struct rte_eth_dev_info dev_info;
4907 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4909 if (!port_is_stopped(res->port_id)) {
4910 printf("Please stop port %d first\n", res->port_id);
4914 if (!strcmp(res->mode, "set"))
4915 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4917 dev_info = check_tunnel_tso_nic_support(res->port_id);
4918 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4919 ports[res->port_id].dev_conf.txmode.offloads &=
4920 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4921 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4922 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4923 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4924 DEV_TX_OFFLOAD_IP_TNL_TSO |
4925 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4926 printf("TSO for tunneled packets is disabled\n");
4928 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4929 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4930 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4931 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4932 DEV_TX_OFFLOAD_IP_TNL_TSO |
4933 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4935 ports[res->port_id].dev_conf.txmode.offloads |=
4936 (tso_offloads & dev_info.tx_offload_capa);
4937 printf("TSO segment size for tunneled packets is %d\n",
4938 ports[res->port_id].tunnel_tso_segsz);
4940 /* Below conditions are needed to make it work:
4941 * (1) tunnel TSO is supported by the NIC;
4942 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4944 * (3) for tunneled pkts with outer L3 of IPv4,
4945 * "csum set outer-ip" must be set to hw, because after tso,
4946 * total_len of outer IP header is changed, and the checksum
4947 * of outer IP header calculated by sw should be wrong; that
4948 * is not necessary for IPv6 tunneled pkts because there's no
4949 * checksum in IP header anymore.
4952 if (!ports[res->port_id].parse_tunnel)
4953 printf("Warning: csum parse_tunnel must be set "
4954 "so that tunneled packets are recognized\n");
4955 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4956 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4957 printf("Warning: csum set outer-ip must be set to hw "
4958 "if outer L3 is IPv4; not necessary for IPv6\n");
4961 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4962 cmd_reconfig_device_queue(res->port_id, 1, 1);
4965 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4966 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4968 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4969 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4971 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4972 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4974 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4975 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4978 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4979 .f = cmd_tunnel_tso_set_parsed,
4981 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4982 "Set TSO segment size of tunneled packets for csum engine "
4985 (void *)&cmd_tunnel_tso_set_tso,
4986 (void *)&cmd_tunnel_tso_set_mode,
4987 (void *)&cmd_tunnel_tso_set_tso_segsz,
4988 (void *)&cmd_tunnel_tso_set_portid,
4993 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4994 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4998 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4999 .f = cmd_tunnel_tso_set_parsed,
5001 .help_str = "tunnel_tso show <port_id> "
5002 "Show TSO segment size of tunneled packets for csum engine",
5004 (void *)&cmd_tunnel_tso_set_tso,
5005 (void *)&cmd_tunnel_tso_show_mode,
5006 (void *)&cmd_tunnel_tso_set_portid,
5011 /* *** SET GRO FOR A PORT *** */
5012 struct cmd_gro_enable_result {
5013 cmdline_fixed_string_t cmd_set;
5014 cmdline_fixed_string_t cmd_port;
5015 cmdline_fixed_string_t cmd_keyword;
5016 cmdline_fixed_string_t cmd_onoff;
5021 cmd_gro_enable_parsed(void *parsed_result,
5022 __rte_unused struct cmdline *cl,
5023 __rte_unused void *data)
5025 struct cmd_gro_enable_result *res;
5027 res = parsed_result;
5028 if (!strcmp(res->cmd_keyword, "gro"))
5029 setup_gro(res->cmd_onoff, res->cmd_pid);
5032 cmdline_parse_token_string_t cmd_gro_enable_set =
5033 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5035 cmdline_parse_token_string_t cmd_gro_enable_port =
5036 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5037 cmd_keyword, "port");
5038 cmdline_parse_token_num_t cmd_gro_enable_pid =
5039 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5041 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5042 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5043 cmd_keyword, "gro");
5044 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5045 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5046 cmd_onoff, "on#off");
5048 cmdline_parse_inst_t cmd_gro_enable = {
5049 .f = cmd_gro_enable_parsed,
5051 .help_str = "set port <port_id> gro on|off",
5053 (void *)&cmd_gro_enable_set,
5054 (void *)&cmd_gro_enable_port,
5055 (void *)&cmd_gro_enable_pid,
5056 (void *)&cmd_gro_enable_keyword,
5057 (void *)&cmd_gro_enable_onoff,
5062 /* *** DISPLAY GRO CONFIGURATION *** */
5063 struct cmd_gro_show_result {
5064 cmdline_fixed_string_t cmd_show;
5065 cmdline_fixed_string_t cmd_port;
5066 cmdline_fixed_string_t cmd_keyword;
5071 cmd_gro_show_parsed(void *parsed_result,
5072 __rte_unused struct cmdline *cl,
5073 __rte_unused void *data)
5075 struct cmd_gro_show_result *res;
5077 res = parsed_result;
5078 if (!strcmp(res->cmd_keyword, "gro"))
5079 show_gro(res->cmd_pid);
5082 cmdline_parse_token_string_t cmd_gro_show_show =
5083 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5085 cmdline_parse_token_string_t cmd_gro_show_port =
5086 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5088 cmdline_parse_token_num_t cmd_gro_show_pid =
5089 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5091 cmdline_parse_token_string_t cmd_gro_show_keyword =
5092 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5093 cmd_keyword, "gro");
5095 cmdline_parse_inst_t cmd_gro_show = {
5096 .f = cmd_gro_show_parsed,
5098 .help_str = "show port <port_id> gro",
5100 (void *)&cmd_gro_show_show,
5101 (void *)&cmd_gro_show_port,
5102 (void *)&cmd_gro_show_pid,
5103 (void *)&cmd_gro_show_keyword,
5108 /* *** SET FLUSH CYCLES FOR GRO *** */
5109 struct cmd_gro_flush_result {
5110 cmdline_fixed_string_t cmd_set;
5111 cmdline_fixed_string_t cmd_keyword;
5112 cmdline_fixed_string_t cmd_flush;
5117 cmd_gro_flush_parsed(void *parsed_result,
5118 __rte_unused struct cmdline *cl,
5119 __rte_unused void *data)
5121 struct cmd_gro_flush_result *res;
5123 res = parsed_result;
5124 if ((!strcmp(res->cmd_keyword, "gro")) &&
5125 (!strcmp(res->cmd_flush, "flush")))
5126 setup_gro_flush_cycles(res->cmd_cycles);
5129 cmdline_parse_token_string_t cmd_gro_flush_set =
5130 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5132 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5133 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5134 cmd_keyword, "gro");
5135 cmdline_parse_token_string_t cmd_gro_flush_flush =
5136 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5137 cmd_flush, "flush");
5138 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5139 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5142 cmdline_parse_inst_t cmd_gro_flush = {
5143 .f = cmd_gro_flush_parsed,
5145 .help_str = "set gro flush <cycles>",
5147 (void *)&cmd_gro_flush_set,
5148 (void *)&cmd_gro_flush_keyword,
5149 (void *)&cmd_gro_flush_flush,
5150 (void *)&cmd_gro_flush_cycles,
5155 /* *** ENABLE/DISABLE GSO *** */
5156 struct cmd_gso_enable_result {
5157 cmdline_fixed_string_t cmd_set;
5158 cmdline_fixed_string_t cmd_port;
5159 cmdline_fixed_string_t cmd_keyword;
5160 cmdline_fixed_string_t cmd_mode;
5165 cmd_gso_enable_parsed(void *parsed_result,
5166 __rte_unused struct cmdline *cl,
5167 __rte_unused void *data)
5169 struct cmd_gso_enable_result *res;
5171 res = parsed_result;
5172 if (!strcmp(res->cmd_keyword, "gso"))
5173 setup_gso(res->cmd_mode, res->cmd_pid);
5176 cmdline_parse_token_string_t cmd_gso_enable_set =
5177 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5179 cmdline_parse_token_string_t cmd_gso_enable_port =
5180 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5182 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5183 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5184 cmd_keyword, "gso");
5185 cmdline_parse_token_string_t cmd_gso_enable_mode =
5186 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5187 cmd_mode, "on#off");
5188 cmdline_parse_token_num_t cmd_gso_enable_pid =
5189 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5192 cmdline_parse_inst_t cmd_gso_enable = {
5193 .f = cmd_gso_enable_parsed,
5195 .help_str = "set port <port_id> gso on|off",
5197 (void *)&cmd_gso_enable_set,
5198 (void *)&cmd_gso_enable_port,
5199 (void *)&cmd_gso_enable_pid,
5200 (void *)&cmd_gso_enable_keyword,
5201 (void *)&cmd_gso_enable_mode,
5206 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5207 struct cmd_gso_size_result {
5208 cmdline_fixed_string_t cmd_set;
5209 cmdline_fixed_string_t cmd_keyword;
5210 cmdline_fixed_string_t cmd_segsz;
5215 cmd_gso_size_parsed(void *parsed_result,
5216 __rte_unused struct cmdline *cl,
5217 __rte_unused void *data)
5219 struct cmd_gso_size_result *res = parsed_result;
5221 if (test_done == 0) {
5222 printf("Before setting GSO segsz, please first"
5223 " stop forwarding\n");
5227 if (!strcmp(res->cmd_keyword, "gso") &&
5228 !strcmp(res->cmd_segsz, "segsz")) {
5229 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5230 printf("gso_size should be larger than %zu."
5231 " Please input a legal value\n",
5232 RTE_GSO_SEG_SIZE_MIN);
5234 gso_max_segment_size = res->cmd_size;
5238 cmdline_parse_token_string_t cmd_gso_size_set =
5239 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5241 cmdline_parse_token_string_t cmd_gso_size_keyword =
5242 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5243 cmd_keyword, "gso");
5244 cmdline_parse_token_string_t cmd_gso_size_segsz =
5245 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5246 cmd_segsz, "segsz");
5247 cmdline_parse_token_num_t cmd_gso_size_size =
5248 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5251 cmdline_parse_inst_t cmd_gso_size = {
5252 .f = cmd_gso_size_parsed,
5254 .help_str = "set gso segsz <length>",
5256 (void *)&cmd_gso_size_set,
5257 (void *)&cmd_gso_size_keyword,
5258 (void *)&cmd_gso_size_segsz,
5259 (void *)&cmd_gso_size_size,
5264 /* *** SHOW GSO CONFIGURATION *** */
5265 struct cmd_gso_show_result {
5266 cmdline_fixed_string_t cmd_show;
5267 cmdline_fixed_string_t cmd_port;
5268 cmdline_fixed_string_t cmd_keyword;
5273 cmd_gso_show_parsed(void *parsed_result,
5274 __rte_unused struct cmdline *cl,
5275 __rte_unused void *data)
5277 struct cmd_gso_show_result *res = parsed_result;
5279 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5280 printf("invalid port id %u\n", res->cmd_pid);
5283 if (!strcmp(res->cmd_keyword, "gso")) {
5284 if (gso_ports[res->cmd_pid].enable) {
5285 printf("Max GSO'd packet size: %uB\n"
5286 "Supported GSO types: TCP/IPv4, "
5287 "UDP/IPv4, VxLAN with inner "
5288 "TCP/IPv4 packet, GRE with inner "
5289 "TCP/IPv4 packet\n",
5290 gso_max_segment_size);
5292 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5296 cmdline_parse_token_string_t cmd_gso_show_show =
5297 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5299 cmdline_parse_token_string_t cmd_gso_show_port =
5300 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5302 cmdline_parse_token_string_t cmd_gso_show_keyword =
5303 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5304 cmd_keyword, "gso");
5305 cmdline_parse_token_num_t cmd_gso_show_pid =
5306 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5309 cmdline_parse_inst_t cmd_gso_show = {
5310 .f = cmd_gso_show_parsed,
5312 .help_str = "show port <port_id> gso",
5314 (void *)&cmd_gso_show_show,
5315 (void *)&cmd_gso_show_port,
5316 (void *)&cmd_gso_show_pid,
5317 (void *)&cmd_gso_show_keyword,
5322 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5323 struct cmd_set_flush_rx {
5324 cmdline_fixed_string_t set;
5325 cmdline_fixed_string_t flush_rx;
5326 cmdline_fixed_string_t mode;
5330 cmd_set_flush_rx_parsed(void *parsed_result,
5331 __rte_unused struct cmdline *cl,
5332 __rte_unused void *data)
5334 struct cmd_set_flush_rx *res = parsed_result;
5335 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5338 cmdline_parse_token_string_t cmd_setflushrx_set =
5339 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5341 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5342 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5343 flush_rx, "flush_rx");
5344 cmdline_parse_token_string_t cmd_setflushrx_mode =
5345 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5349 cmdline_parse_inst_t cmd_set_flush_rx = {
5350 .f = cmd_set_flush_rx_parsed,
5351 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5354 (void *)&cmd_setflushrx_set,
5355 (void *)&cmd_setflushrx_flush_rx,
5356 (void *)&cmd_setflushrx_mode,
5361 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5362 struct cmd_set_link_check {
5363 cmdline_fixed_string_t set;
5364 cmdline_fixed_string_t link_check;
5365 cmdline_fixed_string_t mode;
5369 cmd_set_link_check_parsed(void *parsed_result,
5370 __rte_unused struct cmdline *cl,
5371 __rte_unused void *data)
5373 struct cmd_set_link_check *res = parsed_result;
5374 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5377 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5378 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5380 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5381 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5382 link_check, "link_check");
5383 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5384 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5388 cmdline_parse_inst_t cmd_set_link_check = {
5389 .f = cmd_set_link_check_parsed,
5390 .help_str = "set link_check on|off: Enable/Disable link status check "
5391 "when starting/stopping a port",
5394 (void *)&cmd_setlinkcheck_set,
5395 (void *)&cmd_setlinkcheck_link_check,
5396 (void *)&cmd_setlinkcheck_mode,
5401 /* *** SET NIC BYPASS MODE *** */
5402 struct cmd_set_bypass_mode_result {
5403 cmdline_fixed_string_t set;
5404 cmdline_fixed_string_t bypass;
5405 cmdline_fixed_string_t mode;
5406 cmdline_fixed_string_t value;
5411 cmd_set_bypass_mode_parsed(void *parsed_result,
5412 __rte_unused struct cmdline *cl,
5413 __rte_unused void *data)
5415 struct cmd_set_bypass_mode_result *res = parsed_result;
5416 portid_t port_id = res->port_id;
5417 int32_t rc = -EINVAL;
5419 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5420 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5422 if (!strcmp(res->value, "bypass"))
5423 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5424 else if (!strcmp(res->value, "isolate"))
5425 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5427 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5429 /* Set the bypass mode for the relevant port. */
5430 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5433 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5436 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5437 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5439 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5440 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5442 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5443 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5445 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5446 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5447 value, "normal#bypass#isolate");
5448 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5449 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5452 cmdline_parse_inst_t cmd_set_bypass_mode = {
5453 .f = cmd_set_bypass_mode_parsed,
5454 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5455 "Set the NIC bypass mode for port_id",
5458 (void *)&cmd_setbypass_mode_set,
5459 (void *)&cmd_setbypass_mode_bypass,
5460 (void *)&cmd_setbypass_mode_mode,
5461 (void *)&cmd_setbypass_mode_value,
5462 (void *)&cmd_setbypass_mode_port,
5467 /* *** SET NIC BYPASS EVENT *** */
5468 struct cmd_set_bypass_event_result {
5469 cmdline_fixed_string_t set;
5470 cmdline_fixed_string_t bypass;
5471 cmdline_fixed_string_t event;
5472 cmdline_fixed_string_t event_value;
5473 cmdline_fixed_string_t mode;
5474 cmdline_fixed_string_t mode_value;
5479 cmd_set_bypass_event_parsed(void *parsed_result,
5480 __rte_unused struct cmdline *cl,
5481 __rte_unused void *data)
5483 int32_t rc = -EINVAL;
5484 struct cmd_set_bypass_event_result *res = parsed_result;
5485 portid_t port_id = res->port_id;
5487 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5488 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5489 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5491 if (!strcmp(res->event_value, "timeout"))
5492 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5493 else if (!strcmp(res->event_value, "os_on"))
5494 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5495 else if (!strcmp(res->event_value, "os_off"))
5496 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5497 else if (!strcmp(res->event_value, "power_on"))
5498 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5499 else if (!strcmp(res->event_value, "power_off"))
5500 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5502 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5504 if (!strcmp(res->mode_value, "bypass"))
5505 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5506 else if (!strcmp(res->mode_value, "isolate"))
5507 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5509 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5511 /* Set the watchdog timeout. */
5512 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5515 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5516 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5520 printf("Failed to set timeout value %u "
5521 "for port %d, errto code: %d.\n",
5522 bypass_timeout, port_id, rc);
5526 /* Set the bypass event to transition to bypass mode. */
5527 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5532 printf("\t Failed to set bypass event for port = %d.\n",
5536 cmdline_parse_token_string_t cmd_setbypass_event_set =
5537 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5539 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5540 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5542 cmdline_parse_token_string_t cmd_setbypass_event_event =
5543 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5545 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5546 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5547 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5548 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5549 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5551 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5552 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5553 mode_value, "normal#bypass#isolate");
5554 cmdline_parse_token_num_t cmd_setbypass_event_port =
5555 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5558 cmdline_parse_inst_t cmd_set_bypass_event = {
5559 .f = cmd_set_bypass_event_parsed,
5560 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5561 "power_off mode normal|bypass|isolate <port_id>: "
5562 "Set the NIC bypass event mode for port_id",
5565 (void *)&cmd_setbypass_event_set,
5566 (void *)&cmd_setbypass_event_bypass,
5567 (void *)&cmd_setbypass_event_event,
5568 (void *)&cmd_setbypass_event_event_value,
5569 (void *)&cmd_setbypass_event_mode,
5570 (void *)&cmd_setbypass_event_mode_value,
5571 (void *)&cmd_setbypass_event_port,
5577 /* *** SET NIC BYPASS TIMEOUT *** */
5578 struct cmd_set_bypass_timeout_result {
5579 cmdline_fixed_string_t set;
5580 cmdline_fixed_string_t bypass;
5581 cmdline_fixed_string_t timeout;
5582 cmdline_fixed_string_t value;
5586 cmd_set_bypass_timeout_parsed(void *parsed_result,
5587 __rte_unused struct cmdline *cl,
5588 __rte_unused void *data)
5590 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5592 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5593 if (!strcmp(res->value, "1.5"))
5594 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5595 else if (!strcmp(res->value, "2"))
5596 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5597 else if (!strcmp(res->value, "3"))
5598 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5599 else if (!strcmp(res->value, "4"))
5600 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5601 else if (!strcmp(res->value, "8"))
5602 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5603 else if (!strcmp(res->value, "16"))
5604 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5605 else if (!strcmp(res->value, "32"))
5606 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5608 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5612 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5613 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5615 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5616 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5618 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5619 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5620 timeout, "timeout");
5621 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5622 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5623 value, "0#1.5#2#3#4#8#16#32");
5625 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5626 .f = cmd_set_bypass_timeout_parsed,
5627 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5628 "Set the NIC bypass watchdog timeout in seconds",
5631 (void *)&cmd_setbypass_timeout_set,
5632 (void *)&cmd_setbypass_timeout_bypass,
5633 (void *)&cmd_setbypass_timeout_timeout,
5634 (void *)&cmd_setbypass_timeout_value,
5639 /* *** SHOW NIC BYPASS MODE *** */
5640 struct cmd_show_bypass_config_result {
5641 cmdline_fixed_string_t show;
5642 cmdline_fixed_string_t bypass;
5643 cmdline_fixed_string_t config;
5648 cmd_show_bypass_config_parsed(void *parsed_result,
5649 __rte_unused struct cmdline *cl,
5650 __rte_unused void *data)
5652 struct cmd_show_bypass_config_result *res = parsed_result;
5653 portid_t port_id = res->port_id;
5655 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5656 uint32_t event_mode;
5657 uint32_t bypass_mode;
5658 uint32_t timeout = bypass_timeout;
5661 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5662 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5663 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5664 {"UNKNOWN", "normal", "bypass", "isolate"};
5665 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5673 /* Display the bypass mode.*/
5674 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5675 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5679 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5680 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5682 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5685 /* Display the bypass timeout.*/
5686 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5687 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5689 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5691 /* Display the bypass events and associated modes. */
5692 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5694 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5695 printf("\tFailed to get bypass mode for event = %s\n",
5698 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5699 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5701 printf("\tbypass event: %-16s = %s\n", events[i],
5707 printf("\tFailed to get bypass configuration for port = %d\n",
5711 cmdline_parse_token_string_t cmd_showbypass_config_show =
5712 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5714 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5715 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5717 cmdline_parse_token_string_t cmd_showbypass_config_config =
5718 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5720 cmdline_parse_token_num_t cmd_showbypass_config_port =
5721 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5724 cmdline_parse_inst_t cmd_show_bypass_config = {
5725 .f = cmd_show_bypass_config_parsed,
5726 .help_str = "show bypass config <port_id>: "
5727 "Show the NIC bypass config for port_id",
5730 (void *)&cmd_showbypass_config_show,
5731 (void *)&cmd_showbypass_config_bypass,
5732 (void *)&cmd_showbypass_config_config,
5733 (void *)&cmd_showbypass_config_port,
5738 #ifdef RTE_LIBRTE_PMD_BOND
5739 /* *** SET BONDING MODE *** */
5740 struct cmd_set_bonding_mode_result {
5741 cmdline_fixed_string_t set;
5742 cmdline_fixed_string_t bonding;
5743 cmdline_fixed_string_t mode;
5748 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5749 __rte_unused struct cmdline *cl,
5750 __rte_unused void *data)
5752 struct cmd_set_bonding_mode_result *res = parsed_result;
5753 portid_t port_id = res->port_id;
5755 /* Set the bonding mode for the relevant port. */
5756 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5757 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5760 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5761 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5763 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5764 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5765 bonding, "bonding");
5766 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5767 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5769 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5770 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5772 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5773 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5776 cmdline_parse_inst_t cmd_set_bonding_mode = {
5777 .f = cmd_set_bonding_mode_parsed,
5778 .help_str = "set bonding mode <mode_value> <port_id>: "
5779 "Set the bonding mode for port_id",
5782 (void *) &cmd_setbonding_mode_set,
5783 (void *) &cmd_setbonding_mode_bonding,
5784 (void *) &cmd_setbonding_mode_mode,
5785 (void *) &cmd_setbonding_mode_value,
5786 (void *) &cmd_setbonding_mode_port,
5791 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5792 struct cmd_set_bonding_lacp_dedicated_queues_result {
5793 cmdline_fixed_string_t set;
5794 cmdline_fixed_string_t bonding;
5795 cmdline_fixed_string_t lacp;
5796 cmdline_fixed_string_t dedicated_queues;
5798 cmdline_fixed_string_t mode;
5801 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5802 __rte_unused struct cmdline *cl,
5803 __rte_unused void *data)
5805 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5806 portid_t port_id = res->port_id;
5807 struct rte_port *port;
5809 port = &ports[port_id];
5811 /** Check if the port is not started **/
5812 if (port->port_status != RTE_PORT_STOPPED) {
5813 printf("Please stop port %d first\n", port_id);
5817 if (!strcmp(res->mode, "enable")) {
5818 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5819 printf("Dedicate queues for LACP control packets"
5822 printf("Enabling dedicate queues for LACP control "
5823 "packets on port %d failed\n", port_id);
5824 } else if (!strcmp(res->mode, "disable")) {
5825 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5826 printf("Dedicated queues for LACP control packets "
5829 printf("Disabling dedicated queues for LACP control "
5830 "traffic on port %d failed\n", port_id);
5834 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5835 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5837 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5838 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5839 bonding, "bonding");
5840 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5841 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5843 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5844 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5845 dedicated_queues, "dedicated_queues");
5846 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5847 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5849 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5850 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5851 mode, "enable#disable");
5853 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5854 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5855 .help_str = "set bonding lacp dedicated_queues <port_id> "
5857 "Enable/disable dedicated queues for LACP control traffic for port_id",
5860 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5861 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5862 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5863 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5864 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5865 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5870 /* *** SET BALANCE XMIT POLICY *** */
5871 struct cmd_set_bonding_balance_xmit_policy_result {
5872 cmdline_fixed_string_t set;
5873 cmdline_fixed_string_t bonding;
5874 cmdline_fixed_string_t balance_xmit_policy;
5876 cmdline_fixed_string_t policy;
5879 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5880 __rte_unused struct cmdline *cl,
5881 __rte_unused void *data)
5883 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5884 portid_t port_id = res->port_id;
5887 if (!strcmp(res->policy, "l2")) {
5888 policy = BALANCE_XMIT_POLICY_LAYER2;
5889 } else if (!strcmp(res->policy, "l23")) {
5890 policy = BALANCE_XMIT_POLICY_LAYER23;
5891 } else if (!strcmp(res->policy, "l34")) {
5892 policy = BALANCE_XMIT_POLICY_LAYER34;
5894 printf("\t Invalid xmit policy selection");
5898 /* Set the bonding mode for the relevant port. */
5899 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5900 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5905 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5906 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5908 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5909 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5910 bonding, "bonding");
5911 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5912 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5913 balance_xmit_policy, "balance_xmit_policy");
5914 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5915 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5917 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5918 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5919 policy, "l2#l23#l34");
5921 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5922 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5923 .help_str = "set bonding balance_xmit_policy <port_id> "
5925 "Set the bonding balance_xmit_policy for port_id",
5928 (void *)&cmd_setbonding_balance_xmit_policy_set,
5929 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5930 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5931 (void *)&cmd_setbonding_balance_xmit_policy_port,
5932 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5937 /* *** SHOW NIC BONDING CONFIGURATION *** */
5938 struct cmd_show_bonding_config_result {
5939 cmdline_fixed_string_t show;
5940 cmdline_fixed_string_t bonding;
5941 cmdline_fixed_string_t config;
5945 static void cmd_show_bonding_config_parsed(void *parsed_result,
5946 __rte_unused struct cmdline *cl,
5947 __rte_unused void *data)
5949 struct cmd_show_bonding_config_result *res = parsed_result;
5950 int bonding_mode, agg_mode;
5951 portid_t slaves[RTE_MAX_ETHPORTS];
5952 int num_slaves, num_active_slaves;
5955 portid_t port_id = res->port_id;
5957 /* Display the bonding mode.*/
5958 bonding_mode = rte_eth_bond_mode_get(port_id);
5959 if (bonding_mode < 0) {
5960 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5963 printf("\tBonding mode: %d\n", bonding_mode);
5965 if (bonding_mode == BONDING_MODE_BALANCE) {
5966 int balance_xmit_policy;
5968 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5969 if (balance_xmit_policy < 0) {
5970 printf("\tFailed to get balance xmit policy for port = %d\n",
5974 printf("\tBalance Xmit Policy: ");
5976 switch (balance_xmit_policy) {
5977 case BALANCE_XMIT_POLICY_LAYER2:
5978 printf("BALANCE_XMIT_POLICY_LAYER2");
5980 case BALANCE_XMIT_POLICY_LAYER23:
5981 printf("BALANCE_XMIT_POLICY_LAYER23");
5983 case BALANCE_XMIT_POLICY_LAYER34:
5984 printf("BALANCE_XMIT_POLICY_LAYER34");
5991 if (bonding_mode == BONDING_MODE_8023AD) {
5992 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5993 printf("\tIEEE802.3AD Aggregator Mode: ");
5996 printf("bandwidth");
6008 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6010 if (num_slaves < 0) {
6011 printf("\tFailed to get slave list for port = %d\n", port_id);
6014 if (num_slaves > 0) {
6015 printf("\tSlaves (%d): [", num_slaves);
6016 for (i = 0; i < num_slaves - 1; i++)
6017 printf("%d ", slaves[i]);
6019 printf("%d]\n", slaves[num_slaves - 1]);
6021 printf("\tSlaves: []\n");
6025 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6028 if (num_active_slaves < 0) {
6029 printf("\tFailed to get active slave list for port = %d\n", port_id);
6032 if (num_active_slaves > 0) {
6033 printf("\tActive Slaves (%d): [", num_active_slaves);
6034 for (i = 0; i < num_active_slaves - 1; i++)
6035 printf("%d ", slaves[i]);
6037 printf("%d]\n", slaves[num_active_slaves - 1]);
6040 printf("\tActive Slaves: []\n");
6044 primary_id = rte_eth_bond_primary_get(port_id);
6045 if (primary_id < 0) {
6046 printf("\tFailed to get primary slave for port = %d\n", port_id);
6049 printf("\tPrimary: [%d]\n", primary_id);
6053 cmdline_parse_token_string_t cmd_showbonding_config_show =
6054 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6056 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6057 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6058 bonding, "bonding");
6059 cmdline_parse_token_string_t cmd_showbonding_config_config =
6060 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6062 cmdline_parse_token_num_t cmd_showbonding_config_port =
6063 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6066 cmdline_parse_inst_t cmd_show_bonding_config = {
6067 .f = cmd_show_bonding_config_parsed,
6068 .help_str = "show bonding config <port_id>: "
6069 "Show the bonding config for port_id",
6072 (void *)&cmd_showbonding_config_show,
6073 (void *)&cmd_showbonding_config_bonding,
6074 (void *)&cmd_showbonding_config_config,
6075 (void *)&cmd_showbonding_config_port,
6080 /* *** SET BONDING PRIMARY *** */
6081 struct cmd_set_bonding_primary_result {
6082 cmdline_fixed_string_t set;
6083 cmdline_fixed_string_t bonding;
6084 cmdline_fixed_string_t primary;
6089 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6090 __rte_unused struct cmdline *cl,
6091 __rte_unused void *data)
6093 struct cmd_set_bonding_primary_result *res = parsed_result;
6094 portid_t master_port_id = res->port_id;
6095 portid_t slave_port_id = res->slave_id;
6097 /* Set the primary slave for a bonded device. */
6098 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6099 printf("\t Failed to set primary slave for port = %d.\n",
6106 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6107 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6109 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6110 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6111 bonding, "bonding");
6112 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6113 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6114 primary, "primary");
6115 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6116 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6118 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6119 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6122 cmdline_parse_inst_t cmd_set_bonding_primary = {
6123 .f = cmd_set_bonding_primary_parsed,
6124 .help_str = "set bonding primary <slave_id> <port_id>: "
6125 "Set the primary slave for port_id",
6128 (void *)&cmd_setbonding_primary_set,
6129 (void *)&cmd_setbonding_primary_bonding,
6130 (void *)&cmd_setbonding_primary_primary,
6131 (void *)&cmd_setbonding_primary_slave,
6132 (void *)&cmd_setbonding_primary_port,
6137 /* *** ADD SLAVE *** */
6138 struct cmd_add_bonding_slave_result {
6139 cmdline_fixed_string_t add;
6140 cmdline_fixed_string_t bonding;
6141 cmdline_fixed_string_t slave;
6146 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6147 __rte_unused struct cmdline *cl,
6148 __rte_unused void *data)
6150 struct cmd_add_bonding_slave_result *res = parsed_result;
6151 portid_t master_port_id = res->port_id;
6152 portid_t slave_port_id = res->slave_id;
6154 /* add the slave for a bonded device. */
6155 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6156 printf("\t Failed to add slave %d to master port = %d.\n",
6157 slave_port_id, master_port_id);
6161 set_port_slave_flag(slave_port_id);
6164 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6165 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6167 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6168 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6169 bonding, "bonding");
6170 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6171 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6173 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6174 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6176 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6177 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6180 cmdline_parse_inst_t cmd_add_bonding_slave = {
6181 .f = cmd_add_bonding_slave_parsed,
6182 .help_str = "add bonding slave <slave_id> <port_id>: "
6183 "Add a slave device to a bonded device",
6186 (void *)&cmd_addbonding_slave_add,
6187 (void *)&cmd_addbonding_slave_bonding,
6188 (void *)&cmd_addbonding_slave_slave,
6189 (void *)&cmd_addbonding_slave_slaveid,
6190 (void *)&cmd_addbonding_slave_port,
6195 /* *** REMOVE SLAVE *** */
6196 struct cmd_remove_bonding_slave_result {
6197 cmdline_fixed_string_t remove;
6198 cmdline_fixed_string_t bonding;
6199 cmdline_fixed_string_t slave;
6204 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6205 __rte_unused struct cmdline *cl,
6206 __rte_unused void *data)
6208 struct cmd_remove_bonding_slave_result *res = parsed_result;
6209 portid_t master_port_id = res->port_id;
6210 portid_t slave_port_id = res->slave_id;
6212 /* remove the slave from a bonded device. */
6213 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6214 printf("\t Failed to remove slave %d from master port = %d.\n",
6215 slave_port_id, master_port_id);
6219 clear_port_slave_flag(slave_port_id);
6222 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6223 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6225 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6226 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6227 bonding, "bonding");
6228 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6229 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6231 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6232 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6234 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6235 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6238 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6239 .f = cmd_remove_bonding_slave_parsed,
6240 .help_str = "remove bonding slave <slave_id> <port_id>: "
6241 "Remove a slave device from a bonded device",
6244 (void *)&cmd_removebonding_slave_remove,
6245 (void *)&cmd_removebonding_slave_bonding,
6246 (void *)&cmd_removebonding_slave_slave,
6247 (void *)&cmd_removebonding_slave_slaveid,
6248 (void *)&cmd_removebonding_slave_port,
6253 /* *** CREATE BONDED DEVICE *** */
6254 struct cmd_create_bonded_device_result {
6255 cmdline_fixed_string_t create;
6256 cmdline_fixed_string_t bonded;
6257 cmdline_fixed_string_t device;
6262 static int bond_dev_num = 0;
6264 static void cmd_create_bonded_device_parsed(void *parsed_result,
6265 __rte_unused struct cmdline *cl,
6266 __rte_unused void *data)
6268 struct cmd_create_bonded_device_result *res = parsed_result;
6269 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6273 if (test_done == 0) {
6274 printf("Please stop forwarding first\n");
6278 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6281 /* Create a new bonded device. */
6282 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6284 printf("\t Failed to create bonded device.\n");
6287 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6290 /* Update number of ports */
6291 nb_ports = rte_eth_dev_count_avail();
6292 reconfig(port_id, res->socket);
6293 ret = rte_eth_promiscuous_enable(port_id);
6295 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6296 port_id, rte_strerror(-ret));
6298 ports[port_id].need_setup = 0;
6299 ports[port_id].port_status = RTE_PORT_STOPPED;
6304 cmdline_parse_token_string_t cmd_createbonded_device_create =
6305 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6307 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6308 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6310 cmdline_parse_token_string_t cmd_createbonded_device_device =
6311 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6313 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6314 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6316 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6317 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6320 cmdline_parse_inst_t cmd_create_bonded_device = {
6321 .f = cmd_create_bonded_device_parsed,
6322 .help_str = "create bonded device <mode> <socket>: "
6323 "Create a new bonded device with specific bonding mode and socket",
6326 (void *)&cmd_createbonded_device_create,
6327 (void *)&cmd_createbonded_device_bonded,
6328 (void *)&cmd_createbonded_device_device,
6329 (void *)&cmd_createbonded_device_mode,
6330 (void *)&cmd_createbonded_device_socket,
6335 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6336 struct cmd_set_bond_mac_addr_result {
6337 cmdline_fixed_string_t set;
6338 cmdline_fixed_string_t bonding;
6339 cmdline_fixed_string_t mac_addr;
6341 struct rte_ether_addr address;
6344 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6345 __rte_unused struct cmdline *cl,
6346 __rte_unused void *data)
6348 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6351 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6354 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6356 /* check the return value and print it if is < 0 */
6358 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6361 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6362 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6363 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6364 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6366 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6367 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6369 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6370 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6372 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6373 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6375 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6376 .f = cmd_set_bond_mac_addr_parsed,
6378 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6380 (void *)&cmd_set_bond_mac_addr_set,
6381 (void *)&cmd_set_bond_mac_addr_bonding,
6382 (void *)&cmd_set_bond_mac_addr_mac,
6383 (void *)&cmd_set_bond_mac_addr_portnum,
6384 (void *)&cmd_set_bond_mac_addr_addr,
6390 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6391 struct cmd_set_bond_mon_period_result {
6392 cmdline_fixed_string_t set;
6393 cmdline_fixed_string_t bonding;
6394 cmdline_fixed_string_t mon_period;
6399 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6400 __rte_unused struct cmdline *cl,
6401 __rte_unused void *data)
6403 struct cmd_set_bond_mon_period_result *res = parsed_result;
6406 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6408 /* check the return value and print it if is < 0 */
6410 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6413 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6414 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6416 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6417 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6418 bonding, "bonding");
6419 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6420 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6421 mon_period, "mon_period");
6422 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6423 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6425 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6426 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6429 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6430 .f = cmd_set_bond_mon_period_parsed,
6432 .help_str = "set bonding mon_period <port_id> <period_ms>",
6434 (void *)&cmd_set_bond_mon_period_set,
6435 (void *)&cmd_set_bond_mon_period_bonding,
6436 (void *)&cmd_set_bond_mon_period_mon_period,
6437 (void *)&cmd_set_bond_mon_period_portnum,
6438 (void *)&cmd_set_bond_mon_period_period_ms,
6445 struct cmd_set_bonding_agg_mode_policy_result {
6446 cmdline_fixed_string_t set;
6447 cmdline_fixed_string_t bonding;
6448 cmdline_fixed_string_t agg_mode;
6450 cmdline_fixed_string_t policy;
6455 cmd_set_bonding_agg_mode(void *parsed_result,
6456 __rte_unused struct cmdline *cl,
6457 __rte_unused void *data)
6459 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6460 uint8_t policy = AGG_BANDWIDTH;
6462 if (!strcmp(res->policy, "bandwidth"))
6463 policy = AGG_BANDWIDTH;
6464 else if (!strcmp(res->policy, "stable"))
6465 policy = AGG_STABLE;
6466 else if (!strcmp(res->policy, "count"))
6469 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6473 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6474 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6476 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6477 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6478 bonding, "bonding");
6480 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6481 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6482 agg_mode, "agg_mode");
6484 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6485 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6488 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6489 TOKEN_STRING_INITIALIZER(
6490 struct cmd_set_bonding_balance_xmit_policy_result,
6491 policy, "stable#bandwidth#count");
6493 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6494 .f = cmd_set_bonding_agg_mode,
6496 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6498 (void *)&cmd_set_bonding_agg_mode_set,
6499 (void *)&cmd_set_bonding_agg_mode_bonding,
6500 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6501 (void *)&cmd_set_bonding_agg_mode_portnum,
6502 (void *)&cmd_set_bonding_agg_mode_policy_string,
6508 #endif /* RTE_LIBRTE_PMD_BOND */
6510 /* *** SET FORWARDING MODE *** */
6511 struct cmd_set_fwd_mode_result {
6512 cmdline_fixed_string_t set;
6513 cmdline_fixed_string_t fwd;
6514 cmdline_fixed_string_t mode;
6517 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6518 __rte_unused struct cmdline *cl,
6519 __rte_unused void *data)
6521 struct cmd_set_fwd_mode_result *res = parsed_result;
6524 set_pkt_forwarding_mode(res->mode);
6527 cmdline_parse_token_string_t cmd_setfwd_set =
6528 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6529 cmdline_parse_token_string_t cmd_setfwd_fwd =
6530 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6531 cmdline_parse_token_string_t cmd_setfwd_mode =
6532 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6533 "" /* defined at init */);
6535 cmdline_parse_inst_t cmd_set_fwd_mode = {
6536 .f = cmd_set_fwd_mode_parsed,
6538 .help_str = NULL, /* defined at init */
6540 (void *)&cmd_setfwd_set,
6541 (void *)&cmd_setfwd_fwd,
6542 (void *)&cmd_setfwd_mode,
6547 static void cmd_set_fwd_mode_init(void)
6550 static char token[128];
6551 static char help[256];
6552 cmdline_parse_token_string_t *token_struct;
6554 modes = list_pkt_forwarding_modes();
6555 snprintf(help, sizeof(help), "set fwd %s: "
6556 "Set packet forwarding mode", modes);
6557 cmd_set_fwd_mode.help_str = help;
6559 /* string token separator is # */
6560 for (c = token; *modes != '\0'; modes++)
6565 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6566 token_struct->string_data.str = token;
6569 /* *** SET RETRY FORWARDING MODE *** */
6570 struct cmd_set_fwd_retry_mode_result {
6571 cmdline_fixed_string_t set;
6572 cmdline_fixed_string_t fwd;
6573 cmdline_fixed_string_t mode;
6574 cmdline_fixed_string_t retry;
6577 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6578 __rte_unused struct cmdline *cl,
6579 __rte_unused void *data)
6581 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6584 set_pkt_forwarding_mode(res->mode);
6587 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6588 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6590 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6591 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6593 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6594 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6596 "" /* defined at init */);
6597 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6598 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6601 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6602 .f = cmd_set_fwd_retry_mode_parsed,
6604 .help_str = NULL, /* defined at init */
6606 (void *)&cmd_setfwd_retry_set,
6607 (void *)&cmd_setfwd_retry_fwd,
6608 (void *)&cmd_setfwd_retry_mode,
6609 (void *)&cmd_setfwd_retry_retry,
6614 static void cmd_set_fwd_retry_mode_init(void)
6617 static char token[128];
6618 static char help[256];
6619 cmdline_parse_token_string_t *token_struct;
6621 modes = list_pkt_forwarding_retry_modes();
6622 snprintf(help, sizeof(help), "set fwd %s retry: "
6623 "Set packet forwarding mode with retry", modes);
6624 cmd_set_fwd_retry_mode.help_str = help;
6626 /* string token separator is # */
6627 for (c = token; *modes != '\0'; modes++)
6632 token_struct = (cmdline_parse_token_string_t *)
6633 cmd_set_fwd_retry_mode.tokens[2];
6634 token_struct->string_data.str = token;
6637 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6638 struct cmd_set_burst_tx_retry_result {
6639 cmdline_fixed_string_t set;
6640 cmdline_fixed_string_t burst;
6641 cmdline_fixed_string_t tx;
6642 cmdline_fixed_string_t delay;
6644 cmdline_fixed_string_t retry;
6648 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6649 __rte_unused struct cmdline *cl,
6650 __rte_unused void *data)
6652 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6654 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6655 && !strcmp(res->tx, "tx")) {
6656 if (!strcmp(res->delay, "delay"))
6657 burst_tx_delay_time = res->time;
6658 if (!strcmp(res->retry, "retry"))
6659 burst_tx_retry_num = res->retry_num;
6664 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6665 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6666 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6667 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6669 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6670 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6671 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6672 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6673 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6674 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6675 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6676 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6677 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6678 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6680 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6681 .f = cmd_set_burst_tx_retry_parsed,
6682 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6684 (void *)&cmd_set_burst_tx_retry_set,
6685 (void *)&cmd_set_burst_tx_retry_burst,
6686 (void *)&cmd_set_burst_tx_retry_tx,
6687 (void *)&cmd_set_burst_tx_retry_delay,
6688 (void *)&cmd_set_burst_tx_retry_time,
6689 (void *)&cmd_set_burst_tx_retry_retry,
6690 (void *)&cmd_set_burst_tx_retry_retry_num,
6695 /* *** SET PROMISC MODE *** */
6696 struct cmd_set_promisc_mode_result {
6697 cmdline_fixed_string_t set;
6698 cmdline_fixed_string_t promisc;
6699 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6700 uint16_t port_num; /* valid if "allports" argument == 0 */
6701 cmdline_fixed_string_t mode;
6704 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6705 __rte_unused struct cmdline *cl,
6708 struct cmd_set_promisc_mode_result *res = parsed_result;
6712 if (!strcmp(res->mode, "on"))
6719 RTE_ETH_FOREACH_DEV(i)
6720 eth_set_promisc_mode(i, enable);
6722 eth_set_promisc_mode(res->port_num, enable);
6726 cmdline_parse_token_string_t cmd_setpromisc_set =
6727 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6728 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6729 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6731 cmdline_parse_token_string_t cmd_setpromisc_portall =
6732 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6734 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6735 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6737 cmdline_parse_token_string_t cmd_setpromisc_mode =
6738 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6741 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6742 .f = cmd_set_promisc_mode_parsed,
6744 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6746 (void *)&cmd_setpromisc_set,
6747 (void *)&cmd_setpromisc_promisc,
6748 (void *)&cmd_setpromisc_portall,
6749 (void *)&cmd_setpromisc_mode,
6754 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6755 .f = cmd_set_promisc_mode_parsed,
6757 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6759 (void *)&cmd_setpromisc_set,
6760 (void *)&cmd_setpromisc_promisc,
6761 (void *)&cmd_setpromisc_portnum,
6762 (void *)&cmd_setpromisc_mode,
6767 /* *** SET ALLMULTI MODE *** */
6768 struct cmd_set_allmulti_mode_result {
6769 cmdline_fixed_string_t set;
6770 cmdline_fixed_string_t allmulti;
6771 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6772 uint16_t port_num; /* valid if "allports" argument == 0 */
6773 cmdline_fixed_string_t mode;
6776 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6777 __rte_unused struct cmdline *cl,
6780 struct cmd_set_allmulti_mode_result *res = parsed_result;
6784 if (!strcmp(res->mode, "on"))
6791 RTE_ETH_FOREACH_DEV(i) {
6792 eth_set_allmulticast_mode(i, enable);
6796 eth_set_allmulticast_mode(res->port_num, enable);
6800 cmdline_parse_token_string_t cmd_setallmulti_set =
6801 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6802 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6803 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6805 cmdline_parse_token_string_t cmd_setallmulti_portall =
6806 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6808 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6809 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6811 cmdline_parse_token_string_t cmd_setallmulti_mode =
6812 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6815 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6816 .f = cmd_set_allmulti_mode_parsed,
6818 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6820 (void *)&cmd_setallmulti_set,
6821 (void *)&cmd_setallmulti_allmulti,
6822 (void *)&cmd_setallmulti_portall,
6823 (void *)&cmd_setallmulti_mode,
6828 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6829 .f = cmd_set_allmulti_mode_parsed,
6831 .help_str = "set allmulti <port_id> on|off: "
6832 "Set allmulti mode on port_id",
6834 (void *)&cmd_setallmulti_set,
6835 (void *)&cmd_setallmulti_allmulti,
6836 (void *)&cmd_setallmulti_portnum,
6837 (void *)&cmd_setallmulti_mode,
6842 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6843 struct cmd_link_flow_ctrl_set_result {
6844 cmdline_fixed_string_t set;
6845 cmdline_fixed_string_t flow_ctrl;
6846 cmdline_fixed_string_t rx;
6847 cmdline_fixed_string_t rx_lfc_mode;
6848 cmdline_fixed_string_t tx;
6849 cmdline_fixed_string_t tx_lfc_mode;
6850 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6851 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6852 cmdline_fixed_string_t autoneg_str;
6853 cmdline_fixed_string_t autoneg;
6854 cmdline_fixed_string_t hw_str;
6855 uint32_t high_water;
6856 cmdline_fixed_string_t lw_str;
6858 cmdline_fixed_string_t pt_str;
6859 uint16_t pause_time;
6860 cmdline_fixed_string_t xon_str;
6865 cmdline_parse_token_string_t cmd_lfc_set_set =
6866 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6868 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6869 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6870 flow_ctrl, "flow_ctrl");
6871 cmdline_parse_token_string_t cmd_lfc_set_rx =
6872 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6874 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6875 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6876 rx_lfc_mode, "on#off");
6877 cmdline_parse_token_string_t cmd_lfc_set_tx =
6878 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6880 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6881 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6882 tx_lfc_mode, "on#off");
6883 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6884 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6885 hw_str, "high_water");
6886 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6887 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6888 high_water, UINT32);
6889 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6890 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6891 lw_str, "low_water");
6892 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6893 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6895 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6896 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6897 pt_str, "pause_time");
6898 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6899 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6900 pause_time, UINT16);
6901 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6902 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6903 xon_str, "send_xon");
6904 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6905 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6907 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6908 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6909 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6910 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6911 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6912 mac_ctrl_frame_fwd_mode, "on#off");
6913 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6914 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6915 autoneg_str, "autoneg");
6916 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6917 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6919 cmdline_parse_token_num_t cmd_lfc_set_portid =
6920 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6923 /* forward declaration */
6925 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6928 cmdline_parse_inst_t cmd_link_flow_control_set = {
6929 .f = cmd_link_flow_ctrl_set_parsed,
6931 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6932 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6933 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6935 (void *)&cmd_lfc_set_set,
6936 (void *)&cmd_lfc_set_flow_ctrl,
6937 (void *)&cmd_lfc_set_rx,
6938 (void *)&cmd_lfc_set_rx_mode,
6939 (void *)&cmd_lfc_set_tx,
6940 (void *)&cmd_lfc_set_tx_mode,
6941 (void *)&cmd_lfc_set_high_water,
6942 (void *)&cmd_lfc_set_low_water,
6943 (void *)&cmd_lfc_set_pause_time,
6944 (void *)&cmd_lfc_set_send_xon,
6945 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6946 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6947 (void *)&cmd_lfc_set_autoneg_str,
6948 (void *)&cmd_lfc_set_autoneg,
6949 (void *)&cmd_lfc_set_portid,
6954 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6955 .f = cmd_link_flow_ctrl_set_parsed,
6956 .data = (void *)&cmd_link_flow_control_set_rx,
6957 .help_str = "set flow_ctrl rx on|off <port_id>: "
6958 "Change rx flow control parameter",
6960 (void *)&cmd_lfc_set_set,
6961 (void *)&cmd_lfc_set_flow_ctrl,
6962 (void *)&cmd_lfc_set_rx,
6963 (void *)&cmd_lfc_set_rx_mode,
6964 (void *)&cmd_lfc_set_portid,
6969 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6970 .f = cmd_link_flow_ctrl_set_parsed,
6971 .data = (void *)&cmd_link_flow_control_set_tx,
6972 .help_str = "set flow_ctrl tx on|off <port_id>: "
6973 "Change tx flow control parameter",
6975 (void *)&cmd_lfc_set_set,
6976 (void *)&cmd_lfc_set_flow_ctrl,
6977 (void *)&cmd_lfc_set_tx,
6978 (void *)&cmd_lfc_set_tx_mode,
6979 (void *)&cmd_lfc_set_portid,
6984 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6985 .f = cmd_link_flow_ctrl_set_parsed,
6986 .data = (void *)&cmd_link_flow_control_set_hw,
6987 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6988 "Change high water flow control parameter",
6990 (void *)&cmd_lfc_set_set,
6991 (void *)&cmd_lfc_set_flow_ctrl,
6992 (void *)&cmd_lfc_set_high_water_str,
6993 (void *)&cmd_lfc_set_high_water,
6994 (void *)&cmd_lfc_set_portid,
6999 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7000 .f = cmd_link_flow_ctrl_set_parsed,
7001 .data = (void *)&cmd_link_flow_control_set_lw,
7002 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7003 "Change low water flow control parameter",
7005 (void *)&cmd_lfc_set_set,
7006 (void *)&cmd_lfc_set_flow_ctrl,
7007 (void *)&cmd_lfc_set_low_water_str,
7008 (void *)&cmd_lfc_set_low_water,
7009 (void *)&cmd_lfc_set_portid,
7014 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7015 .f = cmd_link_flow_ctrl_set_parsed,
7016 .data = (void *)&cmd_link_flow_control_set_pt,
7017 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7018 "Change pause time flow control parameter",
7020 (void *)&cmd_lfc_set_set,
7021 (void *)&cmd_lfc_set_flow_ctrl,
7022 (void *)&cmd_lfc_set_pause_time_str,
7023 (void *)&cmd_lfc_set_pause_time,
7024 (void *)&cmd_lfc_set_portid,
7029 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7030 .f = cmd_link_flow_ctrl_set_parsed,
7031 .data = (void *)&cmd_link_flow_control_set_xon,
7032 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7033 "Change send_xon flow control parameter",
7035 (void *)&cmd_lfc_set_set,
7036 (void *)&cmd_lfc_set_flow_ctrl,
7037 (void *)&cmd_lfc_set_send_xon_str,
7038 (void *)&cmd_lfc_set_send_xon,
7039 (void *)&cmd_lfc_set_portid,
7044 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7045 .f = cmd_link_flow_ctrl_set_parsed,
7046 .data = (void *)&cmd_link_flow_control_set_macfwd,
7047 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7048 "Change mac ctrl fwd flow control parameter",
7050 (void *)&cmd_lfc_set_set,
7051 (void *)&cmd_lfc_set_flow_ctrl,
7052 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7053 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7054 (void *)&cmd_lfc_set_portid,
7059 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7060 .f = cmd_link_flow_ctrl_set_parsed,
7061 .data = (void *)&cmd_link_flow_control_set_autoneg,
7062 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7063 "Change autoneg flow control parameter",
7065 (void *)&cmd_lfc_set_set,
7066 (void *)&cmd_lfc_set_flow_ctrl,
7067 (void *)&cmd_lfc_set_autoneg_str,
7068 (void *)&cmd_lfc_set_autoneg,
7069 (void *)&cmd_lfc_set_portid,
7075 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7076 __rte_unused struct cmdline *cl,
7079 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7080 cmdline_parse_inst_t *cmd = data;
7081 struct rte_eth_fc_conf fc_conf;
7087 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7088 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7089 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7090 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7092 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7093 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7096 /* Partial command line, retrieve current configuration */
7098 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7100 printf("cannot get current flow ctrl parameters, return"
7101 "code = %d\n", ret);
7105 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7106 (fc_conf.mode == RTE_FC_FULL))
7108 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7109 (fc_conf.mode == RTE_FC_FULL))
7113 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7114 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7116 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7117 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7119 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7121 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7122 fc_conf.high_water = res->high_water;
7124 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7125 fc_conf.low_water = res->low_water;
7127 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7128 fc_conf.pause_time = res->pause_time;
7130 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7131 fc_conf.send_xon = res->send_xon;
7133 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7134 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7135 fc_conf.mac_ctrl_frame_fwd = 1;
7137 fc_conf.mac_ctrl_frame_fwd = 0;
7140 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7141 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7143 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7145 printf("bad flow contrl parameter, return code = %d \n", ret);
7148 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7149 struct cmd_priority_flow_ctrl_set_result {
7150 cmdline_fixed_string_t set;
7151 cmdline_fixed_string_t pfc_ctrl;
7152 cmdline_fixed_string_t rx;
7153 cmdline_fixed_string_t rx_pfc_mode;
7154 cmdline_fixed_string_t tx;
7155 cmdline_fixed_string_t tx_pfc_mode;
7156 uint32_t high_water;
7158 uint16_t pause_time;
7164 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7165 __rte_unused struct cmdline *cl,
7166 __rte_unused void *data)
7168 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7169 struct rte_eth_pfc_conf pfc_conf;
7170 int rx_fc_enable, tx_fc_enable;
7174 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7175 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7176 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7177 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7179 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7180 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7183 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7184 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7185 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7186 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7187 pfc_conf.fc.high_water = res->high_water;
7188 pfc_conf.fc.low_water = res->low_water;
7189 pfc_conf.fc.pause_time = res->pause_time;
7190 pfc_conf.priority = res->priority;
7192 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7194 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7197 cmdline_parse_token_string_t cmd_pfc_set_set =
7198 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7200 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7201 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7202 pfc_ctrl, "pfc_ctrl");
7203 cmdline_parse_token_string_t cmd_pfc_set_rx =
7204 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7206 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7207 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7208 rx_pfc_mode, "on#off");
7209 cmdline_parse_token_string_t cmd_pfc_set_tx =
7210 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7212 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7213 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7214 tx_pfc_mode, "on#off");
7215 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7216 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7217 high_water, UINT32);
7218 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7219 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7221 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7222 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7223 pause_time, UINT16);
7224 cmdline_parse_token_num_t cmd_pfc_set_priority =
7225 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7227 cmdline_parse_token_num_t cmd_pfc_set_portid =
7228 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7231 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7232 .f = cmd_priority_flow_ctrl_set_parsed,
7234 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7235 "<pause_time> <priority> <port_id>: "
7236 "Configure the Ethernet priority flow control",
7238 (void *)&cmd_pfc_set_set,
7239 (void *)&cmd_pfc_set_flow_ctrl,
7240 (void *)&cmd_pfc_set_rx,
7241 (void *)&cmd_pfc_set_rx_mode,
7242 (void *)&cmd_pfc_set_tx,
7243 (void *)&cmd_pfc_set_tx_mode,
7244 (void *)&cmd_pfc_set_high_water,
7245 (void *)&cmd_pfc_set_low_water,
7246 (void *)&cmd_pfc_set_pause_time,
7247 (void *)&cmd_pfc_set_priority,
7248 (void *)&cmd_pfc_set_portid,
7253 /* *** RESET CONFIGURATION *** */
7254 struct cmd_reset_result {
7255 cmdline_fixed_string_t reset;
7256 cmdline_fixed_string_t def;
7259 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7261 __rte_unused void *data)
7263 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7264 set_def_fwd_config();
7267 cmdline_parse_token_string_t cmd_reset_set =
7268 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7269 cmdline_parse_token_string_t cmd_reset_def =
7270 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7273 cmdline_parse_inst_t cmd_reset = {
7274 .f = cmd_reset_parsed,
7276 .help_str = "set default: Reset default forwarding configuration",
7278 (void *)&cmd_reset_set,
7279 (void *)&cmd_reset_def,
7284 /* *** START FORWARDING *** */
7285 struct cmd_start_result {
7286 cmdline_fixed_string_t start;
7289 cmdline_parse_token_string_t cmd_start_start =
7290 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7292 static void cmd_start_parsed(__rte_unused void *parsed_result,
7293 __rte_unused struct cmdline *cl,
7294 __rte_unused void *data)
7296 start_packet_forwarding(0);
7299 cmdline_parse_inst_t cmd_start = {
7300 .f = cmd_start_parsed,
7302 .help_str = "start: Start packet forwarding",
7304 (void *)&cmd_start_start,
7309 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7310 struct cmd_start_tx_first_result {
7311 cmdline_fixed_string_t start;
7312 cmdline_fixed_string_t tx_first;
7316 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7317 __rte_unused struct cmdline *cl,
7318 __rte_unused void *data)
7320 start_packet_forwarding(1);
7323 cmdline_parse_token_string_t cmd_start_tx_first_start =
7324 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7326 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7327 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7328 tx_first, "tx_first");
7330 cmdline_parse_inst_t cmd_start_tx_first = {
7331 .f = cmd_start_tx_first_parsed,
7333 .help_str = "start tx_first: Start packet forwarding, "
7334 "after sending 1 burst of packets",
7336 (void *)&cmd_start_tx_first_start,
7337 (void *)&cmd_start_tx_first_tx_first,
7342 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7343 struct cmd_start_tx_first_n_result {
7344 cmdline_fixed_string_t start;
7345 cmdline_fixed_string_t tx_first;
7350 cmd_start_tx_first_n_parsed(void *parsed_result,
7351 __rte_unused struct cmdline *cl,
7352 __rte_unused void *data)
7354 struct cmd_start_tx_first_n_result *res = parsed_result;
7356 start_packet_forwarding(res->tx_num);
7359 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7360 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7362 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7363 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7364 tx_first, "tx_first");
7365 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7366 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7369 cmdline_parse_inst_t cmd_start_tx_first_n = {
7370 .f = cmd_start_tx_first_n_parsed,
7372 .help_str = "start tx_first <num>: "
7373 "packet forwarding, after sending <num> bursts of packets",
7375 (void *)&cmd_start_tx_first_n_start,
7376 (void *)&cmd_start_tx_first_n_tx_first,
7377 (void *)&cmd_start_tx_first_n_tx_num,
7382 /* *** SET LINK UP *** */
7383 struct cmd_set_link_up_result {
7384 cmdline_fixed_string_t set;
7385 cmdline_fixed_string_t link_up;
7386 cmdline_fixed_string_t port;
7390 cmdline_parse_token_string_t cmd_set_link_up_set =
7391 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7392 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7393 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7395 cmdline_parse_token_string_t cmd_set_link_up_port =
7396 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7397 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7398 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7400 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7401 __rte_unused struct cmdline *cl,
7402 __rte_unused void *data)
7404 struct cmd_set_link_up_result *res = parsed_result;
7405 dev_set_link_up(res->port_id);
7408 cmdline_parse_inst_t cmd_set_link_up = {
7409 .f = cmd_set_link_up_parsed,
7411 .help_str = "set link-up port <port id>",
7413 (void *)&cmd_set_link_up_set,
7414 (void *)&cmd_set_link_up_link_up,
7415 (void *)&cmd_set_link_up_port,
7416 (void *)&cmd_set_link_up_port_id,
7421 /* *** SET LINK DOWN *** */
7422 struct cmd_set_link_down_result {
7423 cmdline_fixed_string_t set;
7424 cmdline_fixed_string_t link_down;
7425 cmdline_fixed_string_t port;
7429 cmdline_parse_token_string_t cmd_set_link_down_set =
7430 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7431 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7432 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7434 cmdline_parse_token_string_t cmd_set_link_down_port =
7435 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7436 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7437 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7439 static void cmd_set_link_down_parsed(
7440 __rte_unused void *parsed_result,
7441 __rte_unused struct cmdline *cl,
7442 __rte_unused void *data)
7444 struct cmd_set_link_down_result *res = parsed_result;
7445 dev_set_link_down(res->port_id);
7448 cmdline_parse_inst_t cmd_set_link_down = {
7449 .f = cmd_set_link_down_parsed,
7451 .help_str = "set link-down port <port id>",
7453 (void *)&cmd_set_link_down_set,
7454 (void *)&cmd_set_link_down_link_down,
7455 (void *)&cmd_set_link_down_port,
7456 (void *)&cmd_set_link_down_port_id,
7461 /* *** SHOW CFG *** */
7462 struct cmd_showcfg_result {
7463 cmdline_fixed_string_t show;
7464 cmdline_fixed_string_t cfg;
7465 cmdline_fixed_string_t what;
7468 static void cmd_showcfg_parsed(void *parsed_result,
7469 __rte_unused struct cmdline *cl,
7470 __rte_unused void *data)
7472 struct cmd_showcfg_result *res = parsed_result;
7473 if (!strcmp(res->what, "rxtx"))
7474 rxtx_config_display();
7475 else if (!strcmp(res->what, "cores"))
7476 fwd_lcores_config_display();
7477 else if (!strcmp(res->what, "fwd"))
7478 pkt_fwd_config_display(&cur_fwd_config);
7479 else if (!strcmp(res->what, "txpkts"))
7480 show_tx_pkt_segments();
7481 else if (!strcmp(res->what, "txtimes"))
7482 show_tx_pkt_times();
7485 cmdline_parse_token_string_t cmd_showcfg_show =
7486 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7487 cmdline_parse_token_string_t cmd_showcfg_port =
7488 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7489 cmdline_parse_token_string_t cmd_showcfg_what =
7490 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7491 "rxtx#cores#fwd#txpkts#txtimes");
7493 cmdline_parse_inst_t cmd_showcfg = {
7494 .f = cmd_showcfg_parsed,
7496 .help_str = "show config rxtx|cores|fwd|txpkts|txtimes",
7498 (void *)&cmd_showcfg_show,
7499 (void *)&cmd_showcfg_port,
7500 (void *)&cmd_showcfg_what,
7505 /* *** SHOW ALL PORT INFO *** */
7506 struct cmd_showportall_result {
7507 cmdline_fixed_string_t show;
7508 cmdline_fixed_string_t port;
7509 cmdline_fixed_string_t what;
7510 cmdline_fixed_string_t all;
7513 static void cmd_showportall_parsed(void *parsed_result,
7514 __rte_unused struct cmdline *cl,
7515 __rte_unused void *data)
7519 struct cmd_showportall_result *res = parsed_result;
7520 if (!strcmp(res->show, "clear")) {
7521 if (!strcmp(res->what, "stats"))
7522 RTE_ETH_FOREACH_DEV(i)
7524 else if (!strcmp(res->what, "xstats"))
7525 RTE_ETH_FOREACH_DEV(i)
7526 nic_xstats_clear(i);
7527 } else if (!strcmp(res->what, "info"))
7528 RTE_ETH_FOREACH_DEV(i)
7529 port_infos_display(i);
7530 else if (!strcmp(res->what, "summary")) {
7531 port_summary_header_display();
7532 RTE_ETH_FOREACH_DEV(i)
7533 port_summary_display(i);
7535 else if (!strcmp(res->what, "stats"))
7536 RTE_ETH_FOREACH_DEV(i)
7537 nic_stats_display(i);
7538 else if (!strcmp(res->what, "xstats"))
7539 RTE_ETH_FOREACH_DEV(i)
7540 nic_xstats_display(i);
7541 else if (!strcmp(res->what, "fdir"))
7542 RTE_ETH_FOREACH_DEV(i)
7544 else if (!strcmp(res->what, "stat_qmap"))
7545 RTE_ETH_FOREACH_DEV(i)
7546 nic_stats_mapping_display(i);
7547 else if (!strcmp(res->what, "dcb_tc"))
7548 RTE_ETH_FOREACH_DEV(i)
7549 port_dcb_info_display(i);
7550 else if (!strcmp(res->what, "cap"))
7551 RTE_ETH_FOREACH_DEV(i)
7552 port_offload_cap_display(i);
7555 cmdline_parse_token_string_t cmd_showportall_show =
7556 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7558 cmdline_parse_token_string_t cmd_showportall_port =
7559 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7560 cmdline_parse_token_string_t cmd_showportall_what =
7561 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7562 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7563 cmdline_parse_token_string_t cmd_showportall_all =
7564 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7565 cmdline_parse_inst_t cmd_showportall = {
7566 .f = cmd_showportall_parsed,
7568 .help_str = "show|clear port "
7569 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7571 (void *)&cmd_showportall_show,
7572 (void *)&cmd_showportall_port,
7573 (void *)&cmd_showportall_what,
7574 (void *)&cmd_showportall_all,
7579 /* *** SHOW PORT INFO *** */
7580 struct cmd_showport_result {
7581 cmdline_fixed_string_t show;
7582 cmdline_fixed_string_t port;
7583 cmdline_fixed_string_t what;
7587 static void cmd_showport_parsed(void *parsed_result,
7588 __rte_unused struct cmdline *cl,
7589 __rte_unused void *data)
7591 struct cmd_showport_result *res = parsed_result;
7592 if (!strcmp(res->show, "clear")) {
7593 if (!strcmp(res->what, "stats"))
7594 nic_stats_clear(res->portnum);
7595 else if (!strcmp(res->what, "xstats"))
7596 nic_xstats_clear(res->portnum);
7597 } else if (!strcmp(res->what, "info"))
7598 port_infos_display(res->portnum);
7599 else if (!strcmp(res->what, "summary")) {
7600 port_summary_header_display();
7601 port_summary_display(res->portnum);
7603 else if (!strcmp(res->what, "stats"))
7604 nic_stats_display(res->portnum);
7605 else if (!strcmp(res->what, "xstats"))
7606 nic_xstats_display(res->portnum);
7607 else if (!strcmp(res->what, "fdir"))
7608 fdir_get_infos(res->portnum);
7609 else if (!strcmp(res->what, "stat_qmap"))
7610 nic_stats_mapping_display(res->portnum);
7611 else if (!strcmp(res->what, "dcb_tc"))
7612 port_dcb_info_display(res->portnum);
7613 else if (!strcmp(res->what, "cap"))
7614 port_offload_cap_display(res->portnum);
7617 cmdline_parse_token_string_t cmd_showport_show =
7618 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7620 cmdline_parse_token_string_t cmd_showport_port =
7621 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7622 cmdline_parse_token_string_t cmd_showport_what =
7623 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7624 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7625 cmdline_parse_token_num_t cmd_showport_portnum =
7626 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7628 cmdline_parse_inst_t cmd_showport = {
7629 .f = cmd_showport_parsed,
7631 .help_str = "show|clear port "
7632 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7635 (void *)&cmd_showport_show,
7636 (void *)&cmd_showport_port,
7637 (void *)&cmd_showport_what,
7638 (void *)&cmd_showport_portnum,
7643 /* *** SHOW DEVICE INFO *** */
7644 struct cmd_showdevice_result {
7645 cmdline_fixed_string_t show;
7646 cmdline_fixed_string_t device;
7647 cmdline_fixed_string_t what;
7648 cmdline_fixed_string_t identifier;
7651 static void cmd_showdevice_parsed(void *parsed_result,
7652 __rte_unused struct cmdline *cl,
7653 __rte_unused void *data)
7655 struct cmd_showdevice_result *res = parsed_result;
7656 if (!strcmp(res->what, "info")) {
7657 if (!strcmp(res->identifier, "all"))
7658 device_infos_display(NULL);
7660 device_infos_display(res->identifier);
7664 cmdline_parse_token_string_t cmd_showdevice_show =
7665 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7667 cmdline_parse_token_string_t cmd_showdevice_device =
7668 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7669 cmdline_parse_token_string_t cmd_showdevice_what =
7670 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7672 cmdline_parse_token_string_t cmd_showdevice_identifier =
7673 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7676 cmdline_parse_inst_t cmd_showdevice = {
7677 .f = cmd_showdevice_parsed,
7679 .help_str = "show device info <identifier>|all",
7681 (void *)&cmd_showdevice_show,
7682 (void *)&cmd_showdevice_device,
7683 (void *)&cmd_showdevice_what,
7684 (void *)&cmd_showdevice_identifier,
7688 /* *** SHOW QUEUE INFO *** */
7689 struct cmd_showqueue_result {
7690 cmdline_fixed_string_t show;
7691 cmdline_fixed_string_t type;
7692 cmdline_fixed_string_t what;
7698 cmd_showqueue_parsed(void *parsed_result,
7699 __rte_unused struct cmdline *cl,
7700 __rte_unused void *data)
7702 struct cmd_showqueue_result *res = parsed_result;
7704 if (!strcmp(res->type, "rxq"))
7705 rx_queue_infos_display(res->portnum, res->queuenum);
7706 else if (!strcmp(res->type, "txq"))
7707 tx_queue_infos_display(res->portnum, res->queuenum);
7710 cmdline_parse_token_string_t cmd_showqueue_show =
7711 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7712 cmdline_parse_token_string_t cmd_showqueue_type =
7713 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7714 cmdline_parse_token_string_t cmd_showqueue_what =
7715 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7716 cmdline_parse_token_num_t cmd_showqueue_portnum =
7717 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7718 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7719 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7721 cmdline_parse_inst_t cmd_showqueue = {
7722 .f = cmd_showqueue_parsed,
7724 .help_str = "show rxq|txq info <port_id> <queue_id>",
7726 (void *)&cmd_showqueue_show,
7727 (void *)&cmd_showqueue_type,
7728 (void *)&cmd_showqueue_what,
7729 (void *)&cmd_showqueue_portnum,
7730 (void *)&cmd_showqueue_queuenum,
7735 /* show/clear fwd engine statistics */
7737 cmdline_fixed_string_t action;
7738 cmdline_fixed_string_t fwd;
7739 cmdline_fixed_string_t stats;
7740 cmdline_fixed_string_t all;
7743 cmdline_parse_token_string_t cmd_fwd_action =
7744 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7745 cmdline_parse_token_string_t cmd_fwd_fwd =
7746 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7747 cmdline_parse_token_string_t cmd_fwd_stats =
7748 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7749 cmdline_parse_token_string_t cmd_fwd_all =
7750 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7753 cmd_showfwdall_parsed(void *parsed_result,
7754 __rte_unused struct cmdline *cl,
7755 __rte_unused void *data)
7757 struct fwd_result *res = parsed_result;
7759 if (!strcmp(res->action, "show"))
7760 fwd_stats_display();
7765 static cmdline_parse_inst_t cmd_showfwdall = {
7766 .f = cmd_showfwdall_parsed,
7768 .help_str = "show|clear fwd stats all",
7770 (void *)&cmd_fwd_action,
7771 (void *)&cmd_fwd_fwd,
7772 (void *)&cmd_fwd_stats,
7773 (void *)&cmd_fwd_all,
7778 /* *** READ PORT REGISTER *** */
7779 struct cmd_read_reg_result {
7780 cmdline_fixed_string_t read;
7781 cmdline_fixed_string_t reg;
7787 cmd_read_reg_parsed(void *parsed_result,
7788 __rte_unused struct cmdline *cl,
7789 __rte_unused void *data)
7791 struct cmd_read_reg_result *res = parsed_result;
7792 port_reg_display(res->port_id, res->reg_off);
7795 cmdline_parse_token_string_t cmd_read_reg_read =
7796 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7797 cmdline_parse_token_string_t cmd_read_reg_reg =
7798 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7799 cmdline_parse_token_num_t cmd_read_reg_port_id =
7800 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7801 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7802 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7804 cmdline_parse_inst_t cmd_read_reg = {
7805 .f = cmd_read_reg_parsed,
7807 .help_str = "read reg <port_id> <reg_off>",
7809 (void *)&cmd_read_reg_read,
7810 (void *)&cmd_read_reg_reg,
7811 (void *)&cmd_read_reg_port_id,
7812 (void *)&cmd_read_reg_reg_off,
7817 /* *** READ PORT REGISTER BIT FIELD *** */
7818 struct cmd_read_reg_bit_field_result {
7819 cmdline_fixed_string_t read;
7820 cmdline_fixed_string_t regfield;
7828 cmd_read_reg_bit_field_parsed(void *parsed_result,
7829 __rte_unused struct cmdline *cl,
7830 __rte_unused void *data)
7832 struct cmd_read_reg_bit_field_result *res = parsed_result;
7833 port_reg_bit_field_display(res->port_id, res->reg_off,
7834 res->bit1_pos, res->bit2_pos);
7837 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7838 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7840 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7841 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7842 regfield, "regfield");
7843 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7844 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7846 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7847 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7849 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7850 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7852 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7853 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7856 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7857 .f = cmd_read_reg_bit_field_parsed,
7859 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7860 "Read register bit field between bit_x and bit_y included",
7862 (void *)&cmd_read_reg_bit_field_read,
7863 (void *)&cmd_read_reg_bit_field_regfield,
7864 (void *)&cmd_read_reg_bit_field_port_id,
7865 (void *)&cmd_read_reg_bit_field_reg_off,
7866 (void *)&cmd_read_reg_bit_field_bit1_pos,
7867 (void *)&cmd_read_reg_bit_field_bit2_pos,
7872 /* *** READ PORT REGISTER BIT *** */
7873 struct cmd_read_reg_bit_result {
7874 cmdline_fixed_string_t read;
7875 cmdline_fixed_string_t regbit;
7882 cmd_read_reg_bit_parsed(void *parsed_result,
7883 __rte_unused struct cmdline *cl,
7884 __rte_unused void *data)
7886 struct cmd_read_reg_bit_result *res = parsed_result;
7887 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7890 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7891 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7892 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7893 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7895 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7896 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7897 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7898 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7899 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7900 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7902 cmdline_parse_inst_t cmd_read_reg_bit = {
7903 .f = cmd_read_reg_bit_parsed,
7905 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7907 (void *)&cmd_read_reg_bit_read,
7908 (void *)&cmd_read_reg_bit_regbit,
7909 (void *)&cmd_read_reg_bit_port_id,
7910 (void *)&cmd_read_reg_bit_reg_off,
7911 (void *)&cmd_read_reg_bit_bit_pos,
7916 /* *** WRITE PORT REGISTER *** */
7917 struct cmd_write_reg_result {
7918 cmdline_fixed_string_t write;
7919 cmdline_fixed_string_t reg;
7926 cmd_write_reg_parsed(void *parsed_result,
7927 __rte_unused struct cmdline *cl,
7928 __rte_unused void *data)
7930 struct cmd_write_reg_result *res = parsed_result;
7931 port_reg_set(res->port_id, res->reg_off, res->value);
7934 cmdline_parse_token_string_t cmd_write_reg_write =
7935 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7936 cmdline_parse_token_string_t cmd_write_reg_reg =
7937 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7938 cmdline_parse_token_num_t cmd_write_reg_port_id =
7939 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7940 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7941 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7942 cmdline_parse_token_num_t cmd_write_reg_value =
7943 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7945 cmdline_parse_inst_t cmd_write_reg = {
7946 .f = cmd_write_reg_parsed,
7948 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7950 (void *)&cmd_write_reg_write,
7951 (void *)&cmd_write_reg_reg,
7952 (void *)&cmd_write_reg_port_id,
7953 (void *)&cmd_write_reg_reg_off,
7954 (void *)&cmd_write_reg_value,
7959 /* *** WRITE PORT REGISTER BIT FIELD *** */
7960 struct cmd_write_reg_bit_field_result {
7961 cmdline_fixed_string_t write;
7962 cmdline_fixed_string_t regfield;
7971 cmd_write_reg_bit_field_parsed(void *parsed_result,
7972 __rte_unused struct cmdline *cl,
7973 __rte_unused void *data)
7975 struct cmd_write_reg_bit_field_result *res = parsed_result;
7976 port_reg_bit_field_set(res->port_id, res->reg_off,
7977 res->bit1_pos, res->bit2_pos, res->value);
7980 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7981 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7983 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7984 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7985 regfield, "regfield");
7986 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7987 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7989 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7990 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7992 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7993 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7995 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7996 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7998 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7999 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8002 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8003 .f = cmd_write_reg_bit_field_parsed,
8005 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8007 "Set register bit field between bit_x and bit_y included",
8009 (void *)&cmd_write_reg_bit_field_write,
8010 (void *)&cmd_write_reg_bit_field_regfield,
8011 (void *)&cmd_write_reg_bit_field_port_id,
8012 (void *)&cmd_write_reg_bit_field_reg_off,
8013 (void *)&cmd_write_reg_bit_field_bit1_pos,
8014 (void *)&cmd_write_reg_bit_field_bit2_pos,
8015 (void *)&cmd_write_reg_bit_field_value,
8020 /* *** WRITE PORT REGISTER BIT *** */
8021 struct cmd_write_reg_bit_result {
8022 cmdline_fixed_string_t write;
8023 cmdline_fixed_string_t regbit;
8031 cmd_write_reg_bit_parsed(void *parsed_result,
8032 __rte_unused struct cmdline *cl,
8033 __rte_unused void *data)
8035 struct cmd_write_reg_bit_result *res = parsed_result;
8036 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8039 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8040 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8042 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8043 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8045 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8046 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
8047 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8048 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
8049 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8050 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
8051 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8052 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
8054 cmdline_parse_inst_t cmd_write_reg_bit = {
8055 .f = cmd_write_reg_bit_parsed,
8057 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8060 (void *)&cmd_write_reg_bit_write,
8061 (void *)&cmd_write_reg_bit_regbit,
8062 (void *)&cmd_write_reg_bit_port_id,
8063 (void *)&cmd_write_reg_bit_reg_off,
8064 (void *)&cmd_write_reg_bit_bit_pos,
8065 (void *)&cmd_write_reg_bit_value,
8070 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8071 struct cmd_read_rxd_txd_result {
8072 cmdline_fixed_string_t read;
8073 cmdline_fixed_string_t rxd_txd;
8080 cmd_read_rxd_txd_parsed(void *parsed_result,
8081 __rte_unused struct cmdline *cl,
8082 __rte_unused void *data)
8084 struct cmd_read_rxd_txd_result *res = parsed_result;
8086 if (!strcmp(res->rxd_txd, "rxd"))
8087 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8088 else if (!strcmp(res->rxd_txd, "txd"))
8089 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8092 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8093 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8094 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8095 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8097 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8098 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8099 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8100 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8101 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8102 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8104 cmdline_parse_inst_t cmd_read_rxd_txd = {
8105 .f = cmd_read_rxd_txd_parsed,
8107 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8109 (void *)&cmd_read_rxd_txd_read,
8110 (void *)&cmd_read_rxd_txd_rxd_txd,
8111 (void *)&cmd_read_rxd_txd_port_id,
8112 (void *)&cmd_read_rxd_txd_queue_id,
8113 (void *)&cmd_read_rxd_txd_desc_id,
8119 struct cmd_quit_result {
8120 cmdline_fixed_string_t quit;
8123 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8125 __rte_unused void *data)
8130 cmdline_parse_token_string_t cmd_quit_quit =
8131 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8133 cmdline_parse_inst_t cmd_quit = {
8134 .f = cmd_quit_parsed,
8136 .help_str = "quit: Exit application",
8138 (void *)&cmd_quit_quit,
8143 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8144 struct cmd_mac_addr_result {
8145 cmdline_fixed_string_t mac_addr_cmd;
8146 cmdline_fixed_string_t what;
8148 struct rte_ether_addr address;
8151 static void cmd_mac_addr_parsed(void *parsed_result,
8152 __rte_unused struct cmdline *cl,
8153 __rte_unused void *data)
8155 struct cmd_mac_addr_result *res = parsed_result;
8158 if (strcmp(res->what, "add") == 0)
8159 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8160 else if (strcmp(res->what, "set") == 0)
8161 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8164 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8166 /* check the return value and print it if is < 0 */
8168 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8172 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8173 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8175 cmdline_parse_token_string_t cmd_mac_addr_what =
8176 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8178 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8179 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8181 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8182 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8184 cmdline_parse_inst_t cmd_mac_addr = {
8185 .f = cmd_mac_addr_parsed,
8187 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8188 "Add/Remove/Set MAC address on port_id",
8190 (void *)&cmd_mac_addr_cmd,
8191 (void *)&cmd_mac_addr_what,
8192 (void *)&cmd_mac_addr_portnum,
8193 (void *)&cmd_mac_addr_addr,
8198 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8199 struct cmd_eth_peer_result {
8200 cmdline_fixed_string_t set;
8201 cmdline_fixed_string_t eth_peer;
8203 cmdline_fixed_string_t peer_addr;
8206 static void cmd_set_eth_peer_parsed(void *parsed_result,
8207 __rte_unused struct cmdline *cl,
8208 __rte_unused void *data)
8210 struct cmd_eth_peer_result *res = parsed_result;
8212 if (test_done == 0) {
8213 printf("Please stop forwarding first\n");
8216 if (!strcmp(res->eth_peer, "eth-peer")) {
8217 set_fwd_eth_peer(res->port_id, res->peer_addr);
8221 cmdline_parse_token_string_t cmd_eth_peer_set =
8222 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8223 cmdline_parse_token_string_t cmd_eth_peer =
8224 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8225 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8226 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8227 cmdline_parse_token_string_t cmd_eth_peer_addr =
8228 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8230 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8231 .f = cmd_set_eth_peer_parsed,
8233 .help_str = "set eth-peer <port_id> <peer_mac>",
8235 (void *)&cmd_eth_peer_set,
8236 (void *)&cmd_eth_peer,
8237 (void *)&cmd_eth_peer_port_id,
8238 (void *)&cmd_eth_peer_addr,
8243 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8244 struct cmd_set_qmap_result {
8245 cmdline_fixed_string_t set;
8246 cmdline_fixed_string_t qmap;
8247 cmdline_fixed_string_t what;
8254 cmd_set_qmap_parsed(void *parsed_result,
8255 __rte_unused struct cmdline *cl,
8256 __rte_unused void *data)
8258 struct cmd_set_qmap_result *res = parsed_result;
8259 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8261 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8264 cmdline_parse_token_string_t cmd_setqmap_set =
8265 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8267 cmdline_parse_token_string_t cmd_setqmap_qmap =
8268 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8270 cmdline_parse_token_string_t cmd_setqmap_what =
8271 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8273 cmdline_parse_token_num_t cmd_setqmap_portid =
8274 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8276 cmdline_parse_token_num_t cmd_setqmap_queueid =
8277 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8279 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8280 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8283 cmdline_parse_inst_t cmd_set_qmap = {
8284 .f = cmd_set_qmap_parsed,
8286 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8287 "Set statistics mapping value on tx|rx queue_id of port_id",
8289 (void *)&cmd_setqmap_set,
8290 (void *)&cmd_setqmap_qmap,
8291 (void *)&cmd_setqmap_what,
8292 (void *)&cmd_setqmap_portid,
8293 (void *)&cmd_setqmap_queueid,
8294 (void *)&cmd_setqmap_mapvalue,
8299 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8300 struct cmd_set_xstats_hide_zero_result {
8301 cmdline_fixed_string_t keyword;
8302 cmdline_fixed_string_t name;
8303 cmdline_fixed_string_t on_off;
8307 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8308 __rte_unused struct cmdline *cl,
8309 __rte_unused void *data)
8311 struct cmd_set_xstats_hide_zero_result *res;
8312 uint16_t on_off = 0;
8314 res = parsed_result;
8315 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8316 set_xstats_hide_zero(on_off);
8319 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8320 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8322 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8323 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8324 name, "xstats-hide-zero");
8325 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8326 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8329 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8330 .f = cmd_set_xstats_hide_zero_parsed,
8332 .help_str = "set xstats-hide-zero on|off",
8334 (void *)&cmd_set_xstats_hide_zero_keyword,
8335 (void *)&cmd_set_xstats_hide_zero_name,
8336 (void *)&cmd_set_xstats_hide_zero_on_off,
8341 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8342 struct cmd_set_record_core_cycles_result {
8343 cmdline_fixed_string_t keyword;
8344 cmdline_fixed_string_t name;
8345 cmdline_fixed_string_t on_off;
8349 cmd_set_record_core_cycles_parsed(void *parsed_result,
8350 __rte_unused struct cmdline *cl,
8351 __rte_unused void *data)
8353 struct cmd_set_record_core_cycles_result *res;
8354 uint16_t on_off = 0;
8356 res = parsed_result;
8357 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8358 set_record_core_cycles(on_off);
8361 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8362 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8364 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8365 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8366 name, "record-core-cycles");
8367 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8368 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8371 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8372 .f = cmd_set_record_core_cycles_parsed,
8374 .help_str = "set record-core-cycles on|off",
8376 (void *)&cmd_set_record_core_cycles_keyword,
8377 (void *)&cmd_set_record_core_cycles_name,
8378 (void *)&cmd_set_record_core_cycles_on_off,
8383 /* *** CONFIGURE UNICAST HASH TABLE *** */
8384 struct cmd_set_uc_hash_table {
8385 cmdline_fixed_string_t set;
8386 cmdline_fixed_string_t port;
8388 cmdline_fixed_string_t what;
8389 struct rte_ether_addr address;
8390 cmdline_fixed_string_t mode;
8394 cmd_set_uc_hash_parsed(void *parsed_result,
8395 __rte_unused struct cmdline *cl,
8396 __rte_unused void *data)
8399 struct cmd_set_uc_hash_table *res = parsed_result;
8401 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8403 if (strcmp(res->what, "uta") == 0)
8404 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8405 &res->address,(uint8_t)is_on);
8407 printf("bad unicast hash table parameter, return code = %d \n", ret);
8411 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8412 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8414 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8415 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8417 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8418 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8420 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8421 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8423 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8424 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8426 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8427 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8430 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8431 .f = cmd_set_uc_hash_parsed,
8433 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8435 (void *)&cmd_set_uc_hash_set,
8436 (void *)&cmd_set_uc_hash_port,
8437 (void *)&cmd_set_uc_hash_portid,
8438 (void *)&cmd_set_uc_hash_what,
8439 (void *)&cmd_set_uc_hash_mac,
8440 (void *)&cmd_set_uc_hash_mode,
8445 struct cmd_set_uc_all_hash_table {
8446 cmdline_fixed_string_t set;
8447 cmdline_fixed_string_t port;
8449 cmdline_fixed_string_t what;
8450 cmdline_fixed_string_t value;
8451 cmdline_fixed_string_t mode;
8455 cmd_set_uc_all_hash_parsed(void *parsed_result,
8456 __rte_unused struct cmdline *cl,
8457 __rte_unused void *data)
8460 struct cmd_set_uc_all_hash_table *res = parsed_result;
8462 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8464 if ((strcmp(res->what, "uta") == 0) &&
8465 (strcmp(res->value, "all") == 0))
8466 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8468 printf("bad unicast hash table parameter,"
8469 "return code = %d \n", ret);
8472 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8473 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8475 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8476 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8478 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8479 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8481 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8482 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8484 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8485 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8487 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8488 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8491 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8492 .f = cmd_set_uc_all_hash_parsed,
8494 .help_str = "set port <port_id> uta all on|off",
8496 (void *)&cmd_set_uc_all_hash_set,
8497 (void *)&cmd_set_uc_all_hash_port,
8498 (void *)&cmd_set_uc_all_hash_portid,
8499 (void *)&cmd_set_uc_all_hash_what,
8500 (void *)&cmd_set_uc_all_hash_value,
8501 (void *)&cmd_set_uc_all_hash_mode,
8506 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8507 struct cmd_set_vf_macvlan_filter {
8508 cmdline_fixed_string_t set;
8509 cmdline_fixed_string_t port;
8511 cmdline_fixed_string_t vf;
8513 struct rte_ether_addr address;
8514 cmdline_fixed_string_t filter_type;
8515 cmdline_fixed_string_t mode;
8519 cmd_set_vf_macvlan_parsed(void *parsed_result,
8520 __rte_unused struct cmdline *cl,
8521 __rte_unused void *data)
8524 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8525 struct rte_eth_mac_filter filter;
8527 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8529 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8531 /* set VF MAC filter */
8535 filter.dst_id = res->vf_id;
8537 if (!strcmp(res->filter_type, "exact-mac"))
8538 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8539 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8540 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8541 else if (!strcmp(res->filter_type, "hashmac"))
8542 filter.filter_type = RTE_MAC_HASH_MATCH;
8543 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8544 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8546 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8549 ret = rte_eth_dev_filter_ctrl(res->port_id,
8550 RTE_ETH_FILTER_MACVLAN,
8554 ret = rte_eth_dev_filter_ctrl(res->port_id,
8555 RTE_ETH_FILTER_MACVLAN,
8556 RTE_ETH_FILTER_DELETE,
8560 printf("bad set MAC hash parameter, return code = %d\n", ret);
8564 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8565 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8567 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8568 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8570 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8571 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8573 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8574 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8576 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8577 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8579 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8580 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8582 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8583 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8584 filter_type, "exact-mac#exact-mac-vlan"
8585 "#hashmac#hashmac-vlan");
8586 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8587 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8590 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8591 .f = cmd_set_vf_macvlan_parsed,
8593 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8594 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8595 "Exact match rule: exact match of MAC or MAC and VLAN; "
8596 "hash match rule: hash match of MAC and exact match of VLAN",
8598 (void *)&cmd_set_vf_macvlan_set,
8599 (void *)&cmd_set_vf_macvlan_port,
8600 (void *)&cmd_set_vf_macvlan_portid,
8601 (void *)&cmd_set_vf_macvlan_vf,
8602 (void *)&cmd_set_vf_macvlan_vf_id,
8603 (void *)&cmd_set_vf_macvlan_mac,
8604 (void *)&cmd_set_vf_macvlan_filter_type,
8605 (void *)&cmd_set_vf_macvlan_mode,
8610 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8611 struct cmd_set_vf_traffic {
8612 cmdline_fixed_string_t set;
8613 cmdline_fixed_string_t port;
8615 cmdline_fixed_string_t vf;
8617 cmdline_fixed_string_t what;
8618 cmdline_fixed_string_t mode;
8622 cmd_set_vf_traffic_parsed(void *parsed_result,
8623 __rte_unused struct cmdline *cl,
8624 __rte_unused void *data)
8626 struct cmd_set_vf_traffic *res = parsed_result;
8627 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8628 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8630 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8633 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8634 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8636 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8637 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8639 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8640 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8642 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8643 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8645 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8646 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8648 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8649 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8651 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8652 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8655 cmdline_parse_inst_t cmd_set_vf_traffic = {
8656 .f = cmd_set_vf_traffic_parsed,
8658 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8660 (void *)&cmd_setvf_traffic_set,
8661 (void *)&cmd_setvf_traffic_port,
8662 (void *)&cmd_setvf_traffic_portid,
8663 (void *)&cmd_setvf_traffic_vf,
8664 (void *)&cmd_setvf_traffic_vfid,
8665 (void *)&cmd_setvf_traffic_what,
8666 (void *)&cmd_setvf_traffic_mode,
8671 /* *** CONFIGURE VF RECEIVE MODE *** */
8672 struct cmd_set_vf_rxmode {
8673 cmdline_fixed_string_t set;
8674 cmdline_fixed_string_t port;
8676 cmdline_fixed_string_t vf;
8678 cmdline_fixed_string_t what;
8679 cmdline_fixed_string_t mode;
8680 cmdline_fixed_string_t on;
8684 cmd_set_vf_rxmode_parsed(void *parsed_result,
8685 __rte_unused struct cmdline *cl,
8686 __rte_unused void *data)
8689 uint16_t vf_rxmode = 0;
8690 struct cmd_set_vf_rxmode *res = parsed_result;
8692 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8693 if (!strcmp(res->what,"rxmode")) {
8694 if (!strcmp(res->mode, "AUPE"))
8695 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8696 else if (!strcmp(res->mode, "ROPE"))
8697 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8698 else if (!strcmp(res->mode, "BAM"))
8699 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8700 else if (!strncmp(res->mode, "MPE",3))
8701 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8704 RTE_SET_USED(is_on);
8706 #ifdef RTE_LIBRTE_IXGBE_PMD
8707 if (ret == -ENOTSUP)
8708 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8709 vf_rxmode, (uint8_t)is_on);
8711 #ifdef RTE_LIBRTE_BNXT_PMD
8712 if (ret == -ENOTSUP)
8713 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8714 vf_rxmode, (uint8_t)is_on);
8717 printf("bad VF receive mode parameter, return code = %d \n",
8721 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8722 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8724 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8725 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8727 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8728 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8730 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8731 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8733 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8734 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8736 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8737 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8739 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8740 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8741 mode, "AUPE#ROPE#BAM#MPE");
8742 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8743 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8746 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8747 .f = cmd_set_vf_rxmode_parsed,
8749 .help_str = "set port <port_id> vf <vf_id> rxmode "
8750 "AUPE|ROPE|BAM|MPE on|off",
8752 (void *)&cmd_set_vf_rxmode_set,
8753 (void *)&cmd_set_vf_rxmode_port,
8754 (void *)&cmd_set_vf_rxmode_portid,
8755 (void *)&cmd_set_vf_rxmode_vf,
8756 (void *)&cmd_set_vf_rxmode_vfid,
8757 (void *)&cmd_set_vf_rxmode_what,
8758 (void *)&cmd_set_vf_rxmode_mode,
8759 (void *)&cmd_set_vf_rxmode_on,
8764 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8765 struct cmd_vf_mac_addr_result {
8766 cmdline_fixed_string_t mac_addr_cmd;
8767 cmdline_fixed_string_t what;
8768 cmdline_fixed_string_t port;
8770 cmdline_fixed_string_t vf;
8772 struct rte_ether_addr address;
8775 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8776 __rte_unused struct cmdline *cl,
8777 __rte_unused void *data)
8779 struct cmd_vf_mac_addr_result *res = parsed_result;
8782 if (strcmp(res->what, "add") != 0)
8785 #ifdef RTE_LIBRTE_I40E_PMD
8786 if (ret == -ENOTSUP)
8787 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8790 #ifdef RTE_LIBRTE_BNXT_PMD
8791 if (ret == -ENOTSUP)
8792 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8797 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8801 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8802 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8803 mac_addr_cmd,"mac_addr");
8804 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8805 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8807 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8808 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8810 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8811 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8813 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8814 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8816 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8817 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8819 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8820 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8823 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8824 .f = cmd_vf_mac_addr_parsed,
8826 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8827 "Add MAC address filtering for a VF on port_id",
8829 (void *)&cmd_vf_mac_addr_cmd,
8830 (void *)&cmd_vf_mac_addr_what,
8831 (void *)&cmd_vf_mac_addr_port,
8832 (void *)&cmd_vf_mac_addr_portnum,
8833 (void *)&cmd_vf_mac_addr_vf,
8834 (void *)&cmd_vf_mac_addr_vfnum,
8835 (void *)&cmd_vf_mac_addr_addr,
8840 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8841 struct cmd_vf_rx_vlan_filter {
8842 cmdline_fixed_string_t rx_vlan;
8843 cmdline_fixed_string_t what;
8845 cmdline_fixed_string_t port;
8847 cmdline_fixed_string_t vf;
8852 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8853 __rte_unused struct cmdline *cl,
8854 __rte_unused void *data)
8856 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8859 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8861 #ifdef RTE_LIBRTE_IXGBE_PMD
8862 if (ret == -ENOTSUP)
8863 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8864 res->vlan_id, res->vf_mask, is_add);
8866 #ifdef RTE_LIBRTE_I40E_PMD
8867 if (ret == -ENOTSUP)
8868 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8869 res->vlan_id, res->vf_mask, is_add);
8871 #ifdef RTE_LIBRTE_BNXT_PMD
8872 if (ret == -ENOTSUP)
8873 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8874 res->vlan_id, res->vf_mask, is_add);
8881 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8882 res->vlan_id, res->vf_mask);
8885 printf("invalid port_id %d\n", res->port_id);
8888 printf("function not implemented or supported\n");
8891 printf("programming error: (%s)\n", strerror(-ret));
8895 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8896 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8897 rx_vlan, "rx_vlan");
8898 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8899 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8901 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8902 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8904 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8905 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8907 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8908 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8910 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8911 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8913 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8914 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8917 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8918 .f = cmd_vf_rx_vlan_filter_parsed,
8920 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8921 "(vf_mask = hexadecimal VF mask)",
8923 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8924 (void *)&cmd_vf_rx_vlan_filter_what,
8925 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8926 (void *)&cmd_vf_rx_vlan_filter_port,
8927 (void *)&cmd_vf_rx_vlan_filter_portid,
8928 (void *)&cmd_vf_rx_vlan_filter_vf,
8929 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8934 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8935 struct cmd_queue_rate_limit_result {
8936 cmdline_fixed_string_t set;
8937 cmdline_fixed_string_t port;
8939 cmdline_fixed_string_t queue;
8941 cmdline_fixed_string_t rate;
8945 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8946 __rte_unused struct cmdline *cl,
8947 __rte_unused void *data)
8949 struct cmd_queue_rate_limit_result *res = parsed_result;
8952 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8953 && (strcmp(res->queue, "queue") == 0)
8954 && (strcmp(res->rate, "rate") == 0))
8955 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8958 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8962 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8963 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8965 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8966 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8968 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8969 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8971 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8972 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8974 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8975 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8977 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8978 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8980 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8981 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8984 cmdline_parse_inst_t cmd_queue_rate_limit = {
8985 .f = cmd_queue_rate_limit_parsed,
8987 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8988 "Set rate limit for a queue on port_id",
8990 (void *)&cmd_queue_rate_limit_set,
8991 (void *)&cmd_queue_rate_limit_port,
8992 (void *)&cmd_queue_rate_limit_portnum,
8993 (void *)&cmd_queue_rate_limit_queue,
8994 (void *)&cmd_queue_rate_limit_queuenum,
8995 (void *)&cmd_queue_rate_limit_rate,
8996 (void *)&cmd_queue_rate_limit_ratenum,
9001 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9002 struct cmd_vf_rate_limit_result {
9003 cmdline_fixed_string_t set;
9004 cmdline_fixed_string_t port;
9006 cmdline_fixed_string_t vf;
9008 cmdline_fixed_string_t rate;
9010 cmdline_fixed_string_t q_msk;
9014 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9015 __rte_unused struct cmdline *cl,
9016 __rte_unused void *data)
9018 struct cmd_vf_rate_limit_result *res = parsed_result;
9021 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9022 && (strcmp(res->vf, "vf") == 0)
9023 && (strcmp(res->rate, "rate") == 0)
9024 && (strcmp(res->q_msk, "queue_mask") == 0))
9025 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9026 res->rate_num, res->q_msk_val);
9028 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9032 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9033 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9035 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9036 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9038 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9039 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9041 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9042 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9044 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9045 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9047 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9048 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9050 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9051 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9053 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9054 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9055 q_msk, "queue_mask");
9056 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9057 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9060 cmdline_parse_inst_t cmd_vf_rate_limit = {
9061 .f = cmd_vf_rate_limit_parsed,
9063 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9064 "queue_mask <queue_mask_value>: "
9065 "Set rate limit for queues of VF on port_id",
9067 (void *)&cmd_vf_rate_limit_set,
9068 (void *)&cmd_vf_rate_limit_port,
9069 (void *)&cmd_vf_rate_limit_portnum,
9070 (void *)&cmd_vf_rate_limit_vf,
9071 (void *)&cmd_vf_rate_limit_vfnum,
9072 (void *)&cmd_vf_rate_limit_rate,
9073 (void *)&cmd_vf_rate_limit_ratenum,
9074 (void *)&cmd_vf_rate_limit_q_msk,
9075 (void *)&cmd_vf_rate_limit_q_msk_val,
9080 /* *** ADD TUNNEL FILTER OF A PORT *** */
9081 struct cmd_tunnel_filter_result {
9082 cmdline_fixed_string_t cmd;
9083 cmdline_fixed_string_t what;
9085 struct rte_ether_addr outer_mac;
9086 struct rte_ether_addr inner_mac;
9087 cmdline_ipaddr_t ip_value;
9088 uint16_t inner_vlan;
9089 cmdline_fixed_string_t tunnel_type;
9090 cmdline_fixed_string_t filter_type;
9096 cmd_tunnel_filter_parsed(void *parsed_result,
9097 __rte_unused struct cmdline *cl,
9098 __rte_unused void *data)
9100 struct cmd_tunnel_filter_result *res = parsed_result;
9101 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
9104 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
9106 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
9107 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
9108 tunnel_filter_conf.inner_vlan = res->inner_vlan;
9110 if (res->ip_value.family == AF_INET) {
9111 tunnel_filter_conf.ip_addr.ipv4_addr =
9112 res->ip_value.addr.ipv4.s_addr;
9113 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
9115 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
9116 &(res->ip_value.addr.ipv6),
9117 sizeof(struct in6_addr));
9118 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
9121 if (!strcmp(res->filter_type, "imac-ivlan"))
9122 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
9123 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
9124 tunnel_filter_conf.filter_type =
9125 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
9126 else if (!strcmp(res->filter_type, "imac-tenid"))
9127 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
9128 else if (!strcmp(res->filter_type, "imac"))
9129 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
9130 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
9131 tunnel_filter_conf.filter_type =
9132 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
9133 else if (!strcmp(res->filter_type, "oip"))
9134 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9135 else if (!strcmp(res->filter_type, "iip"))
9136 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9138 printf("The filter type is not supported");
9142 if (!strcmp(res->tunnel_type, "vxlan"))
9143 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9144 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9145 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9146 else if (!strcmp(res->tunnel_type, "nvgre"))
9147 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9148 else if (!strcmp(res->tunnel_type, "ipingre"))
9149 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9151 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9155 tunnel_filter_conf.tenant_id = res->tenant_id;
9156 tunnel_filter_conf.queue_id = res->queue_num;
9157 if (!strcmp(res->what, "add"))
9158 ret = rte_eth_dev_filter_ctrl(res->port_id,
9159 RTE_ETH_FILTER_TUNNEL,
9161 &tunnel_filter_conf);
9163 ret = rte_eth_dev_filter_ctrl(res->port_id,
9164 RTE_ETH_FILTER_TUNNEL,
9165 RTE_ETH_FILTER_DELETE,
9166 &tunnel_filter_conf);
9168 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9172 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9173 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9174 cmd, "tunnel_filter");
9175 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9176 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9178 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9179 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9181 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9182 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9184 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9185 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9187 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9188 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9189 inner_vlan, UINT16);
9190 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9191 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9193 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9194 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9195 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9197 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9198 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9199 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9200 "imac#omac-imac-tenid");
9201 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9202 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9204 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9205 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9208 cmdline_parse_inst_t cmd_tunnel_filter = {
9209 .f = cmd_tunnel_filter_parsed,
9211 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9212 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9213 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9214 "<queue_id>: Add/Rm tunnel filter of a port",
9216 (void *)&cmd_tunnel_filter_cmd,
9217 (void *)&cmd_tunnel_filter_what,
9218 (void *)&cmd_tunnel_filter_port_id,
9219 (void *)&cmd_tunnel_filter_outer_mac,
9220 (void *)&cmd_tunnel_filter_inner_mac,
9221 (void *)&cmd_tunnel_filter_ip_value,
9222 (void *)&cmd_tunnel_filter_innner_vlan,
9223 (void *)&cmd_tunnel_filter_tunnel_type,
9224 (void *)&cmd_tunnel_filter_filter_type,
9225 (void *)&cmd_tunnel_filter_tenant_id,
9226 (void *)&cmd_tunnel_filter_queue_num,
9231 /* *** CONFIGURE TUNNEL UDP PORT *** */
9232 struct cmd_tunnel_udp_config {
9233 cmdline_fixed_string_t cmd;
9234 cmdline_fixed_string_t what;
9240 cmd_tunnel_udp_config_parsed(void *parsed_result,
9241 __rte_unused struct cmdline *cl,
9242 __rte_unused void *data)
9244 struct cmd_tunnel_udp_config *res = parsed_result;
9245 struct rte_eth_udp_tunnel tunnel_udp;
9248 tunnel_udp.udp_port = res->udp_port;
9250 if (!strcmp(res->cmd, "rx_vxlan_port"))
9251 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9253 if (!strcmp(res->what, "add"))
9254 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9257 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9261 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9264 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9265 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9266 cmd, "rx_vxlan_port");
9267 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9268 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9270 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9271 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9273 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9274 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9277 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9278 .f = cmd_tunnel_udp_config_parsed,
9280 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9281 "Add/Remove a tunneling UDP port filter",
9283 (void *)&cmd_tunnel_udp_config_cmd,
9284 (void *)&cmd_tunnel_udp_config_what,
9285 (void *)&cmd_tunnel_udp_config_udp_port,
9286 (void *)&cmd_tunnel_udp_config_port_id,
9291 struct cmd_config_tunnel_udp_port {
9292 cmdline_fixed_string_t port;
9293 cmdline_fixed_string_t config;
9295 cmdline_fixed_string_t udp_tunnel_port;
9296 cmdline_fixed_string_t action;
9297 cmdline_fixed_string_t tunnel_type;
9302 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9303 __rte_unused struct cmdline *cl,
9304 __rte_unused void *data)
9306 struct cmd_config_tunnel_udp_port *res = parsed_result;
9307 struct rte_eth_udp_tunnel tunnel_udp;
9310 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9313 tunnel_udp.udp_port = res->udp_port;
9315 if (!strcmp(res->tunnel_type, "vxlan")) {
9316 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9317 } else if (!strcmp(res->tunnel_type, "geneve")) {
9318 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9319 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9320 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9322 printf("Invalid tunnel type\n");
9326 if (!strcmp(res->action, "add"))
9327 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9330 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9334 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9337 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9338 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9340 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9341 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9343 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9344 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9346 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9347 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9350 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9351 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9353 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9354 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9355 "vxlan#geneve#vxlan-gpe");
9356 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9357 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9360 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9361 .f = cmd_cfg_tunnel_udp_port_parsed,
9363 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9365 (void *)&cmd_config_tunnel_udp_port_port,
9366 (void *)&cmd_config_tunnel_udp_port_config,
9367 (void *)&cmd_config_tunnel_udp_port_port_id,
9368 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9369 (void *)&cmd_config_tunnel_udp_port_action,
9370 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9371 (void *)&cmd_config_tunnel_udp_port_value,
9376 /* *** GLOBAL CONFIG *** */
9377 struct cmd_global_config_result {
9378 cmdline_fixed_string_t cmd;
9380 cmdline_fixed_string_t cfg_type;
9385 cmd_global_config_parsed(void *parsed_result,
9386 __rte_unused struct cmdline *cl,
9387 __rte_unused void *data)
9389 struct cmd_global_config_result *res = parsed_result;
9390 struct rte_eth_global_cfg conf;
9393 memset(&conf, 0, sizeof(conf));
9394 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9395 conf.cfg.gre_key_len = res->len;
9396 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9397 RTE_ETH_FILTER_SET, &conf);
9398 #ifdef RTE_LIBRTE_I40E_PMD
9399 if (ret == -ENOTSUP)
9400 ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len);
9403 printf("Global config error\n");
9406 cmdline_parse_token_string_t cmd_global_config_cmd =
9407 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9409 cmdline_parse_token_num_t cmd_global_config_port_id =
9410 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9412 cmdline_parse_token_string_t cmd_global_config_type =
9413 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9414 cfg_type, "gre-key-len");
9415 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9416 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9419 cmdline_parse_inst_t cmd_global_config = {
9420 .f = cmd_global_config_parsed,
9421 .data = (void *)NULL,
9422 .help_str = "global_config <port_id> gre-key-len <key_len>",
9424 (void *)&cmd_global_config_cmd,
9425 (void *)&cmd_global_config_port_id,
9426 (void *)&cmd_global_config_type,
9427 (void *)&cmd_global_config_gre_key_len,
9432 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9433 struct cmd_set_mirror_mask_result {
9434 cmdline_fixed_string_t set;
9435 cmdline_fixed_string_t port;
9437 cmdline_fixed_string_t mirror;
9439 cmdline_fixed_string_t what;
9440 cmdline_fixed_string_t value;
9441 cmdline_fixed_string_t dstpool;
9443 cmdline_fixed_string_t on;
9446 cmdline_parse_token_string_t cmd_mirror_mask_set =
9447 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9449 cmdline_parse_token_string_t cmd_mirror_mask_port =
9450 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9452 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9453 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9455 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9456 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9457 mirror, "mirror-rule");
9458 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9459 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9461 cmdline_parse_token_string_t cmd_mirror_mask_what =
9462 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9463 what, "pool-mirror-up#pool-mirror-down"
9465 cmdline_parse_token_string_t cmd_mirror_mask_value =
9466 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9468 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9469 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9470 dstpool, "dst-pool");
9471 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9472 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9474 cmdline_parse_token_string_t cmd_mirror_mask_on =
9475 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9479 cmd_set_mirror_mask_parsed(void *parsed_result,
9480 __rte_unused struct cmdline *cl,
9481 __rte_unused void *data)
9484 struct cmd_set_mirror_mask_result *res = parsed_result;
9485 struct rte_eth_mirror_conf mr_conf;
9487 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9489 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9491 mr_conf.dst_pool = res->dstpool_id;
9493 if (!strcmp(res->what, "pool-mirror-up")) {
9494 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9495 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9496 } else if (!strcmp(res->what, "pool-mirror-down")) {
9497 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9498 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9499 } else if (!strcmp(res->what, "vlan-mirror")) {
9500 mr_conf.rule_type = ETH_MIRROR_VLAN;
9501 nb_item = parse_item_list(res->value, "vlan",
9502 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9506 for (i = 0; i < nb_item; i++) {
9507 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9508 printf("Invalid vlan_id: must be < 4096\n");
9512 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9513 mr_conf.vlan.vlan_mask |= 1ULL << i;
9517 if (!strcmp(res->on, "on"))
9518 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9521 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9524 printf("mirror rule add error: (%s)\n", strerror(-ret));
9527 cmdline_parse_inst_t cmd_set_mirror_mask = {
9528 .f = cmd_set_mirror_mask_parsed,
9530 .help_str = "set port <port_id> mirror-rule <rule_id> "
9531 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9532 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9534 (void *)&cmd_mirror_mask_set,
9535 (void *)&cmd_mirror_mask_port,
9536 (void *)&cmd_mirror_mask_portid,
9537 (void *)&cmd_mirror_mask_mirror,
9538 (void *)&cmd_mirror_mask_ruleid,
9539 (void *)&cmd_mirror_mask_what,
9540 (void *)&cmd_mirror_mask_value,
9541 (void *)&cmd_mirror_mask_dstpool,
9542 (void *)&cmd_mirror_mask_poolid,
9543 (void *)&cmd_mirror_mask_on,
9548 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9549 struct cmd_set_mirror_link_result {
9550 cmdline_fixed_string_t set;
9551 cmdline_fixed_string_t port;
9553 cmdline_fixed_string_t mirror;
9555 cmdline_fixed_string_t what;
9556 cmdline_fixed_string_t dstpool;
9558 cmdline_fixed_string_t on;
9561 cmdline_parse_token_string_t cmd_mirror_link_set =
9562 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9564 cmdline_parse_token_string_t cmd_mirror_link_port =
9565 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9567 cmdline_parse_token_num_t cmd_mirror_link_portid =
9568 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9570 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9571 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9572 mirror, "mirror-rule");
9573 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9574 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9576 cmdline_parse_token_string_t cmd_mirror_link_what =
9577 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9578 what, "uplink-mirror#downlink-mirror");
9579 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9580 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9581 dstpool, "dst-pool");
9582 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9583 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9585 cmdline_parse_token_string_t cmd_mirror_link_on =
9586 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9590 cmd_set_mirror_link_parsed(void *parsed_result,
9591 __rte_unused struct cmdline *cl,
9592 __rte_unused void *data)
9595 struct cmd_set_mirror_link_result *res = parsed_result;
9596 struct rte_eth_mirror_conf mr_conf;
9598 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9599 if (!strcmp(res->what, "uplink-mirror"))
9600 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9602 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9604 mr_conf.dst_pool = res->dstpool_id;
9606 if (!strcmp(res->on, "on"))
9607 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9610 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9613 /* check the return value and print it if is < 0 */
9615 printf("mirror rule add error: (%s)\n", strerror(-ret));
9619 cmdline_parse_inst_t cmd_set_mirror_link = {
9620 .f = cmd_set_mirror_link_parsed,
9622 .help_str = "set port <port_id> mirror-rule <rule_id> "
9623 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9625 (void *)&cmd_mirror_link_set,
9626 (void *)&cmd_mirror_link_port,
9627 (void *)&cmd_mirror_link_portid,
9628 (void *)&cmd_mirror_link_mirror,
9629 (void *)&cmd_mirror_link_ruleid,
9630 (void *)&cmd_mirror_link_what,
9631 (void *)&cmd_mirror_link_dstpool,
9632 (void *)&cmd_mirror_link_poolid,
9633 (void *)&cmd_mirror_link_on,
9638 /* *** RESET VM MIRROR RULE *** */
9639 struct cmd_rm_mirror_rule_result {
9640 cmdline_fixed_string_t reset;
9641 cmdline_fixed_string_t port;
9643 cmdline_fixed_string_t mirror;
9647 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9648 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9650 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9651 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9653 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9654 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9656 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9657 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9658 mirror, "mirror-rule");
9659 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9660 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9664 cmd_reset_mirror_rule_parsed(void *parsed_result,
9665 __rte_unused struct cmdline *cl,
9666 __rte_unused void *data)
9669 struct cmd_set_mirror_link_result *res = parsed_result;
9671 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9673 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9676 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9677 .f = cmd_reset_mirror_rule_parsed,
9679 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9681 (void *)&cmd_rm_mirror_rule_reset,
9682 (void *)&cmd_rm_mirror_rule_port,
9683 (void *)&cmd_rm_mirror_rule_portid,
9684 (void *)&cmd_rm_mirror_rule_mirror,
9685 (void *)&cmd_rm_mirror_rule_ruleid,
9690 /* ******************************************************************************** */
9692 struct cmd_dump_result {
9693 cmdline_fixed_string_t dump;
9697 dump_struct_sizes(void)
9699 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9700 DUMP_SIZE(struct rte_mbuf);
9701 DUMP_SIZE(struct rte_mempool);
9702 DUMP_SIZE(struct rte_ring);
9707 /* Dump the socket memory statistics on console */
9709 dump_socket_mem(FILE *f)
9711 struct rte_malloc_socket_stats socket_stats;
9716 unsigned int n_alloc = 0;
9717 unsigned int n_free = 0;
9718 static size_t last_allocs;
9719 static size_t last_total;
9722 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9723 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9724 !socket_stats.heap_totalsz_bytes)
9726 total += socket_stats.heap_totalsz_bytes;
9727 alloc += socket_stats.heap_allocsz_bytes;
9728 free += socket_stats.heap_freesz_bytes;
9729 n_alloc += socket_stats.alloc_count;
9730 n_free += socket_stats.free_count;
9732 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9734 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9735 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9736 (double)socket_stats.heap_allocsz_bytes * 100 /
9737 (double)socket_stats.heap_totalsz_bytes,
9738 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9739 socket_stats.alloc_count,
9740 socket_stats.free_count);
9743 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9744 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9745 (double)alloc * 100 / (double)total,
9746 (double)free / (1024 * 1024),
9749 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9750 ((double)total - (double)last_total) / (1024 * 1024),
9751 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9752 last_allocs = alloc;
9756 static void cmd_dump_parsed(void *parsed_result,
9757 __rte_unused struct cmdline *cl,
9758 __rte_unused void *data)
9760 struct cmd_dump_result *res = parsed_result;
9762 if (!strcmp(res->dump, "dump_physmem"))
9763 rte_dump_physmem_layout(stdout);
9764 else if (!strcmp(res->dump, "dump_socket_mem"))
9765 dump_socket_mem(stdout);
9766 else if (!strcmp(res->dump, "dump_memzone"))
9767 rte_memzone_dump(stdout);
9768 else if (!strcmp(res->dump, "dump_struct_sizes"))
9769 dump_struct_sizes();
9770 else if (!strcmp(res->dump, "dump_ring"))
9771 rte_ring_list_dump(stdout);
9772 else if (!strcmp(res->dump, "dump_mempool"))
9773 rte_mempool_list_dump(stdout);
9774 else if (!strcmp(res->dump, "dump_devargs"))
9775 rte_devargs_dump(stdout);
9776 else if (!strcmp(res->dump, "dump_log_types"))
9777 rte_log_dump(stdout);
9780 cmdline_parse_token_string_t cmd_dump_dump =
9781 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9785 "dump_struct_sizes#"
9791 cmdline_parse_inst_t cmd_dump = {
9792 .f = cmd_dump_parsed, /* function to call */
9793 .data = NULL, /* 2nd arg of func */
9794 .help_str = "Dump status",
9795 .tokens = { /* token list, NULL terminated */
9796 (void *)&cmd_dump_dump,
9801 /* ******************************************************************************** */
9803 struct cmd_dump_one_result {
9804 cmdline_fixed_string_t dump;
9805 cmdline_fixed_string_t name;
9808 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9809 __rte_unused void *data)
9811 struct cmd_dump_one_result *res = parsed_result;
9813 if (!strcmp(res->dump, "dump_ring")) {
9815 r = rte_ring_lookup(res->name);
9817 cmdline_printf(cl, "Cannot find ring\n");
9820 rte_ring_dump(stdout, r);
9821 } else if (!strcmp(res->dump, "dump_mempool")) {
9822 struct rte_mempool *mp;
9823 mp = rte_mempool_lookup(res->name);
9825 cmdline_printf(cl, "Cannot find mempool\n");
9828 rte_mempool_dump(stdout, mp);
9832 cmdline_parse_token_string_t cmd_dump_one_dump =
9833 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9834 "dump_ring#dump_mempool");
9836 cmdline_parse_token_string_t cmd_dump_one_name =
9837 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9839 cmdline_parse_inst_t cmd_dump_one = {
9840 .f = cmd_dump_one_parsed, /* function to call */
9841 .data = NULL, /* 2nd arg of func */
9842 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9843 .tokens = { /* token list, NULL terminated */
9844 (void *)&cmd_dump_one_dump,
9845 (void *)&cmd_dump_one_name,
9850 /* *** Add/Del syn filter *** */
9851 struct cmd_syn_filter_result {
9852 cmdline_fixed_string_t filter;
9854 cmdline_fixed_string_t ops;
9855 cmdline_fixed_string_t priority;
9856 cmdline_fixed_string_t high;
9857 cmdline_fixed_string_t queue;
9862 cmd_syn_filter_parsed(void *parsed_result,
9863 __rte_unused struct cmdline *cl,
9864 __rte_unused void *data)
9866 struct cmd_syn_filter_result *res = parsed_result;
9867 struct rte_eth_syn_filter syn_filter;
9870 ret = rte_eth_dev_filter_supported(res->port_id,
9871 RTE_ETH_FILTER_SYN);
9873 printf("syn filter is not supported on port %u.\n",
9878 memset(&syn_filter, 0, sizeof(syn_filter));
9880 if (!strcmp(res->ops, "add")) {
9881 if (!strcmp(res->high, "high"))
9882 syn_filter.hig_pri = 1;
9884 syn_filter.hig_pri = 0;
9886 syn_filter.queue = res->queue_id;
9887 ret = rte_eth_dev_filter_ctrl(res->port_id,
9892 ret = rte_eth_dev_filter_ctrl(res->port_id,
9894 RTE_ETH_FILTER_DELETE,
9898 printf("syn filter programming error: (%s)\n",
9902 cmdline_parse_token_string_t cmd_syn_filter_filter =
9903 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9904 filter, "syn_filter");
9905 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9906 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9908 cmdline_parse_token_string_t cmd_syn_filter_ops =
9909 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9911 cmdline_parse_token_string_t cmd_syn_filter_priority =
9912 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9913 priority, "priority");
9914 cmdline_parse_token_string_t cmd_syn_filter_high =
9915 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9917 cmdline_parse_token_string_t cmd_syn_filter_queue =
9918 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9920 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9921 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9924 cmdline_parse_inst_t cmd_syn_filter = {
9925 .f = cmd_syn_filter_parsed,
9927 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9928 "<queue_id>: Add/Delete syn filter",
9930 (void *)&cmd_syn_filter_filter,
9931 (void *)&cmd_syn_filter_port_id,
9932 (void *)&cmd_syn_filter_ops,
9933 (void *)&cmd_syn_filter_priority,
9934 (void *)&cmd_syn_filter_high,
9935 (void *)&cmd_syn_filter_queue,
9936 (void *)&cmd_syn_filter_queue_id,
9941 /* *** queue region set *** */
9942 struct cmd_queue_region_result {
9943 cmdline_fixed_string_t set;
9944 cmdline_fixed_string_t port;
9946 cmdline_fixed_string_t cmd;
9947 cmdline_fixed_string_t region;
9949 cmdline_fixed_string_t queue_start_index;
9951 cmdline_fixed_string_t queue_num;
9952 uint8_t queue_num_value;
9956 cmd_queue_region_parsed(void *parsed_result,
9957 __rte_unused struct cmdline *cl,
9958 __rte_unused void *data)
9960 struct cmd_queue_region_result *res = parsed_result;
9962 #ifdef RTE_LIBRTE_I40E_PMD
9963 struct rte_pmd_i40e_queue_region_conf region_conf;
9964 enum rte_pmd_i40e_queue_region_op op_type;
9967 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9970 #ifdef RTE_LIBRTE_I40E_PMD
9971 memset(®ion_conf, 0, sizeof(region_conf));
9972 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9973 region_conf.region_id = res->region_id;
9974 region_conf.queue_num = res->queue_num_value;
9975 region_conf.queue_start_index = res->queue_id;
9977 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9978 op_type, ®ion_conf);
9985 printf("function not implemented or supported\n");
9988 printf("queue region config error: (%s)\n", strerror(-ret));
9992 cmdline_parse_token_string_t cmd_queue_region_set =
9993 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9995 cmdline_parse_token_string_t cmd_queue_region_port =
9996 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9997 cmdline_parse_token_num_t cmd_queue_region_port_id =
9998 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10000 cmdline_parse_token_string_t cmd_queue_region_cmd =
10001 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10002 cmd, "queue-region");
10003 cmdline_parse_token_string_t cmd_queue_region_id =
10004 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10005 region, "region_id");
10006 cmdline_parse_token_num_t cmd_queue_region_index =
10007 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10009 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10010 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10011 queue_start_index, "queue_start_index");
10012 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10013 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10015 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10016 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10017 queue_num, "queue_num");
10018 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10019 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10020 queue_num_value, UINT8);
10022 cmdline_parse_inst_t cmd_queue_region = {
10023 .f = cmd_queue_region_parsed,
10025 .help_str = "set port <port_id> queue-region region_id <value> "
10026 "queue_start_index <value> queue_num <value>: Set a queue region",
10028 (void *)&cmd_queue_region_set,
10029 (void *)&cmd_queue_region_port,
10030 (void *)&cmd_queue_region_port_id,
10031 (void *)&cmd_queue_region_cmd,
10032 (void *)&cmd_queue_region_id,
10033 (void *)&cmd_queue_region_index,
10034 (void *)&cmd_queue_region_queue_start_index,
10035 (void *)&cmd_queue_region_queue_id,
10036 (void *)&cmd_queue_region_queue_num,
10037 (void *)&cmd_queue_region_queue_num_value,
10042 /* *** queue region and flowtype set *** */
10043 struct cmd_region_flowtype_result {
10044 cmdline_fixed_string_t set;
10045 cmdline_fixed_string_t port;
10047 cmdline_fixed_string_t cmd;
10048 cmdline_fixed_string_t region;
10050 cmdline_fixed_string_t flowtype;
10051 uint8_t flowtype_id;
10055 cmd_region_flowtype_parsed(void *parsed_result,
10056 __rte_unused struct cmdline *cl,
10057 __rte_unused void *data)
10059 struct cmd_region_flowtype_result *res = parsed_result;
10060 int ret = -ENOTSUP;
10061 #ifdef RTE_LIBRTE_I40E_PMD
10062 struct rte_pmd_i40e_queue_region_conf region_conf;
10063 enum rte_pmd_i40e_queue_region_op op_type;
10066 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10069 #ifdef RTE_LIBRTE_I40E_PMD
10070 memset(®ion_conf, 0, sizeof(region_conf));
10072 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10073 region_conf.region_id = res->region_id;
10074 region_conf.hw_flowtype = res->flowtype_id;
10076 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10077 op_type, ®ion_conf);
10084 printf("function not implemented or supported\n");
10087 printf("region flowtype config error: (%s)\n", strerror(-ret));
10091 cmdline_parse_token_string_t cmd_region_flowtype_set =
10092 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10094 cmdline_parse_token_string_t cmd_region_flowtype_port =
10095 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10097 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10098 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10100 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10101 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10102 cmd, "queue-region");
10103 cmdline_parse_token_string_t cmd_region_flowtype_index =
10104 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10105 region, "region_id");
10106 cmdline_parse_token_num_t cmd_region_flowtype_id =
10107 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10109 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10110 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10111 flowtype, "flowtype");
10112 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10113 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10114 flowtype_id, UINT8);
10115 cmdline_parse_inst_t cmd_region_flowtype = {
10116 .f = cmd_region_flowtype_parsed,
10118 .help_str = "set port <port_id> queue-region region_id <value> "
10119 "flowtype <value>: Set a flowtype region index",
10121 (void *)&cmd_region_flowtype_set,
10122 (void *)&cmd_region_flowtype_port,
10123 (void *)&cmd_region_flowtype_port_index,
10124 (void *)&cmd_region_flowtype_cmd,
10125 (void *)&cmd_region_flowtype_index,
10126 (void *)&cmd_region_flowtype_id,
10127 (void *)&cmd_region_flowtype_flow_index,
10128 (void *)&cmd_region_flowtype_flow_id,
10133 /* *** User Priority (UP) to queue region (region_id) set *** */
10134 struct cmd_user_priority_region_result {
10135 cmdline_fixed_string_t set;
10136 cmdline_fixed_string_t port;
10138 cmdline_fixed_string_t cmd;
10139 cmdline_fixed_string_t user_priority;
10140 uint8_t user_priority_id;
10141 cmdline_fixed_string_t region;
10146 cmd_user_priority_region_parsed(void *parsed_result,
10147 __rte_unused struct cmdline *cl,
10148 __rte_unused void *data)
10150 struct cmd_user_priority_region_result *res = parsed_result;
10151 int ret = -ENOTSUP;
10152 #ifdef RTE_LIBRTE_I40E_PMD
10153 struct rte_pmd_i40e_queue_region_conf region_conf;
10154 enum rte_pmd_i40e_queue_region_op op_type;
10157 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10160 #ifdef RTE_LIBRTE_I40E_PMD
10161 memset(®ion_conf, 0, sizeof(region_conf));
10162 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10163 region_conf.user_priority = res->user_priority_id;
10164 region_conf.region_id = res->region_id;
10166 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10167 op_type, ®ion_conf);
10174 printf("function not implemented or supported\n");
10177 printf("user_priority region config error: (%s)\n",
10182 cmdline_parse_token_string_t cmd_user_priority_region_set =
10183 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10185 cmdline_parse_token_string_t cmd_user_priority_region_port =
10186 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10188 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10189 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10191 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10192 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10193 cmd, "queue-region");
10194 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10195 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10196 user_priority, "UP");
10197 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10198 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10199 user_priority_id, UINT8);
10200 cmdline_parse_token_string_t cmd_user_priority_region_region =
10201 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10202 region, "region_id");
10203 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10204 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10207 cmdline_parse_inst_t cmd_user_priority_region = {
10208 .f = cmd_user_priority_region_parsed,
10210 .help_str = "set port <port_id> queue-region UP <value> "
10211 "region_id <value>: Set the mapping of User Priority (UP) "
10212 "to queue region (region_id) ",
10214 (void *)&cmd_user_priority_region_set,
10215 (void *)&cmd_user_priority_region_port,
10216 (void *)&cmd_user_priority_region_port_index,
10217 (void *)&cmd_user_priority_region_cmd,
10218 (void *)&cmd_user_priority_region_UP,
10219 (void *)&cmd_user_priority_region_UP_id,
10220 (void *)&cmd_user_priority_region_region,
10221 (void *)&cmd_user_priority_region_region_id,
10226 /* *** flush all queue region related configuration *** */
10227 struct cmd_flush_queue_region_result {
10228 cmdline_fixed_string_t set;
10229 cmdline_fixed_string_t port;
10231 cmdline_fixed_string_t cmd;
10232 cmdline_fixed_string_t flush;
10233 cmdline_fixed_string_t what;
10237 cmd_flush_queue_region_parsed(void *parsed_result,
10238 __rte_unused struct cmdline *cl,
10239 __rte_unused void *data)
10241 struct cmd_flush_queue_region_result *res = parsed_result;
10242 int ret = -ENOTSUP;
10243 #ifdef RTE_LIBRTE_I40E_PMD
10244 struct rte_pmd_i40e_queue_region_conf region_conf;
10245 enum rte_pmd_i40e_queue_region_op op_type;
10248 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10251 #ifdef RTE_LIBRTE_I40E_PMD
10252 memset(®ion_conf, 0, sizeof(region_conf));
10254 if (strcmp(res->what, "on") == 0)
10255 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10257 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10259 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10260 op_type, ®ion_conf);
10267 printf("function not implemented or supported\n");
10270 printf("queue region config flush error: (%s)\n",
10275 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10276 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10278 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10279 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10281 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10282 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10284 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10285 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10286 cmd, "queue-region");
10287 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10288 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10290 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10291 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10294 cmdline_parse_inst_t cmd_flush_queue_region = {
10295 .f = cmd_flush_queue_region_parsed,
10297 .help_str = "set port <port_id> queue-region flush on|off"
10298 ": flush all queue region related configuration",
10300 (void *)&cmd_flush_queue_region_set,
10301 (void *)&cmd_flush_queue_region_port,
10302 (void *)&cmd_flush_queue_region_port_index,
10303 (void *)&cmd_flush_queue_region_cmd,
10304 (void *)&cmd_flush_queue_region_flush,
10305 (void *)&cmd_flush_queue_region_what,
10310 /* *** get all queue region related configuration info *** */
10311 struct cmd_show_queue_region_info {
10312 cmdline_fixed_string_t show;
10313 cmdline_fixed_string_t port;
10315 cmdline_fixed_string_t cmd;
10319 cmd_show_queue_region_info_parsed(void *parsed_result,
10320 __rte_unused struct cmdline *cl,
10321 __rte_unused void *data)
10323 struct cmd_show_queue_region_info *res = parsed_result;
10324 int ret = -ENOTSUP;
10325 #ifdef RTE_LIBRTE_I40E_PMD
10326 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10327 enum rte_pmd_i40e_queue_region_op op_type;
10330 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10333 #ifdef RTE_LIBRTE_I40E_PMD
10334 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10336 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10338 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10339 op_type, &rte_pmd_regions);
10341 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10348 printf("function not implemented or supported\n");
10351 printf("queue region config info show error: (%s)\n",
10356 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10357 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10359 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10360 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10362 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10363 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10365 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10366 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10367 cmd, "queue-region");
10369 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10370 .f = cmd_show_queue_region_info_parsed,
10372 .help_str = "show port <port_id> queue-region"
10373 ": show all queue region related configuration info",
10375 (void *)&cmd_show_queue_region_info_get,
10376 (void *)&cmd_show_queue_region_info_port,
10377 (void *)&cmd_show_queue_region_info_port_index,
10378 (void *)&cmd_show_queue_region_info_cmd,
10383 /* *** ADD/REMOVE A 2tuple FILTER *** */
10384 struct cmd_2tuple_filter_result {
10385 cmdline_fixed_string_t filter;
10387 cmdline_fixed_string_t ops;
10388 cmdline_fixed_string_t dst_port;
10389 uint16_t dst_port_value;
10390 cmdline_fixed_string_t protocol;
10391 uint8_t protocol_value;
10392 cmdline_fixed_string_t mask;
10393 uint8_t mask_value;
10394 cmdline_fixed_string_t tcp_flags;
10395 uint8_t tcp_flags_value;
10396 cmdline_fixed_string_t priority;
10397 uint8_t priority_value;
10398 cmdline_fixed_string_t queue;
10403 cmd_2tuple_filter_parsed(void *parsed_result,
10404 __rte_unused struct cmdline *cl,
10405 __rte_unused void *data)
10407 struct rte_eth_ntuple_filter filter;
10408 struct cmd_2tuple_filter_result *res = parsed_result;
10411 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10413 printf("ntuple filter is not supported on port %u.\n",
10418 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10420 filter.flags = RTE_2TUPLE_FLAGS;
10421 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10422 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10423 filter.proto = res->protocol_value;
10424 filter.priority = res->priority_value;
10425 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10426 printf("nonzero tcp_flags is only meaningful"
10427 " when protocol is TCP.\n");
10430 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10431 printf("invalid TCP flags.\n");
10435 if (res->tcp_flags_value != 0) {
10436 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10437 filter.tcp_flags = res->tcp_flags_value;
10440 /* need convert to big endian. */
10441 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10442 filter.queue = res->queue_id;
10444 if (!strcmp(res->ops, "add"))
10445 ret = rte_eth_dev_filter_ctrl(res->port_id,
10446 RTE_ETH_FILTER_NTUPLE,
10447 RTE_ETH_FILTER_ADD,
10450 ret = rte_eth_dev_filter_ctrl(res->port_id,
10451 RTE_ETH_FILTER_NTUPLE,
10452 RTE_ETH_FILTER_DELETE,
10455 printf("2tuple filter programming error: (%s)\n",
10460 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10461 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10462 filter, "2tuple_filter");
10463 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10464 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10466 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10467 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10469 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10470 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10471 dst_port, "dst_port");
10472 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10473 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10474 dst_port_value, UINT16);
10475 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10476 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10477 protocol, "protocol");
10478 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10479 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10480 protocol_value, UINT8);
10481 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10482 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10484 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10485 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10487 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10488 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10489 tcp_flags, "tcp_flags");
10490 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10491 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10492 tcp_flags_value, UINT8);
10493 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10494 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10495 priority, "priority");
10496 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10497 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10498 priority_value, UINT8);
10499 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10500 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10502 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10503 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10506 cmdline_parse_inst_t cmd_2tuple_filter = {
10507 .f = cmd_2tuple_filter_parsed,
10509 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10510 "<value> mask <value> tcp_flags <value> priority <value> queue "
10511 "<queue_id>: Add a 2tuple filter",
10513 (void *)&cmd_2tuple_filter_filter,
10514 (void *)&cmd_2tuple_filter_port_id,
10515 (void *)&cmd_2tuple_filter_ops,
10516 (void *)&cmd_2tuple_filter_dst_port,
10517 (void *)&cmd_2tuple_filter_dst_port_value,
10518 (void *)&cmd_2tuple_filter_protocol,
10519 (void *)&cmd_2tuple_filter_protocol_value,
10520 (void *)&cmd_2tuple_filter_mask,
10521 (void *)&cmd_2tuple_filter_mask_value,
10522 (void *)&cmd_2tuple_filter_tcp_flags,
10523 (void *)&cmd_2tuple_filter_tcp_flags_value,
10524 (void *)&cmd_2tuple_filter_priority,
10525 (void *)&cmd_2tuple_filter_priority_value,
10526 (void *)&cmd_2tuple_filter_queue,
10527 (void *)&cmd_2tuple_filter_queue_id,
10532 /* *** ADD/REMOVE A 5tuple FILTER *** */
10533 struct cmd_5tuple_filter_result {
10534 cmdline_fixed_string_t filter;
10536 cmdline_fixed_string_t ops;
10537 cmdline_fixed_string_t dst_ip;
10538 cmdline_ipaddr_t dst_ip_value;
10539 cmdline_fixed_string_t src_ip;
10540 cmdline_ipaddr_t src_ip_value;
10541 cmdline_fixed_string_t dst_port;
10542 uint16_t dst_port_value;
10543 cmdline_fixed_string_t src_port;
10544 uint16_t src_port_value;
10545 cmdline_fixed_string_t protocol;
10546 uint8_t protocol_value;
10547 cmdline_fixed_string_t mask;
10548 uint8_t mask_value;
10549 cmdline_fixed_string_t tcp_flags;
10550 uint8_t tcp_flags_value;
10551 cmdline_fixed_string_t priority;
10552 uint8_t priority_value;
10553 cmdline_fixed_string_t queue;
10558 cmd_5tuple_filter_parsed(void *parsed_result,
10559 __rte_unused struct cmdline *cl,
10560 __rte_unused void *data)
10562 struct rte_eth_ntuple_filter filter;
10563 struct cmd_5tuple_filter_result *res = parsed_result;
10566 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10568 printf("ntuple filter is not supported on port %u.\n",
10573 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10575 filter.flags = RTE_5TUPLE_FLAGS;
10576 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10577 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10578 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10579 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10580 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10581 filter.proto = res->protocol_value;
10582 filter.priority = res->priority_value;
10583 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10584 printf("nonzero tcp_flags is only meaningful"
10585 " when protocol is TCP.\n");
10588 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10589 printf("invalid TCP flags.\n");
10593 if (res->tcp_flags_value != 0) {
10594 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10595 filter.tcp_flags = res->tcp_flags_value;
10598 if (res->dst_ip_value.family == AF_INET)
10599 /* no need to convert, already big endian. */
10600 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10602 if (filter.dst_ip_mask == 0) {
10603 printf("can not support ipv6 involved compare.\n");
10609 if (res->src_ip_value.family == AF_INET)
10610 /* no need to convert, already big endian. */
10611 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10613 if (filter.src_ip_mask == 0) {
10614 printf("can not support ipv6 involved compare.\n");
10619 /* need convert to big endian. */
10620 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10621 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10622 filter.queue = res->queue_id;
10624 if (!strcmp(res->ops, "add"))
10625 ret = rte_eth_dev_filter_ctrl(res->port_id,
10626 RTE_ETH_FILTER_NTUPLE,
10627 RTE_ETH_FILTER_ADD,
10630 ret = rte_eth_dev_filter_ctrl(res->port_id,
10631 RTE_ETH_FILTER_NTUPLE,
10632 RTE_ETH_FILTER_DELETE,
10635 printf("5tuple filter programming error: (%s)\n",
10639 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10640 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10641 filter, "5tuple_filter");
10642 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10643 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10645 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10646 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10648 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10649 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10651 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10652 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10654 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10655 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10657 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10658 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10660 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10661 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10662 dst_port, "dst_port");
10663 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10664 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10665 dst_port_value, UINT16);
10666 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10667 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10668 src_port, "src_port");
10669 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10670 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10671 src_port_value, UINT16);
10672 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10673 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10674 protocol, "protocol");
10675 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10676 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10677 protocol_value, UINT8);
10678 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10679 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10681 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10682 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10684 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10685 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10686 tcp_flags, "tcp_flags");
10687 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10688 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10689 tcp_flags_value, UINT8);
10690 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10691 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10692 priority, "priority");
10693 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10694 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10695 priority_value, UINT8);
10696 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10697 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10699 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10700 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10703 cmdline_parse_inst_t cmd_5tuple_filter = {
10704 .f = cmd_5tuple_filter_parsed,
10706 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10707 "src_ip <value> dst_port <value> src_port <value> "
10708 "protocol <value> mask <value> tcp_flags <value> "
10709 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10711 (void *)&cmd_5tuple_filter_filter,
10712 (void *)&cmd_5tuple_filter_port_id,
10713 (void *)&cmd_5tuple_filter_ops,
10714 (void *)&cmd_5tuple_filter_dst_ip,
10715 (void *)&cmd_5tuple_filter_dst_ip_value,
10716 (void *)&cmd_5tuple_filter_src_ip,
10717 (void *)&cmd_5tuple_filter_src_ip_value,
10718 (void *)&cmd_5tuple_filter_dst_port,
10719 (void *)&cmd_5tuple_filter_dst_port_value,
10720 (void *)&cmd_5tuple_filter_src_port,
10721 (void *)&cmd_5tuple_filter_src_port_value,
10722 (void *)&cmd_5tuple_filter_protocol,
10723 (void *)&cmd_5tuple_filter_protocol_value,
10724 (void *)&cmd_5tuple_filter_mask,
10725 (void *)&cmd_5tuple_filter_mask_value,
10726 (void *)&cmd_5tuple_filter_tcp_flags,
10727 (void *)&cmd_5tuple_filter_tcp_flags_value,
10728 (void *)&cmd_5tuple_filter_priority,
10729 (void *)&cmd_5tuple_filter_priority_value,
10730 (void *)&cmd_5tuple_filter_queue,
10731 (void *)&cmd_5tuple_filter_queue_id,
10736 /* *** ADD/REMOVE A flex FILTER *** */
10737 struct cmd_flex_filter_result {
10738 cmdline_fixed_string_t filter;
10739 cmdline_fixed_string_t ops;
10741 cmdline_fixed_string_t len;
10743 cmdline_fixed_string_t bytes;
10744 cmdline_fixed_string_t bytes_value;
10745 cmdline_fixed_string_t mask;
10746 cmdline_fixed_string_t mask_value;
10747 cmdline_fixed_string_t priority;
10748 uint8_t priority_value;
10749 cmdline_fixed_string_t queue;
10753 static int xdigit2val(unsigned char c)
10758 else if (isupper(c))
10759 val = c - 'A' + 10;
10761 val = c - 'a' + 10;
10766 cmd_flex_filter_parsed(void *parsed_result,
10767 __rte_unused struct cmdline *cl,
10768 __rte_unused void *data)
10771 struct rte_eth_flex_filter filter;
10772 struct cmd_flex_filter_result *res = parsed_result;
10773 char *bytes_ptr, *mask_ptr;
10774 uint16_t len, i, j = 0;
10779 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10780 printf("the len exceed the max length 128\n");
10783 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10784 filter.len = res->len_value;
10785 filter.priority = res->priority_value;
10786 filter.queue = res->queue_id;
10787 bytes_ptr = res->bytes_value;
10788 mask_ptr = res->mask_value;
10790 /* translate bytes string to array. */
10791 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10792 (bytes_ptr[1] == 'X')))
10794 len = strnlen(bytes_ptr, res->len_value * 2);
10795 if (len == 0 || (len % 8 != 0)) {
10796 printf("please check len and bytes input\n");
10799 for (i = 0; i < len; i++) {
10801 if (isxdigit(c) == 0) {
10802 /* invalid characters. */
10803 printf("invalid input\n");
10806 val = xdigit2val(c);
10809 filter.bytes[j] = byte;
10810 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10817 /* translate mask string to uint8_t array. */
10818 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10819 (mask_ptr[1] == 'X')))
10821 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10823 printf("invalid input\n");
10828 for (i = 0; i < len; i++) {
10830 if (isxdigit(c) == 0) {
10831 /* invalid characters. */
10832 printf("invalid input\n");
10835 val = xdigit2val(c);
10838 filter.mask[j] = byte;
10839 printf("mask[%d]:%02x ", j, filter.mask[j]);
10847 if (!strcmp(res->ops, "add"))
10848 ret = rte_eth_dev_filter_ctrl(res->port_id,
10849 RTE_ETH_FILTER_FLEXIBLE,
10850 RTE_ETH_FILTER_ADD,
10853 ret = rte_eth_dev_filter_ctrl(res->port_id,
10854 RTE_ETH_FILTER_FLEXIBLE,
10855 RTE_ETH_FILTER_DELETE,
10859 printf("flex filter setting error: (%s)\n", strerror(-ret));
10862 cmdline_parse_token_string_t cmd_flex_filter_filter =
10863 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10864 filter, "flex_filter");
10865 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10866 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10868 cmdline_parse_token_string_t cmd_flex_filter_ops =
10869 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10871 cmdline_parse_token_string_t cmd_flex_filter_len =
10872 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10874 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10875 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10877 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10878 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10880 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10881 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10882 bytes_value, NULL);
10883 cmdline_parse_token_string_t cmd_flex_filter_mask =
10884 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10886 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10887 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10889 cmdline_parse_token_string_t cmd_flex_filter_priority =
10890 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10891 priority, "priority");
10892 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10893 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10894 priority_value, UINT8);
10895 cmdline_parse_token_string_t cmd_flex_filter_queue =
10896 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10898 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10899 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10901 cmdline_parse_inst_t cmd_flex_filter = {
10902 .f = cmd_flex_filter_parsed,
10904 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10905 "<value> mask <value> priority <value> queue <queue_id>: "
10906 "Add/Del a flex filter",
10908 (void *)&cmd_flex_filter_filter,
10909 (void *)&cmd_flex_filter_port_id,
10910 (void *)&cmd_flex_filter_ops,
10911 (void *)&cmd_flex_filter_len,
10912 (void *)&cmd_flex_filter_len_value,
10913 (void *)&cmd_flex_filter_bytes,
10914 (void *)&cmd_flex_filter_bytes_value,
10915 (void *)&cmd_flex_filter_mask,
10916 (void *)&cmd_flex_filter_mask_value,
10917 (void *)&cmd_flex_filter_priority,
10918 (void *)&cmd_flex_filter_priority_value,
10919 (void *)&cmd_flex_filter_queue,
10920 (void *)&cmd_flex_filter_queue_id,
10925 /* *** Filters Control *** */
10927 /* *** deal with ethertype filter *** */
10928 struct cmd_ethertype_filter_result {
10929 cmdline_fixed_string_t filter;
10931 cmdline_fixed_string_t ops;
10932 cmdline_fixed_string_t mac;
10933 struct rte_ether_addr mac_addr;
10934 cmdline_fixed_string_t ethertype;
10935 uint16_t ethertype_value;
10936 cmdline_fixed_string_t drop;
10937 cmdline_fixed_string_t queue;
10941 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10942 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10943 filter, "ethertype_filter");
10944 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10945 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10947 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10948 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10950 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10951 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10952 mac, "mac_addr#mac_ignr");
10953 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10954 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10956 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10957 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10958 ethertype, "ethertype");
10959 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10960 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10961 ethertype_value, UINT16);
10962 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10963 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10965 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10966 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10968 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10969 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10973 cmd_ethertype_filter_parsed(void *parsed_result,
10974 __rte_unused struct cmdline *cl,
10975 __rte_unused void *data)
10977 struct cmd_ethertype_filter_result *res = parsed_result;
10978 struct rte_eth_ethertype_filter filter;
10981 ret = rte_eth_dev_filter_supported(res->port_id,
10982 RTE_ETH_FILTER_ETHERTYPE);
10984 printf("ethertype filter is not supported on port %u.\n",
10989 memset(&filter, 0, sizeof(filter));
10990 if (!strcmp(res->mac, "mac_addr")) {
10991 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10992 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10993 sizeof(struct rte_ether_addr));
10995 if (!strcmp(res->drop, "drop"))
10996 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10997 filter.ether_type = res->ethertype_value;
10998 filter.queue = res->queue_id;
11000 if (!strcmp(res->ops, "add"))
11001 ret = rte_eth_dev_filter_ctrl(res->port_id,
11002 RTE_ETH_FILTER_ETHERTYPE,
11003 RTE_ETH_FILTER_ADD,
11006 ret = rte_eth_dev_filter_ctrl(res->port_id,
11007 RTE_ETH_FILTER_ETHERTYPE,
11008 RTE_ETH_FILTER_DELETE,
11011 printf("ethertype filter programming error: (%s)\n",
11015 cmdline_parse_inst_t cmd_ethertype_filter = {
11016 .f = cmd_ethertype_filter_parsed,
11018 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
11019 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
11020 "Add or delete an ethertype filter entry",
11022 (void *)&cmd_ethertype_filter_filter,
11023 (void *)&cmd_ethertype_filter_port_id,
11024 (void *)&cmd_ethertype_filter_ops,
11025 (void *)&cmd_ethertype_filter_mac,
11026 (void *)&cmd_ethertype_filter_mac_addr,
11027 (void *)&cmd_ethertype_filter_ethertype,
11028 (void *)&cmd_ethertype_filter_ethertype_value,
11029 (void *)&cmd_ethertype_filter_drop,
11030 (void *)&cmd_ethertype_filter_queue,
11031 (void *)&cmd_ethertype_filter_queue_id,
11036 /* *** deal with flow director filter *** */
11037 struct cmd_flow_director_result {
11038 cmdline_fixed_string_t flow_director_filter;
11040 cmdline_fixed_string_t mode;
11041 cmdline_fixed_string_t mode_value;
11042 cmdline_fixed_string_t ops;
11043 cmdline_fixed_string_t flow;
11044 cmdline_fixed_string_t flow_type;
11045 cmdline_fixed_string_t ether;
11046 uint16_t ether_type;
11047 cmdline_fixed_string_t src;
11048 cmdline_ipaddr_t ip_src;
11050 cmdline_fixed_string_t dst;
11051 cmdline_ipaddr_t ip_dst;
11053 cmdline_fixed_string_t verify_tag;
11054 uint32_t verify_tag_value;
11055 cmdline_fixed_string_t tos;
11057 cmdline_fixed_string_t proto;
11058 uint8_t proto_value;
11059 cmdline_fixed_string_t ttl;
11061 cmdline_fixed_string_t vlan;
11062 uint16_t vlan_value;
11063 cmdline_fixed_string_t flexbytes;
11064 cmdline_fixed_string_t flexbytes_value;
11065 cmdline_fixed_string_t pf_vf;
11066 cmdline_fixed_string_t drop;
11067 cmdline_fixed_string_t queue;
11069 cmdline_fixed_string_t fd_id;
11070 uint32_t fd_id_value;
11071 cmdline_fixed_string_t mac;
11072 struct rte_ether_addr mac_addr;
11073 cmdline_fixed_string_t tunnel;
11074 cmdline_fixed_string_t tunnel_type;
11075 cmdline_fixed_string_t tunnel_id;
11076 uint32_t tunnel_id_value;
11077 cmdline_fixed_string_t packet;
11082 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
11085 const char *p, *p0 = q_arg;
11087 unsigned long int_fld;
11088 char *str_fld[max_num];
11093 p = strchr(p0, '(');
11097 p0 = strchr(p, ')');
11102 if (size >= sizeof(s))
11105 snprintf(s, sizeof(s), "%.*s", size, p);
11106 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11107 if (ret < 0 || ret > max_num)
11109 for (i = 0; i < ret; i++) {
11111 int_fld = strtoul(str_fld[i], &end, 0);
11112 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
11114 flexbytes[i] = (uint8_t)int_fld;
11120 str2flowtype(char *string)
11123 static const struct {
11126 } flowtype_str[] = {
11127 {"raw", RTE_ETH_FLOW_RAW},
11128 {"ipv4", RTE_ETH_FLOW_IPV4},
11129 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11130 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11131 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11132 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11133 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11134 {"ipv6", RTE_ETH_FLOW_IPV6},
11135 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11136 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11137 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11138 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11139 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11140 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11143 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
11144 if (!strcmp(flowtype_str[i].str, string))
11145 return flowtype_str[i].type;
11148 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
11149 return (uint16_t)atoi(string);
11151 return RTE_ETH_FLOW_UNKNOWN;
11154 static enum rte_eth_fdir_tunnel_type
11155 str2fdir_tunneltype(char *string)
11159 static const struct {
11161 enum rte_eth_fdir_tunnel_type type;
11162 } tunneltype_str[] = {
11163 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
11164 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
11167 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
11168 if (!strcmp(tunneltype_str[i].str, string))
11169 return tunneltype_str[i].type;
11171 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
11174 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
11176 if ((ip_addr).family == AF_INET) \
11177 (ip) = (ip_addr).addr.ipv4.s_addr; \
11179 printf("invalid parameter.\n"); \
11184 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
11186 if ((ip_addr).family == AF_INET6) \
11187 rte_memcpy(&(ip), \
11188 &((ip_addr).addr.ipv6), \
11189 sizeof(struct in6_addr)); \
11191 printf("invalid parameter.\n"); \
11197 cmd_flow_director_filter_parsed(void *parsed_result,
11198 __rte_unused struct cmdline *cl,
11199 __rte_unused void *data)
11201 struct cmd_flow_director_result *res = parsed_result;
11202 struct rte_eth_fdir_filter entry;
11203 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11205 unsigned long vf_id;
11208 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11210 printf("flow director is not supported on port %u.\n",
11214 memset(flexbytes, 0, sizeof(flexbytes));
11215 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11217 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11218 if (strcmp(res->mode_value, "MAC-VLAN")) {
11219 printf("Please set mode to MAC-VLAN.\n");
11222 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11223 if (strcmp(res->mode_value, "Tunnel")) {
11224 printf("Please set mode to Tunnel.\n");
11228 if (!strcmp(res->mode_value, "raw")) {
11229 #ifdef RTE_LIBRTE_I40E_PMD
11230 struct rte_pmd_i40e_flow_type_mapping
11231 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11232 struct rte_pmd_i40e_pkt_template_conf conf;
11233 uint16_t flow_type = str2flowtype(res->flow_type);
11234 uint16_t i, port = res->port_id;
11237 memset(&conf, 0, sizeof(conf));
11239 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11240 printf("Invalid flow type specified.\n");
11243 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11247 if (mapping[flow_type].pctype == 0ULL) {
11248 printf("Invalid flow type specified.\n");
11251 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11252 if (mapping[flow_type].pctype & (1ULL << i)) {
11253 conf.input.pctype = i;
11258 conf.input.packet = open_file(res->filepath,
11259 &conf.input.length);
11260 if (!conf.input.packet)
11262 if (!strcmp(res->drop, "drop"))
11263 conf.action.behavior =
11264 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11266 conf.action.behavior =
11267 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11268 conf.action.report_status =
11269 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11270 conf.action.rx_queue = res->queue_id;
11271 conf.soft_id = res->fd_id_value;
11272 add = strcmp(res->ops, "del") ? 1 : 0;
11273 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11277 printf("flow director config error: (%s)\n",
11279 close_file(conf.input.packet);
11282 } else if (strcmp(res->mode_value, "IP")) {
11283 printf("Please set mode to IP or raw.\n");
11286 entry.input.flow_type = str2flowtype(res->flow_type);
11289 ret = parse_flexbytes(res->flexbytes_value,
11291 RTE_ETH_FDIR_MAX_FLEXLEN);
11293 printf("error: Cannot parse flexbytes input.\n");
11297 switch (entry.input.flow_type) {
11298 case RTE_ETH_FLOW_FRAG_IPV4:
11299 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11300 entry.input.flow.ip4_flow.proto = res->proto_value;
11302 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11303 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11304 IPV4_ADDR_TO_UINT(res->ip_dst,
11305 entry.input.flow.ip4_flow.dst_ip);
11306 IPV4_ADDR_TO_UINT(res->ip_src,
11307 entry.input.flow.ip4_flow.src_ip);
11308 entry.input.flow.ip4_flow.tos = res->tos_value;
11309 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11310 /* need convert to big endian. */
11311 entry.input.flow.udp4_flow.dst_port =
11312 rte_cpu_to_be_16(res->port_dst);
11313 entry.input.flow.udp4_flow.src_port =
11314 rte_cpu_to_be_16(res->port_src);
11316 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11317 IPV4_ADDR_TO_UINT(res->ip_dst,
11318 entry.input.flow.sctp4_flow.ip.dst_ip);
11319 IPV4_ADDR_TO_UINT(res->ip_src,
11320 entry.input.flow.sctp4_flow.ip.src_ip);
11321 entry.input.flow.ip4_flow.tos = res->tos_value;
11322 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11323 /* need convert to big endian. */
11324 entry.input.flow.sctp4_flow.dst_port =
11325 rte_cpu_to_be_16(res->port_dst);
11326 entry.input.flow.sctp4_flow.src_port =
11327 rte_cpu_to_be_16(res->port_src);
11328 entry.input.flow.sctp4_flow.verify_tag =
11329 rte_cpu_to_be_32(res->verify_tag_value);
11331 case RTE_ETH_FLOW_FRAG_IPV6:
11332 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11333 entry.input.flow.ipv6_flow.proto = res->proto_value;
11335 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11336 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11337 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11338 entry.input.flow.ipv6_flow.dst_ip);
11339 IPV6_ADDR_TO_ARRAY(res->ip_src,
11340 entry.input.flow.ipv6_flow.src_ip);
11341 entry.input.flow.ipv6_flow.tc = res->tos_value;
11342 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11343 /* need convert to big endian. */
11344 entry.input.flow.udp6_flow.dst_port =
11345 rte_cpu_to_be_16(res->port_dst);
11346 entry.input.flow.udp6_flow.src_port =
11347 rte_cpu_to_be_16(res->port_src);
11349 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11350 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11351 entry.input.flow.sctp6_flow.ip.dst_ip);
11352 IPV6_ADDR_TO_ARRAY(res->ip_src,
11353 entry.input.flow.sctp6_flow.ip.src_ip);
11354 entry.input.flow.ipv6_flow.tc = res->tos_value;
11355 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11356 /* need convert to big endian. */
11357 entry.input.flow.sctp6_flow.dst_port =
11358 rte_cpu_to_be_16(res->port_dst);
11359 entry.input.flow.sctp6_flow.src_port =
11360 rte_cpu_to_be_16(res->port_src);
11361 entry.input.flow.sctp6_flow.verify_tag =
11362 rte_cpu_to_be_32(res->verify_tag_value);
11364 case RTE_ETH_FLOW_L2_PAYLOAD:
11365 entry.input.flow.l2_flow.ether_type =
11366 rte_cpu_to_be_16(res->ether_type);
11372 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11373 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11375 sizeof(struct rte_ether_addr));
11377 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11378 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11380 sizeof(struct rte_ether_addr));
11381 entry.input.flow.tunnel_flow.tunnel_type =
11382 str2fdir_tunneltype(res->tunnel_type);
11383 entry.input.flow.tunnel_flow.tunnel_id =
11384 rte_cpu_to_be_32(res->tunnel_id_value);
11387 rte_memcpy(entry.input.flow_ext.flexbytes,
11389 RTE_ETH_FDIR_MAX_FLEXLEN);
11391 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11393 entry.action.flex_off = 0; /*use 0 by default */
11394 if (!strcmp(res->drop, "drop"))
11395 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11397 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11399 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11400 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11401 if (!strcmp(res->pf_vf, "pf"))
11402 entry.input.flow_ext.is_vf = 0;
11403 else if (!strncmp(res->pf_vf, "vf", 2)) {
11404 struct rte_eth_dev_info dev_info;
11406 ret = eth_dev_info_get_print_err(res->port_id,
11412 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11413 if (errno != 0 || *end != '\0' ||
11414 vf_id >= dev_info.max_vfs) {
11415 printf("invalid parameter %s.\n", res->pf_vf);
11418 entry.input.flow_ext.is_vf = 1;
11419 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11421 printf("invalid parameter %s.\n", res->pf_vf);
11426 /* set to report FD ID by default */
11427 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11428 entry.action.rx_queue = res->queue_id;
11429 entry.soft_id = res->fd_id_value;
11430 if (!strcmp(res->ops, "add"))
11431 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11432 RTE_ETH_FILTER_ADD, &entry);
11433 else if (!strcmp(res->ops, "del"))
11434 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11435 RTE_ETH_FILTER_DELETE, &entry);
11437 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11438 RTE_ETH_FILTER_UPDATE, &entry);
11440 printf("flow director programming error: (%s)\n",
11444 cmdline_parse_token_string_t cmd_flow_director_filter =
11445 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11446 flow_director_filter, "flow_director_filter");
11447 cmdline_parse_token_num_t cmd_flow_director_port_id =
11448 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11450 cmdline_parse_token_string_t cmd_flow_director_ops =
11451 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11452 ops, "add#del#update");
11453 cmdline_parse_token_string_t cmd_flow_director_flow =
11454 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11456 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11457 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11459 cmdline_parse_token_string_t cmd_flow_director_ether =
11460 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11462 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11463 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11464 ether_type, UINT16);
11465 cmdline_parse_token_string_t cmd_flow_director_src =
11466 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11468 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11469 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11471 cmdline_parse_token_num_t cmd_flow_director_port_src =
11472 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11474 cmdline_parse_token_string_t cmd_flow_director_dst =
11475 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11477 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11478 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11480 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11481 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11483 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11484 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11485 verify_tag, "verify_tag");
11486 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11487 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11488 verify_tag_value, UINT32);
11489 cmdline_parse_token_string_t cmd_flow_director_tos =
11490 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11492 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11493 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11495 cmdline_parse_token_string_t cmd_flow_director_proto =
11496 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11498 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11499 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11500 proto_value, UINT8);
11501 cmdline_parse_token_string_t cmd_flow_director_ttl =
11502 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11504 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11505 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11507 cmdline_parse_token_string_t cmd_flow_director_vlan =
11508 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11510 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11511 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11512 vlan_value, UINT16);
11513 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11514 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11515 flexbytes, "flexbytes");
11516 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11517 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11518 flexbytes_value, NULL);
11519 cmdline_parse_token_string_t cmd_flow_director_drop =
11520 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11522 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11523 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11525 cmdline_parse_token_string_t cmd_flow_director_queue =
11526 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11528 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11529 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11531 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11532 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11534 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11535 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11536 fd_id_value, UINT32);
11538 cmdline_parse_token_string_t cmd_flow_director_mode =
11539 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11541 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11542 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11544 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11545 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11546 mode_value, "MAC-VLAN");
11547 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11548 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11549 mode_value, "Tunnel");
11550 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11551 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11552 mode_value, "raw");
11553 cmdline_parse_token_string_t cmd_flow_director_mac =
11554 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11556 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11557 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11559 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11560 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11562 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11563 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11564 tunnel_type, "NVGRE#VxLAN");
11565 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11566 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11567 tunnel_id, "tunnel-id");
11568 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11569 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11570 tunnel_id_value, UINT32);
11571 cmdline_parse_token_string_t cmd_flow_director_packet =
11572 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11574 cmdline_parse_token_string_t cmd_flow_director_filepath =
11575 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11578 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11579 .f = cmd_flow_director_filter_parsed,
11581 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11582 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11583 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11584 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11585 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11586 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11587 "fd_id <fd_id_value>: "
11588 "Add or delete an ip flow director entry on NIC",
11590 (void *)&cmd_flow_director_filter,
11591 (void *)&cmd_flow_director_port_id,
11592 (void *)&cmd_flow_director_mode,
11593 (void *)&cmd_flow_director_mode_ip,
11594 (void *)&cmd_flow_director_ops,
11595 (void *)&cmd_flow_director_flow,
11596 (void *)&cmd_flow_director_flow_type,
11597 (void *)&cmd_flow_director_src,
11598 (void *)&cmd_flow_director_ip_src,
11599 (void *)&cmd_flow_director_dst,
11600 (void *)&cmd_flow_director_ip_dst,
11601 (void *)&cmd_flow_director_tos,
11602 (void *)&cmd_flow_director_tos_value,
11603 (void *)&cmd_flow_director_proto,
11604 (void *)&cmd_flow_director_proto_value,
11605 (void *)&cmd_flow_director_ttl,
11606 (void *)&cmd_flow_director_ttl_value,
11607 (void *)&cmd_flow_director_vlan,
11608 (void *)&cmd_flow_director_vlan_value,
11609 (void *)&cmd_flow_director_flexbytes,
11610 (void *)&cmd_flow_director_flexbytes_value,
11611 (void *)&cmd_flow_director_drop,
11612 (void *)&cmd_flow_director_pf_vf,
11613 (void *)&cmd_flow_director_queue,
11614 (void *)&cmd_flow_director_queue_id,
11615 (void *)&cmd_flow_director_fd_id,
11616 (void *)&cmd_flow_director_fd_id_value,
11621 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11622 .f = cmd_flow_director_filter_parsed,
11624 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11625 "director entry on NIC",
11627 (void *)&cmd_flow_director_filter,
11628 (void *)&cmd_flow_director_port_id,
11629 (void *)&cmd_flow_director_mode,
11630 (void *)&cmd_flow_director_mode_ip,
11631 (void *)&cmd_flow_director_ops,
11632 (void *)&cmd_flow_director_flow,
11633 (void *)&cmd_flow_director_flow_type,
11634 (void *)&cmd_flow_director_src,
11635 (void *)&cmd_flow_director_ip_src,
11636 (void *)&cmd_flow_director_port_src,
11637 (void *)&cmd_flow_director_dst,
11638 (void *)&cmd_flow_director_ip_dst,
11639 (void *)&cmd_flow_director_port_dst,
11640 (void *)&cmd_flow_director_tos,
11641 (void *)&cmd_flow_director_tos_value,
11642 (void *)&cmd_flow_director_ttl,
11643 (void *)&cmd_flow_director_ttl_value,
11644 (void *)&cmd_flow_director_vlan,
11645 (void *)&cmd_flow_director_vlan_value,
11646 (void *)&cmd_flow_director_flexbytes,
11647 (void *)&cmd_flow_director_flexbytes_value,
11648 (void *)&cmd_flow_director_drop,
11649 (void *)&cmd_flow_director_pf_vf,
11650 (void *)&cmd_flow_director_queue,
11651 (void *)&cmd_flow_director_queue_id,
11652 (void *)&cmd_flow_director_fd_id,
11653 (void *)&cmd_flow_director_fd_id_value,
11658 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11659 .f = cmd_flow_director_filter_parsed,
11661 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11662 "director entry on NIC",
11664 (void *)&cmd_flow_director_filter,
11665 (void *)&cmd_flow_director_port_id,
11666 (void *)&cmd_flow_director_mode,
11667 (void *)&cmd_flow_director_mode_ip,
11668 (void *)&cmd_flow_director_ops,
11669 (void *)&cmd_flow_director_flow,
11670 (void *)&cmd_flow_director_flow_type,
11671 (void *)&cmd_flow_director_src,
11672 (void *)&cmd_flow_director_ip_src,
11673 (void *)&cmd_flow_director_port_src,
11674 (void *)&cmd_flow_director_dst,
11675 (void *)&cmd_flow_director_ip_dst,
11676 (void *)&cmd_flow_director_port_dst,
11677 (void *)&cmd_flow_director_verify_tag,
11678 (void *)&cmd_flow_director_verify_tag_value,
11679 (void *)&cmd_flow_director_tos,
11680 (void *)&cmd_flow_director_tos_value,
11681 (void *)&cmd_flow_director_ttl,
11682 (void *)&cmd_flow_director_ttl_value,
11683 (void *)&cmd_flow_director_vlan,
11684 (void *)&cmd_flow_director_vlan_value,
11685 (void *)&cmd_flow_director_flexbytes,
11686 (void *)&cmd_flow_director_flexbytes_value,
11687 (void *)&cmd_flow_director_drop,
11688 (void *)&cmd_flow_director_pf_vf,
11689 (void *)&cmd_flow_director_queue,
11690 (void *)&cmd_flow_director_queue_id,
11691 (void *)&cmd_flow_director_fd_id,
11692 (void *)&cmd_flow_director_fd_id_value,
11697 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11698 .f = cmd_flow_director_filter_parsed,
11700 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11701 "director entry on NIC",
11703 (void *)&cmd_flow_director_filter,
11704 (void *)&cmd_flow_director_port_id,
11705 (void *)&cmd_flow_director_mode,
11706 (void *)&cmd_flow_director_mode_ip,
11707 (void *)&cmd_flow_director_ops,
11708 (void *)&cmd_flow_director_flow,
11709 (void *)&cmd_flow_director_flow_type,
11710 (void *)&cmd_flow_director_ether,
11711 (void *)&cmd_flow_director_ether_type,
11712 (void *)&cmd_flow_director_flexbytes,
11713 (void *)&cmd_flow_director_flexbytes_value,
11714 (void *)&cmd_flow_director_drop,
11715 (void *)&cmd_flow_director_pf_vf,
11716 (void *)&cmd_flow_director_queue,
11717 (void *)&cmd_flow_director_queue_id,
11718 (void *)&cmd_flow_director_fd_id,
11719 (void *)&cmd_flow_director_fd_id_value,
11724 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11725 .f = cmd_flow_director_filter_parsed,
11727 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11728 "director entry on NIC",
11730 (void *)&cmd_flow_director_filter,
11731 (void *)&cmd_flow_director_port_id,
11732 (void *)&cmd_flow_director_mode,
11733 (void *)&cmd_flow_director_mode_mac_vlan,
11734 (void *)&cmd_flow_director_ops,
11735 (void *)&cmd_flow_director_mac,
11736 (void *)&cmd_flow_director_mac_addr,
11737 (void *)&cmd_flow_director_vlan,
11738 (void *)&cmd_flow_director_vlan_value,
11739 (void *)&cmd_flow_director_flexbytes,
11740 (void *)&cmd_flow_director_flexbytes_value,
11741 (void *)&cmd_flow_director_drop,
11742 (void *)&cmd_flow_director_queue,
11743 (void *)&cmd_flow_director_queue_id,
11744 (void *)&cmd_flow_director_fd_id,
11745 (void *)&cmd_flow_director_fd_id_value,
11750 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11751 .f = cmd_flow_director_filter_parsed,
11753 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11754 "director entry on NIC",
11756 (void *)&cmd_flow_director_filter,
11757 (void *)&cmd_flow_director_port_id,
11758 (void *)&cmd_flow_director_mode,
11759 (void *)&cmd_flow_director_mode_tunnel,
11760 (void *)&cmd_flow_director_ops,
11761 (void *)&cmd_flow_director_mac,
11762 (void *)&cmd_flow_director_mac_addr,
11763 (void *)&cmd_flow_director_vlan,
11764 (void *)&cmd_flow_director_vlan_value,
11765 (void *)&cmd_flow_director_tunnel,
11766 (void *)&cmd_flow_director_tunnel_type,
11767 (void *)&cmd_flow_director_tunnel_id,
11768 (void *)&cmd_flow_director_tunnel_id_value,
11769 (void *)&cmd_flow_director_flexbytes,
11770 (void *)&cmd_flow_director_flexbytes_value,
11771 (void *)&cmd_flow_director_drop,
11772 (void *)&cmd_flow_director_queue,
11773 (void *)&cmd_flow_director_queue_id,
11774 (void *)&cmd_flow_director_fd_id,
11775 (void *)&cmd_flow_director_fd_id_value,
11780 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11781 .f = cmd_flow_director_filter_parsed,
11783 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11784 "director entry on NIC",
11786 (void *)&cmd_flow_director_filter,
11787 (void *)&cmd_flow_director_port_id,
11788 (void *)&cmd_flow_director_mode,
11789 (void *)&cmd_flow_director_mode_raw,
11790 (void *)&cmd_flow_director_ops,
11791 (void *)&cmd_flow_director_flow,
11792 (void *)&cmd_flow_director_flow_type,
11793 (void *)&cmd_flow_director_drop,
11794 (void *)&cmd_flow_director_queue,
11795 (void *)&cmd_flow_director_queue_id,
11796 (void *)&cmd_flow_director_fd_id,
11797 (void *)&cmd_flow_director_fd_id_value,
11798 (void *)&cmd_flow_director_packet,
11799 (void *)&cmd_flow_director_filepath,
11804 struct cmd_flush_flow_director_result {
11805 cmdline_fixed_string_t flush_flow_director;
11809 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11810 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11811 flush_flow_director, "flush_flow_director");
11812 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11813 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11817 cmd_flush_flow_director_parsed(void *parsed_result,
11818 __rte_unused struct cmdline *cl,
11819 __rte_unused void *data)
11821 struct cmd_flow_director_result *res = parsed_result;
11824 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11826 printf("flow director is not supported on port %u.\n",
11831 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11832 RTE_ETH_FILTER_FLUSH, NULL);
11834 printf("flow director table flushing error: (%s)\n",
11838 cmdline_parse_inst_t cmd_flush_flow_director = {
11839 .f = cmd_flush_flow_director_parsed,
11841 .help_str = "flush_flow_director <port_id>: "
11842 "Flush all flow director entries of a device on NIC",
11844 (void *)&cmd_flush_flow_director_flush,
11845 (void *)&cmd_flush_flow_director_port_id,
11850 /* *** deal with flow director mask *** */
11851 struct cmd_flow_director_mask_result {
11852 cmdline_fixed_string_t flow_director_mask;
11854 cmdline_fixed_string_t mode;
11855 cmdline_fixed_string_t mode_value;
11856 cmdline_fixed_string_t vlan;
11857 uint16_t vlan_mask;
11858 cmdline_fixed_string_t src_mask;
11859 cmdline_ipaddr_t ipv4_src;
11860 cmdline_ipaddr_t ipv6_src;
11862 cmdline_fixed_string_t dst_mask;
11863 cmdline_ipaddr_t ipv4_dst;
11864 cmdline_ipaddr_t ipv6_dst;
11866 cmdline_fixed_string_t mac;
11867 uint8_t mac_addr_byte_mask;
11868 cmdline_fixed_string_t tunnel_id;
11869 uint32_t tunnel_id_mask;
11870 cmdline_fixed_string_t tunnel_type;
11871 uint8_t tunnel_type_mask;
11875 cmd_flow_director_mask_parsed(void *parsed_result,
11876 __rte_unused struct cmdline *cl,
11877 __rte_unused void *data)
11879 struct cmd_flow_director_mask_result *res = parsed_result;
11880 struct rte_eth_fdir_masks *mask;
11881 struct rte_port *port;
11883 port = &ports[res->port_id];
11884 /** Check if the port is not started **/
11885 if (port->port_status != RTE_PORT_STOPPED) {
11886 printf("Please stop port %d first\n", res->port_id);
11890 mask = &port->dev_conf.fdir_conf.mask;
11892 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11893 if (strcmp(res->mode_value, "MAC-VLAN")) {
11894 printf("Please set mode to MAC-VLAN.\n");
11898 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11899 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11900 if (strcmp(res->mode_value, "Tunnel")) {
11901 printf("Please set mode to Tunnel.\n");
11905 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11906 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11907 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11908 mask->tunnel_type_mask = res->tunnel_type_mask;
11910 if (strcmp(res->mode_value, "IP")) {
11911 printf("Please set mode to IP.\n");
11915 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11916 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11917 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11918 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11919 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11920 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11921 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11924 cmd_reconfig_device_queue(res->port_id, 1, 1);
11927 cmdline_parse_token_string_t cmd_flow_director_mask =
11928 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11929 flow_director_mask, "flow_director_mask");
11930 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11931 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11933 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11934 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11936 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11937 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11938 vlan_mask, UINT16);
11939 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11940 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11941 src_mask, "src_mask");
11942 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11943 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11945 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11946 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11948 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11949 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11951 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11952 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11953 dst_mask, "dst_mask");
11954 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11955 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11957 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11958 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11960 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11961 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11964 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11965 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11967 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11968 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11970 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11971 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11972 mode_value, "MAC-VLAN");
11973 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11974 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11975 mode_value, "Tunnel");
11976 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11977 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11979 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11980 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11981 mac_addr_byte_mask, UINT8);
11982 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11983 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11984 tunnel_type, "tunnel-type");
11985 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11986 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11987 tunnel_type_mask, UINT8);
11988 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11989 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11990 tunnel_id, "tunnel-id");
11991 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11992 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11993 tunnel_id_mask, UINT32);
11995 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11996 .f = cmd_flow_director_mask_parsed,
11998 .help_str = "flow_director_mask ... : "
11999 "Set IP mode flow director's mask on NIC",
12001 (void *)&cmd_flow_director_mask,
12002 (void *)&cmd_flow_director_mask_port_id,
12003 (void *)&cmd_flow_director_mask_mode,
12004 (void *)&cmd_flow_director_mask_mode_ip,
12005 (void *)&cmd_flow_director_mask_vlan,
12006 (void *)&cmd_flow_director_mask_vlan_value,
12007 (void *)&cmd_flow_director_mask_src,
12008 (void *)&cmd_flow_director_mask_ipv4_src,
12009 (void *)&cmd_flow_director_mask_ipv6_src,
12010 (void *)&cmd_flow_director_mask_port_src,
12011 (void *)&cmd_flow_director_mask_dst,
12012 (void *)&cmd_flow_director_mask_ipv4_dst,
12013 (void *)&cmd_flow_director_mask_ipv6_dst,
12014 (void *)&cmd_flow_director_mask_port_dst,
12019 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
12020 .f = cmd_flow_director_mask_parsed,
12022 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
12023 "flow director's mask on NIC",
12025 (void *)&cmd_flow_director_mask,
12026 (void *)&cmd_flow_director_mask_port_id,
12027 (void *)&cmd_flow_director_mask_mode,
12028 (void *)&cmd_flow_director_mask_mode_mac_vlan,
12029 (void *)&cmd_flow_director_mask_vlan,
12030 (void *)&cmd_flow_director_mask_vlan_value,
12035 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
12036 .f = cmd_flow_director_mask_parsed,
12038 .help_str = "flow_director_mask ... : Set tunnel mode "
12039 "flow director's mask on NIC",
12041 (void *)&cmd_flow_director_mask,
12042 (void *)&cmd_flow_director_mask_port_id,
12043 (void *)&cmd_flow_director_mask_mode,
12044 (void *)&cmd_flow_director_mask_mode_tunnel,
12045 (void *)&cmd_flow_director_mask_vlan,
12046 (void *)&cmd_flow_director_mask_vlan_value,
12047 (void *)&cmd_flow_director_mask_mac,
12048 (void *)&cmd_flow_director_mask_mac_value,
12049 (void *)&cmd_flow_director_mask_tunnel_type,
12050 (void *)&cmd_flow_director_mask_tunnel_type_value,
12051 (void *)&cmd_flow_director_mask_tunnel_id,
12052 (void *)&cmd_flow_director_mask_tunnel_id_value,
12057 /* *** deal with flow director mask on flexible payload *** */
12058 struct cmd_flow_director_flex_mask_result {
12059 cmdline_fixed_string_t flow_director_flexmask;
12061 cmdline_fixed_string_t flow;
12062 cmdline_fixed_string_t flow_type;
12063 cmdline_fixed_string_t mask;
12067 cmd_flow_director_flex_mask_parsed(void *parsed_result,
12068 __rte_unused struct cmdline *cl,
12069 __rte_unused void *data)
12071 struct cmd_flow_director_flex_mask_result *res = parsed_result;
12072 struct rte_eth_fdir_info fdir_info;
12073 struct rte_eth_fdir_flex_mask flex_mask;
12074 struct rte_port *port;
12075 uint64_t flow_type_mask;
12079 port = &ports[res->port_id];
12080 /** Check if the port is not started **/
12081 if (port->port_status != RTE_PORT_STOPPED) {
12082 printf("Please stop port %d first\n", res->port_id);
12086 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
12087 ret = parse_flexbytes(res->mask,
12089 RTE_ETH_FDIR_MAX_FLEXLEN);
12091 printf("error: Cannot parse mask input.\n");
12095 memset(&fdir_info, 0, sizeof(fdir_info));
12096 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12097 RTE_ETH_FILTER_INFO, &fdir_info);
12099 printf("Cannot get FDir filter info\n");
12103 if (!strcmp(res->flow_type, "none")) {
12104 /* means don't specify the flow type */
12105 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
12106 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
12107 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
12108 0, sizeof(struct rte_eth_fdir_flex_mask));
12109 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
12110 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
12112 sizeof(struct rte_eth_fdir_flex_mask));
12113 cmd_reconfig_device_queue(res->port_id, 1, 1);
12116 flow_type_mask = fdir_info.flow_types_mask[0];
12117 if (!strcmp(res->flow_type, "all")) {
12118 if (!flow_type_mask) {
12119 printf("No flow type supported\n");
12122 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
12123 if (flow_type_mask & (1ULL << i)) {
12124 flex_mask.flow_type = i;
12125 fdir_set_flex_mask(res->port_id, &flex_mask);
12128 cmd_reconfig_device_queue(res->port_id, 1, 1);
12131 flex_mask.flow_type = str2flowtype(res->flow_type);
12132 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
12133 printf("Flow type %s not supported on port %d\n",
12134 res->flow_type, res->port_id);
12137 fdir_set_flex_mask(res->port_id, &flex_mask);
12138 cmd_reconfig_device_queue(res->port_id, 1, 1);
12141 cmdline_parse_token_string_t cmd_flow_director_flexmask =
12142 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12143 flow_director_flexmask,
12144 "flow_director_flex_mask");
12145 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
12146 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12148 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
12149 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12151 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
12152 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12153 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
12154 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
12155 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
12156 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12159 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
12160 .f = cmd_flow_director_flex_mask_parsed,
12162 .help_str = "flow_director_flex_mask ... : "
12163 "Set flow director's flex mask on NIC",
12165 (void *)&cmd_flow_director_flexmask,
12166 (void *)&cmd_flow_director_flexmask_port_id,
12167 (void *)&cmd_flow_director_flexmask_flow,
12168 (void *)&cmd_flow_director_flexmask_flow_type,
12169 (void *)&cmd_flow_director_flexmask_mask,
12174 /* *** deal with flow director flexible payload configuration *** */
12175 struct cmd_flow_director_flexpayload_result {
12176 cmdline_fixed_string_t flow_director_flexpayload;
12178 cmdline_fixed_string_t payload_layer;
12179 cmdline_fixed_string_t payload_cfg;
12183 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
12186 const char *p, *p0 = q_arg;
12188 unsigned long int_fld;
12189 char *str_fld[max_num];
12194 p = strchr(p0, '(');
12198 p0 = strchr(p, ')');
12203 if (size >= sizeof(s))
12206 snprintf(s, sizeof(s), "%.*s", size, p);
12207 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12208 if (ret < 0 || ret > max_num)
12210 for (i = 0; i < ret; i++) {
12212 int_fld = strtoul(str_fld[i], &end, 0);
12213 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12215 offsets[i] = (uint16_t)int_fld;
12221 cmd_flow_director_flxpld_parsed(void *parsed_result,
12222 __rte_unused struct cmdline *cl,
12223 __rte_unused void *data)
12225 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12226 struct rte_eth_flex_payload_cfg flex_cfg;
12227 struct rte_port *port;
12230 port = &ports[res->port_id];
12231 /** Check if the port is not started **/
12232 if (port->port_status != RTE_PORT_STOPPED) {
12233 printf("Please stop port %d first\n", res->port_id);
12237 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12239 if (!strcmp(res->payload_layer, "raw"))
12240 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12241 else if (!strcmp(res->payload_layer, "l2"))
12242 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12243 else if (!strcmp(res->payload_layer, "l3"))
12244 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12245 else if (!strcmp(res->payload_layer, "l4"))
12246 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12248 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12249 RTE_ETH_FDIR_MAX_FLEXLEN);
12251 printf("error: Cannot parse flex payload input.\n");
12255 fdir_set_flex_payload(res->port_id, &flex_cfg);
12256 cmd_reconfig_device_queue(res->port_id, 1, 1);
12259 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12260 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12261 flow_director_flexpayload,
12262 "flow_director_flex_payload");
12263 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12264 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12266 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12267 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12268 payload_layer, "raw#l2#l3#l4");
12269 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12270 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12271 payload_cfg, NULL);
12273 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12274 .f = cmd_flow_director_flxpld_parsed,
12276 .help_str = "flow_director_flexpayload ... : "
12277 "Set flow director's flex payload on NIC",
12279 (void *)&cmd_flow_director_flexpayload,
12280 (void *)&cmd_flow_director_flexpayload_port_id,
12281 (void *)&cmd_flow_director_flexpayload_payload_layer,
12282 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12287 /* Generic flow interface command. */
12288 extern cmdline_parse_inst_t cmd_flow;
12290 /* *** Classification Filters Control *** */
12291 /* *** Get symmetric hash enable per port *** */
12292 struct cmd_get_sym_hash_ena_per_port_result {
12293 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12298 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12299 __rte_unused struct cmdline *cl,
12300 __rte_unused void *data)
12302 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12303 struct rte_eth_hash_filter_info info;
12306 if (rte_eth_dev_filter_supported(res->port_id,
12307 RTE_ETH_FILTER_HASH) < 0) {
12308 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12313 memset(&info, 0, sizeof(info));
12314 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12315 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12316 RTE_ETH_FILTER_GET, &info);
12319 printf("Cannot get symmetric hash enable per port "
12320 "on port %u\n", res->port_id);
12324 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12325 "enabled" : "disabled", res->port_id);
12328 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12329 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12330 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12331 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12332 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12335 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12336 .f = cmd_get_sym_hash_per_port_parsed,
12338 .help_str = "get_sym_hash_ena_per_port <port_id>",
12340 (void *)&cmd_get_sym_hash_ena_per_port_all,
12341 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12346 /* *** Set symmetric hash enable per port *** */
12347 struct cmd_set_sym_hash_ena_per_port_result {
12348 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12349 cmdline_fixed_string_t enable;
12354 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12355 __rte_unused struct cmdline *cl,
12356 __rte_unused void *data)
12358 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12359 struct rte_eth_hash_filter_info info;
12362 if (rte_eth_dev_filter_supported(res->port_id,
12363 RTE_ETH_FILTER_HASH) < 0) {
12364 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12369 memset(&info, 0, sizeof(info));
12370 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12371 if (!strcmp(res->enable, "enable"))
12372 info.info.enable = 1;
12373 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12374 RTE_ETH_FILTER_SET, &info);
12376 printf("Cannot set symmetric hash enable per port on "
12377 "port %u\n", res->port_id);
12380 printf("Symmetric hash has been set to %s on port %u\n",
12381 res->enable, res->port_id);
12384 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12385 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12386 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12387 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12388 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12390 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12391 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12392 enable, "enable#disable");
12394 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12395 .f = cmd_set_sym_hash_per_port_parsed,
12397 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12399 (void *)&cmd_set_sym_hash_ena_per_port_all,
12400 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12401 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12406 /* Get global config of hash function */
12407 struct cmd_get_hash_global_config_result {
12408 cmdline_fixed_string_t get_hash_global_config;
12413 flowtype_to_str(uint16_t ftype)
12419 } ftype_table[] = {
12420 {"ipv4", RTE_ETH_FLOW_IPV4},
12421 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12422 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12423 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12424 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12425 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12426 {"ipv6", RTE_ETH_FLOW_IPV6},
12427 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12428 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12429 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12430 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12431 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12432 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12433 {"port", RTE_ETH_FLOW_PORT},
12434 {"vxlan", RTE_ETH_FLOW_VXLAN},
12435 {"geneve", RTE_ETH_FLOW_GENEVE},
12436 {"nvgre", RTE_ETH_FLOW_NVGRE},
12437 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12440 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12441 if (ftype_table[i].ftype == ftype)
12442 return ftype_table[i].str;
12449 cmd_get_hash_global_config_parsed(void *parsed_result,
12450 __rte_unused struct cmdline *cl,
12451 __rte_unused void *data)
12453 struct cmd_get_hash_global_config_result *res = parsed_result;
12454 struct rte_eth_hash_filter_info info;
12455 uint32_t idx, offset;
12460 if (rte_eth_dev_filter_supported(res->port_id,
12461 RTE_ETH_FILTER_HASH) < 0) {
12462 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12467 memset(&info, 0, sizeof(info));
12468 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12469 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12470 RTE_ETH_FILTER_GET, &info);
12472 printf("Cannot get hash global configurations by port %d\n",
12477 switch (info.info.global_conf.hash_func) {
12478 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12479 printf("Hash function is Toeplitz\n");
12481 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12482 printf("Hash function is Simple XOR\n");
12484 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12485 printf("Hash function is Symmetric Toeplitz\n");
12488 printf("Unknown hash function\n");
12492 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12493 idx = i / UINT64_BIT;
12494 offset = i % UINT64_BIT;
12495 if (!(info.info.global_conf.valid_bit_mask[idx] &
12498 str = flowtype_to_str(i);
12501 printf("Symmetric hash is %s globally for flow type %s "
12503 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12504 (1ULL << offset)) ? "enabled" : "disabled"), str,
12509 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12510 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12511 get_hash_global_config, "get_hash_global_config");
12512 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12513 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12516 cmdline_parse_inst_t cmd_get_hash_global_config = {
12517 .f = cmd_get_hash_global_config_parsed,
12519 .help_str = "get_hash_global_config <port_id>",
12521 (void *)&cmd_get_hash_global_config_all,
12522 (void *)&cmd_get_hash_global_config_port_id,
12527 /* Set global config of hash function */
12528 struct cmd_set_hash_global_config_result {
12529 cmdline_fixed_string_t set_hash_global_config;
12531 cmdline_fixed_string_t hash_func;
12532 cmdline_fixed_string_t flow_type;
12533 cmdline_fixed_string_t enable;
12537 cmd_set_hash_global_config_parsed(void *parsed_result,
12538 __rte_unused struct cmdline *cl,
12539 __rte_unused void *data)
12541 struct cmd_set_hash_global_config_result *res = parsed_result;
12542 struct rte_eth_hash_filter_info info;
12543 uint32_t ftype, idx, offset;
12546 if (rte_eth_dev_filter_supported(res->port_id,
12547 RTE_ETH_FILTER_HASH) < 0) {
12548 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12552 memset(&info, 0, sizeof(info));
12553 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12554 if (!strcmp(res->hash_func, "toeplitz"))
12555 info.info.global_conf.hash_func =
12556 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12557 else if (!strcmp(res->hash_func, "simple_xor"))
12558 info.info.global_conf.hash_func =
12559 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12560 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12561 info.info.global_conf.hash_func =
12562 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12563 else if (!strcmp(res->hash_func, "default"))
12564 info.info.global_conf.hash_func =
12565 RTE_ETH_HASH_FUNCTION_DEFAULT;
12567 ftype = str2flowtype(res->flow_type);
12568 idx = ftype / UINT64_BIT;
12569 offset = ftype % UINT64_BIT;
12570 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12571 if (!strcmp(res->enable, "enable"))
12572 info.info.global_conf.sym_hash_enable_mask[idx] |=
12574 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12575 RTE_ETH_FILTER_SET, &info);
12577 printf("Cannot set global hash configurations by port %d\n",
12580 printf("Global hash configurations have been set "
12581 "successfully by port %d\n", res->port_id);
12584 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12585 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12586 set_hash_global_config, "set_hash_global_config");
12587 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12588 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12590 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12591 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12592 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12593 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12594 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12596 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12597 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12598 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12599 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12600 enable, "enable#disable");
12602 cmdline_parse_inst_t cmd_set_hash_global_config = {
12603 .f = cmd_set_hash_global_config_parsed,
12605 .help_str = "set_hash_global_config <port_id> "
12606 "toeplitz|simple_xor|symmetric_toeplitz|default "
12607 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12608 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12609 "l2_payload enable|disable",
12611 (void *)&cmd_set_hash_global_config_all,
12612 (void *)&cmd_set_hash_global_config_port_id,
12613 (void *)&cmd_set_hash_global_config_hash_func,
12614 (void *)&cmd_set_hash_global_config_flow_type,
12615 (void *)&cmd_set_hash_global_config_enable,
12620 /* Set hash input set */
12621 struct cmd_set_hash_input_set_result {
12622 cmdline_fixed_string_t set_hash_input_set;
12624 cmdline_fixed_string_t flow_type;
12625 cmdline_fixed_string_t inset_field;
12626 cmdline_fixed_string_t select;
12629 static enum rte_eth_input_set_field
12630 str2inset(char *string)
12634 static const struct {
12636 enum rte_eth_input_set_field inset;
12637 } inset_table[] = {
12638 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12639 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12640 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12641 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12642 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12643 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12644 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12645 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12646 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12647 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12648 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12649 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12650 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12651 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12652 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12653 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12654 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12655 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12656 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12657 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12658 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12659 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12660 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12661 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12662 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12663 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12664 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12665 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12666 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12667 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12668 {"none", RTE_ETH_INPUT_SET_NONE},
12671 for (i = 0; i < RTE_DIM(inset_table); i++) {
12672 if (!strcmp(string, inset_table[i].str))
12673 return inset_table[i].inset;
12676 return RTE_ETH_INPUT_SET_UNKNOWN;
12680 cmd_set_hash_input_set_parsed(void *parsed_result,
12681 __rte_unused struct cmdline *cl,
12682 __rte_unused void *data)
12684 struct cmd_set_hash_input_set_result *res = parsed_result;
12685 struct rte_eth_hash_filter_info info;
12687 memset(&info, 0, sizeof(info));
12688 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12689 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12690 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12691 info.info.input_set_conf.inset_size = 1;
12692 if (!strcmp(res->select, "select"))
12693 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12694 else if (!strcmp(res->select, "add"))
12695 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12696 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12697 RTE_ETH_FILTER_SET, &info);
12700 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12701 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12702 set_hash_input_set, "set_hash_input_set");
12703 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12704 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12706 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12707 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12709 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12710 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12712 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12713 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12714 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12715 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12716 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12718 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12719 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12720 select, "select#add");
12722 cmdline_parse_inst_t cmd_set_hash_input_set = {
12723 .f = cmd_set_hash_input_set_parsed,
12725 .help_str = "set_hash_input_set <port_id> "
12726 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12727 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12728 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12729 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12730 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12731 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12732 "fld-7th|fld-8th|none select|add",
12734 (void *)&cmd_set_hash_input_set_cmd,
12735 (void *)&cmd_set_hash_input_set_port_id,
12736 (void *)&cmd_set_hash_input_set_flow_type,
12737 (void *)&cmd_set_hash_input_set_field,
12738 (void *)&cmd_set_hash_input_set_select,
12743 /* Set flow director input set */
12744 struct cmd_set_fdir_input_set_result {
12745 cmdline_fixed_string_t set_fdir_input_set;
12747 cmdline_fixed_string_t flow_type;
12748 cmdline_fixed_string_t inset_field;
12749 cmdline_fixed_string_t select;
12753 cmd_set_fdir_input_set_parsed(void *parsed_result,
12754 __rte_unused struct cmdline *cl,
12755 __rte_unused void *data)
12757 struct cmd_set_fdir_input_set_result *res = parsed_result;
12758 struct rte_eth_fdir_filter_info info;
12760 memset(&info, 0, sizeof(info));
12761 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12762 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12763 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12764 info.info.input_set_conf.inset_size = 1;
12765 if (!strcmp(res->select, "select"))
12766 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12767 else if (!strcmp(res->select, "add"))
12768 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12769 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12770 RTE_ETH_FILTER_SET, &info);
12773 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12774 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12775 set_fdir_input_set, "set_fdir_input_set");
12776 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12777 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12779 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12780 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12782 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12783 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12784 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12785 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12787 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12788 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12789 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12790 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12791 "sctp-veri-tag#none");
12792 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12793 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12794 select, "select#add");
12796 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12797 .f = cmd_set_fdir_input_set_parsed,
12799 .help_str = "set_fdir_input_set <port_id> "
12800 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12801 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12802 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12803 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12804 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12805 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12806 "sctp-veri-tag|none select|add",
12808 (void *)&cmd_set_fdir_input_set_cmd,
12809 (void *)&cmd_set_fdir_input_set_port_id,
12810 (void *)&cmd_set_fdir_input_set_flow_type,
12811 (void *)&cmd_set_fdir_input_set_field,
12812 (void *)&cmd_set_fdir_input_set_select,
12817 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12818 struct cmd_mcast_addr_result {
12819 cmdline_fixed_string_t mcast_addr_cmd;
12820 cmdline_fixed_string_t what;
12822 struct rte_ether_addr mc_addr;
12825 static void cmd_mcast_addr_parsed(void *parsed_result,
12826 __rte_unused struct cmdline *cl,
12827 __rte_unused void *data)
12829 struct cmd_mcast_addr_result *res = parsed_result;
12831 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12832 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12833 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12834 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12835 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12838 if (strcmp(res->what, "add") == 0)
12839 mcast_addr_add(res->port_num, &res->mc_addr);
12841 mcast_addr_remove(res->port_num, &res->mc_addr);
12844 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12845 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12846 mcast_addr_cmd, "mcast_addr");
12847 cmdline_parse_token_string_t cmd_mcast_addr_what =
12848 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12850 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12851 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12852 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12853 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12855 cmdline_parse_inst_t cmd_mcast_addr = {
12856 .f = cmd_mcast_addr_parsed,
12858 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12859 "Add/Remove multicast MAC address on port_id",
12861 (void *)&cmd_mcast_addr_cmd,
12862 (void *)&cmd_mcast_addr_what,
12863 (void *)&cmd_mcast_addr_portnum,
12864 (void *)&cmd_mcast_addr_addr,
12869 /* l2 tunnel config
12870 * only support E-tag now.
12873 /* Ether type config */
12874 struct cmd_config_l2_tunnel_eth_type_result {
12875 cmdline_fixed_string_t port;
12876 cmdline_fixed_string_t config;
12877 cmdline_fixed_string_t all;
12879 cmdline_fixed_string_t l2_tunnel;
12880 cmdline_fixed_string_t l2_tunnel_type;
12881 cmdline_fixed_string_t eth_type;
12882 uint16_t eth_type_val;
12885 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12886 TOKEN_STRING_INITIALIZER
12887 (struct cmd_config_l2_tunnel_eth_type_result,
12889 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12890 TOKEN_STRING_INITIALIZER
12891 (struct cmd_config_l2_tunnel_eth_type_result,
12893 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12894 TOKEN_STRING_INITIALIZER
12895 (struct cmd_config_l2_tunnel_eth_type_result,
12897 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12898 TOKEN_NUM_INITIALIZER
12899 (struct cmd_config_l2_tunnel_eth_type_result,
12901 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12902 TOKEN_STRING_INITIALIZER
12903 (struct cmd_config_l2_tunnel_eth_type_result,
12904 l2_tunnel, "l2-tunnel");
12905 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12906 TOKEN_STRING_INITIALIZER
12907 (struct cmd_config_l2_tunnel_eth_type_result,
12908 l2_tunnel_type, "E-tag");
12909 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12910 TOKEN_STRING_INITIALIZER
12911 (struct cmd_config_l2_tunnel_eth_type_result,
12912 eth_type, "ether-type");
12913 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12914 TOKEN_NUM_INITIALIZER
12915 (struct cmd_config_l2_tunnel_eth_type_result,
12916 eth_type_val, UINT16);
12918 static enum rte_eth_tunnel_type
12919 str2fdir_l2_tunnel_type(char *string)
12923 static const struct {
12925 enum rte_eth_tunnel_type type;
12926 } l2_tunnel_type_str[] = {
12927 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12930 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12931 if (!strcmp(l2_tunnel_type_str[i].str, string))
12932 return l2_tunnel_type_str[i].type;
12934 return RTE_TUNNEL_TYPE_NONE;
12937 /* ether type config for all ports */
12939 cmd_config_l2_tunnel_eth_type_all_parsed
12940 (void *parsed_result,
12941 __rte_unused struct cmdline *cl,
12942 __rte_unused void *data)
12944 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12945 struct rte_eth_l2_tunnel_conf entry;
12948 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12949 entry.ether_type = res->eth_type_val;
12951 RTE_ETH_FOREACH_DEV(pid) {
12952 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12956 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12957 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12959 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12961 (void *)&cmd_config_l2_tunnel_eth_type_port,
12962 (void *)&cmd_config_l2_tunnel_eth_type_config,
12963 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12964 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12965 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12966 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12967 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12972 /* ether type config for a specific port */
12974 cmd_config_l2_tunnel_eth_type_specific_parsed(
12975 void *parsed_result,
12976 __rte_unused struct cmdline *cl,
12977 __rte_unused void *data)
12979 struct cmd_config_l2_tunnel_eth_type_result *res =
12981 struct rte_eth_l2_tunnel_conf entry;
12983 if (port_id_is_invalid(res->id, ENABLED_WARN))
12986 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12987 entry.ether_type = res->eth_type_val;
12989 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12992 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12993 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12995 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12997 (void *)&cmd_config_l2_tunnel_eth_type_port,
12998 (void *)&cmd_config_l2_tunnel_eth_type_config,
12999 (void *)&cmd_config_l2_tunnel_eth_type_id,
13000 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
13001 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
13002 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
13003 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
13008 /* Enable/disable l2 tunnel */
13009 struct cmd_config_l2_tunnel_en_dis_result {
13010 cmdline_fixed_string_t port;
13011 cmdline_fixed_string_t config;
13012 cmdline_fixed_string_t all;
13014 cmdline_fixed_string_t l2_tunnel;
13015 cmdline_fixed_string_t l2_tunnel_type;
13016 cmdline_fixed_string_t en_dis;
13019 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
13020 TOKEN_STRING_INITIALIZER
13021 (struct cmd_config_l2_tunnel_en_dis_result,
13023 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
13024 TOKEN_STRING_INITIALIZER
13025 (struct cmd_config_l2_tunnel_en_dis_result,
13027 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
13028 TOKEN_STRING_INITIALIZER
13029 (struct cmd_config_l2_tunnel_en_dis_result,
13031 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
13032 TOKEN_NUM_INITIALIZER
13033 (struct cmd_config_l2_tunnel_en_dis_result,
13035 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
13036 TOKEN_STRING_INITIALIZER
13037 (struct cmd_config_l2_tunnel_en_dis_result,
13038 l2_tunnel, "l2-tunnel");
13039 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
13040 TOKEN_STRING_INITIALIZER
13041 (struct cmd_config_l2_tunnel_en_dis_result,
13042 l2_tunnel_type, "E-tag");
13043 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
13044 TOKEN_STRING_INITIALIZER
13045 (struct cmd_config_l2_tunnel_en_dis_result,
13046 en_dis, "enable#disable");
13048 /* enable/disable l2 tunnel for all ports */
13050 cmd_config_l2_tunnel_en_dis_all_parsed(
13051 void *parsed_result,
13052 __rte_unused struct cmdline *cl,
13053 __rte_unused void *data)
13055 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
13056 struct rte_eth_l2_tunnel_conf entry;
13060 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13062 if (!strcmp("enable", res->en_dis))
13067 RTE_ETH_FOREACH_DEV(pid) {
13068 rte_eth_dev_l2_tunnel_offload_set(pid,
13070 ETH_L2_TUNNEL_ENABLE_MASK,
13075 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
13076 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
13078 .help_str = "port config all l2-tunnel E-tag enable|disable",
13080 (void *)&cmd_config_l2_tunnel_en_dis_port,
13081 (void *)&cmd_config_l2_tunnel_en_dis_config,
13082 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
13083 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13084 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13085 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13090 /* enable/disable l2 tunnel for a port */
13092 cmd_config_l2_tunnel_en_dis_specific_parsed(
13093 void *parsed_result,
13094 __rte_unused struct cmdline *cl,
13095 __rte_unused void *data)
13097 struct cmd_config_l2_tunnel_en_dis_result *res =
13099 struct rte_eth_l2_tunnel_conf entry;
13101 if (port_id_is_invalid(res->id, ENABLED_WARN))
13104 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13106 if (!strcmp("enable", res->en_dis))
13107 rte_eth_dev_l2_tunnel_offload_set(res->id,
13109 ETH_L2_TUNNEL_ENABLE_MASK,
13112 rte_eth_dev_l2_tunnel_offload_set(res->id,
13114 ETH_L2_TUNNEL_ENABLE_MASK,
13118 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
13119 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
13121 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
13123 (void *)&cmd_config_l2_tunnel_en_dis_port,
13124 (void *)&cmd_config_l2_tunnel_en_dis_config,
13125 (void *)&cmd_config_l2_tunnel_en_dis_id,
13126 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13127 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13128 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13133 /* E-tag configuration */
13135 /* Common result structure for all E-tag configuration */
13136 struct cmd_config_e_tag_result {
13137 cmdline_fixed_string_t e_tag;
13138 cmdline_fixed_string_t set;
13139 cmdline_fixed_string_t insertion;
13140 cmdline_fixed_string_t stripping;
13141 cmdline_fixed_string_t forwarding;
13142 cmdline_fixed_string_t filter;
13143 cmdline_fixed_string_t add;
13144 cmdline_fixed_string_t del;
13145 cmdline_fixed_string_t on;
13146 cmdline_fixed_string_t off;
13147 cmdline_fixed_string_t on_off;
13148 cmdline_fixed_string_t port_tag_id;
13149 uint32_t port_tag_id_val;
13150 cmdline_fixed_string_t e_tag_id;
13151 uint16_t e_tag_id_val;
13152 cmdline_fixed_string_t dst_pool;
13153 uint8_t dst_pool_val;
13154 cmdline_fixed_string_t port;
13156 cmdline_fixed_string_t vf;
13160 /* Common CLI fields for all E-tag configuration */
13161 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
13162 TOKEN_STRING_INITIALIZER
13163 (struct cmd_config_e_tag_result,
13165 cmdline_parse_token_string_t cmd_config_e_tag_set =
13166 TOKEN_STRING_INITIALIZER
13167 (struct cmd_config_e_tag_result,
13169 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
13170 TOKEN_STRING_INITIALIZER
13171 (struct cmd_config_e_tag_result,
13172 insertion, "insertion");
13173 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
13174 TOKEN_STRING_INITIALIZER
13175 (struct cmd_config_e_tag_result,
13176 stripping, "stripping");
13177 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
13178 TOKEN_STRING_INITIALIZER
13179 (struct cmd_config_e_tag_result,
13180 forwarding, "forwarding");
13181 cmdline_parse_token_string_t cmd_config_e_tag_filter =
13182 TOKEN_STRING_INITIALIZER
13183 (struct cmd_config_e_tag_result,
13185 cmdline_parse_token_string_t cmd_config_e_tag_add =
13186 TOKEN_STRING_INITIALIZER
13187 (struct cmd_config_e_tag_result,
13189 cmdline_parse_token_string_t cmd_config_e_tag_del =
13190 TOKEN_STRING_INITIALIZER
13191 (struct cmd_config_e_tag_result,
13193 cmdline_parse_token_string_t cmd_config_e_tag_on =
13194 TOKEN_STRING_INITIALIZER
13195 (struct cmd_config_e_tag_result,
13197 cmdline_parse_token_string_t cmd_config_e_tag_off =
13198 TOKEN_STRING_INITIALIZER
13199 (struct cmd_config_e_tag_result,
13201 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13202 TOKEN_STRING_INITIALIZER
13203 (struct cmd_config_e_tag_result,
13205 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13206 TOKEN_STRING_INITIALIZER
13207 (struct cmd_config_e_tag_result,
13208 port_tag_id, "port-tag-id");
13209 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13210 TOKEN_NUM_INITIALIZER
13211 (struct cmd_config_e_tag_result,
13212 port_tag_id_val, UINT32);
13213 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13214 TOKEN_STRING_INITIALIZER
13215 (struct cmd_config_e_tag_result,
13216 e_tag_id, "e-tag-id");
13217 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13218 TOKEN_NUM_INITIALIZER
13219 (struct cmd_config_e_tag_result,
13220 e_tag_id_val, UINT16);
13221 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13222 TOKEN_STRING_INITIALIZER
13223 (struct cmd_config_e_tag_result,
13224 dst_pool, "dst-pool");
13225 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13226 TOKEN_NUM_INITIALIZER
13227 (struct cmd_config_e_tag_result,
13228 dst_pool_val, UINT8);
13229 cmdline_parse_token_string_t cmd_config_e_tag_port =
13230 TOKEN_STRING_INITIALIZER
13231 (struct cmd_config_e_tag_result,
13233 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13234 TOKEN_NUM_INITIALIZER
13235 (struct cmd_config_e_tag_result,
13237 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13238 TOKEN_STRING_INITIALIZER
13239 (struct cmd_config_e_tag_result,
13241 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13242 TOKEN_NUM_INITIALIZER
13243 (struct cmd_config_e_tag_result,
13246 /* E-tag insertion configuration */
13248 cmd_config_e_tag_insertion_en_parsed(
13249 void *parsed_result,
13250 __rte_unused struct cmdline *cl,
13251 __rte_unused void *data)
13253 struct cmd_config_e_tag_result *res =
13255 struct rte_eth_l2_tunnel_conf entry;
13257 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13260 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13261 entry.tunnel_id = res->port_tag_id_val;
13262 entry.vf_id = res->vf_id;
13263 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13265 ETH_L2_TUNNEL_INSERTION_MASK,
13270 cmd_config_e_tag_insertion_dis_parsed(
13271 void *parsed_result,
13272 __rte_unused struct cmdline *cl,
13273 __rte_unused void *data)
13275 struct cmd_config_e_tag_result *res =
13277 struct rte_eth_l2_tunnel_conf entry;
13279 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13282 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13283 entry.vf_id = res->vf_id;
13285 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13287 ETH_L2_TUNNEL_INSERTION_MASK,
13291 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13292 .f = cmd_config_e_tag_insertion_en_parsed,
13294 .help_str = "E-tag ... : E-tag insertion enable",
13296 (void *)&cmd_config_e_tag_e_tag,
13297 (void *)&cmd_config_e_tag_set,
13298 (void *)&cmd_config_e_tag_insertion,
13299 (void *)&cmd_config_e_tag_on,
13300 (void *)&cmd_config_e_tag_port_tag_id,
13301 (void *)&cmd_config_e_tag_port_tag_id_val,
13302 (void *)&cmd_config_e_tag_port,
13303 (void *)&cmd_config_e_tag_port_id,
13304 (void *)&cmd_config_e_tag_vf,
13305 (void *)&cmd_config_e_tag_vf_id,
13310 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13311 .f = cmd_config_e_tag_insertion_dis_parsed,
13313 .help_str = "E-tag ... : E-tag insertion disable",
13315 (void *)&cmd_config_e_tag_e_tag,
13316 (void *)&cmd_config_e_tag_set,
13317 (void *)&cmd_config_e_tag_insertion,
13318 (void *)&cmd_config_e_tag_off,
13319 (void *)&cmd_config_e_tag_port,
13320 (void *)&cmd_config_e_tag_port_id,
13321 (void *)&cmd_config_e_tag_vf,
13322 (void *)&cmd_config_e_tag_vf_id,
13327 /* E-tag stripping configuration */
13329 cmd_config_e_tag_stripping_parsed(
13330 void *parsed_result,
13331 __rte_unused struct cmdline *cl,
13332 __rte_unused void *data)
13334 struct cmd_config_e_tag_result *res =
13336 struct rte_eth_l2_tunnel_conf entry;
13338 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13341 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13343 if (!strcmp(res->on_off, "on"))
13344 rte_eth_dev_l2_tunnel_offload_set
13347 ETH_L2_TUNNEL_STRIPPING_MASK,
13350 rte_eth_dev_l2_tunnel_offload_set
13353 ETH_L2_TUNNEL_STRIPPING_MASK,
13357 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13358 .f = cmd_config_e_tag_stripping_parsed,
13360 .help_str = "E-tag ... : E-tag stripping enable/disable",
13362 (void *)&cmd_config_e_tag_e_tag,
13363 (void *)&cmd_config_e_tag_set,
13364 (void *)&cmd_config_e_tag_stripping,
13365 (void *)&cmd_config_e_tag_on_off,
13366 (void *)&cmd_config_e_tag_port,
13367 (void *)&cmd_config_e_tag_port_id,
13372 /* E-tag forwarding configuration */
13374 cmd_config_e_tag_forwarding_parsed(
13375 void *parsed_result,
13376 __rte_unused struct cmdline *cl,
13377 __rte_unused void *data)
13379 struct cmd_config_e_tag_result *res = parsed_result;
13380 struct rte_eth_l2_tunnel_conf entry;
13382 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13385 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13387 if (!strcmp(res->on_off, "on"))
13388 rte_eth_dev_l2_tunnel_offload_set
13391 ETH_L2_TUNNEL_FORWARDING_MASK,
13394 rte_eth_dev_l2_tunnel_offload_set
13397 ETH_L2_TUNNEL_FORWARDING_MASK,
13401 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13402 .f = cmd_config_e_tag_forwarding_parsed,
13404 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13406 (void *)&cmd_config_e_tag_e_tag,
13407 (void *)&cmd_config_e_tag_set,
13408 (void *)&cmd_config_e_tag_forwarding,
13409 (void *)&cmd_config_e_tag_on_off,
13410 (void *)&cmd_config_e_tag_port,
13411 (void *)&cmd_config_e_tag_port_id,
13416 /* E-tag filter configuration */
13418 cmd_config_e_tag_filter_add_parsed(
13419 void *parsed_result,
13420 __rte_unused struct cmdline *cl,
13421 __rte_unused void *data)
13423 struct cmd_config_e_tag_result *res = parsed_result;
13424 struct rte_eth_l2_tunnel_conf entry;
13427 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13430 if (res->e_tag_id_val > 0x3fff) {
13431 printf("e-tag-id must be equal or less than 0x3fff.\n");
13435 ret = rte_eth_dev_filter_supported(res->port_id,
13436 RTE_ETH_FILTER_L2_TUNNEL);
13438 printf("E-tag filter is not supported on port %u.\n",
13443 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13444 entry.tunnel_id = res->e_tag_id_val;
13445 entry.pool = res->dst_pool_val;
13447 ret = rte_eth_dev_filter_ctrl(res->port_id,
13448 RTE_ETH_FILTER_L2_TUNNEL,
13449 RTE_ETH_FILTER_ADD,
13452 printf("E-tag filter programming error: (%s)\n",
13456 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13457 .f = cmd_config_e_tag_filter_add_parsed,
13459 .help_str = "E-tag ... : E-tag filter add",
13461 (void *)&cmd_config_e_tag_e_tag,
13462 (void *)&cmd_config_e_tag_set,
13463 (void *)&cmd_config_e_tag_filter,
13464 (void *)&cmd_config_e_tag_add,
13465 (void *)&cmd_config_e_tag_e_tag_id,
13466 (void *)&cmd_config_e_tag_e_tag_id_val,
13467 (void *)&cmd_config_e_tag_dst_pool,
13468 (void *)&cmd_config_e_tag_dst_pool_val,
13469 (void *)&cmd_config_e_tag_port,
13470 (void *)&cmd_config_e_tag_port_id,
13476 cmd_config_e_tag_filter_del_parsed(
13477 void *parsed_result,
13478 __rte_unused struct cmdline *cl,
13479 __rte_unused void *data)
13481 struct cmd_config_e_tag_result *res = parsed_result;
13482 struct rte_eth_l2_tunnel_conf entry;
13485 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13488 if (res->e_tag_id_val > 0x3fff) {
13489 printf("e-tag-id must be less than 0x3fff.\n");
13493 ret = rte_eth_dev_filter_supported(res->port_id,
13494 RTE_ETH_FILTER_L2_TUNNEL);
13496 printf("E-tag filter is not supported on port %u.\n",
13501 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13502 entry.tunnel_id = res->e_tag_id_val;
13504 ret = rte_eth_dev_filter_ctrl(res->port_id,
13505 RTE_ETH_FILTER_L2_TUNNEL,
13506 RTE_ETH_FILTER_DELETE,
13509 printf("E-tag filter programming error: (%s)\n",
13513 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13514 .f = cmd_config_e_tag_filter_del_parsed,
13516 .help_str = "E-tag ... : E-tag filter delete",
13518 (void *)&cmd_config_e_tag_e_tag,
13519 (void *)&cmd_config_e_tag_set,
13520 (void *)&cmd_config_e_tag_filter,
13521 (void *)&cmd_config_e_tag_del,
13522 (void *)&cmd_config_e_tag_e_tag_id,
13523 (void *)&cmd_config_e_tag_e_tag_id_val,
13524 (void *)&cmd_config_e_tag_port,
13525 (void *)&cmd_config_e_tag_port_id,
13530 /* vf vlan anti spoof configuration */
13532 /* Common result structure for vf vlan anti spoof */
13533 struct cmd_vf_vlan_anti_spoof_result {
13534 cmdline_fixed_string_t set;
13535 cmdline_fixed_string_t vf;
13536 cmdline_fixed_string_t vlan;
13537 cmdline_fixed_string_t antispoof;
13540 cmdline_fixed_string_t on_off;
13543 /* Common CLI fields for vf vlan anti spoof enable disable */
13544 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13545 TOKEN_STRING_INITIALIZER
13546 (struct cmd_vf_vlan_anti_spoof_result,
13548 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13549 TOKEN_STRING_INITIALIZER
13550 (struct cmd_vf_vlan_anti_spoof_result,
13552 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13553 TOKEN_STRING_INITIALIZER
13554 (struct cmd_vf_vlan_anti_spoof_result,
13556 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13557 TOKEN_STRING_INITIALIZER
13558 (struct cmd_vf_vlan_anti_spoof_result,
13559 antispoof, "antispoof");
13560 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13561 TOKEN_NUM_INITIALIZER
13562 (struct cmd_vf_vlan_anti_spoof_result,
13564 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13565 TOKEN_NUM_INITIALIZER
13566 (struct cmd_vf_vlan_anti_spoof_result,
13568 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13569 TOKEN_STRING_INITIALIZER
13570 (struct cmd_vf_vlan_anti_spoof_result,
13574 cmd_set_vf_vlan_anti_spoof_parsed(
13575 void *parsed_result,
13576 __rte_unused struct cmdline *cl,
13577 __rte_unused void *data)
13579 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13580 int ret = -ENOTSUP;
13582 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13584 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13587 #ifdef RTE_LIBRTE_IXGBE_PMD
13588 if (ret == -ENOTSUP)
13589 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13590 res->vf_id, is_on);
13592 #ifdef RTE_LIBRTE_I40E_PMD
13593 if (ret == -ENOTSUP)
13594 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13595 res->vf_id, is_on);
13597 #ifdef RTE_LIBRTE_BNXT_PMD
13598 if (ret == -ENOTSUP)
13599 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13600 res->vf_id, is_on);
13607 printf("invalid vf_id %d\n", res->vf_id);
13610 printf("invalid port_id %d\n", res->port_id);
13613 printf("function not implemented\n");
13616 printf("programming error: (%s)\n", strerror(-ret));
13620 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13621 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13623 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13625 (void *)&cmd_vf_vlan_anti_spoof_set,
13626 (void *)&cmd_vf_vlan_anti_spoof_vf,
13627 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13628 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13629 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13630 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13631 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13636 /* vf mac anti spoof configuration */
13638 /* Common result structure for vf mac anti spoof */
13639 struct cmd_vf_mac_anti_spoof_result {
13640 cmdline_fixed_string_t set;
13641 cmdline_fixed_string_t vf;
13642 cmdline_fixed_string_t mac;
13643 cmdline_fixed_string_t antispoof;
13646 cmdline_fixed_string_t on_off;
13649 /* Common CLI fields for vf mac anti spoof enable disable */
13650 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13651 TOKEN_STRING_INITIALIZER
13652 (struct cmd_vf_mac_anti_spoof_result,
13654 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13655 TOKEN_STRING_INITIALIZER
13656 (struct cmd_vf_mac_anti_spoof_result,
13658 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13659 TOKEN_STRING_INITIALIZER
13660 (struct cmd_vf_mac_anti_spoof_result,
13662 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13663 TOKEN_STRING_INITIALIZER
13664 (struct cmd_vf_mac_anti_spoof_result,
13665 antispoof, "antispoof");
13666 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13667 TOKEN_NUM_INITIALIZER
13668 (struct cmd_vf_mac_anti_spoof_result,
13670 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13671 TOKEN_NUM_INITIALIZER
13672 (struct cmd_vf_mac_anti_spoof_result,
13674 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13675 TOKEN_STRING_INITIALIZER
13676 (struct cmd_vf_mac_anti_spoof_result,
13680 cmd_set_vf_mac_anti_spoof_parsed(
13681 void *parsed_result,
13682 __rte_unused struct cmdline *cl,
13683 __rte_unused void *data)
13685 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13686 int ret = -ENOTSUP;
13688 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13690 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13693 #ifdef RTE_LIBRTE_IXGBE_PMD
13694 if (ret == -ENOTSUP)
13695 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13696 res->vf_id, is_on);
13698 #ifdef RTE_LIBRTE_I40E_PMD
13699 if (ret == -ENOTSUP)
13700 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13701 res->vf_id, is_on);
13703 #ifdef RTE_LIBRTE_BNXT_PMD
13704 if (ret == -ENOTSUP)
13705 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13706 res->vf_id, is_on);
13713 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13716 printf("invalid port_id %d\n", res->port_id);
13719 printf("function not implemented\n");
13722 printf("programming error: (%s)\n", strerror(-ret));
13726 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13727 .f = cmd_set_vf_mac_anti_spoof_parsed,
13729 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13731 (void *)&cmd_vf_mac_anti_spoof_set,
13732 (void *)&cmd_vf_mac_anti_spoof_vf,
13733 (void *)&cmd_vf_mac_anti_spoof_mac,
13734 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13735 (void *)&cmd_vf_mac_anti_spoof_port_id,
13736 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13737 (void *)&cmd_vf_mac_anti_spoof_on_off,
13742 /* vf vlan strip queue configuration */
13744 /* Common result structure for vf mac anti spoof */
13745 struct cmd_vf_vlan_stripq_result {
13746 cmdline_fixed_string_t set;
13747 cmdline_fixed_string_t vf;
13748 cmdline_fixed_string_t vlan;
13749 cmdline_fixed_string_t stripq;
13752 cmdline_fixed_string_t on_off;
13755 /* Common CLI fields for vf vlan strip enable disable */
13756 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13757 TOKEN_STRING_INITIALIZER
13758 (struct cmd_vf_vlan_stripq_result,
13760 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13761 TOKEN_STRING_INITIALIZER
13762 (struct cmd_vf_vlan_stripq_result,
13764 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13765 TOKEN_STRING_INITIALIZER
13766 (struct cmd_vf_vlan_stripq_result,
13768 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13769 TOKEN_STRING_INITIALIZER
13770 (struct cmd_vf_vlan_stripq_result,
13772 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13773 TOKEN_NUM_INITIALIZER
13774 (struct cmd_vf_vlan_stripq_result,
13776 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13777 TOKEN_NUM_INITIALIZER
13778 (struct cmd_vf_vlan_stripq_result,
13780 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13781 TOKEN_STRING_INITIALIZER
13782 (struct cmd_vf_vlan_stripq_result,
13786 cmd_set_vf_vlan_stripq_parsed(
13787 void *parsed_result,
13788 __rte_unused struct cmdline *cl,
13789 __rte_unused void *data)
13791 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13792 int ret = -ENOTSUP;
13794 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13796 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13799 #ifdef RTE_LIBRTE_IXGBE_PMD
13800 if (ret == -ENOTSUP)
13801 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13802 res->vf_id, is_on);
13804 #ifdef RTE_LIBRTE_I40E_PMD
13805 if (ret == -ENOTSUP)
13806 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13807 res->vf_id, is_on);
13809 #ifdef RTE_LIBRTE_BNXT_PMD
13810 if (ret == -ENOTSUP)
13811 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13812 res->vf_id, is_on);
13819 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13822 printf("invalid port_id %d\n", res->port_id);
13825 printf("function not implemented\n");
13828 printf("programming error: (%s)\n", strerror(-ret));
13832 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13833 .f = cmd_set_vf_vlan_stripq_parsed,
13835 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13837 (void *)&cmd_vf_vlan_stripq_set,
13838 (void *)&cmd_vf_vlan_stripq_vf,
13839 (void *)&cmd_vf_vlan_stripq_vlan,
13840 (void *)&cmd_vf_vlan_stripq_stripq,
13841 (void *)&cmd_vf_vlan_stripq_port_id,
13842 (void *)&cmd_vf_vlan_stripq_vf_id,
13843 (void *)&cmd_vf_vlan_stripq_on_off,
13848 /* vf vlan insert configuration */
13850 /* Common result structure for vf vlan insert */
13851 struct cmd_vf_vlan_insert_result {
13852 cmdline_fixed_string_t set;
13853 cmdline_fixed_string_t vf;
13854 cmdline_fixed_string_t vlan;
13855 cmdline_fixed_string_t insert;
13861 /* Common CLI fields for vf vlan insert enable disable */
13862 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13863 TOKEN_STRING_INITIALIZER
13864 (struct cmd_vf_vlan_insert_result,
13866 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13867 TOKEN_STRING_INITIALIZER
13868 (struct cmd_vf_vlan_insert_result,
13870 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13871 TOKEN_STRING_INITIALIZER
13872 (struct cmd_vf_vlan_insert_result,
13874 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13875 TOKEN_STRING_INITIALIZER
13876 (struct cmd_vf_vlan_insert_result,
13878 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13879 TOKEN_NUM_INITIALIZER
13880 (struct cmd_vf_vlan_insert_result,
13882 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13883 TOKEN_NUM_INITIALIZER
13884 (struct cmd_vf_vlan_insert_result,
13886 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13887 TOKEN_NUM_INITIALIZER
13888 (struct cmd_vf_vlan_insert_result,
13892 cmd_set_vf_vlan_insert_parsed(
13893 void *parsed_result,
13894 __rte_unused struct cmdline *cl,
13895 __rte_unused void *data)
13897 struct cmd_vf_vlan_insert_result *res = parsed_result;
13898 int ret = -ENOTSUP;
13900 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13903 #ifdef RTE_LIBRTE_IXGBE_PMD
13904 if (ret == -ENOTSUP)
13905 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13908 #ifdef RTE_LIBRTE_I40E_PMD
13909 if (ret == -ENOTSUP)
13910 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13913 #ifdef RTE_LIBRTE_BNXT_PMD
13914 if (ret == -ENOTSUP)
13915 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13923 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13926 printf("invalid port_id %d\n", res->port_id);
13929 printf("function not implemented\n");
13932 printf("programming error: (%s)\n", strerror(-ret));
13936 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13937 .f = cmd_set_vf_vlan_insert_parsed,
13939 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13941 (void *)&cmd_vf_vlan_insert_set,
13942 (void *)&cmd_vf_vlan_insert_vf,
13943 (void *)&cmd_vf_vlan_insert_vlan,
13944 (void *)&cmd_vf_vlan_insert_insert,
13945 (void *)&cmd_vf_vlan_insert_port_id,
13946 (void *)&cmd_vf_vlan_insert_vf_id,
13947 (void *)&cmd_vf_vlan_insert_vlan_id,
13952 /* tx loopback configuration */
13954 /* Common result structure for tx loopback */
13955 struct cmd_tx_loopback_result {
13956 cmdline_fixed_string_t set;
13957 cmdline_fixed_string_t tx;
13958 cmdline_fixed_string_t loopback;
13960 cmdline_fixed_string_t on_off;
13963 /* Common CLI fields for tx loopback enable disable */
13964 cmdline_parse_token_string_t cmd_tx_loopback_set =
13965 TOKEN_STRING_INITIALIZER
13966 (struct cmd_tx_loopback_result,
13968 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13969 TOKEN_STRING_INITIALIZER
13970 (struct cmd_tx_loopback_result,
13972 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13973 TOKEN_STRING_INITIALIZER
13974 (struct cmd_tx_loopback_result,
13975 loopback, "loopback");
13976 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13977 TOKEN_NUM_INITIALIZER
13978 (struct cmd_tx_loopback_result,
13980 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13981 TOKEN_STRING_INITIALIZER
13982 (struct cmd_tx_loopback_result,
13986 cmd_set_tx_loopback_parsed(
13987 void *parsed_result,
13988 __rte_unused struct cmdline *cl,
13989 __rte_unused void *data)
13991 struct cmd_tx_loopback_result *res = parsed_result;
13992 int ret = -ENOTSUP;
13994 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13996 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13999 #ifdef RTE_LIBRTE_IXGBE_PMD
14000 if (ret == -ENOTSUP)
14001 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
14003 #ifdef RTE_LIBRTE_I40E_PMD
14004 if (ret == -ENOTSUP)
14005 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
14007 #ifdef RTE_LIBRTE_BNXT_PMD
14008 if (ret == -ENOTSUP)
14009 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
14011 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
14012 if (ret == -ENOTSUP)
14013 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
14020 printf("invalid is_on %d\n", is_on);
14023 printf("invalid port_id %d\n", res->port_id);
14026 printf("function not implemented\n");
14029 printf("programming error: (%s)\n", strerror(-ret));
14033 cmdline_parse_inst_t cmd_set_tx_loopback = {
14034 .f = cmd_set_tx_loopback_parsed,
14036 .help_str = "set tx loopback <port_id> on|off",
14038 (void *)&cmd_tx_loopback_set,
14039 (void *)&cmd_tx_loopback_tx,
14040 (void *)&cmd_tx_loopback_loopback,
14041 (void *)&cmd_tx_loopback_port_id,
14042 (void *)&cmd_tx_loopback_on_off,
14047 /* all queues drop enable configuration */
14049 /* Common result structure for all queues drop enable */
14050 struct cmd_all_queues_drop_en_result {
14051 cmdline_fixed_string_t set;
14052 cmdline_fixed_string_t all;
14053 cmdline_fixed_string_t queues;
14054 cmdline_fixed_string_t drop;
14056 cmdline_fixed_string_t on_off;
14059 /* Common CLI fields for tx loopback enable disable */
14060 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
14061 TOKEN_STRING_INITIALIZER
14062 (struct cmd_all_queues_drop_en_result,
14064 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
14065 TOKEN_STRING_INITIALIZER
14066 (struct cmd_all_queues_drop_en_result,
14068 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
14069 TOKEN_STRING_INITIALIZER
14070 (struct cmd_all_queues_drop_en_result,
14072 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
14073 TOKEN_STRING_INITIALIZER
14074 (struct cmd_all_queues_drop_en_result,
14076 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
14077 TOKEN_NUM_INITIALIZER
14078 (struct cmd_all_queues_drop_en_result,
14080 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
14081 TOKEN_STRING_INITIALIZER
14082 (struct cmd_all_queues_drop_en_result,
14086 cmd_set_all_queues_drop_en_parsed(
14087 void *parsed_result,
14088 __rte_unused struct cmdline *cl,
14089 __rte_unused void *data)
14091 struct cmd_all_queues_drop_en_result *res = parsed_result;
14092 int ret = -ENOTSUP;
14093 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14095 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14098 #ifdef RTE_LIBRTE_IXGBE_PMD
14099 if (ret == -ENOTSUP)
14100 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
14102 #ifdef RTE_LIBRTE_BNXT_PMD
14103 if (ret == -ENOTSUP)
14104 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
14110 printf("invalid is_on %d\n", is_on);
14113 printf("invalid port_id %d\n", res->port_id);
14116 printf("function not implemented\n");
14119 printf("programming error: (%s)\n", strerror(-ret));
14123 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
14124 .f = cmd_set_all_queues_drop_en_parsed,
14126 .help_str = "set all queues drop <port_id> on|off",
14128 (void *)&cmd_all_queues_drop_en_set,
14129 (void *)&cmd_all_queues_drop_en_all,
14130 (void *)&cmd_all_queues_drop_en_queues,
14131 (void *)&cmd_all_queues_drop_en_drop,
14132 (void *)&cmd_all_queues_drop_en_port_id,
14133 (void *)&cmd_all_queues_drop_en_on_off,
14138 /* vf split drop enable configuration */
14140 /* Common result structure for vf split drop enable */
14141 struct cmd_vf_split_drop_en_result {
14142 cmdline_fixed_string_t set;
14143 cmdline_fixed_string_t vf;
14144 cmdline_fixed_string_t split;
14145 cmdline_fixed_string_t drop;
14148 cmdline_fixed_string_t on_off;
14151 /* Common CLI fields for vf split drop enable disable */
14152 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
14153 TOKEN_STRING_INITIALIZER
14154 (struct cmd_vf_split_drop_en_result,
14156 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
14157 TOKEN_STRING_INITIALIZER
14158 (struct cmd_vf_split_drop_en_result,
14160 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
14161 TOKEN_STRING_INITIALIZER
14162 (struct cmd_vf_split_drop_en_result,
14164 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
14165 TOKEN_STRING_INITIALIZER
14166 (struct cmd_vf_split_drop_en_result,
14168 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
14169 TOKEN_NUM_INITIALIZER
14170 (struct cmd_vf_split_drop_en_result,
14172 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
14173 TOKEN_NUM_INITIALIZER
14174 (struct cmd_vf_split_drop_en_result,
14176 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
14177 TOKEN_STRING_INITIALIZER
14178 (struct cmd_vf_split_drop_en_result,
14182 cmd_set_vf_split_drop_en_parsed(
14183 void *parsed_result,
14184 __rte_unused struct cmdline *cl,
14185 __rte_unused void *data)
14187 struct cmd_vf_split_drop_en_result *res = parsed_result;
14188 int ret = -ENOTSUP;
14189 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14191 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14194 #ifdef RTE_LIBRTE_IXGBE_PMD
14195 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14202 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14205 printf("invalid port_id %d\n", res->port_id);
14208 printf("not supported on port %d\n", res->port_id);
14211 printf("programming error: (%s)\n", strerror(-ret));
14215 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14216 .f = cmd_set_vf_split_drop_en_parsed,
14218 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14220 (void *)&cmd_vf_split_drop_en_set,
14221 (void *)&cmd_vf_split_drop_en_vf,
14222 (void *)&cmd_vf_split_drop_en_split,
14223 (void *)&cmd_vf_split_drop_en_drop,
14224 (void *)&cmd_vf_split_drop_en_port_id,
14225 (void *)&cmd_vf_split_drop_en_vf_id,
14226 (void *)&cmd_vf_split_drop_en_on_off,
14231 /* vf mac address configuration */
14233 /* Common result structure for vf mac address */
14234 struct cmd_set_vf_mac_addr_result {
14235 cmdline_fixed_string_t set;
14236 cmdline_fixed_string_t vf;
14237 cmdline_fixed_string_t mac;
14238 cmdline_fixed_string_t addr;
14241 struct rte_ether_addr mac_addr;
14245 /* Common CLI fields for vf split drop enable disable */
14246 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14247 TOKEN_STRING_INITIALIZER
14248 (struct cmd_set_vf_mac_addr_result,
14250 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14251 TOKEN_STRING_INITIALIZER
14252 (struct cmd_set_vf_mac_addr_result,
14254 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14255 TOKEN_STRING_INITIALIZER
14256 (struct cmd_set_vf_mac_addr_result,
14258 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14259 TOKEN_STRING_INITIALIZER
14260 (struct cmd_set_vf_mac_addr_result,
14262 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14263 TOKEN_NUM_INITIALIZER
14264 (struct cmd_set_vf_mac_addr_result,
14266 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14267 TOKEN_NUM_INITIALIZER
14268 (struct cmd_set_vf_mac_addr_result,
14270 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14271 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14275 cmd_set_vf_mac_addr_parsed(
14276 void *parsed_result,
14277 __rte_unused struct cmdline *cl,
14278 __rte_unused void *data)
14280 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14281 int ret = -ENOTSUP;
14283 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14286 #ifdef RTE_LIBRTE_IXGBE_PMD
14287 if (ret == -ENOTSUP)
14288 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14291 #ifdef RTE_LIBRTE_I40E_PMD
14292 if (ret == -ENOTSUP)
14293 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14296 #ifdef RTE_LIBRTE_BNXT_PMD
14297 if (ret == -ENOTSUP)
14298 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14306 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14309 printf("invalid port_id %d\n", res->port_id);
14312 printf("function not implemented\n");
14315 printf("programming error: (%s)\n", strerror(-ret));
14319 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14320 .f = cmd_set_vf_mac_addr_parsed,
14322 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14324 (void *)&cmd_set_vf_mac_addr_set,
14325 (void *)&cmd_set_vf_mac_addr_vf,
14326 (void *)&cmd_set_vf_mac_addr_mac,
14327 (void *)&cmd_set_vf_mac_addr_addr,
14328 (void *)&cmd_set_vf_mac_addr_port_id,
14329 (void *)&cmd_set_vf_mac_addr_vf_id,
14330 (void *)&cmd_set_vf_mac_addr_mac_addr,
14335 /* MACsec configuration */
14337 /* Common result structure for MACsec offload enable */
14338 struct cmd_macsec_offload_on_result {
14339 cmdline_fixed_string_t set;
14340 cmdline_fixed_string_t macsec;
14341 cmdline_fixed_string_t offload;
14343 cmdline_fixed_string_t on;
14344 cmdline_fixed_string_t encrypt;
14345 cmdline_fixed_string_t en_on_off;
14346 cmdline_fixed_string_t replay_protect;
14347 cmdline_fixed_string_t rp_on_off;
14350 /* Common CLI fields for MACsec offload disable */
14351 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14352 TOKEN_STRING_INITIALIZER
14353 (struct cmd_macsec_offload_on_result,
14355 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14356 TOKEN_STRING_INITIALIZER
14357 (struct cmd_macsec_offload_on_result,
14359 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14360 TOKEN_STRING_INITIALIZER
14361 (struct cmd_macsec_offload_on_result,
14362 offload, "offload");
14363 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14364 TOKEN_NUM_INITIALIZER
14365 (struct cmd_macsec_offload_on_result,
14367 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14368 TOKEN_STRING_INITIALIZER
14369 (struct cmd_macsec_offload_on_result,
14371 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14372 TOKEN_STRING_INITIALIZER
14373 (struct cmd_macsec_offload_on_result,
14374 encrypt, "encrypt");
14375 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14376 TOKEN_STRING_INITIALIZER
14377 (struct cmd_macsec_offload_on_result,
14378 en_on_off, "on#off");
14379 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14380 TOKEN_STRING_INITIALIZER
14381 (struct cmd_macsec_offload_on_result,
14382 replay_protect, "replay-protect");
14383 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14384 TOKEN_STRING_INITIALIZER
14385 (struct cmd_macsec_offload_on_result,
14386 rp_on_off, "on#off");
14389 cmd_set_macsec_offload_on_parsed(
14390 void *parsed_result,
14391 __rte_unused struct cmdline *cl,
14392 __rte_unused void *data)
14394 struct cmd_macsec_offload_on_result *res = parsed_result;
14395 int ret = -ENOTSUP;
14396 portid_t port_id = res->port_id;
14397 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14398 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14399 struct rte_eth_dev_info dev_info;
14401 if (port_id_is_invalid(port_id, ENABLED_WARN))
14403 if (!port_is_stopped(port_id)) {
14404 printf("Please stop port %d first\n", port_id);
14408 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14412 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14413 #ifdef RTE_LIBRTE_IXGBE_PMD
14414 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14422 ports[port_id].dev_conf.txmode.offloads |=
14423 DEV_TX_OFFLOAD_MACSEC_INSERT;
14424 cmd_reconfig_device_queue(port_id, 1, 1);
14427 printf("invalid port_id %d\n", port_id);
14430 printf("not supported on port %d\n", port_id);
14433 printf("programming error: (%s)\n", strerror(-ret));
14437 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14438 .f = cmd_set_macsec_offload_on_parsed,
14440 .help_str = "set macsec offload <port_id> on "
14441 "encrypt on|off replay-protect on|off",
14443 (void *)&cmd_macsec_offload_on_set,
14444 (void *)&cmd_macsec_offload_on_macsec,
14445 (void *)&cmd_macsec_offload_on_offload,
14446 (void *)&cmd_macsec_offload_on_port_id,
14447 (void *)&cmd_macsec_offload_on_on,
14448 (void *)&cmd_macsec_offload_on_encrypt,
14449 (void *)&cmd_macsec_offload_on_en_on_off,
14450 (void *)&cmd_macsec_offload_on_replay_protect,
14451 (void *)&cmd_macsec_offload_on_rp_on_off,
14456 /* Common result structure for MACsec offload disable */
14457 struct cmd_macsec_offload_off_result {
14458 cmdline_fixed_string_t set;
14459 cmdline_fixed_string_t macsec;
14460 cmdline_fixed_string_t offload;
14462 cmdline_fixed_string_t off;
14465 /* Common CLI fields for MACsec offload disable */
14466 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14467 TOKEN_STRING_INITIALIZER
14468 (struct cmd_macsec_offload_off_result,
14470 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14471 TOKEN_STRING_INITIALIZER
14472 (struct cmd_macsec_offload_off_result,
14474 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14475 TOKEN_STRING_INITIALIZER
14476 (struct cmd_macsec_offload_off_result,
14477 offload, "offload");
14478 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14479 TOKEN_NUM_INITIALIZER
14480 (struct cmd_macsec_offload_off_result,
14482 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14483 TOKEN_STRING_INITIALIZER
14484 (struct cmd_macsec_offload_off_result,
14488 cmd_set_macsec_offload_off_parsed(
14489 void *parsed_result,
14490 __rte_unused struct cmdline *cl,
14491 __rte_unused void *data)
14493 struct cmd_macsec_offload_off_result *res = parsed_result;
14494 int ret = -ENOTSUP;
14495 struct rte_eth_dev_info dev_info;
14496 portid_t port_id = res->port_id;
14498 if (port_id_is_invalid(port_id, ENABLED_WARN))
14500 if (!port_is_stopped(port_id)) {
14501 printf("Please stop port %d first\n", port_id);
14505 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14509 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14510 #ifdef RTE_LIBRTE_IXGBE_PMD
14511 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14516 ports[port_id].dev_conf.txmode.offloads &=
14517 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14518 cmd_reconfig_device_queue(port_id, 1, 1);
14521 printf("invalid port_id %d\n", port_id);
14524 printf("not supported on port %d\n", port_id);
14527 printf("programming error: (%s)\n", strerror(-ret));
14531 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14532 .f = cmd_set_macsec_offload_off_parsed,
14534 .help_str = "set macsec offload <port_id> off",
14536 (void *)&cmd_macsec_offload_off_set,
14537 (void *)&cmd_macsec_offload_off_macsec,
14538 (void *)&cmd_macsec_offload_off_offload,
14539 (void *)&cmd_macsec_offload_off_port_id,
14540 (void *)&cmd_macsec_offload_off_off,
14545 /* Common result structure for MACsec secure connection configure */
14546 struct cmd_macsec_sc_result {
14547 cmdline_fixed_string_t set;
14548 cmdline_fixed_string_t macsec;
14549 cmdline_fixed_string_t sc;
14550 cmdline_fixed_string_t tx_rx;
14552 struct rte_ether_addr mac;
14556 /* Common CLI fields for MACsec secure connection configure */
14557 cmdline_parse_token_string_t cmd_macsec_sc_set =
14558 TOKEN_STRING_INITIALIZER
14559 (struct cmd_macsec_sc_result,
14561 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14562 TOKEN_STRING_INITIALIZER
14563 (struct cmd_macsec_sc_result,
14565 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14566 TOKEN_STRING_INITIALIZER
14567 (struct cmd_macsec_sc_result,
14569 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14570 TOKEN_STRING_INITIALIZER
14571 (struct cmd_macsec_sc_result,
14573 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14574 TOKEN_NUM_INITIALIZER
14575 (struct cmd_macsec_sc_result,
14577 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14578 TOKEN_ETHERADDR_INITIALIZER
14579 (struct cmd_macsec_sc_result,
14581 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14582 TOKEN_NUM_INITIALIZER
14583 (struct cmd_macsec_sc_result,
14587 cmd_set_macsec_sc_parsed(
14588 void *parsed_result,
14589 __rte_unused struct cmdline *cl,
14590 __rte_unused void *data)
14592 struct cmd_macsec_sc_result *res = parsed_result;
14593 int ret = -ENOTSUP;
14594 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14596 #ifdef RTE_LIBRTE_IXGBE_PMD
14598 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14599 res->mac.addr_bytes) :
14600 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14601 res->mac.addr_bytes, res->pi);
14603 RTE_SET_USED(is_tx);
14609 printf("invalid port_id %d\n", res->port_id);
14612 printf("not supported on port %d\n", res->port_id);
14615 printf("programming error: (%s)\n", strerror(-ret));
14619 cmdline_parse_inst_t cmd_set_macsec_sc = {
14620 .f = cmd_set_macsec_sc_parsed,
14622 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14624 (void *)&cmd_macsec_sc_set,
14625 (void *)&cmd_macsec_sc_macsec,
14626 (void *)&cmd_macsec_sc_sc,
14627 (void *)&cmd_macsec_sc_tx_rx,
14628 (void *)&cmd_macsec_sc_port_id,
14629 (void *)&cmd_macsec_sc_mac,
14630 (void *)&cmd_macsec_sc_pi,
14635 /* Common result structure for MACsec secure connection configure */
14636 struct cmd_macsec_sa_result {
14637 cmdline_fixed_string_t set;
14638 cmdline_fixed_string_t macsec;
14639 cmdline_fixed_string_t sa;
14640 cmdline_fixed_string_t tx_rx;
14645 cmdline_fixed_string_t key;
14648 /* Common CLI fields for MACsec secure connection configure */
14649 cmdline_parse_token_string_t cmd_macsec_sa_set =
14650 TOKEN_STRING_INITIALIZER
14651 (struct cmd_macsec_sa_result,
14653 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14654 TOKEN_STRING_INITIALIZER
14655 (struct cmd_macsec_sa_result,
14657 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14658 TOKEN_STRING_INITIALIZER
14659 (struct cmd_macsec_sa_result,
14661 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14662 TOKEN_STRING_INITIALIZER
14663 (struct cmd_macsec_sa_result,
14665 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14666 TOKEN_NUM_INITIALIZER
14667 (struct cmd_macsec_sa_result,
14669 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14670 TOKEN_NUM_INITIALIZER
14671 (struct cmd_macsec_sa_result,
14673 cmdline_parse_token_num_t cmd_macsec_sa_an =
14674 TOKEN_NUM_INITIALIZER
14675 (struct cmd_macsec_sa_result,
14677 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14678 TOKEN_NUM_INITIALIZER
14679 (struct cmd_macsec_sa_result,
14681 cmdline_parse_token_string_t cmd_macsec_sa_key =
14682 TOKEN_STRING_INITIALIZER
14683 (struct cmd_macsec_sa_result,
14687 cmd_set_macsec_sa_parsed(
14688 void *parsed_result,
14689 __rte_unused struct cmdline *cl,
14690 __rte_unused void *data)
14692 struct cmd_macsec_sa_result *res = parsed_result;
14693 int ret = -ENOTSUP;
14694 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14695 uint8_t key[16] = { 0 };
14701 key_len = strlen(res->key) / 2;
14705 for (i = 0; i < key_len; i++) {
14706 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14709 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14712 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14715 #ifdef RTE_LIBRTE_IXGBE_PMD
14717 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14718 res->idx, res->an, res->pn, key) :
14719 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14720 res->idx, res->an, res->pn, key);
14722 RTE_SET_USED(is_tx);
14729 printf("invalid idx %d or an %d\n", res->idx, res->an);
14732 printf("invalid port_id %d\n", res->port_id);
14735 printf("not supported on port %d\n", res->port_id);
14738 printf("programming error: (%s)\n", strerror(-ret));
14742 cmdline_parse_inst_t cmd_set_macsec_sa = {
14743 .f = cmd_set_macsec_sa_parsed,
14745 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14747 (void *)&cmd_macsec_sa_set,
14748 (void *)&cmd_macsec_sa_macsec,
14749 (void *)&cmd_macsec_sa_sa,
14750 (void *)&cmd_macsec_sa_tx_rx,
14751 (void *)&cmd_macsec_sa_port_id,
14752 (void *)&cmd_macsec_sa_idx,
14753 (void *)&cmd_macsec_sa_an,
14754 (void *)&cmd_macsec_sa_pn,
14755 (void *)&cmd_macsec_sa_key,
14760 /* VF unicast promiscuous mode configuration */
14762 /* Common result structure for VF unicast promiscuous mode */
14763 struct cmd_vf_promisc_result {
14764 cmdline_fixed_string_t set;
14765 cmdline_fixed_string_t vf;
14766 cmdline_fixed_string_t promisc;
14769 cmdline_fixed_string_t on_off;
14772 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14773 cmdline_parse_token_string_t cmd_vf_promisc_set =
14774 TOKEN_STRING_INITIALIZER
14775 (struct cmd_vf_promisc_result,
14777 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14778 TOKEN_STRING_INITIALIZER
14779 (struct cmd_vf_promisc_result,
14781 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14782 TOKEN_STRING_INITIALIZER
14783 (struct cmd_vf_promisc_result,
14784 promisc, "promisc");
14785 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14786 TOKEN_NUM_INITIALIZER
14787 (struct cmd_vf_promisc_result,
14789 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14790 TOKEN_NUM_INITIALIZER
14791 (struct cmd_vf_promisc_result,
14793 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14794 TOKEN_STRING_INITIALIZER
14795 (struct cmd_vf_promisc_result,
14799 cmd_set_vf_promisc_parsed(
14800 void *parsed_result,
14801 __rte_unused struct cmdline *cl,
14802 __rte_unused void *data)
14804 struct cmd_vf_promisc_result *res = parsed_result;
14805 int ret = -ENOTSUP;
14807 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14809 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14812 #ifdef RTE_LIBRTE_I40E_PMD
14813 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14814 res->vf_id, is_on);
14821 printf("invalid vf_id %d\n", res->vf_id);
14824 printf("invalid port_id %d\n", res->port_id);
14827 printf("function not implemented\n");
14830 printf("programming error: (%s)\n", strerror(-ret));
14834 cmdline_parse_inst_t cmd_set_vf_promisc = {
14835 .f = cmd_set_vf_promisc_parsed,
14837 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14838 "Set unicast promiscuous mode for a VF from the PF",
14840 (void *)&cmd_vf_promisc_set,
14841 (void *)&cmd_vf_promisc_vf,
14842 (void *)&cmd_vf_promisc_promisc,
14843 (void *)&cmd_vf_promisc_port_id,
14844 (void *)&cmd_vf_promisc_vf_id,
14845 (void *)&cmd_vf_promisc_on_off,
14850 /* VF multicast promiscuous mode configuration */
14852 /* Common result structure for VF multicast promiscuous mode */
14853 struct cmd_vf_allmulti_result {
14854 cmdline_fixed_string_t set;
14855 cmdline_fixed_string_t vf;
14856 cmdline_fixed_string_t allmulti;
14859 cmdline_fixed_string_t on_off;
14862 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14863 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14864 TOKEN_STRING_INITIALIZER
14865 (struct cmd_vf_allmulti_result,
14867 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14868 TOKEN_STRING_INITIALIZER
14869 (struct cmd_vf_allmulti_result,
14871 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14872 TOKEN_STRING_INITIALIZER
14873 (struct cmd_vf_allmulti_result,
14874 allmulti, "allmulti");
14875 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14876 TOKEN_NUM_INITIALIZER
14877 (struct cmd_vf_allmulti_result,
14879 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14880 TOKEN_NUM_INITIALIZER
14881 (struct cmd_vf_allmulti_result,
14883 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14884 TOKEN_STRING_INITIALIZER
14885 (struct cmd_vf_allmulti_result,
14889 cmd_set_vf_allmulti_parsed(
14890 void *parsed_result,
14891 __rte_unused struct cmdline *cl,
14892 __rte_unused void *data)
14894 struct cmd_vf_allmulti_result *res = parsed_result;
14895 int ret = -ENOTSUP;
14897 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14899 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14902 #ifdef RTE_LIBRTE_I40E_PMD
14903 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14904 res->vf_id, is_on);
14911 printf("invalid vf_id %d\n", res->vf_id);
14914 printf("invalid port_id %d\n", res->port_id);
14917 printf("function not implemented\n");
14920 printf("programming error: (%s)\n", strerror(-ret));
14924 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14925 .f = cmd_set_vf_allmulti_parsed,
14927 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14928 "Set multicast promiscuous mode for a VF from the PF",
14930 (void *)&cmd_vf_allmulti_set,
14931 (void *)&cmd_vf_allmulti_vf,
14932 (void *)&cmd_vf_allmulti_allmulti,
14933 (void *)&cmd_vf_allmulti_port_id,
14934 (void *)&cmd_vf_allmulti_vf_id,
14935 (void *)&cmd_vf_allmulti_on_off,
14940 /* vf broadcast mode configuration */
14942 /* Common result structure for vf broadcast */
14943 struct cmd_set_vf_broadcast_result {
14944 cmdline_fixed_string_t set;
14945 cmdline_fixed_string_t vf;
14946 cmdline_fixed_string_t broadcast;
14949 cmdline_fixed_string_t on_off;
14952 /* Common CLI fields for vf broadcast enable disable */
14953 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14954 TOKEN_STRING_INITIALIZER
14955 (struct cmd_set_vf_broadcast_result,
14957 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14958 TOKEN_STRING_INITIALIZER
14959 (struct cmd_set_vf_broadcast_result,
14961 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14962 TOKEN_STRING_INITIALIZER
14963 (struct cmd_set_vf_broadcast_result,
14964 broadcast, "broadcast");
14965 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14966 TOKEN_NUM_INITIALIZER
14967 (struct cmd_set_vf_broadcast_result,
14969 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14970 TOKEN_NUM_INITIALIZER
14971 (struct cmd_set_vf_broadcast_result,
14973 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14974 TOKEN_STRING_INITIALIZER
14975 (struct cmd_set_vf_broadcast_result,
14979 cmd_set_vf_broadcast_parsed(
14980 void *parsed_result,
14981 __rte_unused struct cmdline *cl,
14982 __rte_unused void *data)
14984 struct cmd_set_vf_broadcast_result *res = parsed_result;
14985 int ret = -ENOTSUP;
14987 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14989 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14992 #ifdef RTE_LIBRTE_I40E_PMD
14993 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14994 res->vf_id, is_on);
15001 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15004 printf("invalid port_id %d\n", res->port_id);
15007 printf("function not implemented\n");
15010 printf("programming error: (%s)\n", strerror(-ret));
15014 cmdline_parse_inst_t cmd_set_vf_broadcast = {
15015 .f = cmd_set_vf_broadcast_parsed,
15017 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
15019 (void *)&cmd_set_vf_broadcast_set,
15020 (void *)&cmd_set_vf_broadcast_vf,
15021 (void *)&cmd_set_vf_broadcast_broadcast,
15022 (void *)&cmd_set_vf_broadcast_port_id,
15023 (void *)&cmd_set_vf_broadcast_vf_id,
15024 (void *)&cmd_set_vf_broadcast_on_off,
15029 /* vf vlan tag configuration */
15031 /* Common result structure for vf vlan tag */
15032 struct cmd_set_vf_vlan_tag_result {
15033 cmdline_fixed_string_t set;
15034 cmdline_fixed_string_t vf;
15035 cmdline_fixed_string_t vlan;
15036 cmdline_fixed_string_t tag;
15039 cmdline_fixed_string_t on_off;
15042 /* Common CLI fields for vf vlan tag enable disable */
15043 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
15044 TOKEN_STRING_INITIALIZER
15045 (struct cmd_set_vf_vlan_tag_result,
15047 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
15048 TOKEN_STRING_INITIALIZER
15049 (struct cmd_set_vf_vlan_tag_result,
15051 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
15052 TOKEN_STRING_INITIALIZER
15053 (struct cmd_set_vf_vlan_tag_result,
15055 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
15056 TOKEN_STRING_INITIALIZER
15057 (struct cmd_set_vf_vlan_tag_result,
15059 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
15060 TOKEN_NUM_INITIALIZER
15061 (struct cmd_set_vf_vlan_tag_result,
15063 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
15064 TOKEN_NUM_INITIALIZER
15065 (struct cmd_set_vf_vlan_tag_result,
15067 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
15068 TOKEN_STRING_INITIALIZER
15069 (struct cmd_set_vf_vlan_tag_result,
15073 cmd_set_vf_vlan_tag_parsed(
15074 void *parsed_result,
15075 __rte_unused struct cmdline *cl,
15076 __rte_unused void *data)
15078 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
15079 int ret = -ENOTSUP;
15081 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15083 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15086 #ifdef RTE_LIBRTE_I40E_PMD
15087 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
15088 res->vf_id, is_on);
15095 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15098 printf("invalid port_id %d\n", res->port_id);
15101 printf("function not implemented\n");
15104 printf("programming error: (%s)\n", strerror(-ret));
15108 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
15109 .f = cmd_set_vf_vlan_tag_parsed,
15111 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
15113 (void *)&cmd_set_vf_vlan_tag_set,
15114 (void *)&cmd_set_vf_vlan_tag_vf,
15115 (void *)&cmd_set_vf_vlan_tag_vlan,
15116 (void *)&cmd_set_vf_vlan_tag_tag,
15117 (void *)&cmd_set_vf_vlan_tag_port_id,
15118 (void *)&cmd_set_vf_vlan_tag_vf_id,
15119 (void *)&cmd_set_vf_vlan_tag_on_off,
15124 /* Common definition of VF and TC TX bandwidth configuration */
15125 struct cmd_vf_tc_bw_result {
15126 cmdline_fixed_string_t set;
15127 cmdline_fixed_string_t vf;
15128 cmdline_fixed_string_t tc;
15129 cmdline_fixed_string_t tx;
15130 cmdline_fixed_string_t min_bw;
15131 cmdline_fixed_string_t max_bw;
15132 cmdline_fixed_string_t strict_link_prio;
15137 cmdline_fixed_string_t bw_list;
15141 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
15142 TOKEN_STRING_INITIALIZER
15143 (struct cmd_vf_tc_bw_result,
15145 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
15146 TOKEN_STRING_INITIALIZER
15147 (struct cmd_vf_tc_bw_result,
15149 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
15150 TOKEN_STRING_INITIALIZER
15151 (struct cmd_vf_tc_bw_result,
15153 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
15154 TOKEN_STRING_INITIALIZER
15155 (struct cmd_vf_tc_bw_result,
15157 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
15158 TOKEN_STRING_INITIALIZER
15159 (struct cmd_vf_tc_bw_result,
15160 strict_link_prio, "strict-link-priority");
15161 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
15162 TOKEN_STRING_INITIALIZER
15163 (struct cmd_vf_tc_bw_result,
15164 min_bw, "min-bandwidth");
15165 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
15166 TOKEN_STRING_INITIALIZER
15167 (struct cmd_vf_tc_bw_result,
15168 max_bw, "max-bandwidth");
15169 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
15170 TOKEN_NUM_INITIALIZER
15171 (struct cmd_vf_tc_bw_result,
15173 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
15174 TOKEN_NUM_INITIALIZER
15175 (struct cmd_vf_tc_bw_result,
15177 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
15178 TOKEN_NUM_INITIALIZER
15179 (struct cmd_vf_tc_bw_result,
15181 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
15182 TOKEN_NUM_INITIALIZER
15183 (struct cmd_vf_tc_bw_result,
15185 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
15186 TOKEN_STRING_INITIALIZER
15187 (struct cmd_vf_tc_bw_result,
15189 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
15190 TOKEN_NUM_INITIALIZER
15191 (struct cmd_vf_tc_bw_result,
15194 /* VF max bandwidth setting */
15196 cmd_vf_max_bw_parsed(
15197 void *parsed_result,
15198 __rte_unused struct cmdline *cl,
15199 __rte_unused void *data)
15201 struct cmd_vf_tc_bw_result *res = parsed_result;
15202 int ret = -ENOTSUP;
15204 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15207 #ifdef RTE_LIBRTE_I40E_PMD
15208 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15209 res->vf_id, res->bw);
15216 printf("invalid vf_id %d or bandwidth %d\n",
15217 res->vf_id, res->bw);
15220 printf("invalid port_id %d\n", res->port_id);
15223 printf("function not implemented\n");
15226 printf("programming error: (%s)\n", strerror(-ret));
15230 cmdline_parse_inst_t cmd_vf_max_bw = {
15231 .f = cmd_vf_max_bw_parsed,
15233 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15235 (void *)&cmd_vf_tc_bw_set,
15236 (void *)&cmd_vf_tc_bw_vf,
15237 (void *)&cmd_vf_tc_bw_tx,
15238 (void *)&cmd_vf_tc_bw_max_bw,
15239 (void *)&cmd_vf_tc_bw_port_id,
15240 (void *)&cmd_vf_tc_bw_vf_id,
15241 (void *)&cmd_vf_tc_bw_bw,
15247 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15252 const char *p, *p0 = str;
15259 p = strchr(p0, '(');
15261 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15265 p0 = strchr(p, ')');
15267 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15271 if (size >= sizeof(s)) {
15272 printf("The string size exceeds the internal buffer size\n");
15275 snprintf(s, sizeof(s), "%.*s", size, p);
15276 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15278 printf("Failed to get the bandwidth list. ");
15282 for (i = 0; i < ret; i++)
15283 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15288 /* TC min bandwidth setting */
15290 cmd_vf_tc_min_bw_parsed(
15291 void *parsed_result,
15292 __rte_unused struct cmdline *cl,
15293 __rte_unused void *data)
15295 struct cmd_vf_tc_bw_result *res = parsed_result;
15298 int ret = -ENOTSUP;
15300 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15303 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15307 #ifdef RTE_LIBRTE_I40E_PMD
15308 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15316 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15319 printf("invalid port_id %d\n", res->port_id);
15322 printf("function not implemented\n");
15325 printf("programming error: (%s)\n", strerror(-ret));
15329 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15330 .f = cmd_vf_tc_min_bw_parsed,
15332 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15333 " <bw1, bw2, ...>",
15335 (void *)&cmd_vf_tc_bw_set,
15336 (void *)&cmd_vf_tc_bw_vf,
15337 (void *)&cmd_vf_tc_bw_tc,
15338 (void *)&cmd_vf_tc_bw_tx,
15339 (void *)&cmd_vf_tc_bw_min_bw,
15340 (void *)&cmd_vf_tc_bw_port_id,
15341 (void *)&cmd_vf_tc_bw_vf_id,
15342 (void *)&cmd_vf_tc_bw_bw_list,
15348 cmd_tc_min_bw_parsed(
15349 void *parsed_result,
15350 __rte_unused struct cmdline *cl,
15351 __rte_unused void *data)
15353 struct cmd_vf_tc_bw_result *res = parsed_result;
15354 struct rte_port *port;
15357 int ret = -ENOTSUP;
15359 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15362 port = &ports[res->port_id];
15363 /** Check if the port is not started **/
15364 if (port->port_status != RTE_PORT_STOPPED) {
15365 printf("Please stop port %d first\n", res->port_id);
15369 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15373 #ifdef RTE_LIBRTE_IXGBE_PMD
15374 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15381 printf("invalid bandwidth\n");
15384 printf("invalid port_id %d\n", res->port_id);
15387 printf("function not implemented\n");
15390 printf("programming error: (%s)\n", strerror(-ret));
15394 cmdline_parse_inst_t cmd_tc_min_bw = {
15395 .f = cmd_tc_min_bw_parsed,
15397 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15399 (void *)&cmd_vf_tc_bw_set,
15400 (void *)&cmd_vf_tc_bw_tc,
15401 (void *)&cmd_vf_tc_bw_tx,
15402 (void *)&cmd_vf_tc_bw_min_bw,
15403 (void *)&cmd_vf_tc_bw_port_id,
15404 (void *)&cmd_vf_tc_bw_bw_list,
15409 /* TC max bandwidth setting */
15411 cmd_vf_tc_max_bw_parsed(
15412 void *parsed_result,
15413 __rte_unused struct cmdline *cl,
15414 __rte_unused void *data)
15416 struct cmd_vf_tc_bw_result *res = parsed_result;
15417 int ret = -ENOTSUP;
15419 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15422 #ifdef RTE_LIBRTE_I40E_PMD
15423 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15424 res->tc_no, res->bw);
15431 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15432 res->vf_id, res->tc_no, res->bw);
15435 printf("invalid port_id %d\n", res->port_id);
15438 printf("function not implemented\n");
15441 printf("programming error: (%s)\n", strerror(-ret));
15445 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15446 .f = cmd_vf_tc_max_bw_parsed,
15448 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15451 (void *)&cmd_vf_tc_bw_set,
15452 (void *)&cmd_vf_tc_bw_vf,
15453 (void *)&cmd_vf_tc_bw_tc,
15454 (void *)&cmd_vf_tc_bw_tx,
15455 (void *)&cmd_vf_tc_bw_max_bw,
15456 (void *)&cmd_vf_tc_bw_port_id,
15457 (void *)&cmd_vf_tc_bw_vf_id,
15458 (void *)&cmd_vf_tc_bw_tc_no,
15459 (void *)&cmd_vf_tc_bw_bw,
15464 /** Set VXLAN encapsulation details */
15465 struct cmd_set_vxlan_result {
15466 cmdline_fixed_string_t set;
15467 cmdline_fixed_string_t vxlan;
15468 cmdline_fixed_string_t pos_token;
15469 cmdline_fixed_string_t ip_version;
15470 uint32_t vlan_present:1;
15474 cmdline_ipaddr_t ip_src;
15475 cmdline_ipaddr_t ip_dst;
15479 struct rte_ether_addr eth_src;
15480 struct rte_ether_addr eth_dst;
15483 cmdline_parse_token_string_t cmd_set_vxlan_set =
15484 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15485 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15486 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15487 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15488 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15490 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15491 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15492 "vxlan-with-vlan");
15493 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15494 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15496 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15497 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15499 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15500 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15502 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15503 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15504 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15505 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15507 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15508 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15509 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15510 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15512 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15513 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15514 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15515 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15517 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15518 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15519 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15520 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15522 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15523 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15524 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15525 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15527 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15528 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15529 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15530 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15532 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15533 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15534 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15535 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15537 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15538 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15539 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15540 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15542 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15543 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15544 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15545 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15547 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15548 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15550 static void cmd_set_vxlan_parsed(void *parsed_result,
15551 __rte_unused struct cmdline *cl,
15552 __rte_unused void *data)
15554 struct cmd_set_vxlan_result *res = parsed_result;
15559 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15562 vxlan_encap_conf.select_tos_ttl = 0;
15563 if (strcmp(res->vxlan, "vxlan") == 0)
15564 vxlan_encap_conf.select_vlan = 0;
15565 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15566 vxlan_encap_conf.select_vlan = 1;
15567 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15568 vxlan_encap_conf.select_vlan = 0;
15569 vxlan_encap_conf.select_tos_ttl = 1;
15571 if (strcmp(res->ip_version, "ipv4") == 0)
15572 vxlan_encap_conf.select_ipv4 = 1;
15573 else if (strcmp(res->ip_version, "ipv6") == 0)
15574 vxlan_encap_conf.select_ipv4 = 0;
15577 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15578 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15579 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15580 vxlan_encap_conf.ip_tos = res->tos;
15581 vxlan_encap_conf.ip_ttl = res->ttl;
15582 if (vxlan_encap_conf.select_ipv4) {
15583 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15584 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15586 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15587 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15589 if (vxlan_encap_conf.select_vlan)
15590 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15591 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15592 RTE_ETHER_ADDR_LEN);
15593 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15594 RTE_ETHER_ADDR_LEN);
15597 cmdline_parse_inst_t cmd_set_vxlan = {
15598 .f = cmd_set_vxlan_parsed,
15600 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15601 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15602 " eth-src <eth-src> eth-dst <eth-dst>",
15604 (void *)&cmd_set_vxlan_set,
15605 (void *)&cmd_set_vxlan_vxlan,
15606 (void *)&cmd_set_vxlan_ip_version,
15607 (void *)&cmd_set_vxlan_ip_version_value,
15608 (void *)&cmd_set_vxlan_vni,
15609 (void *)&cmd_set_vxlan_vni_value,
15610 (void *)&cmd_set_vxlan_udp_src,
15611 (void *)&cmd_set_vxlan_udp_src_value,
15612 (void *)&cmd_set_vxlan_udp_dst,
15613 (void *)&cmd_set_vxlan_udp_dst_value,
15614 (void *)&cmd_set_vxlan_ip_src,
15615 (void *)&cmd_set_vxlan_ip_src_value,
15616 (void *)&cmd_set_vxlan_ip_dst,
15617 (void *)&cmd_set_vxlan_ip_dst_value,
15618 (void *)&cmd_set_vxlan_eth_src,
15619 (void *)&cmd_set_vxlan_eth_src_value,
15620 (void *)&cmd_set_vxlan_eth_dst,
15621 (void *)&cmd_set_vxlan_eth_dst_value,
15626 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15627 .f = cmd_set_vxlan_parsed,
15629 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15630 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15631 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15632 " eth-dst <eth-dst>",
15634 (void *)&cmd_set_vxlan_set,
15635 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15636 (void *)&cmd_set_vxlan_ip_version,
15637 (void *)&cmd_set_vxlan_ip_version_value,
15638 (void *)&cmd_set_vxlan_vni,
15639 (void *)&cmd_set_vxlan_vni_value,
15640 (void *)&cmd_set_vxlan_udp_src,
15641 (void *)&cmd_set_vxlan_udp_src_value,
15642 (void *)&cmd_set_vxlan_udp_dst,
15643 (void *)&cmd_set_vxlan_udp_dst_value,
15644 (void *)&cmd_set_vxlan_ip_tos,
15645 (void *)&cmd_set_vxlan_ip_tos_value,
15646 (void *)&cmd_set_vxlan_ip_ttl,
15647 (void *)&cmd_set_vxlan_ip_ttl_value,
15648 (void *)&cmd_set_vxlan_ip_src,
15649 (void *)&cmd_set_vxlan_ip_src_value,
15650 (void *)&cmd_set_vxlan_ip_dst,
15651 (void *)&cmd_set_vxlan_ip_dst_value,
15652 (void *)&cmd_set_vxlan_eth_src,
15653 (void *)&cmd_set_vxlan_eth_src_value,
15654 (void *)&cmd_set_vxlan_eth_dst,
15655 (void *)&cmd_set_vxlan_eth_dst_value,
15660 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15661 .f = cmd_set_vxlan_parsed,
15663 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15664 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15665 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15668 (void *)&cmd_set_vxlan_set,
15669 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15670 (void *)&cmd_set_vxlan_ip_version,
15671 (void *)&cmd_set_vxlan_ip_version_value,
15672 (void *)&cmd_set_vxlan_vni,
15673 (void *)&cmd_set_vxlan_vni_value,
15674 (void *)&cmd_set_vxlan_udp_src,
15675 (void *)&cmd_set_vxlan_udp_src_value,
15676 (void *)&cmd_set_vxlan_udp_dst,
15677 (void *)&cmd_set_vxlan_udp_dst_value,
15678 (void *)&cmd_set_vxlan_ip_src,
15679 (void *)&cmd_set_vxlan_ip_src_value,
15680 (void *)&cmd_set_vxlan_ip_dst,
15681 (void *)&cmd_set_vxlan_ip_dst_value,
15682 (void *)&cmd_set_vxlan_vlan,
15683 (void *)&cmd_set_vxlan_vlan_value,
15684 (void *)&cmd_set_vxlan_eth_src,
15685 (void *)&cmd_set_vxlan_eth_src_value,
15686 (void *)&cmd_set_vxlan_eth_dst,
15687 (void *)&cmd_set_vxlan_eth_dst_value,
15692 /** Set NVGRE encapsulation details */
15693 struct cmd_set_nvgre_result {
15694 cmdline_fixed_string_t set;
15695 cmdline_fixed_string_t nvgre;
15696 cmdline_fixed_string_t pos_token;
15697 cmdline_fixed_string_t ip_version;
15699 cmdline_ipaddr_t ip_src;
15700 cmdline_ipaddr_t ip_dst;
15702 struct rte_ether_addr eth_src;
15703 struct rte_ether_addr eth_dst;
15706 cmdline_parse_token_string_t cmd_set_nvgre_set =
15707 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15708 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15709 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15710 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15711 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15712 "nvgre-with-vlan");
15713 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15714 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15716 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15717 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15719 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15720 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15722 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15723 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15724 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15725 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15727 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15728 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15729 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15730 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15732 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15733 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15734 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15735 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15737 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15738 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15739 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15740 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15742 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15743 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15744 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15745 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15747 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15748 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15750 static void cmd_set_nvgre_parsed(void *parsed_result,
15751 __rte_unused struct cmdline *cl,
15752 __rte_unused void *data)
15754 struct cmd_set_nvgre_result *res = parsed_result;
15756 uint32_t nvgre_tni;
15759 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15762 if (strcmp(res->nvgre, "nvgre") == 0)
15763 nvgre_encap_conf.select_vlan = 0;
15764 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15765 nvgre_encap_conf.select_vlan = 1;
15766 if (strcmp(res->ip_version, "ipv4") == 0)
15767 nvgre_encap_conf.select_ipv4 = 1;
15768 else if (strcmp(res->ip_version, "ipv6") == 0)
15769 nvgre_encap_conf.select_ipv4 = 0;
15772 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15773 if (nvgre_encap_conf.select_ipv4) {
15774 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15775 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15777 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15778 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15780 if (nvgre_encap_conf.select_vlan)
15781 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15782 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15783 RTE_ETHER_ADDR_LEN);
15784 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15785 RTE_ETHER_ADDR_LEN);
15788 cmdline_parse_inst_t cmd_set_nvgre = {
15789 .f = cmd_set_nvgre_parsed,
15791 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15792 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15793 " eth-dst <eth-dst>",
15795 (void *)&cmd_set_nvgre_set,
15796 (void *)&cmd_set_nvgre_nvgre,
15797 (void *)&cmd_set_nvgre_ip_version,
15798 (void *)&cmd_set_nvgre_ip_version_value,
15799 (void *)&cmd_set_nvgre_tni,
15800 (void *)&cmd_set_nvgre_tni_value,
15801 (void *)&cmd_set_nvgre_ip_src,
15802 (void *)&cmd_set_nvgre_ip_src_value,
15803 (void *)&cmd_set_nvgre_ip_dst,
15804 (void *)&cmd_set_nvgre_ip_dst_value,
15805 (void *)&cmd_set_nvgre_eth_src,
15806 (void *)&cmd_set_nvgre_eth_src_value,
15807 (void *)&cmd_set_nvgre_eth_dst,
15808 (void *)&cmd_set_nvgre_eth_dst_value,
15813 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15814 .f = cmd_set_nvgre_parsed,
15816 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15817 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15818 " eth-src <eth-src> eth-dst <eth-dst>",
15820 (void *)&cmd_set_nvgre_set,
15821 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15822 (void *)&cmd_set_nvgre_ip_version,
15823 (void *)&cmd_set_nvgre_ip_version_value,
15824 (void *)&cmd_set_nvgre_tni,
15825 (void *)&cmd_set_nvgre_tni_value,
15826 (void *)&cmd_set_nvgre_ip_src,
15827 (void *)&cmd_set_nvgre_ip_src_value,
15828 (void *)&cmd_set_nvgre_ip_dst,
15829 (void *)&cmd_set_nvgre_ip_dst_value,
15830 (void *)&cmd_set_nvgre_vlan,
15831 (void *)&cmd_set_nvgre_vlan_value,
15832 (void *)&cmd_set_nvgre_eth_src,
15833 (void *)&cmd_set_nvgre_eth_src_value,
15834 (void *)&cmd_set_nvgre_eth_dst,
15835 (void *)&cmd_set_nvgre_eth_dst_value,
15840 /** Set L2 encapsulation details */
15841 struct cmd_set_l2_encap_result {
15842 cmdline_fixed_string_t set;
15843 cmdline_fixed_string_t l2_encap;
15844 cmdline_fixed_string_t pos_token;
15845 cmdline_fixed_string_t ip_version;
15846 uint32_t vlan_present:1;
15848 struct rte_ether_addr eth_src;
15849 struct rte_ether_addr eth_dst;
15852 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15853 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15854 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15855 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15856 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15857 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15858 "l2_encap-with-vlan");
15859 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15860 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15862 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15863 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15865 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15866 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15868 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15869 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15870 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15871 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15873 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15874 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15875 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15876 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15878 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15879 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15881 static void cmd_set_l2_encap_parsed(void *parsed_result,
15882 __rte_unused struct cmdline *cl,
15883 __rte_unused void *data)
15885 struct cmd_set_l2_encap_result *res = parsed_result;
15887 if (strcmp(res->l2_encap, "l2_encap") == 0)
15888 l2_encap_conf.select_vlan = 0;
15889 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15890 l2_encap_conf.select_vlan = 1;
15891 if (strcmp(res->ip_version, "ipv4") == 0)
15892 l2_encap_conf.select_ipv4 = 1;
15893 else if (strcmp(res->ip_version, "ipv6") == 0)
15894 l2_encap_conf.select_ipv4 = 0;
15897 if (l2_encap_conf.select_vlan)
15898 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15899 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15900 RTE_ETHER_ADDR_LEN);
15901 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15902 RTE_ETHER_ADDR_LEN);
15905 cmdline_parse_inst_t cmd_set_l2_encap = {
15906 .f = cmd_set_l2_encap_parsed,
15908 .help_str = "set l2_encap ip-version ipv4|ipv6"
15909 " eth-src <eth-src> eth-dst <eth-dst>",
15911 (void *)&cmd_set_l2_encap_set,
15912 (void *)&cmd_set_l2_encap_l2_encap,
15913 (void *)&cmd_set_l2_encap_ip_version,
15914 (void *)&cmd_set_l2_encap_ip_version_value,
15915 (void *)&cmd_set_l2_encap_eth_src,
15916 (void *)&cmd_set_l2_encap_eth_src_value,
15917 (void *)&cmd_set_l2_encap_eth_dst,
15918 (void *)&cmd_set_l2_encap_eth_dst_value,
15923 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15924 .f = cmd_set_l2_encap_parsed,
15926 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15927 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15929 (void *)&cmd_set_l2_encap_set,
15930 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15931 (void *)&cmd_set_l2_encap_ip_version,
15932 (void *)&cmd_set_l2_encap_ip_version_value,
15933 (void *)&cmd_set_l2_encap_vlan,
15934 (void *)&cmd_set_l2_encap_vlan_value,
15935 (void *)&cmd_set_l2_encap_eth_src,
15936 (void *)&cmd_set_l2_encap_eth_src_value,
15937 (void *)&cmd_set_l2_encap_eth_dst,
15938 (void *)&cmd_set_l2_encap_eth_dst_value,
15943 /** Set L2 decapsulation details */
15944 struct cmd_set_l2_decap_result {
15945 cmdline_fixed_string_t set;
15946 cmdline_fixed_string_t l2_decap;
15947 cmdline_fixed_string_t pos_token;
15948 uint32_t vlan_present:1;
15951 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15952 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15953 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15954 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15956 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15957 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15958 "l2_decap-with-vlan");
15960 static void cmd_set_l2_decap_parsed(void *parsed_result,
15961 __rte_unused struct cmdline *cl,
15962 __rte_unused void *data)
15964 struct cmd_set_l2_decap_result *res = parsed_result;
15966 if (strcmp(res->l2_decap, "l2_decap") == 0)
15967 l2_decap_conf.select_vlan = 0;
15968 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15969 l2_decap_conf.select_vlan = 1;
15972 cmdline_parse_inst_t cmd_set_l2_decap = {
15973 .f = cmd_set_l2_decap_parsed,
15975 .help_str = "set l2_decap",
15977 (void *)&cmd_set_l2_decap_set,
15978 (void *)&cmd_set_l2_decap_l2_decap,
15983 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15984 .f = cmd_set_l2_decap_parsed,
15986 .help_str = "set l2_decap-with-vlan",
15988 (void *)&cmd_set_l2_decap_set,
15989 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15994 /** Set MPLSoGRE encapsulation details */
15995 struct cmd_set_mplsogre_encap_result {
15996 cmdline_fixed_string_t set;
15997 cmdline_fixed_string_t mplsogre;
15998 cmdline_fixed_string_t pos_token;
15999 cmdline_fixed_string_t ip_version;
16000 uint32_t vlan_present:1;
16002 cmdline_ipaddr_t ip_src;
16003 cmdline_ipaddr_t ip_dst;
16005 struct rte_ether_addr eth_src;
16006 struct rte_ether_addr eth_dst;
16009 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
16010 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
16012 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
16013 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
16015 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
16016 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16017 mplsogre, "mplsogre_encap-with-vlan");
16018 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
16019 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16020 pos_token, "ip-version");
16021 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
16022 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16023 ip_version, "ipv4#ipv6");
16024 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
16025 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16026 pos_token, "label");
16027 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
16028 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
16030 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
16031 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16032 pos_token, "ip-src");
16033 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
16034 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
16035 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
16036 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16037 pos_token, "ip-dst");
16038 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
16039 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
16040 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
16041 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16042 pos_token, "vlan-tci");
16043 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
16044 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
16046 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
16047 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16048 pos_token, "eth-src");
16049 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
16050 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16052 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
16053 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16054 pos_token, "eth-dst");
16055 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
16056 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16059 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
16060 __rte_unused struct cmdline *cl,
16061 __rte_unused void *data)
16063 struct cmd_set_mplsogre_encap_result *res = parsed_result;
16065 uint32_t mplsogre_label;
16068 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
16071 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
16072 mplsogre_encap_conf.select_vlan = 0;
16073 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
16074 mplsogre_encap_conf.select_vlan = 1;
16075 if (strcmp(res->ip_version, "ipv4") == 0)
16076 mplsogre_encap_conf.select_ipv4 = 1;
16077 else if (strcmp(res->ip_version, "ipv6") == 0)
16078 mplsogre_encap_conf.select_ipv4 = 0;
16081 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
16082 if (mplsogre_encap_conf.select_ipv4) {
16083 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
16084 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
16086 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
16087 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
16089 if (mplsogre_encap_conf.select_vlan)
16090 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16091 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
16092 RTE_ETHER_ADDR_LEN);
16093 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16094 RTE_ETHER_ADDR_LEN);
16097 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
16098 .f = cmd_set_mplsogre_encap_parsed,
16100 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
16101 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
16102 " eth-dst <eth-dst>",
16104 (void *)&cmd_set_mplsogre_encap_set,
16105 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
16106 (void *)&cmd_set_mplsogre_encap_ip_version,
16107 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16108 (void *)&cmd_set_mplsogre_encap_label,
16109 (void *)&cmd_set_mplsogre_encap_label_value,
16110 (void *)&cmd_set_mplsogre_encap_ip_src,
16111 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16112 (void *)&cmd_set_mplsogre_encap_ip_dst,
16113 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16114 (void *)&cmd_set_mplsogre_encap_eth_src,
16115 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16116 (void *)&cmd_set_mplsogre_encap_eth_dst,
16117 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16122 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16123 .f = cmd_set_mplsogre_encap_parsed,
16125 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16126 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16127 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16129 (void *)&cmd_set_mplsogre_encap_set,
16130 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16131 (void *)&cmd_set_mplsogre_encap_ip_version,
16132 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16133 (void *)&cmd_set_mplsogre_encap_label,
16134 (void *)&cmd_set_mplsogre_encap_label_value,
16135 (void *)&cmd_set_mplsogre_encap_ip_src,
16136 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16137 (void *)&cmd_set_mplsogre_encap_ip_dst,
16138 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16139 (void *)&cmd_set_mplsogre_encap_vlan,
16140 (void *)&cmd_set_mplsogre_encap_vlan_value,
16141 (void *)&cmd_set_mplsogre_encap_eth_src,
16142 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16143 (void *)&cmd_set_mplsogre_encap_eth_dst,
16144 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16149 /** Set MPLSoGRE decapsulation details */
16150 struct cmd_set_mplsogre_decap_result {
16151 cmdline_fixed_string_t set;
16152 cmdline_fixed_string_t mplsogre;
16153 cmdline_fixed_string_t pos_token;
16154 cmdline_fixed_string_t ip_version;
16155 uint32_t vlan_present:1;
16158 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16159 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16161 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16162 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16164 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16165 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16166 mplsogre, "mplsogre_decap-with-vlan");
16167 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16168 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16169 pos_token, "ip-version");
16170 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16171 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16172 ip_version, "ipv4#ipv6");
16174 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16175 __rte_unused struct cmdline *cl,
16176 __rte_unused void *data)
16178 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16180 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16181 mplsogre_decap_conf.select_vlan = 0;
16182 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16183 mplsogre_decap_conf.select_vlan = 1;
16184 if (strcmp(res->ip_version, "ipv4") == 0)
16185 mplsogre_decap_conf.select_ipv4 = 1;
16186 else if (strcmp(res->ip_version, "ipv6") == 0)
16187 mplsogre_decap_conf.select_ipv4 = 0;
16190 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16191 .f = cmd_set_mplsogre_decap_parsed,
16193 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16195 (void *)&cmd_set_mplsogre_decap_set,
16196 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16197 (void *)&cmd_set_mplsogre_decap_ip_version,
16198 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16203 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16204 .f = cmd_set_mplsogre_decap_parsed,
16206 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16208 (void *)&cmd_set_mplsogre_decap_set,
16209 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16210 (void *)&cmd_set_mplsogre_decap_ip_version,
16211 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16216 /** Set MPLSoUDP encapsulation details */
16217 struct cmd_set_mplsoudp_encap_result {
16218 cmdline_fixed_string_t set;
16219 cmdline_fixed_string_t mplsoudp;
16220 cmdline_fixed_string_t pos_token;
16221 cmdline_fixed_string_t ip_version;
16222 uint32_t vlan_present:1;
16226 cmdline_ipaddr_t ip_src;
16227 cmdline_ipaddr_t ip_dst;
16229 struct rte_ether_addr eth_src;
16230 struct rte_ether_addr eth_dst;
16233 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16234 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16236 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16237 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16239 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16240 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16241 mplsoudp, "mplsoudp_encap-with-vlan");
16242 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16243 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16244 pos_token, "ip-version");
16245 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16246 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16247 ip_version, "ipv4#ipv6");
16248 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16249 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16250 pos_token, "label");
16251 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16252 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16254 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16255 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16256 pos_token, "udp-src");
16257 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16258 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16260 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16261 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16262 pos_token, "udp-dst");
16263 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16264 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16266 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16267 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16268 pos_token, "ip-src");
16269 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16270 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16271 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16272 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16273 pos_token, "ip-dst");
16274 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16275 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16276 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16277 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16278 pos_token, "vlan-tci");
16279 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16280 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16282 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16283 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16284 pos_token, "eth-src");
16285 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16286 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16288 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16289 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16290 pos_token, "eth-dst");
16291 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16292 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16295 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16296 __rte_unused struct cmdline *cl,
16297 __rte_unused void *data)
16299 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16301 uint32_t mplsoudp_label;
16304 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16307 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16308 mplsoudp_encap_conf.select_vlan = 0;
16309 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16310 mplsoudp_encap_conf.select_vlan = 1;
16311 if (strcmp(res->ip_version, "ipv4") == 0)
16312 mplsoudp_encap_conf.select_ipv4 = 1;
16313 else if (strcmp(res->ip_version, "ipv6") == 0)
16314 mplsoudp_encap_conf.select_ipv4 = 0;
16317 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16318 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16319 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16320 if (mplsoudp_encap_conf.select_ipv4) {
16321 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16322 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16324 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16325 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16327 if (mplsoudp_encap_conf.select_vlan)
16328 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16329 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16330 RTE_ETHER_ADDR_LEN);
16331 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16332 RTE_ETHER_ADDR_LEN);
16335 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16336 .f = cmd_set_mplsoudp_encap_parsed,
16338 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16339 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16340 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16342 (void *)&cmd_set_mplsoudp_encap_set,
16343 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16344 (void *)&cmd_set_mplsoudp_encap_ip_version,
16345 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16346 (void *)&cmd_set_mplsoudp_encap_label,
16347 (void *)&cmd_set_mplsoudp_encap_label_value,
16348 (void *)&cmd_set_mplsoudp_encap_udp_src,
16349 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16350 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16351 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16352 (void *)&cmd_set_mplsoudp_encap_ip_src,
16353 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16354 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16355 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16356 (void *)&cmd_set_mplsoudp_encap_eth_src,
16357 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16358 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16359 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16364 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16365 .f = cmd_set_mplsoudp_encap_parsed,
16367 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16368 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16369 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16370 " eth-src <eth-src> eth-dst <eth-dst>",
16372 (void *)&cmd_set_mplsoudp_encap_set,
16373 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16374 (void *)&cmd_set_mplsoudp_encap_ip_version,
16375 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16376 (void *)&cmd_set_mplsoudp_encap_label,
16377 (void *)&cmd_set_mplsoudp_encap_label_value,
16378 (void *)&cmd_set_mplsoudp_encap_udp_src,
16379 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16380 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16381 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16382 (void *)&cmd_set_mplsoudp_encap_ip_src,
16383 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16384 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16385 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16386 (void *)&cmd_set_mplsoudp_encap_vlan,
16387 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16388 (void *)&cmd_set_mplsoudp_encap_eth_src,
16389 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16390 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16391 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16396 /** Set MPLSoUDP decapsulation details */
16397 struct cmd_set_mplsoudp_decap_result {
16398 cmdline_fixed_string_t set;
16399 cmdline_fixed_string_t mplsoudp;
16400 cmdline_fixed_string_t pos_token;
16401 cmdline_fixed_string_t ip_version;
16402 uint32_t vlan_present:1;
16405 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16406 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16408 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16409 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16411 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16412 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16413 mplsoudp, "mplsoudp_decap-with-vlan");
16414 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16415 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16416 pos_token, "ip-version");
16417 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16418 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16419 ip_version, "ipv4#ipv6");
16421 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16422 __rte_unused struct cmdline *cl,
16423 __rte_unused void *data)
16425 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16427 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16428 mplsoudp_decap_conf.select_vlan = 0;
16429 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16430 mplsoudp_decap_conf.select_vlan = 1;
16431 if (strcmp(res->ip_version, "ipv4") == 0)
16432 mplsoudp_decap_conf.select_ipv4 = 1;
16433 else if (strcmp(res->ip_version, "ipv6") == 0)
16434 mplsoudp_decap_conf.select_ipv4 = 0;
16437 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16438 .f = cmd_set_mplsoudp_decap_parsed,
16440 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16442 (void *)&cmd_set_mplsoudp_decap_set,
16443 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16444 (void *)&cmd_set_mplsoudp_decap_ip_version,
16445 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16450 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16451 .f = cmd_set_mplsoudp_decap_parsed,
16453 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16455 (void *)&cmd_set_mplsoudp_decap_set,
16456 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16457 (void *)&cmd_set_mplsoudp_decap_ip_version,
16458 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16463 /* Strict link priority scheduling mode setting */
16465 cmd_strict_link_prio_parsed(
16466 void *parsed_result,
16467 __rte_unused struct cmdline *cl,
16468 __rte_unused void *data)
16470 struct cmd_vf_tc_bw_result *res = parsed_result;
16471 int ret = -ENOTSUP;
16473 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16476 #ifdef RTE_LIBRTE_I40E_PMD
16477 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16484 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16487 printf("invalid port_id %d\n", res->port_id);
16490 printf("function not implemented\n");
16493 printf("programming error: (%s)\n", strerror(-ret));
16497 cmdline_parse_inst_t cmd_strict_link_prio = {
16498 .f = cmd_strict_link_prio_parsed,
16500 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16502 (void *)&cmd_vf_tc_bw_set,
16503 (void *)&cmd_vf_tc_bw_tx,
16504 (void *)&cmd_vf_tc_bw_strict_link_prio,
16505 (void *)&cmd_vf_tc_bw_port_id,
16506 (void *)&cmd_vf_tc_bw_tc_map,
16511 /* Load dynamic device personalization*/
16512 struct cmd_ddp_add_result {
16513 cmdline_fixed_string_t ddp;
16514 cmdline_fixed_string_t add;
16519 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16520 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16521 cmdline_parse_token_string_t cmd_ddp_add_add =
16522 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16523 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16524 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16525 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16526 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16529 cmd_ddp_add_parsed(
16530 void *parsed_result,
16531 __rte_unused struct cmdline *cl,
16532 __rte_unused void *data)
16534 struct cmd_ddp_add_result *res = parsed_result;
16540 int ret = -ENOTSUP;
16542 if (!all_ports_stopped()) {
16543 printf("Please stop all ports first\n");
16547 filepath = strdup(res->filepath);
16548 if (filepath == NULL) {
16549 printf("Failed to allocate memory\n");
16552 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16554 buff = open_file(file_fld[0], &size);
16556 free((void *)filepath);
16560 #ifdef RTE_LIBRTE_I40E_PMD
16561 if (ret == -ENOTSUP)
16562 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16564 RTE_PMD_I40E_PKG_OP_WR_ADD);
16567 if (ret == -EEXIST)
16568 printf("Profile has already existed.\n");
16570 printf("Failed to load profile.\n");
16571 else if (file_num == 2)
16572 save_file(file_fld[1], buff, size);
16575 free((void *)filepath);
16578 cmdline_parse_inst_t cmd_ddp_add = {
16579 .f = cmd_ddp_add_parsed,
16581 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16583 (void *)&cmd_ddp_add_ddp,
16584 (void *)&cmd_ddp_add_add,
16585 (void *)&cmd_ddp_add_port_id,
16586 (void *)&cmd_ddp_add_filepath,
16591 /* Delete dynamic device personalization*/
16592 struct cmd_ddp_del_result {
16593 cmdline_fixed_string_t ddp;
16594 cmdline_fixed_string_t del;
16599 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16600 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16601 cmdline_parse_token_string_t cmd_ddp_del_del =
16602 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16603 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16604 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16605 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16606 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16609 cmd_ddp_del_parsed(
16610 void *parsed_result,
16611 __rte_unused struct cmdline *cl,
16612 __rte_unused void *data)
16614 struct cmd_ddp_del_result *res = parsed_result;
16617 int ret = -ENOTSUP;
16619 if (!all_ports_stopped()) {
16620 printf("Please stop all ports first\n");
16624 buff = open_file(res->filepath, &size);
16628 #ifdef RTE_LIBRTE_I40E_PMD
16629 if (ret == -ENOTSUP)
16630 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16632 RTE_PMD_I40E_PKG_OP_WR_DEL);
16635 if (ret == -EACCES)
16636 printf("Profile does not exist.\n");
16638 printf("Failed to delete profile.\n");
16643 cmdline_parse_inst_t cmd_ddp_del = {
16644 .f = cmd_ddp_del_parsed,
16646 .help_str = "ddp del <port_id> <backup_profile_path>",
16648 (void *)&cmd_ddp_del_ddp,
16649 (void *)&cmd_ddp_del_del,
16650 (void *)&cmd_ddp_del_port_id,
16651 (void *)&cmd_ddp_del_filepath,
16656 /* Get dynamic device personalization profile info */
16657 struct cmd_ddp_info_result {
16658 cmdline_fixed_string_t ddp;
16659 cmdline_fixed_string_t get;
16660 cmdline_fixed_string_t info;
16664 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16665 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16666 cmdline_parse_token_string_t cmd_ddp_info_get =
16667 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16668 cmdline_parse_token_string_t cmd_ddp_info_info =
16669 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16670 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16671 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16674 cmd_ddp_info_parsed(
16675 void *parsed_result,
16676 __rte_unused struct cmdline *cl,
16677 __rte_unused void *data)
16679 struct cmd_ddp_info_result *res = parsed_result;
16682 int ret = -ENOTSUP;
16683 #ifdef RTE_LIBRTE_I40E_PMD
16686 uint32_t buff_size = 0;
16687 struct rte_pmd_i40e_profile_info info;
16688 uint32_t dev_num = 0;
16689 struct rte_pmd_i40e_ddp_device_id *devs;
16690 uint32_t proto_num = 0;
16691 struct rte_pmd_i40e_proto_info *proto = NULL;
16692 uint32_t pctype_num = 0;
16693 struct rte_pmd_i40e_ptype_info *pctype;
16694 uint32_t ptype_num = 0;
16695 struct rte_pmd_i40e_ptype_info *ptype;
16700 pkg = open_file(res->filepath, &pkg_size);
16704 #ifdef RTE_LIBRTE_I40E_PMD
16705 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16706 (uint8_t *)&info, sizeof(info),
16707 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16709 printf("Global Track id: 0x%x\n", info.track_id);
16710 printf("Global Version: %d.%d.%d.%d\n",
16711 info.version.major,
16712 info.version.minor,
16713 info.version.update,
16714 info.version.draft);
16715 printf("Global Package name: %s\n\n", info.name);
16718 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16719 (uint8_t *)&info, sizeof(info),
16720 RTE_PMD_I40E_PKG_INFO_HEADER);
16722 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16723 printf("i40e Profile Version: %d.%d.%d.%d\n",
16724 info.version.major,
16725 info.version.minor,
16726 info.version.update,
16727 info.version.draft);
16728 printf("i40e Profile name: %s\n\n", info.name);
16731 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16732 (uint8_t *)&buff_size, sizeof(buff_size),
16733 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16734 if (!ret && buff_size) {
16735 buff = (uint8_t *)malloc(buff_size);
16737 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16739 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16741 printf("Package Notes:\n%s\n\n", buff);
16746 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16747 (uint8_t *)&dev_num, sizeof(dev_num),
16748 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16749 if (!ret && dev_num) {
16750 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16751 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16753 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16754 (uint8_t *)devs, buff_size,
16755 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16757 printf("List of supported devices:\n");
16758 for (i = 0; i < dev_num; i++) {
16759 printf(" %04X:%04X %04X:%04X\n",
16760 devs[i].vendor_dev_id >> 16,
16761 devs[i].vendor_dev_id & 0xFFFF,
16762 devs[i].sub_vendor_dev_id >> 16,
16763 devs[i].sub_vendor_dev_id & 0xFFFF);
16771 /* get information about protocols and packet types */
16772 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16773 (uint8_t *)&proto_num, sizeof(proto_num),
16774 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16775 if (ret || !proto_num)
16776 goto no_print_return;
16778 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16779 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16781 goto no_print_return;
16783 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16785 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16787 printf("List of used protocols:\n");
16788 for (i = 0; i < proto_num; i++)
16789 printf(" %2u: %s\n", proto[i].proto_id,
16793 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16794 (uint8_t *)&pctype_num, sizeof(pctype_num),
16795 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16796 if (ret || !pctype_num)
16797 goto no_print_pctypes;
16799 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16800 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16802 goto no_print_pctypes;
16804 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16806 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16809 goto no_print_pctypes;
16812 printf("List of defined packet classification types:\n");
16813 for (i = 0; i < pctype_num; i++) {
16814 printf(" %2u:", pctype[i].ptype_id);
16815 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16816 proto_id = pctype[i].protocols[j];
16817 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16818 for (n = 0; n < proto_num; n++) {
16819 if (proto[n].proto_id == proto_id) {
16820 printf(" %s", proto[n].name);
16833 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16835 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16836 if (ret || !ptype_num)
16837 goto no_print_return;
16839 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16840 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16842 goto no_print_return;
16844 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16846 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16849 goto no_print_return;
16851 printf("List of defined packet types:\n");
16852 for (i = 0; i < ptype_num; i++) {
16853 printf(" %2u:", ptype[i].ptype_id);
16854 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16855 proto_id = ptype[i].protocols[j];
16856 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16857 for (n = 0; n < proto_num; n++) {
16858 if (proto[n].proto_id == proto_id) {
16859 printf(" %s", proto[n].name);
16875 if (ret == -ENOTSUP)
16876 printf("Function not supported in PMD driver\n");
16880 cmdline_parse_inst_t cmd_ddp_get_info = {
16881 .f = cmd_ddp_info_parsed,
16883 .help_str = "ddp get info <profile_path>",
16885 (void *)&cmd_ddp_info_ddp,
16886 (void *)&cmd_ddp_info_get,
16887 (void *)&cmd_ddp_info_info,
16888 (void *)&cmd_ddp_info_filepath,
16893 /* Get dynamic device personalization profile info list*/
16894 #define PROFILE_INFO_SIZE 48
16895 #define MAX_PROFILE_NUM 16
16897 struct cmd_ddp_get_list_result {
16898 cmdline_fixed_string_t ddp;
16899 cmdline_fixed_string_t get;
16900 cmdline_fixed_string_t list;
16904 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16905 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16906 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16907 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16908 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16909 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16910 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16911 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16914 cmd_ddp_get_list_parsed(
16915 __rte_unused void *parsed_result,
16916 __rte_unused struct cmdline *cl,
16917 __rte_unused void *data)
16919 #ifdef RTE_LIBRTE_I40E_PMD
16920 struct cmd_ddp_get_list_result *res = parsed_result;
16921 struct rte_pmd_i40e_profile_list *p_list;
16922 struct rte_pmd_i40e_profile_info *p_info;
16927 int ret = -ENOTSUP;
16929 #ifdef RTE_LIBRTE_I40E_PMD
16930 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16931 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16933 printf("%s: Failed to malloc buffer\n", __func__);
16937 if (ret == -ENOTSUP)
16938 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16939 (uint8_t *)p_list, size);
16942 p_num = p_list->p_count;
16943 printf("Profile number is: %d\n\n", p_num);
16945 for (i = 0; i < p_num; i++) {
16946 p_info = &p_list->p_info[i];
16947 printf("Profile %d:\n", i);
16948 printf("Track id: 0x%x\n", p_info->track_id);
16949 printf("Version: %d.%d.%d.%d\n",
16950 p_info->version.major,
16951 p_info->version.minor,
16952 p_info->version.update,
16953 p_info->version.draft);
16954 printf("Profile name: %s\n\n", p_info->name);
16962 printf("Failed to get ddp list\n");
16965 cmdline_parse_inst_t cmd_ddp_get_list = {
16966 .f = cmd_ddp_get_list_parsed,
16968 .help_str = "ddp get list <port_id>",
16970 (void *)&cmd_ddp_get_list_ddp,
16971 (void *)&cmd_ddp_get_list_get,
16972 (void *)&cmd_ddp_get_list_list,
16973 (void *)&cmd_ddp_get_list_port_id,
16978 /* Configure input set */
16979 struct cmd_cfg_input_set_result {
16980 cmdline_fixed_string_t port;
16981 cmdline_fixed_string_t cfg;
16983 cmdline_fixed_string_t pctype;
16985 cmdline_fixed_string_t inset_type;
16986 cmdline_fixed_string_t opt;
16987 cmdline_fixed_string_t field;
16992 cmd_cfg_input_set_parsed(
16993 __rte_unused void *parsed_result,
16994 __rte_unused struct cmdline *cl,
16995 __rte_unused void *data)
16997 #ifdef RTE_LIBRTE_I40E_PMD
16998 struct cmd_cfg_input_set_result *res = parsed_result;
16999 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17000 struct rte_pmd_i40e_inset inset;
17002 int ret = -ENOTSUP;
17004 if (!all_ports_stopped()) {
17005 printf("Please stop all ports first\n");
17009 #ifdef RTE_LIBRTE_I40E_PMD
17010 if (!strcmp(res->inset_type, "hash_inset"))
17011 inset_type = INSET_HASH;
17012 else if (!strcmp(res->inset_type, "fdir_inset"))
17013 inset_type = INSET_FDIR;
17014 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17015 inset_type = INSET_FDIR_FLX;
17016 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
17017 &inset, inset_type);
17019 printf("Failed to get input set.\n");
17023 if (!strcmp(res->opt, "get")) {
17024 ret = rte_pmd_i40e_inset_field_get(inset.inset,
17027 printf("Field index %d is enabled.\n", res->field_idx);
17029 printf("Field index %d is disabled.\n", res->field_idx);
17031 } else if (!strcmp(res->opt, "set"))
17032 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
17034 else if (!strcmp(res->opt, "clear"))
17035 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
17038 printf("Failed to configure input set field.\n");
17042 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17043 &inset, inset_type);
17045 printf("Failed to set input set.\n");
17050 if (ret == -ENOTSUP)
17051 printf("Function not supported\n");
17054 cmdline_parse_token_string_t cmd_cfg_input_set_port =
17055 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17057 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
17058 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17060 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
17061 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17063 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
17064 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17066 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
17067 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17069 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
17070 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17072 "hash_inset#fdir_inset#fdir_flx_inset");
17073 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
17074 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17075 opt, "get#set#clear");
17076 cmdline_parse_token_string_t cmd_cfg_input_set_field =
17077 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17079 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
17080 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17083 cmdline_parse_inst_t cmd_cfg_input_set = {
17084 .f = cmd_cfg_input_set_parsed,
17086 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17087 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
17089 (void *)&cmd_cfg_input_set_port,
17090 (void *)&cmd_cfg_input_set_cfg,
17091 (void *)&cmd_cfg_input_set_port_id,
17092 (void *)&cmd_cfg_input_set_pctype,
17093 (void *)&cmd_cfg_input_set_pctype_id,
17094 (void *)&cmd_cfg_input_set_inset_type,
17095 (void *)&cmd_cfg_input_set_opt,
17096 (void *)&cmd_cfg_input_set_field,
17097 (void *)&cmd_cfg_input_set_field_idx,
17102 /* Clear input set */
17103 struct cmd_clear_input_set_result {
17104 cmdline_fixed_string_t port;
17105 cmdline_fixed_string_t cfg;
17107 cmdline_fixed_string_t pctype;
17109 cmdline_fixed_string_t inset_type;
17110 cmdline_fixed_string_t clear;
17111 cmdline_fixed_string_t all;
17115 cmd_clear_input_set_parsed(
17116 __rte_unused void *parsed_result,
17117 __rte_unused struct cmdline *cl,
17118 __rte_unused void *data)
17120 #ifdef RTE_LIBRTE_I40E_PMD
17121 struct cmd_clear_input_set_result *res = parsed_result;
17122 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17123 struct rte_pmd_i40e_inset inset;
17125 int ret = -ENOTSUP;
17127 if (!all_ports_stopped()) {
17128 printf("Please stop all ports first\n");
17132 #ifdef RTE_LIBRTE_I40E_PMD
17133 if (!strcmp(res->inset_type, "hash_inset"))
17134 inset_type = INSET_HASH;
17135 else if (!strcmp(res->inset_type, "fdir_inset"))
17136 inset_type = INSET_FDIR;
17137 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17138 inset_type = INSET_FDIR_FLX;
17140 memset(&inset, 0, sizeof(inset));
17142 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17143 &inset, inset_type);
17145 printf("Failed to clear input set.\n");
17151 if (ret == -ENOTSUP)
17152 printf("Function not supported\n");
17155 cmdline_parse_token_string_t cmd_clear_input_set_port =
17156 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17158 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17159 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17161 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17162 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17164 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17165 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17167 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17168 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17170 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17171 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17173 "hash_inset#fdir_inset#fdir_flx_inset");
17174 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17175 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17177 cmdline_parse_token_string_t cmd_clear_input_set_all =
17178 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17181 cmdline_parse_inst_t cmd_clear_input_set = {
17182 .f = cmd_clear_input_set_parsed,
17184 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17185 "fdir_inset|fdir_flx_inset clear all",
17187 (void *)&cmd_clear_input_set_port,
17188 (void *)&cmd_clear_input_set_cfg,
17189 (void *)&cmd_clear_input_set_port_id,
17190 (void *)&cmd_clear_input_set_pctype,
17191 (void *)&cmd_clear_input_set_pctype_id,
17192 (void *)&cmd_clear_input_set_inset_type,
17193 (void *)&cmd_clear_input_set_clear,
17194 (void *)&cmd_clear_input_set_all,
17199 /* show vf stats */
17201 /* Common result structure for show vf stats */
17202 struct cmd_show_vf_stats_result {
17203 cmdline_fixed_string_t show;
17204 cmdline_fixed_string_t vf;
17205 cmdline_fixed_string_t stats;
17210 /* Common CLI fields show vf stats*/
17211 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17212 TOKEN_STRING_INITIALIZER
17213 (struct cmd_show_vf_stats_result,
17215 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17216 TOKEN_STRING_INITIALIZER
17217 (struct cmd_show_vf_stats_result,
17219 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17220 TOKEN_STRING_INITIALIZER
17221 (struct cmd_show_vf_stats_result,
17223 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17224 TOKEN_NUM_INITIALIZER
17225 (struct cmd_show_vf_stats_result,
17227 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17228 TOKEN_NUM_INITIALIZER
17229 (struct cmd_show_vf_stats_result,
17233 cmd_show_vf_stats_parsed(
17234 void *parsed_result,
17235 __rte_unused struct cmdline *cl,
17236 __rte_unused void *data)
17238 struct cmd_show_vf_stats_result *res = parsed_result;
17239 struct rte_eth_stats stats;
17240 int ret = -ENOTSUP;
17241 static const char *nic_stats_border = "########################";
17243 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17246 memset(&stats, 0, sizeof(stats));
17248 #ifdef RTE_LIBRTE_I40E_PMD
17249 if (ret == -ENOTSUP)
17250 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17254 #ifdef RTE_LIBRTE_BNXT_PMD
17255 if (ret == -ENOTSUP)
17256 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17265 printf("invalid vf_id %d\n", res->vf_id);
17268 printf("invalid port_id %d\n", res->port_id);
17271 printf("function not implemented\n");
17274 printf("programming error: (%s)\n", strerror(-ret));
17277 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17278 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17280 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17282 stats.ipackets, stats.imissed, stats.ibytes);
17283 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17284 printf(" RX-nombuf: %-10"PRIu64"\n",
17286 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17288 stats.opackets, stats.oerrors, stats.obytes);
17290 printf(" %s############################%s\n",
17291 nic_stats_border, nic_stats_border);
17294 cmdline_parse_inst_t cmd_show_vf_stats = {
17295 .f = cmd_show_vf_stats_parsed,
17297 .help_str = "show vf stats <port_id> <vf_id>",
17299 (void *)&cmd_show_vf_stats_show,
17300 (void *)&cmd_show_vf_stats_vf,
17301 (void *)&cmd_show_vf_stats_stats,
17302 (void *)&cmd_show_vf_stats_port_id,
17303 (void *)&cmd_show_vf_stats_vf_id,
17308 /* clear vf stats */
17310 /* Common result structure for clear vf stats */
17311 struct cmd_clear_vf_stats_result {
17312 cmdline_fixed_string_t clear;
17313 cmdline_fixed_string_t vf;
17314 cmdline_fixed_string_t stats;
17319 /* Common CLI fields clear vf stats*/
17320 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17321 TOKEN_STRING_INITIALIZER
17322 (struct cmd_clear_vf_stats_result,
17324 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17325 TOKEN_STRING_INITIALIZER
17326 (struct cmd_clear_vf_stats_result,
17328 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17329 TOKEN_STRING_INITIALIZER
17330 (struct cmd_clear_vf_stats_result,
17332 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17333 TOKEN_NUM_INITIALIZER
17334 (struct cmd_clear_vf_stats_result,
17336 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17337 TOKEN_NUM_INITIALIZER
17338 (struct cmd_clear_vf_stats_result,
17342 cmd_clear_vf_stats_parsed(
17343 void *parsed_result,
17344 __rte_unused struct cmdline *cl,
17345 __rte_unused void *data)
17347 struct cmd_clear_vf_stats_result *res = parsed_result;
17348 int ret = -ENOTSUP;
17350 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17353 #ifdef RTE_LIBRTE_I40E_PMD
17354 if (ret == -ENOTSUP)
17355 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17358 #ifdef RTE_LIBRTE_BNXT_PMD
17359 if (ret == -ENOTSUP)
17360 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17368 printf("invalid vf_id %d\n", res->vf_id);
17371 printf("invalid port_id %d\n", res->port_id);
17374 printf("function not implemented\n");
17377 printf("programming error: (%s)\n", strerror(-ret));
17381 cmdline_parse_inst_t cmd_clear_vf_stats = {
17382 .f = cmd_clear_vf_stats_parsed,
17384 .help_str = "clear vf stats <port_id> <vf_id>",
17386 (void *)&cmd_clear_vf_stats_clear,
17387 (void *)&cmd_clear_vf_stats_vf,
17388 (void *)&cmd_clear_vf_stats_stats,
17389 (void *)&cmd_clear_vf_stats_port_id,
17390 (void *)&cmd_clear_vf_stats_vf_id,
17395 /* port config pctype mapping reset */
17397 /* Common result structure for port config pctype mapping reset */
17398 struct cmd_pctype_mapping_reset_result {
17399 cmdline_fixed_string_t port;
17400 cmdline_fixed_string_t config;
17402 cmdline_fixed_string_t pctype;
17403 cmdline_fixed_string_t mapping;
17404 cmdline_fixed_string_t reset;
17407 /* Common CLI fields for port config pctype mapping reset*/
17408 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17409 TOKEN_STRING_INITIALIZER
17410 (struct cmd_pctype_mapping_reset_result,
17412 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17413 TOKEN_STRING_INITIALIZER
17414 (struct cmd_pctype_mapping_reset_result,
17416 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17417 TOKEN_NUM_INITIALIZER
17418 (struct cmd_pctype_mapping_reset_result,
17420 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17421 TOKEN_STRING_INITIALIZER
17422 (struct cmd_pctype_mapping_reset_result,
17424 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17425 TOKEN_STRING_INITIALIZER
17426 (struct cmd_pctype_mapping_reset_result,
17427 mapping, "mapping");
17428 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17429 TOKEN_STRING_INITIALIZER
17430 (struct cmd_pctype_mapping_reset_result,
17434 cmd_pctype_mapping_reset_parsed(
17435 void *parsed_result,
17436 __rte_unused struct cmdline *cl,
17437 __rte_unused void *data)
17439 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17440 int ret = -ENOTSUP;
17442 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17445 #ifdef RTE_LIBRTE_I40E_PMD
17446 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17453 printf("invalid port_id %d\n", res->port_id);
17456 printf("function not implemented\n");
17459 printf("programming error: (%s)\n", strerror(-ret));
17463 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17464 .f = cmd_pctype_mapping_reset_parsed,
17466 .help_str = "port config <port_id> pctype mapping reset",
17468 (void *)&cmd_pctype_mapping_reset_port,
17469 (void *)&cmd_pctype_mapping_reset_config,
17470 (void *)&cmd_pctype_mapping_reset_port_id,
17471 (void *)&cmd_pctype_mapping_reset_pctype,
17472 (void *)&cmd_pctype_mapping_reset_mapping,
17473 (void *)&cmd_pctype_mapping_reset_reset,
17478 /* show port pctype mapping */
17480 /* Common result structure for show port pctype mapping */
17481 struct cmd_pctype_mapping_get_result {
17482 cmdline_fixed_string_t show;
17483 cmdline_fixed_string_t port;
17485 cmdline_fixed_string_t pctype;
17486 cmdline_fixed_string_t mapping;
17489 /* Common CLI fields for pctype mapping get */
17490 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17491 TOKEN_STRING_INITIALIZER
17492 (struct cmd_pctype_mapping_get_result,
17494 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17495 TOKEN_STRING_INITIALIZER
17496 (struct cmd_pctype_mapping_get_result,
17498 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17499 TOKEN_NUM_INITIALIZER
17500 (struct cmd_pctype_mapping_get_result,
17502 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17503 TOKEN_STRING_INITIALIZER
17504 (struct cmd_pctype_mapping_get_result,
17506 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17507 TOKEN_STRING_INITIALIZER
17508 (struct cmd_pctype_mapping_get_result,
17509 mapping, "mapping");
17512 cmd_pctype_mapping_get_parsed(
17513 void *parsed_result,
17514 __rte_unused struct cmdline *cl,
17515 __rte_unused void *data)
17517 struct cmd_pctype_mapping_get_result *res = parsed_result;
17518 int ret = -ENOTSUP;
17519 #ifdef RTE_LIBRTE_I40E_PMD
17520 struct rte_pmd_i40e_flow_type_mapping
17521 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17522 int i, j, first_pctype;
17525 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17528 #ifdef RTE_LIBRTE_I40E_PMD
17529 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17536 printf("invalid port_id %d\n", res->port_id);
17539 printf("function not implemented\n");
17542 printf("programming error: (%s)\n", strerror(-ret));
17546 #ifdef RTE_LIBRTE_I40E_PMD
17547 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17548 if (mapping[i].pctype != 0ULL) {
17551 printf("pctype: ");
17552 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17553 if (mapping[i].pctype & (1ULL << j)) {
17554 printf(first_pctype ?
17555 "%02d" : ",%02d", j);
17559 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17565 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17566 .f = cmd_pctype_mapping_get_parsed,
17568 .help_str = "show port <port_id> pctype mapping",
17570 (void *)&cmd_pctype_mapping_get_show,
17571 (void *)&cmd_pctype_mapping_get_port,
17572 (void *)&cmd_pctype_mapping_get_port_id,
17573 (void *)&cmd_pctype_mapping_get_pctype,
17574 (void *)&cmd_pctype_mapping_get_mapping,
17579 /* port config pctype mapping update */
17581 /* Common result structure for port config pctype mapping update */
17582 struct cmd_pctype_mapping_update_result {
17583 cmdline_fixed_string_t port;
17584 cmdline_fixed_string_t config;
17586 cmdline_fixed_string_t pctype;
17587 cmdline_fixed_string_t mapping;
17588 cmdline_fixed_string_t update;
17589 cmdline_fixed_string_t pctype_list;
17590 uint16_t flow_type;
17593 /* Common CLI fields for pctype mapping update*/
17594 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17595 TOKEN_STRING_INITIALIZER
17596 (struct cmd_pctype_mapping_update_result,
17598 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17599 TOKEN_STRING_INITIALIZER
17600 (struct cmd_pctype_mapping_update_result,
17602 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17603 TOKEN_NUM_INITIALIZER
17604 (struct cmd_pctype_mapping_update_result,
17606 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17607 TOKEN_STRING_INITIALIZER
17608 (struct cmd_pctype_mapping_update_result,
17610 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17611 TOKEN_STRING_INITIALIZER
17612 (struct cmd_pctype_mapping_update_result,
17613 mapping, "mapping");
17614 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17615 TOKEN_STRING_INITIALIZER
17616 (struct cmd_pctype_mapping_update_result,
17618 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17619 TOKEN_STRING_INITIALIZER
17620 (struct cmd_pctype_mapping_update_result,
17621 pctype_list, NULL);
17622 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17623 TOKEN_NUM_INITIALIZER
17624 (struct cmd_pctype_mapping_update_result,
17625 flow_type, UINT16);
17628 cmd_pctype_mapping_update_parsed(
17629 void *parsed_result,
17630 __rte_unused struct cmdline *cl,
17631 __rte_unused void *data)
17633 struct cmd_pctype_mapping_update_result *res = parsed_result;
17634 int ret = -ENOTSUP;
17635 #ifdef RTE_LIBRTE_I40E_PMD
17636 struct rte_pmd_i40e_flow_type_mapping mapping;
17638 unsigned int nb_item;
17639 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17642 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17645 #ifdef RTE_LIBRTE_I40E_PMD
17646 nb_item = parse_item_list(res->pctype_list, "pctypes",
17647 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17648 mapping.flow_type = res->flow_type;
17649 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17650 mapping.pctype |= (1ULL << pctype_list[i]);
17651 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17661 printf("invalid pctype or flow type\n");
17664 printf("invalid port_id %d\n", res->port_id);
17667 printf("function not implemented\n");
17670 printf("programming error: (%s)\n", strerror(-ret));
17674 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17675 .f = cmd_pctype_mapping_update_parsed,
17677 .help_str = "port config <port_id> pctype mapping update"
17678 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17680 (void *)&cmd_pctype_mapping_update_port,
17681 (void *)&cmd_pctype_mapping_update_config,
17682 (void *)&cmd_pctype_mapping_update_port_id,
17683 (void *)&cmd_pctype_mapping_update_pctype,
17684 (void *)&cmd_pctype_mapping_update_mapping,
17685 (void *)&cmd_pctype_mapping_update_update,
17686 (void *)&cmd_pctype_mapping_update_pc_type,
17687 (void *)&cmd_pctype_mapping_update_flow_type,
17692 /* ptype mapping get */
17694 /* Common result structure for ptype mapping get */
17695 struct cmd_ptype_mapping_get_result {
17696 cmdline_fixed_string_t ptype;
17697 cmdline_fixed_string_t mapping;
17698 cmdline_fixed_string_t get;
17700 uint8_t valid_only;
17703 /* Common CLI fields for ptype mapping get */
17704 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17705 TOKEN_STRING_INITIALIZER
17706 (struct cmd_ptype_mapping_get_result,
17708 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17709 TOKEN_STRING_INITIALIZER
17710 (struct cmd_ptype_mapping_get_result,
17711 mapping, "mapping");
17712 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17713 TOKEN_STRING_INITIALIZER
17714 (struct cmd_ptype_mapping_get_result,
17716 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17717 TOKEN_NUM_INITIALIZER
17718 (struct cmd_ptype_mapping_get_result,
17720 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17721 TOKEN_NUM_INITIALIZER
17722 (struct cmd_ptype_mapping_get_result,
17723 valid_only, UINT8);
17726 cmd_ptype_mapping_get_parsed(
17727 void *parsed_result,
17728 __rte_unused struct cmdline *cl,
17729 __rte_unused void *data)
17731 struct cmd_ptype_mapping_get_result *res = parsed_result;
17732 int ret = -ENOTSUP;
17733 #ifdef RTE_LIBRTE_I40E_PMD
17734 int max_ptype_num = 256;
17735 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17740 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17743 #ifdef RTE_LIBRTE_I40E_PMD
17744 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17755 printf("invalid port_id %d\n", res->port_id);
17758 printf("function not implemented\n");
17761 printf("programming error: (%s)\n", strerror(-ret));
17764 #ifdef RTE_LIBRTE_I40E_PMD
17766 for (i = 0; i < count; i++)
17767 printf("%3d\t0x%08x\n",
17768 mapping[i].hw_ptype, mapping[i].sw_ptype);
17773 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17774 .f = cmd_ptype_mapping_get_parsed,
17776 .help_str = "ptype mapping get <port_id> <valid_only>",
17778 (void *)&cmd_ptype_mapping_get_ptype,
17779 (void *)&cmd_ptype_mapping_get_mapping,
17780 (void *)&cmd_ptype_mapping_get_get,
17781 (void *)&cmd_ptype_mapping_get_port_id,
17782 (void *)&cmd_ptype_mapping_get_valid_only,
17787 /* ptype mapping replace */
17789 /* Common result structure for ptype mapping replace */
17790 struct cmd_ptype_mapping_replace_result {
17791 cmdline_fixed_string_t ptype;
17792 cmdline_fixed_string_t mapping;
17793 cmdline_fixed_string_t replace;
17800 /* Common CLI fields for ptype mapping replace */
17801 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17802 TOKEN_STRING_INITIALIZER
17803 (struct cmd_ptype_mapping_replace_result,
17805 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17806 TOKEN_STRING_INITIALIZER
17807 (struct cmd_ptype_mapping_replace_result,
17808 mapping, "mapping");
17809 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17810 TOKEN_STRING_INITIALIZER
17811 (struct cmd_ptype_mapping_replace_result,
17812 replace, "replace");
17813 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17814 TOKEN_NUM_INITIALIZER
17815 (struct cmd_ptype_mapping_replace_result,
17817 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17818 TOKEN_NUM_INITIALIZER
17819 (struct cmd_ptype_mapping_replace_result,
17821 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17822 TOKEN_NUM_INITIALIZER
17823 (struct cmd_ptype_mapping_replace_result,
17825 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17826 TOKEN_NUM_INITIALIZER
17827 (struct cmd_ptype_mapping_replace_result,
17831 cmd_ptype_mapping_replace_parsed(
17832 void *parsed_result,
17833 __rte_unused struct cmdline *cl,
17834 __rte_unused void *data)
17836 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17837 int ret = -ENOTSUP;
17839 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17842 #ifdef RTE_LIBRTE_I40E_PMD
17843 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17853 printf("invalid ptype 0x%8x or 0x%8x\n",
17854 res->target, res->pkt_type);
17857 printf("invalid port_id %d\n", res->port_id);
17860 printf("function not implemented\n");
17863 printf("programming error: (%s)\n", strerror(-ret));
17867 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17868 .f = cmd_ptype_mapping_replace_parsed,
17871 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17873 (void *)&cmd_ptype_mapping_replace_ptype,
17874 (void *)&cmd_ptype_mapping_replace_mapping,
17875 (void *)&cmd_ptype_mapping_replace_replace,
17876 (void *)&cmd_ptype_mapping_replace_port_id,
17877 (void *)&cmd_ptype_mapping_replace_target,
17878 (void *)&cmd_ptype_mapping_replace_mask,
17879 (void *)&cmd_ptype_mapping_replace_pkt_type,
17884 /* ptype mapping reset */
17886 /* Common result structure for ptype mapping reset */
17887 struct cmd_ptype_mapping_reset_result {
17888 cmdline_fixed_string_t ptype;
17889 cmdline_fixed_string_t mapping;
17890 cmdline_fixed_string_t reset;
17894 /* Common CLI fields for ptype mapping reset*/
17895 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17896 TOKEN_STRING_INITIALIZER
17897 (struct cmd_ptype_mapping_reset_result,
17899 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17900 TOKEN_STRING_INITIALIZER
17901 (struct cmd_ptype_mapping_reset_result,
17902 mapping, "mapping");
17903 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17904 TOKEN_STRING_INITIALIZER
17905 (struct cmd_ptype_mapping_reset_result,
17907 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17908 TOKEN_NUM_INITIALIZER
17909 (struct cmd_ptype_mapping_reset_result,
17913 cmd_ptype_mapping_reset_parsed(
17914 void *parsed_result,
17915 __rte_unused struct cmdline *cl,
17916 __rte_unused void *data)
17918 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17919 int ret = -ENOTSUP;
17921 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17924 #ifdef RTE_LIBRTE_I40E_PMD
17925 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17932 printf("invalid port_id %d\n", res->port_id);
17935 printf("function not implemented\n");
17938 printf("programming error: (%s)\n", strerror(-ret));
17942 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17943 .f = cmd_ptype_mapping_reset_parsed,
17945 .help_str = "ptype mapping reset <port_id>",
17947 (void *)&cmd_ptype_mapping_reset_ptype,
17948 (void *)&cmd_ptype_mapping_reset_mapping,
17949 (void *)&cmd_ptype_mapping_reset_reset,
17950 (void *)&cmd_ptype_mapping_reset_port_id,
17955 /* ptype mapping update */
17957 /* Common result structure for ptype mapping update */
17958 struct cmd_ptype_mapping_update_result {
17959 cmdline_fixed_string_t ptype;
17960 cmdline_fixed_string_t mapping;
17961 cmdline_fixed_string_t reset;
17967 /* Common CLI fields for ptype mapping update*/
17968 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17969 TOKEN_STRING_INITIALIZER
17970 (struct cmd_ptype_mapping_update_result,
17972 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17973 TOKEN_STRING_INITIALIZER
17974 (struct cmd_ptype_mapping_update_result,
17975 mapping, "mapping");
17976 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17977 TOKEN_STRING_INITIALIZER
17978 (struct cmd_ptype_mapping_update_result,
17980 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17981 TOKEN_NUM_INITIALIZER
17982 (struct cmd_ptype_mapping_update_result,
17984 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17985 TOKEN_NUM_INITIALIZER
17986 (struct cmd_ptype_mapping_update_result,
17988 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17989 TOKEN_NUM_INITIALIZER
17990 (struct cmd_ptype_mapping_update_result,
17994 cmd_ptype_mapping_update_parsed(
17995 void *parsed_result,
17996 __rte_unused struct cmdline *cl,
17997 __rte_unused void *data)
17999 struct cmd_ptype_mapping_update_result *res = parsed_result;
18000 int ret = -ENOTSUP;
18001 #ifdef RTE_LIBRTE_I40E_PMD
18002 struct rte_pmd_i40e_ptype_mapping mapping;
18004 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18007 #ifdef RTE_LIBRTE_I40E_PMD
18008 mapping.hw_ptype = res->hw_ptype;
18009 mapping.sw_ptype = res->sw_ptype;
18010 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
18020 printf("invalid ptype 0x%8x\n", res->sw_ptype);
18023 printf("invalid port_id %d\n", res->port_id);
18026 printf("function not implemented\n");
18029 printf("programming error: (%s)\n", strerror(-ret));
18033 cmdline_parse_inst_t cmd_ptype_mapping_update = {
18034 .f = cmd_ptype_mapping_update_parsed,
18036 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
18038 (void *)&cmd_ptype_mapping_update_ptype,
18039 (void *)&cmd_ptype_mapping_update_mapping,
18040 (void *)&cmd_ptype_mapping_update_update,
18041 (void *)&cmd_ptype_mapping_update_port_id,
18042 (void *)&cmd_ptype_mapping_update_hw_ptype,
18043 (void *)&cmd_ptype_mapping_update_sw_ptype,
18048 /* Common result structure for file commands */
18049 struct cmd_cmdfile_result {
18050 cmdline_fixed_string_t load;
18051 cmdline_fixed_string_t filename;
18054 /* Common CLI fields for file commands */
18055 cmdline_parse_token_string_t cmd_load_cmdfile =
18056 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
18057 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
18058 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
18061 cmd_load_from_file_parsed(
18062 void *parsed_result,
18063 __rte_unused struct cmdline *cl,
18064 __rte_unused void *data)
18066 struct cmd_cmdfile_result *res = parsed_result;
18068 cmdline_read_from_file(res->filename);
18071 cmdline_parse_inst_t cmd_load_from_file = {
18072 .f = cmd_load_from_file_parsed,
18074 .help_str = "load <filename>",
18076 (void *)&cmd_load_cmdfile,
18077 (void *)&cmd_load_cmdfile_filename,
18082 /* Get Rx offloads capabilities */
18083 struct cmd_rx_offload_get_capa_result {
18084 cmdline_fixed_string_t show;
18085 cmdline_fixed_string_t port;
18087 cmdline_fixed_string_t rx_offload;
18088 cmdline_fixed_string_t capabilities;
18091 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
18092 TOKEN_STRING_INITIALIZER
18093 (struct cmd_rx_offload_get_capa_result,
18095 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
18096 TOKEN_STRING_INITIALIZER
18097 (struct cmd_rx_offload_get_capa_result,
18099 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
18100 TOKEN_NUM_INITIALIZER
18101 (struct cmd_rx_offload_get_capa_result,
18103 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
18104 TOKEN_STRING_INITIALIZER
18105 (struct cmd_rx_offload_get_capa_result,
18106 rx_offload, "rx_offload");
18107 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
18108 TOKEN_STRING_INITIALIZER
18109 (struct cmd_rx_offload_get_capa_result,
18110 capabilities, "capabilities");
18113 print_rx_offloads(uint64_t offloads)
18115 uint64_t single_offload;
18123 begin = __builtin_ctzll(offloads);
18124 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18126 single_offload = 1ULL << begin;
18127 for (bit = begin; bit < end; bit++) {
18128 if (offloads & single_offload)
18130 rte_eth_dev_rx_offload_name(single_offload));
18131 single_offload <<= 1;
18136 cmd_rx_offload_get_capa_parsed(
18137 void *parsed_result,
18138 __rte_unused struct cmdline *cl,
18139 __rte_unused void *data)
18141 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18142 struct rte_eth_dev_info dev_info;
18143 portid_t port_id = res->port_id;
18144 uint64_t queue_offloads;
18145 uint64_t port_offloads;
18148 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18152 queue_offloads = dev_info.rx_queue_offload_capa;
18153 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18155 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18156 printf(" Per Queue :");
18157 print_rx_offloads(queue_offloads);
18160 printf(" Per Port :");
18161 print_rx_offloads(port_offloads);
18165 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18166 .f = cmd_rx_offload_get_capa_parsed,
18168 .help_str = "show port <port_id> rx_offload capabilities",
18170 (void *)&cmd_rx_offload_get_capa_show,
18171 (void *)&cmd_rx_offload_get_capa_port,
18172 (void *)&cmd_rx_offload_get_capa_port_id,
18173 (void *)&cmd_rx_offload_get_capa_rx_offload,
18174 (void *)&cmd_rx_offload_get_capa_capabilities,
18179 /* Get Rx offloads configuration */
18180 struct cmd_rx_offload_get_configuration_result {
18181 cmdline_fixed_string_t show;
18182 cmdline_fixed_string_t port;
18184 cmdline_fixed_string_t rx_offload;
18185 cmdline_fixed_string_t configuration;
18188 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18189 TOKEN_STRING_INITIALIZER
18190 (struct cmd_rx_offload_get_configuration_result,
18192 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18193 TOKEN_STRING_INITIALIZER
18194 (struct cmd_rx_offload_get_configuration_result,
18196 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18197 TOKEN_NUM_INITIALIZER
18198 (struct cmd_rx_offload_get_configuration_result,
18200 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18201 TOKEN_STRING_INITIALIZER
18202 (struct cmd_rx_offload_get_configuration_result,
18203 rx_offload, "rx_offload");
18204 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18205 TOKEN_STRING_INITIALIZER
18206 (struct cmd_rx_offload_get_configuration_result,
18207 configuration, "configuration");
18210 cmd_rx_offload_get_configuration_parsed(
18211 void *parsed_result,
18212 __rte_unused struct cmdline *cl,
18213 __rte_unused void *data)
18215 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18216 struct rte_eth_dev_info dev_info;
18217 portid_t port_id = res->port_id;
18218 struct rte_port *port = &ports[port_id];
18219 uint64_t port_offloads;
18220 uint64_t queue_offloads;
18221 uint16_t nb_rx_queues;
18225 printf("Rx Offloading Configuration of port %d :\n", port_id);
18227 port_offloads = port->dev_conf.rxmode.offloads;
18229 print_rx_offloads(port_offloads);
18232 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18236 nb_rx_queues = dev_info.nb_rx_queues;
18237 for (q = 0; q < nb_rx_queues; q++) {
18238 queue_offloads = port->rx_conf[q].offloads;
18239 printf(" Queue[%2d] :", q);
18240 print_rx_offloads(queue_offloads);
18246 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18247 .f = cmd_rx_offload_get_configuration_parsed,
18249 .help_str = "show port <port_id> rx_offload configuration",
18251 (void *)&cmd_rx_offload_get_configuration_show,
18252 (void *)&cmd_rx_offload_get_configuration_port,
18253 (void *)&cmd_rx_offload_get_configuration_port_id,
18254 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18255 (void *)&cmd_rx_offload_get_configuration_configuration,
18260 /* Enable/Disable a per port offloading */
18261 struct cmd_config_per_port_rx_offload_result {
18262 cmdline_fixed_string_t port;
18263 cmdline_fixed_string_t config;
18265 cmdline_fixed_string_t rx_offload;
18266 cmdline_fixed_string_t offload;
18267 cmdline_fixed_string_t on_off;
18270 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18271 TOKEN_STRING_INITIALIZER
18272 (struct cmd_config_per_port_rx_offload_result,
18274 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18275 TOKEN_STRING_INITIALIZER
18276 (struct cmd_config_per_port_rx_offload_result,
18278 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18279 TOKEN_NUM_INITIALIZER
18280 (struct cmd_config_per_port_rx_offload_result,
18282 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18283 TOKEN_STRING_INITIALIZER
18284 (struct cmd_config_per_port_rx_offload_result,
18285 rx_offload, "rx_offload");
18286 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18287 TOKEN_STRING_INITIALIZER
18288 (struct cmd_config_per_port_rx_offload_result,
18289 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18290 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18291 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18292 "scatter#timestamp#security#keep_crc#rss_hash");
18293 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18294 TOKEN_STRING_INITIALIZER
18295 (struct cmd_config_per_port_rx_offload_result,
18299 search_rx_offload(const char *name)
18301 uint64_t single_offload;
18302 const char *single_name;
18306 single_offload = 1;
18307 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18308 single_name = rte_eth_dev_rx_offload_name(single_offload);
18309 if (!strcasecmp(single_name, name)) {
18313 single_offload <<= 1;
18317 return single_offload;
18323 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18324 __rte_unused struct cmdline *cl,
18325 __rte_unused void *data)
18327 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18328 portid_t port_id = res->port_id;
18329 struct rte_eth_dev_info dev_info;
18330 struct rte_port *port = &ports[port_id];
18331 uint64_t single_offload;
18332 uint16_t nb_rx_queues;
18336 if (port->port_status != RTE_PORT_STOPPED) {
18337 printf("Error: Can't config offload when Port %d "
18338 "is not stopped\n", port_id);
18342 single_offload = search_rx_offload(res->offload);
18343 if (single_offload == 0) {
18344 printf("Unknown offload name: %s\n", res->offload);
18348 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18352 nb_rx_queues = dev_info.nb_rx_queues;
18353 if (!strcmp(res->on_off, "on")) {
18354 port->dev_conf.rxmode.offloads |= single_offload;
18355 for (q = 0; q < nb_rx_queues; q++)
18356 port->rx_conf[q].offloads |= single_offload;
18358 port->dev_conf.rxmode.offloads &= ~single_offload;
18359 for (q = 0; q < nb_rx_queues; q++)
18360 port->rx_conf[q].offloads &= ~single_offload;
18363 cmd_reconfig_device_queue(port_id, 1, 1);
18366 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18367 .f = cmd_config_per_port_rx_offload_parsed,
18369 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18370 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18371 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18372 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18375 (void *)&cmd_config_per_port_rx_offload_result_port,
18376 (void *)&cmd_config_per_port_rx_offload_result_config,
18377 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18378 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18379 (void *)&cmd_config_per_port_rx_offload_result_offload,
18380 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18385 /* Enable/Disable a per queue offloading */
18386 struct cmd_config_per_queue_rx_offload_result {
18387 cmdline_fixed_string_t port;
18389 cmdline_fixed_string_t rxq;
18391 cmdline_fixed_string_t rx_offload;
18392 cmdline_fixed_string_t offload;
18393 cmdline_fixed_string_t on_off;
18396 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18397 TOKEN_STRING_INITIALIZER
18398 (struct cmd_config_per_queue_rx_offload_result,
18400 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18401 TOKEN_NUM_INITIALIZER
18402 (struct cmd_config_per_queue_rx_offload_result,
18404 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18405 TOKEN_STRING_INITIALIZER
18406 (struct cmd_config_per_queue_rx_offload_result,
18408 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18409 TOKEN_NUM_INITIALIZER
18410 (struct cmd_config_per_queue_rx_offload_result,
18412 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18413 TOKEN_STRING_INITIALIZER
18414 (struct cmd_config_per_queue_rx_offload_result,
18415 rx_offload, "rx_offload");
18416 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18417 TOKEN_STRING_INITIALIZER
18418 (struct cmd_config_per_queue_rx_offload_result,
18419 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18420 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18421 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18422 "scatter#timestamp#security#keep_crc");
18423 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18424 TOKEN_STRING_INITIALIZER
18425 (struct cmd_config_per_queue_rx_offload_result,
18429 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18430 __rte_unused struct cmdline *cl,
18431 __rte_unused void *data)
18433 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18434 struct rte_eth_dev_info dev_info;
18435 portid_t port_id = res->port_id;
18436 uint16_t queue_id = res->queue_id;
18437 struct rte_port *port = &ports[port_id];
18438 uint64_t single_offload;
18441 if (port->port_status != RTE_PORT_STOPPED) {
18442 printf("Error: Can't config offload when Port %d "
18443 "is not stopped\n", port_id);
18447 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18451 if (queue_id >= dev_info.nb_rx_queues) {
18452 printf("Error: input queue_id should be 0 ... "
18453 "%d\n", dev_info.nb_rx_queues - 1);
18457 single_offload = search_rx_offload(res->offload);
18458 if (single_offload == 0) {
18459 printf("Unknown offload name: %s\n", res->offload);
18463 if (!strcmp(res->on_off, "on"))
18464 port->rx_conf[queue_id].offloads |= single_offload;
18466 port->rx_conf[queue_id].offloads &= ~single_offload;
18468 cmd_reconfig_device_queue(port_id, 1, 1);
18471 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18472 .f = cmd_config_per_queue_rx_offload_parsed,
18474 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18475 "vlan_strip|ipv4_cksum|"
18476 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18477 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18478 "jumbo_frame|scatter|timestamp|security|keep_crc "
18481 (void *)&cmd_config_per_queue_rx_offload_result_port,
18482 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18483 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18484 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18485 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18486 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18487 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18492 /* Get Tx offloads capabilities */
18493 struct cmd_tx_offload_get_capa_result {
18494 cmdline_fixed_string_t show;
18495 cmdline_fixed_string_t port;
18497 cmdline_fixed_string_t tx_offload;
18498 cmdline_fixed_string_t capabilities;
18501 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18502 TOKEN_STRING_INITIALIZER
18503 (struct cmd_tx_offload_get_capa_result,
18505 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18506 TOKEN_STRING_INITIALIZER
18507 (struct cmd_tx_offload_get_capa_result,
18509 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18510 TOKEN_NUM_INITIALIZER
18511 (struct cmd_tx_offload_get_capa_result,
18513 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18514 TOKEN_STRING_INITIALIZER
18515 (struct cmd_tx_offload_get_capa_result,
18516 tx_offload, "tx_offload");
18517 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18518 TOKEN_STRING_INITIALIZER
18519 (struct cmd_tx_offload_get_capa_result,
18520 capabilities, "capabilities");
18523 print_tx_offloads(uint64_t offloads)
18525 uint64_t single_offload;
18533 begin = __builtin_ctzll(offloads);
18534 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18536 single_offload = 1ULL << begin;
18537 for (bit = begin; bit < end; bit++) {
18538 if (offloads & single_offload)
18540 rte_eth_dev_tx_offload_name(single_offload));
18541 single_offload <<= 1;
18546 cmd_tx_offload_get_capa_parsed(
18547 void *parsed_result,
18548 __rte_unused struct cmdline *cl,
18549 __rte_unused void *data)
18551 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18552 struct rte_eth_dev_info dev_info;
18553 portid_t port_id = res->port_id;
18554 uint64_t queue_offloads;
18555 uint64_t port_offloads;
18558 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18562 queue_offloads = dev_info.tx_queue_offload_capa;
18563 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18565 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18566 printf(" Per Queue :");
18567 print_tx_offloads(queue_offloads);
18570 printf(" Per Port :");
18571 print_tx_offloads(port_offloads);
18575 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18576 .f = cmd_tx_offload_get_capa_parsed,
18578 .help_str = "show port <port_id> tx_offload capabilities",
18580 (void *)&cmd_tx_offload_get_capa_show,
18581 (void *)&cmd_tx_offload_get_capa_port,
18582 (void *)&cmd_tx_offload_get_capa_port_id,
18583 (void *)&cmd_tx_offload_get_capa_tx_offload,
18584 (void *)&cmd_tx_offload_get_capa_capabilities,
18589 /* Get Tx offloads configuration */
18590 struct cmd_tx_offload_get_configuration_result {
18591 cmdline_fixed_string_t show;
18592 cmdline_fixed_string_t port;
18594 cmdline_fixed_string_t tx_offload;
18595 cmdline_fixed_string_t configuration;
18598 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18599 TOKEN_STRING_INITIALIZER
18600 (struct cmd_tx_offload_get_configuration_result,
18602 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18603 TOKEN_STRING_INITIALIZER
18604 (struct cmd_tx_offload_get_configuration_result,
18606 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18607 TOKEN_NUM_INITIALIZER
18608 (struct cmd_tx_offload_get_configuration_result,
18610 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18611 TOKEN_STRING_INITIALIZER
18612 (struct cmd_tx_offload_get_configuration_result,
18613 tx_offload, "tx_offload");
18614 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18615 TOKEN_STRING_INITIALIZER
18616 (struct cmd_tx_offload_get_configuration_result,
18617 configuration, "configuration");
18620 cmd_tx_offload_get_configuration_parsed(
18621 void *parsed_result,
18622 __rte_unused struct cmdline *cl,
18623 __rte_unused void *data)
18625 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18626 struct rte_eth_dev_info dev_info;
18627 portid_t port_id = res->port_id;
18628 struct rte_port *port = &ports[port_id];
18629 uint64_t port_offloads;
18630 uint64_t queue_offloads;
18631 uint16_t nb_tx_queues;
18635 printf("Tx Offloading Configuration of port %d :\n", port_id);
18637 port_offloads = port->dev_conf.txmode.offloads;
18639 print_tx_offloads(port_offloads);
18642 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18646 nb_tx_queues = dev_info.nb_tx_queues;
18647 for (q = 0; q < nb_tx_queues; q++) {
18648 queue_offloads = port->tx_conf[q].offloads;
18649 printf(" Queue[%2d] :", q);
18650 print_tx_offloads(queue_offloads);
18656 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18657 .f = cmd_tx_offload_get_configuration_parsed,
18659 .help_str = "show port <port_id> tx_offload configuration",
18661 (void *)&cmd_tx_offload_get_configuration_show,
18662 (void *)&cmd_tx_offload_get_configuration_port,
18663 (void *)&cmd_tx_offload_get_configuration_port_id,
18664 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18665 (void *)&cmd_tx_offload_get_configuration_configuration,
18670 /* Enable/Disable a per port offloading */
18671 struct cmd_config_per_port_tx_offload_result {
18672 cmdline_fixed_string_t port;
18673 cmdline_fixed_string_t config;
18675 cmdline_fixed_string_t tx_offload;
18676 cmdline_fixed_string_t offload;
18677 cmdline_fixed_string_t on_off;
18680 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18681 TOKEN_STRING_INITIALIZER
18682 (struct cmd_config_per_port_tx_offload_result,
18684 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18685 TOKEN_STRING_INITIALIZER
18686 (struct cmd_config_per_port_tx_offload_result,
18688 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18689 TOKEN_NUM_INITIALIZER
18690 (struct cmd_config_per_port_tx_offload_result,
18692 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18693 TOKEN_STRING_INITIALIZER
18694 (struct cmd_config_per_port_tx_offload_result,
18695 tx_offload, "tx_offload");
18696 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18697 TOKEN_STRING_INITIALIZER
18698 (struct cmd_config_per_port_tx_offload_result,
18699 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18700 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18701 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18702 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18703 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18704 "send_on_timestamp");
18705 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18706 TOKEN_STRING_INITIALIZER
18707 (struct cmd_config_per_port_tx_offload_result,
18711 search_tx_offload(const char *name)
18713 uint64_t single_offload;
18714 const char *single_name;
18718 single_offload = 1;
18719 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18720 single_name = rte_eth_dev_tx_offload_name(single_offload);
18721 if (single_name == NULL)
18723 if (!strcasecmp(single_name, name)) {
18726 } else if (!strcasecmp(single_name, "UNKNOWN"))
18728 single_offload <<= 1;
18732 return single_offload;
18738 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18739 __rte_unused struct cmdline *cl,
18740 __rte_unused void *data)
18742 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18743 portid_t port_id = res->port_id;
18744 struct rte_eth_dev_info dev_info;
18745 struct rte_port *port = &ports[port_id];
18746 uint64_t single_offload;
18747 uint16_t nb_tx_queues;
18751 if (port->port_status != RTE_PORT_STOPPED) {
18752 printf("Error: Can't config offload when Port %d "
18753 "is not stopped\n", port_id);
18757 single_offload = search_tx_offload(res->offload);
18758 if (single_offload == 0) {
18759 printf("Unknown offload name: %s\n", res->offload);
18763 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18767 nb_tx_queues = dev_info.nb_tx_queues;
18768 if (!strcmp(res->on_off, "on")) {
18769 port->dev_conf.txmode.offloads |= single_offload;
18770 for (q = 0; q < nb_tx_queues; q++)
18771 port->tx_conf[q].offloads |= single_offload;
18773 port->dev_conf.txmode.offloads &= ~single_offload;
18774 for (q = 0; q < nb_tx_queues; q++)
18775 port->tx_conf[q].offloads &= ~single_offload;
18778 cmd_reconfig_device_queue(port_id, 1, 1);
18781 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18782 .f = cmd_config_per_port_tx_offload_parsed,
18784 .help_str = "port config <port_id> tx_offload "
18785 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18786 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18787 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18788 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18789 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18790 "send_on_timestamp on|off",
18792 (void *)&cmd_config_per_port_tx_offload_result_port,
18793 (void *)&cmd_config_per_port_tx_offload_result_config,
18794 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18795 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18796 (void *)&cmd_config_per_port_tx_offload_result_offload,
18797 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18802 /* Enable/Disable a per queue offloading */
18803 struct cmd_config_per_queue_tx_offload_result {
18804 cmdline_fixed_string_t port;
18806 cmdline_fixed_string_t txq;
18808 cmdline_fixed_string_t tx_offload;
18809 cmdline_fixed_string_t offload;
18810 cmdline_fixed_string_t on_off;
18813 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18814 TOKEN_STRING_INITIALIZER
18815 (struct cmd_config_per_queue_tx_offload_result,
18817 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18818 TOKEN_NUM_INITIALIZER
18819 (struct cmd_config_per_queue_tx_offload_result,
18821 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18822 TOKEN_STRING_INITIALIZER
18823 (struct cmd_config_per_queue_tx_offload_result,
18825 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18826 TOKEN_NUM_INITIALIZER
18827 (struct cmd_config_per_queue_tx_offload_result,
18829 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18830 TOKEN_STRING_INITIALIZER
18831 (struct cmd_config_per_queue_tx_offload_result,
18832 tx_offload, "tx_offload");
18833 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18834 TOKEN_STRING_INITIALIZER
18835 (struct cmd_config_per_queue_tx_offload_result,
18836 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18837 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18838 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18839 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18840 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18841 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18842 TOKEN_STRING_INITIALIZER
18843 (struct cmd_config_per_queue_tx_offload_result,
18847 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18848 __rte_unused struct cmdline *cl,
18849 __rte_unused void *data)
18851 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18852 struct rte_eth_dev_info dev_info;
18853 portid_t port_id = res->port_id;
18854 uint16_t queue_id = res->queue_id;
18855 struct rte_port *port = &ports[port_id];
18856 uint64_t single_offload;
18859 if (port->port_status != RTE_PORT_STOPPED) {
18860 printf("Error: Can't config offload when Port %d "
18861 "is not stopped\n", port_id);
18865 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18869 if (queue_id >= dev_info.nb_tx_queues) {
18870 printf("Error: input queue_id should be 0 ... "
18871 "%d\n", dev_info.nb_tx_queues - 1);
18875 single_offload = search_tx_offload(res->offload);
18876 if (single_offload == 0) {
18877 printf("Unknown offload name: %s\n", res->offload);
18881 if (!strcmp(res->on_off, "on"))
18882 port->tx_conf[queue_id].offloads |= single_offload;
18884 port->tx_conf[queue_id].offloads &= ~single_offload;
18886 cmd_reconfig_device_queue(port_id, 1, 1);
18889 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18890 .f = cmd_config_per_queue_tx_offload_parsed,
18892 .help_str = "port <port_id> txq <queue_id> tx_offload "
18893 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18894 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18895 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18896 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18897 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18900 (void *)&cmd_config_per_queue_tx_offload_result_port,
18901 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18902 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18903 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18904 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18905 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18906 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18911 /* *** configure tx_metadata for specific port *** */
18912 struct cmd_config_tx_metadata_specific_result {
18913 cmdline_fixed_string_t port;
18914 cmdline_fixed_string_t keyword;
18916 cmdline_fixed_string_t item;
18921 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18922 __rte_unused struct cmdline *cl,
18923 __rte_unused void *data)
18925 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18927 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18929 ports[res->port_id].tx_metadata = res->value;
18930 /* Add/remove callback to insert valid metadata in every Tx packet. */
18931 if (ports[res->port_id].tx_metadata)
18932 add_tx_md_callback(res->port_id);
18934 remove_tx_md_callback(res->port_id);
18935 rte_flow_dynf_metadata_register();
18938 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18939 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18941 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18942 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18943 keyword, "config");
18944 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18945 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18947 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18948 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18949 item, "tx_metadata");
18950 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18951 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18954 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18955 .f = cmd_config_tx_metadata_specific_parsed,
18957 .help_str = "port config <port_id> tx_metadata <value>",
18959 (void *)&cmd_config_tx_metadata_specific_port,
18960 (void *)&cmd_config_tx_metadata_specific_keyword,
18961 (void *)&cmd_config_tx_metadata_specific_id,
18962 (void *)&cmd_config_tx_metadata_specific_item,
18963 (void *)&cmd_config_tx_metadata_specific_value,
18968 /* *** set dynf *** */
18969 struct cmd_config_tx_dynf_specific_result {
18970 cmdline_fixed_string_t port;
18971 cmdline_fixed_string_t keyword;
18973 cmdline_fixed_string_t item;
18974 cmdline_fixed_string_t name;
18975 cmdline_fixed_string_t value;
18979 cmd_config_dynf_specific_parsed(void *parsed_result,
18980 __rte_unused struct cmdline *cl,
18981 __rte_unused void *data)
18983 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
18984 struct rte_mbuf_dynflag desc_flag;
18986 uint64_t old_port_flags;
18988 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18990 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
18992 if (strlcpy(desc_flag.name, res->name,
18993 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
18994 printf("Flag name too long\n");
18997 desc_flag.flags = 0;
18998 flag = rte_mbuf_dynflag_register(&desc_flag);
19000 printf("Can't register flag\n");
19003 strcpy(dynf_names[flag], desc_flag.name);
19005 old_port_flags = ports[res->port_id].mbuf_dynf;
19006 if (!strcmp(res->value, "set")) {
19007 ports[res->port_id].mbuf_dynf |= 1UL << flag;
19008 if (old_port_flags == 0)
19009 add_tx_dynf_callback(res->port_id);
19011 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
19012 if (ports[res->port_id].mbuf_dynf == 0)
19013 remove_tx_dynf_callback(res->port_id);
19017 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
19018 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19020 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
19021 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19022 keyword, "config");
19023 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
19024 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19026 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
19027 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19029 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
19030 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19032 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
19033 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19034 value, "set#clear");
19036 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
19037 .f = cmd_config_dynf_specific_parsed,
19039 .help_str = "port config <port id> dynf <name> set|clear",
19041 (void *)&cmd_config_tx_dynf_specific_port,
19042 (void *)&cmd_config_tx_dynf_specific_keyword,
19043 (void *)&cmd_config_tx_dynf_specific_port_id,
19044 (void *)&cmd_config_tx_dynf_specific_item,
19045 (void *)&cmd_config_tx_dynf_specific_name,
19046 (void *)&cmd_config_tx_dynf_specific_value,
19051 /* *** display tx_metadata per port configuration *** */
19052 struct cmd_show_tx_metadata_result {
19053 cmdline_fixed_string_t cmd_show;
19054 cmdline_fixed_string_t cmd_port;
19055 cmdline_fixed_string_t cmd_keyword;
19060 cmd_show_tx_metadata_parsed(void *parsed_result,
19061 __rte_unused struct cmdline *cl,
19062 __rte_unused void *data)
19064 struct cmd_show_tx_metadata_result *res = parsed_result;
19066 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19067 printf("invalid port id %u\n", res->cmd_pid);
19070 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
19071 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
19072 ports[res->cmd_pid].tx_metadata);
19076 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
19077 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19079 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
19080 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19082 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
19083 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
19085 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
19086 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19087 cmd_keyword, "tx_metadata");
19089 cmdline_parse_inst_t cmd_show_tx_metadata = {
19090 .f = cmd_show_tx_metadata_parsed,
19092 .help_str = "show port <port_id> tx_metadata",
19094 (void *)&cmd_show_tx_metadata_show,
19095 (void *)&cmd_show_tx_metadata_port,
19096 (void *)&cmd_show_tx_metadata_pid,
19097 (void *)&cmd_show_tx_metadata_keyword,
19102 /* show port supported ptypes */
19104 /* Common result structure for show port ptypes */
19105 struct cmd_show_port_supported_ptypes_result {
19106 cmdline_fixed_string_t show;
19107 cmdline_fixed_string_t port;
19109 cmdline_fixed_string_t ptypes;
19112 /* Common CLI fields for show port ptypes */
19113 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
19114 TOKEN_STRING_INITIALIZER
19115 (struct cmd_show_port_supported_ptypes_result,
19117 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
19118 TOKEN_STRING_INITIALIZER
19119 (struct cmd_show_port_supported_ptypes_result,
19121 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19122 TOKEN_NUM_INITIALIZER
19123 (struct cmd_show_port_supported_ptypes_result,
19125 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19126 TOKEN_STRING_INITIALIZER
19127 (struct cmd_show_port_supported_ptypes_result,
19131 cmd_show_port_supported_ptypes_parsed(
19132 void *parsed_result,
19133 __rte_unused struct cmdline *cl,
19134 __rte_unused void *data)
19136 #define RSVD_PTYPE_MASK 0xf0000000
19137 #define MAX_PTYPES_PER_LAYER 16
19138 #define LTYPE_NAMESIZE 32
19139 #define PTYPE_NAMESIZE 256
19140 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19141 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19142 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19143 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19144 uint16_t port_id = res->port_id;
19147 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19151 while (ptype_mask != RSVD_PTYPE_MASK) {
19153 switch (ptype_mask) {
19154 case RTE_PTYPE_L2_MASK:
19155 strlcpy(ltype, "L2", sizeof(ltype));
19157 case RTE_PTYPE_L3_MASK:
19158 strlcpy(ltype, "L3", sizeof(ltype));
19160 case RTE_PTYPE_L4_MASK:
19161 strlcpy(ltype, "L4", sizeof(ltype));
19163 case RTE_PTYPE_TUNNEL_MASK:
19164 strlcpy(ltype, "Tunnel", sizeof(ltype));
19166 case RTE_PTYPE_INNER_L2_MASK:
19167 strlcpy(ltype, "Inner L2", sizeof(ltype));
19169 case RTE_PTYPE_INNER_L3_MASK:
19170 strlcpy(ltype, "Inner L3", sizeof(ltype));
19172 case RTE_PTYPE_INNER_L4_MASK:
19173 strlcpy(ltype, "Inner L4", sizeof(ltype));
19179 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19180 ptype_mask, ptypes,
19181 MAX_PTYPES_PER_LAYER);
19184 printf("Supported %s ptypes:\n", ltype);
19186 printf("%s ptypes unsupported\n", ltype);
19188 for (i = 0; i < ret; ++i) {
19189 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19190 printf("%s\n", buf);
19197 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19198 .f = cmd_show_port_supported_ptypes_parsed,
19200 .help_str = "show port <port_id> ptypes",
19202 (void *)&cmd_show_port_supported_ptypes_show,
19203 (void *)&cmd_show_port_supported_ptypes_port,
19204 (void *)&cmd_show_port_supported_ptypes_port_id,
19205 (void *)&cmd_show_port_supported_ptypes_ptypes,
19210 /* *** display rx/tx descriptor status *** */
19211 struct cmd_show_rx_tx_desc_status_result {
19212 cmdline_fixed_string_t cmd_show;
19213 cmdline_fixed_string_t cmd_port;
19214 cmdline_fixed_string_t cmd_keyword;
19215 cmdline_fixed_string_t cmd_desc;
19216 cmdline_fixed_string_t cmd_status;
19223 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19224 __rte_unused struct cmdline *cl,
19225 __rte_unused void *data)
19227 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19230 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19231 printf("invalid port id %u\n", res->cmd_pid);
19235 if (!strcmp(res->cmd_keyword, "rxq")) {
19236 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19239 printf("Invalid queueid = %d\n", res->cmd_qid);
19242 if (rc == RTE_ETH_RX_DESC_AVAIL)
19243 printf("Desc status = AVAILABLE\n");
19244 else if (rc == RTE_ETH_RX_DESC_DONE)
19245 printf("Desc status = DONE\n");
19247 printf("Desc status = UNAVAILABLE\n");
19248 } else if (!strcmp(res->cmd_keyword, "txq")) {
19249 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19252 printf("Invalid queueid = %d\n", res->cmd_qid);
19255 if (rc == RTE_ETH_TX_DESC_FULL)
19256 printf("Desc status = FULL\n");
19257 else if (rc == RTE_ETH_TX_DESC_DONE)
19258 printf("Desc status = DONE\n");
19260 printf("Desc status = UNAVAILABLE\n");
19264 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19265 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19267 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19268 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19270 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19271 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19273 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19274 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19275 cmd_keyword, "rxq#txq");
19276 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19277 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19279 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19280 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19282 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19283 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19285 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19286 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19287 cmd_status, "status");
19288 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19289 .f = cmd_show_rx_tx_desc_status_parsed,
19291 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19294 (void *)&cmd_show_rx_tx_desc_status_show,
19295 (void *)&cmd_show_rx_tx_desc_status_port,
19296 (void *)&cmd_show_rx_tx_desc_status_pid,
19297 (void *)&cmd_show_rx_tx_desc_status_keyword,
19298 (void *)&cmd_show_rx_tx_desc_status_qid,
19299 (void *)&cmd_show_rx_tx_desc_status_desc,
19300 (void *)&cmd_show_rx_tx_desc_status_did,
19301 (void *)&cmd_show_rx_tx_desc_status_status,
19306 /* Common result structure for set port ptypes */
19307 struct cmd_set_port_ptypes_result {
19308 cmdline_fixed_string_t set;
19309 cmdline_fixed_string_t port;
19311 cmdline_fixed_string_t ptype_mask;
19315 /* Common CLI fields for set port ptypes */
19316 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19317 TOKEN_STRING_INITIALIZER
19318 (struct cmd_set_port_ptypes_result,
19320 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19321 TOKEN_STRING_INITIALIZER
19322 (struct cmd_set_port_ptypes_result,
19324 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19325 TOKEN_NUM_INITIALIZER
19326 (struct cmd_set_port_ptypes_result,
19328 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19329 TOKEN_STRING_INITIALIZER
19330 (struct cmd_set_port_ptypes_result,
19331 ptype_mask, "ptype_mask");
19332 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19333 TOKEN_NUM_INITIALIZER
19334 (struct cmd_set_port_ptypes_result,
19338 cmd_set_port_ptypes_parsed(
19339 void *parsed_result,
19340 __rte_unused struct cmdline *cl,
19341 __rte_unused void *data)
19343 struct cmd_set_port_ptypes_result *res = parsed_result;
19344 #define PTYPE_NAMESIZE 256
19345 char ptype_name[PTYPE_NAMESIZE];
19346 uint16_t port_id = res->port_id;
19347 uint32_t ptype_mask = res->mask;
19350 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19353 printf("Port %d doesn't support any ptypes.\n", port_id);
19357 uint32_t ptypes[ret];
19359 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19361 printf("Unable to set requested ptypes for Port %d\n", port_id);
19365 printf("Successfully set following ptypes for Port %d\n", port_id);
19366 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19367 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19368 printf("%s\n", ptype_name);
19371 clear_ptypes = false;
19374 cmdline_parse_inst_t cmd_set_port_ptypes = {
19375 .f = cmd_set_port_ptypes_parsed,
19377 .help_str = "set port <port_id> ptype_mask <mask>",
19379 (void *)&cmd_set_port_ptypes_set,
19380 (void *)&cmd_set_port_ptypes_port,
19381 (void *)&cmd_set_port_ptypes_port_id,
19382 (void *)&cmd_set_port_ptypes_mask_str,
19383 (void *)&cmd_set_port_ptypes_mask_u32,
19388 /* *** display mac addresses added to a port *** */
19389 struct cmd_showport_macs_result {
19390 cmdline_fixed_string_t cmd_show;
19391 cmdline_fixed_string_t cmd_port;
19392 cmdline_fixed_string_t cmd_keyword;
19397 cmd_showport_macs_parsed(void *parsed_result,
19398 __rte_unused struct cmdline *cl,
19399 __rte_unused void *data)
19401 struct cmd_showport_macs_result *res = parsed_result;
19403 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19406 if (!strcmp(res->cmd_keyword, "macs"))
19407 show_macs(res->cmd_pid);
19408 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19409 show_mcast_macs(res->cmd_pid);
19412 cmdline_parse_token_string_t cmd_showport_macs_show =
19413 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19415 cmdline_parse_token_string_t cmd_showport_macs_port =
19416 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19418 cmdline_parse_token_num_t cmd_showport_macs_pid =
19419 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19421 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19422 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19423 cmd_keyword, "macs#mcast_macs");
19425 cmdline_parse_inst_t cmd_showport_macs = {
19426 .f = cmd_showport_macs_parsed,
19428 .help_str = "show port <port_id> macs|mcast_macs",
19430 (void *)&cmd_showport_macs_show,
19431 (void *)&cmd_showport_macs_port,
19432 (void *)&cmd_showport_macs_pid,
19433 (void *)&cmd_showport_macs_keyword,
19438 /* ******************************************************************************** */
19440 /* list of instructions */
19441 cmdline_parse_ctx_t main_ctx[] = {
19442 (cmdline_parse_inst_t *)&cmd_help_brief,
19443 (cmdline_parse_inst_t *)&cmd_help_long,
19444 (cmdline_parse_inst_t *)&cmd_quit,
19445 (cmdline_parse_inst_t *)&cmd_load_from_file,
19446 (cmdline_parse_inst_t *)&cmd_showport,
19447 (cmdline_parse_inst_t *)&cmd_showqueue,
19448 (cmdline_parse_inst_t *)&cmd_showportall,
19449 (cmdline_parse_inst_t *)&cmd_showdevice,
19450 (cmdline_parse_inst_t *)&cmd_showcfg,
19451 (cmdline_parse_inst_t *)&cmd_showfwdall,
19452 (cmdline_parse_inst_t *)&cmd_start,
19453 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19454 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19455 (cmdline_parse_inst_t *)&cmd_set_link_up,
19456 (cmdline_parse_inst_t *)&cmd_set_link_down,
19457 (cmdline_parse_inst_t *)&cmd_reset,
19458 (cmdline_parse_inst_t *)&cmd_set_numbers,
19459 (cmdline_parse_inst_t *)&cmd_set_log,
19460 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19461 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19462 (cmdline_parse_inst_t *)&cmd_set_txtimes,
19463 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19464 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19465 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19466 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19467 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19468 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19469 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19470 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19471 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19472 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19473 (cmdline_parse_inst_t *)&cmd_set_link_check,
19474 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19475 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19476 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19477 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19478 #ifdef RTE_LIBRTE_PMD_BOND
19479 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19480 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19481 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19482 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19483 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19484 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19485 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19486 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19487 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19488 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19489 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19491 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19492 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19493 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19494 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19495 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19496 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19497 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19498 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19499 (cmdline_parse_inst_t *)&cmd_csum_set,
19500 (cmdline_parse_inst_t *)&cmd_csum_show,
19501 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19502 (cmdline_parse_inst_t *)&cmd_tso_set,
19503 (cmdline_parse_inst_t *)&cmd_tso_show,
19504 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19505 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19506 (cmdline_parse_inst_t *)&cmd_gro_enable,
19507 (cmdline_parse_inst_t *)&cmd_gro_flush,
19508 (cmdline_parse_inst_t *)&cmd_gro_show,
19509 (cmdline_parse_inst_t *)&cmd_gso_enable,
19510 (cmdline_parse_inst_t *)&cmd_gso_size,
19511 (cmdline_parse_inst_t *)&cmd_gso_show,
19512 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19513 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19514 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19515 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19516 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19517 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19518 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19519 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19520 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19521 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19522 (cmdline_parse_inst_t *)&cmd_config_dcb,
19523 (cmdline_parse_inst_t *)&cmd_read_reg,
19524 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19525 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19526 (cmdline_parse_inst_t *)&cmd_write_reg,
19527 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19528 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19529 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19530 (cmdline_parse_inst_t *)&cmd_stop,
19531 (cmdline_parse_inst_t *)&cmd_mac_addr,
19532 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19533 (cmdline_parse_inst_t *)&cmd_set_qmap,
19534 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19535 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
19536 (cmdline_parse_inst_t *)&cmd_operate_port,
19537 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19538 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19539 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19540 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19541 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19542 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19543 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19544 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19545 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19546 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19547 (cmdline_parse_inst_t *)&cmd_config_mtu,
19548 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19549 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19550 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19551 (cmdline_parse_inst_t *)&cmd_config_rss,
19552 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19553 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19554 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19555 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19556 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19557 (cmdline_parse_inst_t *)&cmd_showport_reta,
19558 (cmdline_parse_inst_t *)&cmd_showport_macs,
19559 (cmdline_parse_inst_t *)&cmd_config_burst,
19560 (cmdline_parse_inst_t *)&cmd_config_thresh,
19561 (cmdline_parse_inst_t *)&cmd_config_threshold,
19562 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19563 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19564 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19565 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19566 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19567 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19568 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19569 (cmdline_parse_inst_t *)&cmd_global_config,
19570 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19571 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19572 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19573 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19574 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19575 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19576 (cmdline_parse_inst_t *)&cmd_dump,
19577 (cmdline_parse_inst_t *)&cmd_dump_one,
19578 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19579 (cmdline_parse_inst_t *)&cmd_syn_filter,
19580 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19581 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19582 (cmdline_parse_inst_t *)&cmd_flex_filter,
19583 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19584 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19585 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19586 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19587 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19588 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19589 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19590 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19591 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19592 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19593 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19594 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19595 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19596 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19597 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19598 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19599 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19600 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19601 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19602 (cmdline_parse_inst_t *)&cmd_flow,
19603 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19604 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19605 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19606 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19607 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19608 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19609 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19610 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19611 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19612 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19613 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19614 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19615 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19616 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19617 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19618 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19619 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19620 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19621 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19622 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19623 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19624 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19625 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19626 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19627 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19628 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19629 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19630 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19631 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19632 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19633 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19634 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19635 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19636 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19637 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19638 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19639 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19640 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19641 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19642 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19643 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19644 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19645 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19646 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19647 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19648 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19649 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19650 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19651 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19652 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19653 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19654 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19655 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19656 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19657 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19658 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19659 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19660 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19661 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19662 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19663 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19664 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19665 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19666 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19667 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19668 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19669 (cmdline_parse_inst_t *)&cmd_ddp_add,
19670 (cmdline_parse_inst_t *)&cmd_ddp_del,
19671 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19672 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19673 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19674 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19675 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19676 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19677 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19678 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19679 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19680 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19681 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19682 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19684 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19685 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19686 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19687 (cmdline_parse_inst_t *)&cmd_queue_region,
19688 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19689 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19690 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19691 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19692 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19693 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19694 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19695 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19696 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19697 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19698 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19699 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19700 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19701 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19702 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19703 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19704 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19705 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19706 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19707 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19708 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19709 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19710 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19711 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19712 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19713 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19714 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19715 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19716 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19717 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19718 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19719 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19720 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19721 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19722 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19723 #ifdef RTE_LIBRTE_BPF
19724 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19725 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19727 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19728 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19729 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19730 (cmdline_parse_inst_t *)&cmd_set_raw,
19731 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19732 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19733 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
19737 /* read cmdline commands from file */
19739 cmdline_read_from_file(const char *filename)
19741 struct cmdline *cl;
19743 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19745 printf("Failed to create file based cmdline context: %s\n",
19750 cmdline_interact(cl);
19755 printf("Read CLI commands from %s\n", filename);
19758 /* prompt function, called from main on MASTER lcore */
19762 /* initialize non-constant commands */
19763 cmd_set_fwd_mode_init();
19764 cmd_set_fwd_retry_mode_init();
19766 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19767 if (testpmd_cl == NULL)
19769 cmdline_interact(testpmd_cl);
19770 cmdline_stdin_exit(testpmd_cl);
19776 if (testpmd_cl != NULL)
19777 cmdline_quit(testpmd_cl);
19781 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19783 if (id == (portid_t)RTE_PORT_ALL) {
19786 RTE_ETH_FOREACH_DEV(pid) {
19787 /* check if need_reconfig has been set to 1 */
19788 if (ports[pid].need_reconfig == 0)
19789 ports[pid].need_reconfig = dev;
19790 /* check if need_reconfig_queues has been set to 1 */
19791 if (ports[pid].need_reconfig_queues == 0)
19792 ports[pid].need_reconfig_queues = queue;
19794 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19795 /* check if need_reconfig has been set to 1 */
19796 if (ports[id].need_reconfig == 0)
19797 ports[id].need_reconfig = dev;
19798 /* check if need_reconfig_queues has been set to 1 */
19799 if (ports[id].need_reconfig_queues == 0)
19800 ports[id].need_reconfig_queues = queue;