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 port (port_id) vf (vf_id) rx|tx on|off\n"
533 " Enable/Disable a VF receive/tranmit from a port\n\n"
535 "set port (port_id) vf (vf_id) (mac_addr)"
536 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
537 " Add/Remove unicast or multicast MAC addr filter"
540 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
542 " AUPE:accepts untagged VLAN;"
543 "ROPE:accept unicast hash\n\n"
544 " BAM:accepts broadcast packets;"
545 "MPE:accepts all multicast packets\n\n"
546 " Enable/Disable a VF receive mode of a port\n\n"
548 "set port (port_id) queue (queue_id) rate (rate_num)\n"
549 " Set rate limit for a queue of a port\n\n"
551 "set port (port_id) vf (vf_id) rate (rate_num) "
552 "queue_mask (queue_mask_value)\n"
553 " Set rate limit for queues in VF of a port\n\n"
555 "set port (port_id) mirror-rule (rule_id)"
556 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
557 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
558 " Set pool or vlan type mirror rule on a port.\n"
559 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
560 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
563 "set port (port_id) mirror-rule (rule_id)"
564 " (uplink-mirror|downlink-mirror) dst-pool"
565 " (pool_id) (on|off)\n"
566 " Set uplink or downlink type mirror rule on a port.\n"
567 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
568 " 0 on' enable mirror income traffic to pool 0.\n\n"
570 "reset port (port_id) mirror-rule (rule_id)\n"
571 " Reset a mirror rule.\n\n"
573 "set flush_rx (on|off)\n"
574 " Flush (default) or don't flush RX streams before"
575 " forwarding. Mainly used with PCAP drivers.\n\n"
577 "set bypass mode (normal|bypass|isolate) (port_id)\n"
578 " Set the bypass mode for the lowest port on bypass enabled"
581 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
582 "mode (normal|bypass|isolate) (port_id)\n"
583 " Set the event required to initiate specified bypass mode for"
584 " the lowest port on a bypass enabled NIC where:\n"
585 " timeout = enable bypass after watchdog timeout.\n"
586 " os_on = enable bypass when OS/board is powered on.\n"
587 " os_off = enable bypass when OS/board is powered off.\n"
588 " power_on = enable bypass when power supply is turned on.\n"
589 " power_off = enable bypass when power supply is turned off."
592 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
593 " Set the bypass watchdog timeout to 'n' seconds"
594 " where 0 = instant.\n\n"
596 "show bypass config (port_id)\n"
597 " Show the bypass configuration for a bypass enabled NIC"
598 " using the lowest port on the NIC.\n\n"
600 #ifdef RTE_LIBRTE_PMD_BOND
601 "create bonded device (mode) (socket)\n"
602 " Create a new bonded device with specific bonding mode and socket.\n\n"
604 "add bonding slave (slave_id) (port_id)\n"
605 " Add a slave device to a bonded device.\n\n"
607 "remove bonding slave (slave_id) (port_id)\n"
608 " Remove a slave device from a bonded device.\n\n"
610 "set bonding mode (value) (port_id)\n"
611 " Set the bonding mode on a bonded device.\n\n"
613 "set bonding primary (slave_id) (port_id)\n"
614 " Set the primary slave for a bonded device.\n\n"
616 "show bonding config (port_id)\n"
617 " Show the bonding config for port_id.\n\n"
619 "set bonding mac_addr (port_id) (address)\n"
620 " Set the MAC address of a bonded device.\n\n"
622 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
623 " Set Aggregation mode for IEEE802.3AD (mode 4)"
625 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
626 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
628 "set bonding mon_period (port_id) (value)\n"
629 " Set the bonding link status monitoring polling period in ms.\n\n"
631 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
632 " Enable/disable dedicated queues for LACP control traffic.\n\n"
635 "set link-up port (port_id)\n"
636 " Set link up for a port.\n\n"
638 "set link-down port (port_id)\n"
639 " Set link down for a port.\n\n"
641 "E-tag set insertion on port-tag-id (value)"
642 " port (port_id) vf (vf_id)\n"
643 " Enable E-tag insertion for a VF on a port\n\n"
645 "E-tag set insertion off port (port_id) vf (vf_id)\n"
646 " Disable E-tag insertion for a VF on a port\n\n"
648 "E-tag set stripping (on|off) port (port_id)\n"
649 " Enable/disable E-tag stripping on a port\n\n"
651 "E-tag set forwarding (on|off) port (port_id)\n"
652 " Enable/disable E-tag based forwarding"
655 "E-tag set filter add e-tag-id (value) dst-pool"
656 " (pool_id) port (port_id)\n"
657 " Add an E-tag forwarding filter on a port\n\n"
659 "E-tag set filter del e-tag-id (value) port (port_id)\n"
660 " Delete an E-tag forwarding filter on a port\n\n"
662 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
663 " Load a profile package on a port\n\n"
665 "ddp del (port_id) (backup_profile_path)\n"
666 " Delete a profile package from a port\n\n"
668 "ptype mapping get (port_id) (valid_only)\n"
669 " Get ptype mapping on a port\n\n"
671 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
672 " Replace target with the pkt_type in ptype mapping\n\n"
674 "ptype mapping reset (port_id)\n"
675 " Reset ptype mapping on a port\n\n"
677 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
678 " Update a ptype mapping item on a port\n\n"
680 "set port (port_id) ptype_mask (ptype_mask)\n"
681 " set packet types classification for a specific port\n\n"
683 "set port (port_id) queue-region region_id (value) "
684 "queue_start_index (value) queue_num (value)\n"
685 " Set a queue region on a port\n\n"
687 "set port (port_id) queue-region region_id (value) "
689 " Set a flowtype region index on a port\n\n"
691 "set port (port_id) queue-region UP (value) region_id (value)\n"
692 " Set the mapping of User Priority to "
693 "queue region on a port\n\n"
695 "set port (port_id) queue-region flush (on|off)\n"
696 " flush all queue region related configuration\n\n"
698 "show port meter cap (port_id)\n"
699 " Show port meter capability information\n\n"
701 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
702 " meter profile add - srtcm rfc 2697\n\n"
704 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
705 " meter profile add - trtcm rfc 2698\n\n"
707 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
708 " meter profile add - trtcm rfc 4115\n\n"
710 "del port meter profile (port_id) (profile_id)\n"
711 " meter profile delete\n\n"
713 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
714 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
715 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
716 "(dscp_tbl_entry63)]\n"
719 "enable port meter (port_id) (mtr_id)\n"
722 "disable port meter (port_id) (mtr_id)\n"
725 "del port meter (port_id) (mtr_id)\n"
728 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
729 " meter update meter profile\n\n"
731 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
732 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
733 " update meter dscp table entries\n\n"
735 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
736 "(action0) [(action1) (action2)]\n"
737 " meter update policer action\n\n"
739 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
740 " meter update stats\n\n"
742 "show port (port_id) queue-region\n"
743 " show all queue region related configuration info\n\n"
745 , list_pkt_forwarding_modes()
749 if (show_all || !strcmp(res->section, "ports")) {
755 "----------------\n\n"
757 "port start (port_id|all)\n"
758 " Start all ports or port_id.\n\n"
760 "port stop (port_id|all)\n"
761 " Stop all ports or port_id.\n\n"
763 "port close (port_id|all)\n"
764 " Close all ports or port_id.\n\n"
766 "port reset (port_id|all)\n"
767 " Reset all ports or port_id.\n\n"
769 "port attach (ident)\n"
770 " Attach physical or virtual dev by pci address or virtual device name\n\n"
772 "port detach (port_id)\n"
773 " Detach physical or virtual dev by port_id\n\n"
775 "port config (port_id|all)"
776 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
777 " duplex (half|full|auto)\n"
778 " Set speed and duplex for all ports or port_id\n\n"
780 "port config (port_id|all) loopback (mode)\n"
781 " Set loopback mode for all ports or port_id\n\n"
783 "port config all (rxq|txq|rxd|txd) (value)\n"
784 " Set number for rxq/txq/rxd/txd.\n\n"
786 "port config all max-pkt-len (value)\n"
787 " Set the max packet length.\n\n"
789 "port config all max-lro-pkt-size (value)\n"
790 " Set the max LRO aggregated packet size.\n\n"
792 "port config all drop-en (on|off)\n"
793 " Enable or disable packet drop on all RX queues of all ports when no "
794 "receive buffers available.\n\n"
796 "port config all rss (all|default|ip|tcp|udp|sctp|"
797 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
798 " Set the RSS mode.\n\n"
800 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
801 " Set the RSS redirection table.\n\n"
803 "port config (port_id) dcb vt (on|off) (traffic_class)"
805 " Set the DCB mode.\n\n"
807 "port config all burst (value)\n"
808 " Set the number of packets per burst.\n\n"
810 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
812 " Set the ring prefetch/host/writeback threshold"
813 " for tx/rx queue.\n\n"
815 "port config all (txfreet|txrst|rxfreet) (value)\n"
816 " Set free threshold for rx/tx, or set"
817 " tx rs bit threshold.\n\n"
818 "port config mtu X value\n"
819 " Set the MTU of port X to a given value\n\n"
821 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
822 " Set a rx/tx queue's ring size configuration, the new"
823 " value will take effect after command that (re-)start the port"
824 " or command that setup the specific queue\n\n"
826 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
827 " Start/stop a rx/tx queue of port X. Only take effect"
828 " when port X is started\n\n"
830 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
831 " Switch on/off a deferred start of port X rx/tx queue. Only"
832 " take effect when port X is stopped.\n\n"
834 "port (port_id) (rxq|txq) (queue_id) setup\n"
835 " Setup a rx/tx queue of port X.\n\n"
837 "port config (port_id|all) l2-tunnel E-tag ether-type"
839 " Set the value of E-tag ether-type.\n\n"
841 "port config (port_id|all) l2-tunnel E-tag"
842 " (enable|disable)\n"
843 " Enable/disable the E-tag support.\n\n"
845 "port config (port_id) pctype mapping reset\n"
846 " Reset flow type to pctype mapping on a port\n\n"
848 "port config (port_id) pctype mapping update"
849 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
850 " Update a flow type to pctype mapping item on a port\n\n"
852 "port config (port_id) pctype (pctype_id) hash_inset|"
853 "fdir_inset|fdir_flx_inset get|set|clear field\n"
855 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
857 "port config (port_id) pctype (pctype_id) hash_inset|"
858 "fdir_inset|fdir_flx_inset clear all"
859 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
861 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
862 " Add/remove UDP tunnel port for tunneling offload\n\n"
864 "port config <port_id> rx_offload vlan_strip|"
865 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
866 "outer_ipv4_cksum|macsec_strip|header_split|"
867 "vlan_filter|vlan_extend|jumbo_frame|"
868 "scatter|timestamp|security|keep_crc on|off\n"
869 " Enable or disable a per port Rx offloading"
870 " on all Rx queues of a port\n\n"
872 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
873 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
874 "outer_ipv4_cksum|macsec_strip|header_split|"
875 "vlan_filter|vlan_extend|jumbo_frame|"
876 "scatter|timestamp|security|keep_crc on|off\n"
877 " Enable or disable a per queue Rx offloading"
878 " only on a specific Rx queue\n\n"
880 "port config (port_id) tx_offload vlan_insert|"
881 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
882 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
883 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
884 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
886 " Enable or disable a per port Tx offloading"
887 " on all Tx queues of a port\n\n"
889 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
890 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
891 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
892 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
893 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
895 " Enable or disable a per queue Tx offloading"
896 " only on a specific Tx queue\n\n"
898 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
899 " Load an eBPF program as a callback"
900 " for particular RX/TX queue\n\n"
902 "bpf-unload rx|tx (port) (queue)\n"
903 " Unload previously loaded eBPF program"
904 " for particular RX/TX queue\n\n"
906 "port config (port_id) tx_metadata (value)\n"
907 " Set Tx metadata value per port. Testpmd will add this value"
908 " to any Tx packet sent from this port\n\n"
910 "port config (port_id) dynf (name) set|clear\n"
911 " Register a dynf and Set/clear this flag on Tx. "
912 "Testpmd will set this value to any Tx packet "
913 "sent from this port\n\n"
917 if (show_all || !strcmp(res->section, "registers")) {
925 "read reg (port_id) (address)\n"
926 " Display value of a port register.\n\n"
928 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
929 " Display a port register bit field.\n\n"
931 "read regbit (port_id) (address) (bit_x)\n"
932 " Display a single port register bit.\n\n"
934 "write reg (port_id) (address) (value)\n"
935 " Set value of a port register.\n\n"
937 "write regfield (port_id) (address) (bit_x) (bit_y)"
939 " Set bit field of a port register.\n\n"
941 "write regbit (port_id) (address) (bit_x) (value)\n"
942 " Set single bit value of a port register.\n\n"
945 if (show_all || !strcmp(res->section, "filters")) {
953 "ethertype_filter (port_id) (add|del)"
954 " (mac_addr|mac_ignr) (mac_address) ethertype"
955 " (ether_type) (drop|fwd) queue (queue_id)\n"
956 " Add/Del an ethertype filter.\n\n"
958 "2tuple_filter (port_id) (add|del)"
959 " dst_port (dst_port_value) protocol (protocol_value)"
960 " mask (mask_value) tcp_flags (tcp_flags_value)"
961 " priority (prio_value) queue (queue_id)\n"
962 " Add/Del a 2tuple filter.\n\n"
964 "5tuple_filter (port_id) (add|del)"
965 " dst_ip (dst_address) src_ip (src_address)"
966 " dst_port (dst_port_value) src_port (src_port_value)"
967 " protocol (protocol_value)"
968 " mask (mask_value) tcp_flags (tcp_flags_value)"
969 " priority (prio_value) queue (queue_id)\n"
970 " Add/Del a 5tuple filter.\n\n"
972 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
973 " Add/Del syn filter.\n\n"
975 "flex_filter (port_id) (add|del) len (len_value)"
976 " bytes (bytes_value) mask (mask_value)"
977 " priority (prio_value) queue (queue_id)\n"
978 " Add/Del a flex filter.\n\n"
980 "flow_director_filter (port_id) mode IP (add|del|update)"
981 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
982 " src (src_ip_address) dst (dst_ip_address)"
983 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
984 " vlan (vlan_value) flexbytes (flexbytes_value)"
985 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
986 " fd_id (fd_id_value)\n"
987 " Add/Del an IP type flow director filter.\n\n"
989 "flow_director_filter (port_id) mode IP (add|del|update)"
990 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
991 " src (src_ip_address) (src_port)"
992 " dst (dst_ip_address) (dst_port)"
993 " tos (tos_value) ttl (ttl_value)"
994 " vlan (vlan_value) flexbytes (flexbytes_value)"
995 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
996 " fd_id (fd_id_value)\n"
997 " Add/Del an UDP/TCP type flow director filter.\n\n"
999 "flow_director_filter (port_id) mode IP (add|del|update)"
1000 " flow (ipv4-sctp|ipv6-sctp)"
1001 " src (src_ip_address) (src_port)"
1002 " dst (dst_ip_address) (dst_port)"
1003 " tag (verification_tag) "
1004 " tos (tos_value) ttl (ttl_value)"
1005 " vlan (vlan_value)"
1006 " flexbytes (flexbytes_value) (drop|fwd)"
1007 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1008 " Add/Del a SCTP type flow director filter.\n\n"
1010 "flow_director_filter (port_id) mode IP (add|del|update)"
1011 " flow l2_payload ether (ethertype)"
1012 " flexbytes (flexbytes_value) (drop|fwd)"
1013 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1014 " Add/Del a l2 payload type flow director filter.\n\n"
1016 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1017 " mac (mac_address) vlan (vlan_value)"
1018 " flexbytes (flexbytes_value) (drop|fwd)"
1019 " queue (queue_id) fd_id (fd_id_value)\n"
1020 " Add/Del a MAC-VLAN flow director filter.\n\n"
1022 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1023 " mac (mac_address) vlan (vlan_value)"
1024 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1025 " flexbytes (flexbytes_value) (drop|fwd)"
1026 " queue (queue_id) fd_id (fd_id_value)\n"
1027 " Add/Del a Tunnel flow director filter.\n\n"
1029 "flow_director_filter (port_id) mode raw (add|del|update)"
1030 " flow (flow_id) (drop|fwd) queue (queue_id)"
1031 " fd_id (fd_id_value) packet (packet file name)\n"
1032 " Add/Del a raw type flow director filter.\n\n"
1034 "flush_flow_director (port_id)\n"
1035 " Flush all flow director entries of a device.\n\n"
1037 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1038 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1039 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1040 " Set flow director IP mask.\n\n"
1042 "flow_director_mask (port_id) mode MAC-VLAN"
1043 " vlan (vlan_value)\n"
1044 " Set flow director MAC-VLAN mask.\n\n"
1046 "flow_director_mask (port_id) mode Tunnel"
1047 " vlan (vlan_value) mac (mac_value)"
1048 " tunnel-type (tunnel_type_value)"
1049 " tunnel-id (tunnel_id_value)\n"
1050 " Set flow director Tunnel mask.\n\n"
1052 "flow_director_flex_mask (port_id)"
1053 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1054 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1056 " Configure mask of flex payload.\n\n"
1058 "flow_director_flex_payload (port_id)"
1059 " (raw|l2|l3|l4) (config)\n"
1060 " Configure flex payload selection.\n\n"
1062 "get_sym_hash_ena_per_port (port_id)\n"
1063 " get symmetric hash enable configuration per port.\n\n"
1065 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1066 " set symmetric hash enable configuration per port"
1067 " to enable or disable.\n\n"
1069 "get_hash_global_config (port_id)\n"
1070 " Get the global configurations of hash filters.\n\n"
1072 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1073 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1074 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1075 " (enable|disable)\n"
1076 " Set the global configurations of hash filters.\n\n"
1078 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1079 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1080 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1081 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1082 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1083 "ipv6-next-header|udp-src-port|udp-dst-port|"
1084 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1085 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1086 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1087 "fld-8th|none) (select|add)\n"
1088 " Set the input set for hash.\n\n"
1090 "set_fdir_input_set (port_id) "
1091 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1092 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1093 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1094 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1095 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1096 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1097 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1099 " Set the input set for FDir.\n\n"
1101 "flow validate {port_id}"
1102 " [group {group_id}] [priority {level}]"
1103 " [ingress] [egress]"
1104 " pattern {item} [/ {item} [...]] / end"
1105 " actions {action} [/ {action} [...]] / end\n"
1106 " Check whether a flow rule can be created.\n\n"
1108 "flow create {port_id}"
1109 " [group {group_id}] [priority {level}]"
1110 " [ingress] [egress]"
1111 " pattern {item} [/ {item} [...]] / end"
1112 " actions {action} [/ {action} [...]] / end\n"
1113 " Create a flow rule.\n\n"
1115 "flow destroy {port_id} rule {rule_id} [...]\n"
1116 " Destroy specific flow rules.\n\n"
1118 "flow flush {port_id}\n"
1119 " Destroy all flow rules.\n\n"
1121 "flow query {port_id} {rule_id} {action}\n"
1122 " Query an existing flow rule.\n\n"
1124 "flow list {port_id} [group {group_id}] [...]\n"
1125 " List existing flow rules sorted by priority,"
1126 " filtered by group identifiers.\n\n"
1128 "flow isolate {port_id} {boolean}\n"
1129 " Restrict ingress traffic to the defined"
1132 "flow aged {port_id} [destroy]\n"
1133 " List and destroy aged flows"
1136 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1137 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1138 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1139 " Configure the VXLAN encapsulation for flows.\n\n"
1141 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1142 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1143 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1144 " eth-dst (eth-dst)\n"
1145 " Configure the VXLAN encapsulation for flows.\n\n"
1147 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1148 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1149 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1150 " eth-dst (eth-dst)\n"
1151 " Configure the VXLAN encapsulation for flows.\n\n"
1153 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1154 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1156 " Configure the NVGRE encapsulation for flows.\n\n"
1158 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1159 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1160 " eth-src (eth-src) eth-dst (eth-dst)\n"
1161 " Configure the NVGRE encapsulation for flows.\n\n"
1163 "set raw_encap {flow items}\n"
1164 " Configure the encapsulation with raw data.\n\n"
1166 "set raw_decap {flow items}\n"
1167 " Configure the decapsulation with raw data.\n\n"
1172 if (show_all || !strcmp(res->section, "traffic_management")) {
1176 "Traffic Management:\n"
1178 "show port tm cap (port_id)\n"
1179 " Display the port TM capability.\n\n"
1181 "show port tm level cap (port_id) (level_id)\n"
1182 " Display the port TM hierarchical level capability.\n\n"
1184 "show port tm node cap (port_id) (node_id)\n"
1185 " Display the port TM node capability.\n\n"
1187 "show port tm node type (port_id) (node_id)\n"
1188 " Display the port TM node type.\n\n"
1190 "show port tm node stats (port_id) (node_id) (clear)\n"
1191 " Display the port TM node stats.\n\n"
1193 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1194 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1195 " (packet_length_adjust)\n"
1196 " Add port tm node private shaper profile.\n\n"
1198 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1199 " Delete port tm node private shaper profile.\n\n"
1201 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1202 " (shaper_profile_id)\n"
1203 " Add/update port tm node shared shaper.\n\n"
1205 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1206 " Delete port tm node shared shaper.\n\n"
1208 "set port tm node shaper profile (port_id) (node_id)"
1209 " (shaper_profile_id)\n"
1210 " Set port tm node shaper profile.\n\n"
1212 "add port tm node wred profile (port_id) (wred_profile_id)"
1213 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1214 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1215 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1216 " Add port tm node wred profile.\n\n"
1218 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1219 " Delete port tm node wred profile.\n\n"
1221 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1222 " (priority) (weight) (level_id) (shaper_profile_id)"
1223 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1224 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1225 " Add port tm nonleaf node.\n\n"
1227 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1228 " (priority) (weight) (level_id) (shaper_profile_id)"
1229 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1230 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1231 " Add port tm leaf node.\n\n"
1233 "del port tm node (port_id) (node_id)\n"
1234 " Delete port tm node.\n\n"
1236 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1237 " (priority) (weight)\n"
1238 " Set port tm node parent.\n\n"
1240 "suspend port tm node (port_id) (node_id)"
1241 " Suspend tm node.\n\n"
1243 "resume port tm node (port_id) (node_id)"
1244 " Resume tm node.\n\n"
1246 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1247 " Commit tm hierarchy.\n\n"
1249 "set port tm mark ip_ecn (port) (green) (yellow)"
1251 " Enables/Disables the traffic management marking"
1252 " for IP ECN (Explicit Congestion Notification)"
1253 " packets on a given port\n\n"
1255 "set port tm mark ip_dscp (port) (green) (yellow)"
1257 " Enables/Disables the traffic management marking"
1258 " on the port for IP dscp packets\n\n"
1260 "set port tm mark vlan_dei (port) (green) (yellow)"
1262 " Enables/Disables the traffic management marking"
1263 " on the port for VLAN packets with DEI enabled\n\n"
1267 if (show_all || !strcmp(res->section, "devices")) {
1271 "Device Operations:\n"
1273 "device detach (identifier)\n"
1274 " Detach device by identifier.\n\n"
1280 cmdline_parse_token_string_t cmd_help_long_help =
1281 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1283 cmdline_parse_token_string_t cmd_help_long_section =
1284 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1285 "all#control#display#config#"
1286 "ports#registers#filters#traffic_management#devices");
1288 cmdline_parse_inst_t cmd_help_long = {
1289 .f = cmd_help_long_parsed,
1291 .help_str = "help all|control|display|config|ports|register|"
1292 "filters|traffic_management|devices: "
1295 (void *)&cmd_help_long_help,
1296 (void *)&cmd_help_long_section,
1302 /* *** start/stop/close all ports *** */
1303 struct cmd_operate_port_result {
1304 cmdline_fixed_string_t keyword;
1305 cmdline_fixed_string_t name;
1306 cmdline_fixed_string_t value;
1309 static void cmd_operate_port_parsed(void *parsed_result,
1310 __rte_unused struct cmdline *cl,
1311 __rte_unused void *data)
1313 struct cmd_operate_port_result *res = parsed_result;
1315 if (!strcmp(res->name, "start"))
1316 start_port(RTE_PORT_ALL);
1317 else if (!strcmp(res->name, "stop"))
1318 stop_port(RTE_PORT_ALL);
1319 else if (!strcmp(res->name, "close"))
1320 close_port(RTE_PORT_ALL);
1321 else if (!strcmp(res->name, "reset"))
1322 reset_port(RTE_PORT_ALL);
1324 printf("Unknown parameter\n");
1327 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1328 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1330 cmdline_parse_token_string_t cmd_operate_port_all_port =
1331 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1332 "start#stop#close#reset");
1333 cmdline_parse_token_string_t cmd_operate_port_all_all =
1334 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1336 cmdline_parse_inst_t cmd_operate_port = {
1337 .f = cmd_operate_port_parsed,
1339 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1341 (void *)&cmd_operate_port_all_cmd,
1342 (void *)&cmd_operate_port_all_port,
1343 (void *)&cmd_operate_port_all_all,
1348 /* *** start/stop/close specific port *** */
1349 struct cmd_operate_specific_port_result {
1350 cmdline_fixed_string_t keyword;
1351 cmdline_fixed_string_t name;
1355 static void cmd_operate_specific_port_parsed(void *parsed_result,
1356 __rte_unused struct cmdline *cl,
1357 __rte_unused void *data)
1359 struct cmd_operate_specific_port_result *res = parsed_result;
1361 if (!strcmp(res->name, "start"))
1362 start_port(res->value);
1363 else if (!strcmp(res->name, "stop"))
1364 stop_port(res->value);
1365 else if (!strcmp(res->name, "close"))
1366 close_port(res->value);
1367 else if (!strcmp(res->name, "reset"))
1368 reset_port(res->value);
1370 printf("Unknown parameter\n");
1373 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1374 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1376 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1377 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1378 name, "start#stop#close#reset");
1379 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1380 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1383 cmdline_parse_inst_t cmd_operate_specific_port = {
1384 .f = cmd_operate_specific_port_parsed,
1386 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1388 (void *)&cmd_operate_specific_port_cmd,
1389 (void *)&cmd_operate_specific_port_port,
1390 (void *)&cmd_operate_specific_port_id,
1395 /* *** enable port setup (after attach) via iterator or event *** */
1396 struct cmd_set_port_setup_on_result {
1397 cmdline_fixed_string_t set;
1398 cmdline_fixed_string_t port;
1399 cmdline_fixed_string_t setup;
1400 cmdline_fixed_string_t on;
1401 cmdline_fixed_string_t mode;
1404 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1405 __rte_unused struct cmdline *cl,
1406 __rte_unused void *data)
1408 struct cmd_set_port_setup_on_result *res = parsed_result;
1410 if (strcmp(res->mode, "event") == 0)
1411 setup_on_probe_event = true;
1412 else if (strcmp(res->mode, "iterator") == 0)
1413 setup_on_probe_event = false;
1415 printf("Unknown mode\n");
1418 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1419 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1421 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1422 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1424 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1425 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1427 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1428 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1430 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1431 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1432 mode, "iterator#event");
1434 cmdline_parse_inst_t cmd_set_port_setup_on = {
1435 .f = cmd_set_port_setup_on_parsed,
1437 .help_str = "set port setup on iterator|event",
1439 (void *)&cmd_set_port_setup_on_set,
1440 (void *)&cmd_set_port_setup_on_port,
1441 (void *)&cmd_set_port_setup_on_setup,
1442 (void *)&cmd_set_port_setup_on_on,
1443 (void *)&cmd_set_port_setup_on_mode,
1448 /* *** attach a specified port *** */
1449 struct cmd_operate_attach_port_result {
1450 cmdline_fixed_string_t port;
1451 cmdline_fixed_string_t keyword;
1452 cmdline_multi_string_t identifier;
1455 static void cmd_operate_attach_port_parsed(void *parsed_result,
1456 __rte_unused struct cmdline *cl,
1457 __rte_unused void *data)
1459 struct cmd_operate_attach_port_result *res = parsed_result;
1461 if (!strcmp(res->keyword, "attach"))
1462 attach_port(res->identifier);
1464 printf("Unknown parameter\n");
1467 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1468 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1470 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1471 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1473 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1474 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1475 identifier, TOKEN_STRING_MULTI);
1477 cmdline_parse_inst_t cmd_operate_attach_port = {
1478 .f = cmd_operate_attach_port_parsed,
1480 .help_str = "port attach <identifier>: "
1481 "(identifier: pci address or virtual dev name)",
1483 (void *)&cmd_operate_attach_port_port,
1484 (void *)&cmd_operate_attach_port_keyword,
1485 (void *)&cmd_operate_attach_port_identifier,
1490 /* *** detach a specified port *** */
1491 struct cmd_operate_detach_port_result {
1492 cmdline_fixed_string_t port;
1493 cmdline_fixed_string_t keyword;
1497 static void cmd_operate_detach_port_parsed(void *parsed_result,
1498 __rte_unused struct cmdline *cl,
1499 __rte_unused void *data)
1501 struct cmd_operate_detach_port_result *res = parsed_result;
1503 if (!strcmp(res->keyword, "detach")) {
1504 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1505 detach_port_device(res->port_id);
1507 printf("Unknown parameter\n");
1511 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1512 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1514 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1515 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1517 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1518 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1521 cmdline_parse_inst_t cmd_operate_detach_port = {
1522 .f = cmd_operate_detach_port_parsed,
1524 .help_str = "port detach <port_id>",
1526 (void *)&cmd_operate_detach_port_port,
1527 (void *)&cmd_operate_detach_port_keyword,
1528 (void *)&cmd_operate_detach_port_port_id,
1533 /* *** detach device by identifier *** */
1534 struct cmd_operate_detach_device_result {
1535 cmdline_fixed_string_t device;
1536 cmdline_fixed_string_t keyword;
1537 cmdline_fixed_string_t identifier;
1540 static void cmd_operate_detach_device_parsed(void *parsed_result,
1541 __rte_unused struct cmdline *cl,
1542 __rte_unused void *data)
1544 struct cmd_operate_detach_device_result *res = parsed_result;
1546 if (!strcmp(res->keyword, "detach"))
1547 detach_devargs(res->identifier);
1549 printf("Unknown parameter\n");
1552 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1553 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1555 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1556 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1558 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1559 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1562 cmdline_parse_inst_t cmd_operate_detach_device = {
1563 .f = cmd_operate_detach_device_parsed,
1565 .help_str = "device detach <identifier>:"
1566 "(identifier: pci address or virtual dev name)",
1568 (void *)&cmd_operate_detach_device_device,
1569 (void *)&cmd_operate_detach_device_keyword,
1570 (void *)&cmd_operate_detach_device_identifier,
1574 /* *** configure speed for all ports *** */
1575 struct cmd_config_speed_all {
1576 cmdline_fixed_string_t port;
1577 cmdline_fixed_string_t keyword;
1578 cmdline_fixed_string_t all;
1579 cmdline_fixed_string_t item1;
1580 cmdline_fixed_string_t item2;
1581 cmdline_fixed_string_t value1;
1582 cmdline_fixed_string_t value2;
1586 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1591 if (!strcmp(duplexstr, "half")) {
1592 duplex = ETH_LINK_HALF_DUPLEX;
1593 } else if (!strcmp(duplexstr, "full")) {
1594 duplex = ETH_LINK_FULL_DUPLEX;
1595 } else if (!strcmp(duplexstr, "auto")) {
1596 duplex = ETH_LINK_FULL_DUPLEX;
1598 printf("Unknown duplex parameter\n");
1602 if (!strcmp(speedstr, "10")) {
1603 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1604 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1605 } else if (!strcmp(speedstr, "100")) {
1606 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1607 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1609 if (duplex != ETH_LINK_FULL_DUPLEX) {
1610 printf("Invalid speed/duplex parameters\n");
1613 if (!strcmp(speedstr, "1000")) {
1614 *speed = ETH_LINK_SPEED_1G;
1615 } else if (!strcmp(speedstr, "10000")) {
1616 *speed = ETH_LINK_SPEED_10G;
1617 } else if (!strcmp(speedstr, "25000")) {
1618 *speed = ETH_LINK_SPEED_25G;
1619 } else if (!strcmp(speedstr, "40000")) {
1620 *speed = ETH_LINK_SPEED_40G;
1621 } else if (!strcmp(speedstr, "50000")) {
1622 *speed = ETH_LINK_SPEED_50G;
1623 } else if (!strcmp(speedstr, "100000")) {
1624 *speed = ETH_LINK_SPEED_100G;
1625 } else if (!strcmp(speedstr, "200000")) {
1626 *speed = ETH_LINK_SPEED_200G;
1627 } else if (!strcmp(speedstr, "auto")) {
1628 *speed = ETH_LINK_SPEED_AUTONEG;
1630 printf("Unknown speed parameter\n");
1639 cmd_config_speed_all_parsed(void *parsed_result,
1640 __rte_unused struct cmdline *cl,
1641 __rte_unused void *data)
1643 struct cmd_config_speed_all *res = parsed_result;
1644 uint32_t link_speed;
1647 if (!all_ports_stopped()) {
1648 printf("Please stop all ports first\n");
1652 if (parse_and_check_speed_duplex(res->value1, res->value2,
1656 RTE_ETH_FOREACH_DEV(pid) {
1657 ports[pid].dev_conf.link_speeds = link_speed;
1660 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1663 cmdline_parse_token_string_t cmd_config_speed_all_port =
1664 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1665 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1666 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1668 cmdline_parse_token_string_t cmd_config_speed_all_all =
1669 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1670 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1671 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1672 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1673 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1674 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1675 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1676 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1677 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1678 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1681 cmdline_parse_inst_t cmd_config_speed_all = {
1682 .f = cmd_config_speed_all_parsed,
1684 .help_str = "port config all speed "
1685 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1688 (void *)&cmd_config_speed_all_port,
1689 (void *)&cmd_config_speed_all_keyword,
1690 (void *)&cmd_config_speed_all_all,
1691 (void *)&cmd_config_speed_all_item1,
1692 (void *)&cmd_config_speed_all_value1,
1693 (void *)&cmd_config_speed_all_item2,
1694 (void *)&cmd_config_speed_all_value2,
1699 /* *** configure speed for specific port *** */
1700 struct cmd_config_speed_specific {
1701 cmdline_fixed_string_t port;
1702 cmdline_fixed_string_t keyword;
1704 cmdline_fixed_string_t item1;
1705 cmdline_fixed_string_t item2;
1706 cmdline_fixed_string_t value1;
1707 cmdline_fixed_string_t value2;
1711 cmd_config_speed_specific_parsed(void *parsed_result,
1712 __rte_unused struct cmdline *cl,
1713 __rte_unused void *data)
1715 struct cmd_config_speed_specific *res = parsed_result;
1716 uint32_t link_speed;
1718 if (!all_ports_stopped()) {
1719 printf("Please stop all ports first\n");
1723 if (port_id_is_invalid(res->id, ENABLED_WARN))
1726 if (parse_and_check_speed_duplex(res->value1, res->value2,
1730 ports[res->id].dev_conf.link_speeds = link_speed;
1732 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1736 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1737 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1739 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1740 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1742 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1743 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1744 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1745 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1747 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1748 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1749 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1750 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1751 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1753 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1754 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1757 cmdline_parse_inst_t cmd_config_speed_specific = {
1758 .f = cmd_config_speed_specific_parsed,
1760 .help_str = "port config <port_id> speed "
1761 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1764 (void *)&cmd_config_speed_specific_port,
1765 (void *)&cmd_config_speed_specific_keyword,
1766 (void *)&cmd_config_speed_specific_id,
1767 (void *)&cmd_config_speed_specific_item1,
1768 (void *)&cmd_config_speed_specific_value1,
1769 (void *)&cmd_config_speed_specific_item2,
1770 (void *)&cmd_config_speed_specific_value2,
1775 /* *** configure loopback for all ports *** */
1776 struct cmd_config_loopback_all {
1777 cmdline_fixed_string_t port;
1778 cmdline_fixed_string_t keyword;
1779 cmdline_fixed_string_t all;
1780 cmdline_fixed_string_t item;
1785 cmd_config_loopback_all_parsed(void *parsed_result,
1786 __rte_unused struct cmdline *cl,
1787 __rte_unused void *data)
1789 struct cmd_config_loopback_all *res = parsed_result;
1792 if (!all_ports_stopped()) {
1793 printf("Please stop all ports first\n");
1797 RTE_ETH_FOREACH_DEV(pid) {
1798 ports[pid].dev_conf.lpbk_mode = res->mode;
1801 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1804 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1805 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1806 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1807 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1809 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1810 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1811 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1812 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1814 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1815 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1817 cmdline_parse_inst_t cmd_config_loopback_all = {
1818 .f = cmd_config_loopback_all_parsed,
1820 .help_str = "port config all loopback <mode>",
1822 (void *)&cmd_config_loopback_all_port,
1823 (void *)&cmd_config_loopback_all_keyword,
1824 (void *)&cmd_config_loopback_all_all,
1825 (void *)&cmd_config_loopback_all_item,
1826 (void *)&cmd_config_loopback_all_mode,
1831 /* *** configure loopback for specific port *** */
1832 struct cmd_config_loopback_specific {
1833 cmdline_fixed_string_t port;
1834 cmdline_fixed_string_t keyword;
1836 cmdline_fixed_string_t item;
1841 cmd_config_loopback_specific_parsed(void *parsed_result,
1842 __rte_unused struct cmdline *cl,
1843 __rte_unused void *data)
1845 struct cmd_config_loopback_specific *res = parsed_result;
1847 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1850 if (!port_is_stopped(res->port_id)) {
1851 printf("Please stop port %u first\n", res->port_id);
1855 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1857 cmd_reconfig_device_queue(res->port_id, 1, 1);
1861 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1862 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1864 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1865 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1867 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1868 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1870 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1871 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1873 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1874 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1877 cmdline_parse_inst_t cmd_config_loopback_specific = {
1878 .f = cmd_config_loopback_specific_parsed,
1880 .help_str = "port config <port_id> loopback <mode>",
1882 (void *)&cmd_config_loopback_specific_port,
1883 (void *)&cmd_config_loopback_specific_keyword,
1884 (void *)&cmd_config_loopback_specific_id,
1885 (void *)&cmd_config_loopback_specific_item,
1886 (void *)&cmd_config_loopback_specific_mode,
1891 /* *** configure txq/rxq, txd/rxd *** */
1892 struct cmd_config_rx_tx {
1893 cmdline_fixed_string_t port;
1894 cmdline_fixed_string_t keyword;
1895 cmdline_fixed_string_t all;
1896 cmdline_fixed_string_t name;
1901 cmd_config_rx_tx_parsed(void *parsed_result,
1902 __rte_unused struct cmdline *cl,
1903 __rte_unused void *data)
1905 struct cmd_config_rx_tx *res = parsed_result;
1907 if (!all_ports_stopped()) {
1908 printf("Please stop all ports first\n");
1911 if (!strcmp(res->name, "rxq")) {
1912 if (!res->value && !nb_txq) {
1913 printf("Warning: Either rx or tx queues should be non zero\n");
1916 if (check_nb_rxq(res->value) != 0)
1918 nb_rxq = res->value;
1920 else if (!strcmp(res->name, "txq")) {
1921 if (!res->value && !nb_rxq) {
1922 printf("Warning: Either rx or tx queues should be non zero\n");
1925 if (check_nb_txq(res->value) != 0)
1927 nb_txq = res->value;
1929 else if (!strcmp(res->name, "rxd")) {
1930 if (check_nb_rxd(res->value) != 0)
1932 nb_rxd = res->value;
1933 } else if (!strcmp(res->name, "txd")) {
1934 if (check_nb_txd(res->value) != 0)
1937 nb_txd = res->value;
1939 printf("Unknown parameter\n");
1947 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1950 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1951 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1952 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1953 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1954 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1955 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1956 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1957 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1959 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1960 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1962 cmdline_parse_inst_t cmd_config_rx_tx = {
1963 .f = cmd_config_rx_tx_parsed,
1965 .help_str = "port config all rxq|txq|rxd|txd <value>",
1967 (void *)&cmd_config_rx_tx_port,
1968 (void *)&cmd_config_rx_tx_keyword,
1969 (void *)&cmd_config_rx_tx_all,
1970 (void *)&cmd_config_rx_tx_name,
1971 (void *)&cmd_config_rx_tx_value,
1976 /* *** config max packet length *** */
1977 struct cmd_config_max_pkt_len_result {
1978 cmdline_fixed_string_t port;
1979 cmdline_fixed_string_t keyword;
1980 cmdline_fixed_string_t all;
1981 cmdline_fixed_string_t name;
1986 cmd_config_max_pkt_len_parsed(void *parsed_result,
1987 __rte_unused struct cmdline *cl,
1988 __rte_unused void *data)
1990 struct cmd_config_max_pkt_len_result *res = parsed_result;
1993 if (!all_ports_stopped()) {
1994 printf("Please stop all ports first\n");
1998 RTE_ETH_FOREACH_DEV(pid) {
1999 struct rte_port *port = &ports[pid];
2000 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
2002 if (!strcmp(res->name, "max-pkt-len")) {
2003 if (res->value < RTE_ETHER_MIN_LEN) {
2004 printf("max-pkt-len can not be less than %d\n",
2008 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2011 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2012 if (res->value > RTE_ETHER_MAX_LEN)
2013 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2015 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2016 port->dev_conf.rxmode.offloads = rx_offloads;
2018 printf("Unknown parameter\n");
2025 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2028 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2029 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2031 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2032 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2034 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2035 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2037 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2038 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2040 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2041 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2044 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2045 .f = cmd_config_max_pkt_len_parsed,
2047 .help_str = "port config all max-pkt-len <value>",
2049 (void *)&cmd_config_max_pkt_len_port,
2050 (void *)&cmd_config_max_pkt_len_keyword,
2051 (void *)&cmd_config_max_pkt_len_all,
2052 (void *)&cmd_config_max_pkt_len_name,
2053 (void *)&cmd_config_max_pkt_len_value,
2058 /* *** config max LRO aggregated packet size *** */
2059 struct cmd_config_max_lro_pkt_size_result {
2060 cmdline_fixed_string_t port;
2061 cmdline_fixed_string_t keyword;
2062 cmdline_fixed_string_t all;
2063 cmdline_fixed_string_t name;
2068 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2069 __rte_unused struct cmdline *cl,
2070 __rte_unused void *data)
2072 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2075 if (!all_ports_stopped()) {
2076 printf("Please stop all ports first\n");
2080 RTE_ETH_FOREACH_DEV(pid) {
2081 struct rte_port *port = &ports[pid];
2083 if (!strcmp(res->name, "max-lro-pkt-size")) {
2085 port->dev_conf.rxmode.max_lro_pkt_size)
2088 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2090 printf("Unknown parameter\n");
2097 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2100 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2101 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2103 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2104 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2106 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2107 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2109 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2110 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2111 name, "max-lro-pkt-size");
2112 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2113 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2116 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2117 .f = cmd_config_max_lro_pkt_size_parsed,
2119 .help_str = "port config all max-lro-pkt-size <value>",
2121 (void *)&cmd_config_max_lro_pkt_size_port,
2122 (void *)&cmd_config_max_lro_pkt_size_keyword,
2123 (void *)&cmd_config_max_lro_pkt_size_all,
2124 (void *)&cmd_config_max_lro_pkt_size_name,
2125 (void *)&cmd_config_max_lro_pkt_size_value,
2130 /* *** configure port MTU *** */
2131 struct cmd_config_mtu_result {
2132 cmdline_fixed_string_t port;
2133 cmdline_fixed_string_t keyword;
2134 cmdline_fixed_string_t mtu;
2140 cmd_config_mtu_parsed(void *parsed_result,
2141 __rte_unused struct cmdline *cl,
2142 __rte_unused void *data)
2144 struct cmd_config_mtu_result *res = parsed_result;
2146 if (res->value < RTE_ETHER_MIN_LEN) {
2147 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2150 port_mtu_set(res->port_id, res->value);
2153 cmdline_parse_token_string_t cmd_config_mtu_port =
2154 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2156 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2157 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2159 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2160 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2162 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2163 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2164 cmdline_parse_token_num_t cmd_config_mtu_value =
2165 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2167 cmdline_parse_inst_t cmd_config_mtu = {
2168 .f = cmd_config_mtu_parsed,
2170 .help_str = "port config mtu <port_id> <value>",
2172 (void *)&cmd_config_mtu_port,
2173 (void *)&cmd_config_mtu_keyword,
2174 (void *)&cmd_config_mtu_mtu,
2175 (void *)&cmd_config_mtu_port_id,
2176 (void *)&cmd_config_mtu_value,
2181 /* *** configure rx mode *** */
2182 struct cmd_config_rx_mode_flag {
2183 cmdline_fixed_string_t port;
2184 cmdline_fixed_string_t keyword;
2185 cmdline_fixed_string_t all;
2186 cmdline_fixed_string_t name;
2187 cmdline_fixed_string_t value;
2191 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2192 __rte_unused struct cmdline *cl,
2193 __rte_unused void *data)
2195 struct cmd_config_rx_mode_flag *res = parsed_result;
2197 if (!all_ports_stopped()) {
2198 printf("Please stop all ports first\n");
2202 if (!strcmp(res->name, "drop-en")) {
2203 if (!strcmp(res->value, "on"))
2205 else if (!strcmp(res->value, "off"))
2208 printf("Unknown parameter\n");
2212 printf("Unknown parameter\n");
2218 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2221 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2222 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2223 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2224 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2226 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2227 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2228 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2229 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2231 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2232 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2235 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2236 .f = cmd_config_rx_mode_flag_parsed,
2238 .help_str = "port config all drop-en on|off",
2240 (void *)&cmd_config_rx_mode_flag_port,
2241 (void *)&cmd_config_rx_mode_flag_keyword,
2242 (void *)&cmd_config_rx_mode_flag_all,
2243 (void *)&cmd_config_rx_mode_flag_name,
2244 (void *)&cmd_config_rx_mode_flag_value,
2249 /* *** configure rss *** */
2250 struct cmd_config_rss {
2251 cmdline_fixed_string_t port;
2252 cmdline_fixed_string_t keyword;
2253 cmdline_fixed_string_t all;
2254 cmdline_fixed_string_t name;
2255 cmdline_fixed_string_t value;
2259 cmd_config_rss_parsed(void *parsed_result,
2260 __rte_unused struct cmdline *cl,
2261 __rte_unused void *data)
2263 struct cmd_config_rss *res = parsed_result;
2264 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2265 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2266 int use_default = 0;
2267 int all_updated = 1;
2272 if (!strcmp(res->value, "all"))
2273 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2274 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2275 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2276 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU;
2277 else if (!strcmp(res->value, "eth"))
2278 rss_conf.rss_hf = ETH_RSS_ETH;
2279 else if (!strcmp(res->value, "vlan"))
2280 rss_conf.rss_hf = ETH_RSS_VLAN;
2281 else if (!strcmp(res->value, "ip"))
2282 rss_conf.rss_hf = ETH_RSS_IP;
2283 else if (!strcmp(res->value, "udp"))
2284 rss_conf.rss_hf = ETH_RSS_UDP;
2285 else if (!strcmp(res->value, "tcp"))
2286 rss_conf.rss_hf = ETH_RSS_TCP;
2287 else if (!strcmp(res->value, "sctp"))
2288 rss_conf.rss_hf = ETH_RSS_SCTP;
2289 else if (!strcmp(res->value, "ether"))
2290 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2291 else if (!strcmp(res->value, "port"))
2292 rss_conf.rss_hf = ETH_RSS_PORT;
2293 else if (!strcmp(res->value, "vxlan"))
2294 rss_conf.rss_hf = ETH_RSS_VXLAN;
2295 else if (!strcmp(res->value, "geneve"))
2296 rss_conf.rss_hf = ETH_RSS_GENEVE;
2297 else if (!strcmp(res->value, "nvgre"))
2298 rss_conf.rss_hf = ETH_RSS_NVGRE;
2299 else if (!strcmp(res->value, "l3-pre32"))
2300 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2301 else if (!strcmp(res->value, "l3-pre40"))
2302 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2303 else if (!strcmp(res->value, "l3-pre48"))
2304 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2305 else if (!strcmp(res->value, "l3-pre56"))
2306 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2307 else if (!strcmp(res->value, "l3-pre64"))
2308 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2309 else if (!strcmp(res->value, "l3-pre96"))
2310 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2311 else if (!strcmp(res->value, "l3-src-only"))
2312 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2313 else if (!strcmp(res->value, "l3-dst-only"))
2314 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2315 else if (!strcmp(res->value, "l4-src-only"))
2316 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2317 else if (!strcmp(res->value, "l4-dst-only"))
2318 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2319 else if (!strcmp(res->value, "l2-src-only"))
2320 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2321 else if (!strcmp(res->value, "l2-dst-only"))
2322 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2323 else if (!strcmp(res->value, "l2tpv3"))
2324 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2325 else if (!strcmp(res->value, "esp"))
2326 rss_conf.rss_hf = ETH_RSS_ESP;
2327 else if (!strcmp(res->value, "ah"))
2328 rss_conf.rss_hf = ETH_RSS_AH;
2329 else if (!strcmp(res->value, "pfcp"))
2330 rss_conf.rss_hf = ETH_RSS_PFCP;
2331 else if (!strcmp(res->value, "pppoe"))
2332 rss_conf.rss_hf = ETH_RSS_PPPOE;
2333 else if (!strcmp(res->value, "gtpu"))
2334 rss_conf.rss_hf = ETH_RSS_GTPU;
2335 else if (!strcmp(res->value, "none"))
2336 rss_conf.rss_hf = 0;
2337 else if (!strcmp(res->value, "default"))
2339 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2340 atoi(res->value) < 64)
2341 rss_conf.rss_hf = 1ULL << atoi(res->value);
2343 printf("Unknown parameter\n");
2346 rss_conf.rss_key = NULL;
2347 /* Update global configuration for RSS types. */
2348 RTE_ETH_FOREACH_DEV(i) {
2349 struct rte_eth_rss_conf local_rss_conf;
2351 ret = eth_dev_info_get_print_err(i, &dev_info);
2356 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2358 local_rss_conf = rss_conf;
2359 local_rss_conf.rss_hf = rss_conf.rss_hf &
2360 dev_info.flow_type_rss_offloads;
2361 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2362 printf("Port %u modified RSS hash function based on hardware support,"
2363 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2364 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2366 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2369 printf("Configuration of RSS hash at ethernet port %d "
2370 "failed with error (%d): %s.\n",
2371 i, -diag, strerror(-diag));
2374 if (all_updated && !use_default) {
2375 rss_hf = rss_conf.rss_hf;
2376 printf("rss_hf %#"PRIx64"\n", rss_hf);
2380 cmdline_parse_token_string_t cmd_config_rss_port =
2381 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2382 cmdline_parse_token_string_t cmd_config_rss_keyword =
2383 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2384 cmdline_parse_token_string_t cmd_config_rss_all =
2385 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2386 cmdline_parse_token_string_t cmd_config_rss_name =
2387 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2388 cmdline_parse_token_string_t cmd_config_rss_value =
2389 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2391 cmdline_parse_inst_t cmd_config_rss = {
2392 .f = cmd_config_rss_parsed,
2394 .help_str = "port config all rss "
2395 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2396 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|<flowtype_id>",
2398 (void *)&cmd_config_rss_port,
2399 (void *)&cmd_config_rss_keyword,
2400 (void *)&cmd_config_rss_all,
2401 (void *)&cmd_config_rss_name,
2402 (void *)&cmd_config_rss_value,
2407 /* *** configure rss hash key *** */
2408 struct cmd_config_rss_hash_key {
2409 cmdline_fixed_string_t port;
2410 cmdline_fixed_string_t config;
2412 cmdline_fixed_string_t rss_hash_key;
2413 cmdline_fixed_string_t rss_type;
2414 cmdline_fixed_string_t key;
2418 hexa_digit_to_value(char hexa_digit)
2420 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2421 return (uint8_t) (hexa_digit - '0');
2422 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2423 return (uint8_t) ((hexa_digit - 'a') + 10);
2424 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2425 return (uint8_t) ((hexa_digit - 'A') + 10);
2426 /* Invalid hexa digit */
2431 parse_and_check_key_hexa_digit(char *key, int idx)
2435 hexa_v = hexa_digit_to_value(key[idx]);
2437 printf("invalid key: character %c at position %d is not a "
2438 "valid hexa digit\n", key[idx], idx);
2443 cmd_config_rss_hash_key_parsed(void *parsed_result,
2444 __rte_unused struct cmdline *cl,
2445 __rte_unused void *data)
2447 struct cmd_config_rss_hash_key *res = parsed_result;
2448 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2452 struct rte_eth_dev_info dev_info;
2453 uint8_t hash_key_size;
2457 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2461 if (dev_info.hash_key_size > 0 &&
2462 dev_info.hash_key_size <= sizeof(hash_key))
2463 hash_key_size = dev_info.hash_key_size;
2465 printf("dev_info did not provide a valid hash key size\n");
2468 /* Check the length of the RSS hash key */
2469 key_len = strlen(res->key);
2470 if (key_len != (hash_key_size * 2)) {
2471 printf("key length: %d invalid - key must be a string of %d"
2472 " hexa-decimal numbers\n",
2473 (int) key_len, hash_key_size * 2);
2476 /* Translate RSS hash key into binary representation */
2477 for (i = 0; i < hash_key_size; i++) {
2478 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2481 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2484 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2486 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2490 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2491 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2492 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2493 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2495 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2496 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2497 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2498 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2499 rss_hash_key, "rss-hash-key");
2500 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2501 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2502 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2503 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2504 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2505 "ipv6-tcp-ex#ipv6-udp-ex#"
2506 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2507 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2508 "l2tpv3#esp#ah#pfcp#pppoe#gtpu");
2509 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2510 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2512 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2513 .f = cmd_config_rss_hash_key_parsed,
2515 .help_str = "port config <port_id> rss-hash-key "
2516 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2517 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2518 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2519 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2520 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2521 "l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2522 "<string of hex digits (variable length, NIC dependent)>",
2524 (void *)&cmd_config_rss_hash_key_port,
2525 (void *)&cmd_config_rss_hash_key_config,
2526 (void *)&cmd_config_rss_hash_key_port_id,
2527 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2528 (void *)&cmd_config_rss_hash_key_rss_type,
2529 (void *)&cmd_config_rss_hash_key_value,
2534 /* *** configure port rxq/txq ring size *** */
2535 struct cmd_config_rxtx_ring_size {
2536 cmdline_fixed_string_t port;
2537 cmdline_fixed_string_t config;
2539 cmdline_fixed_string_t rxtxq;
2541 cmdline_fixed_string_t rsize;
2546 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2547 __rte_unused struct cmdline *cl,
2548 __rte_unused void *data)
2550 struct cmd_config_rxtx_ring_size *res = parsed_result;
2551 struct rte_port *port;
2554 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2557 if (res->portid == (portid_t)RTE_PORT_ALL) {
2558 printf("Invalid port id\n");
2562 port = &ports[res->portid];
2564 if (!strcmp(res->rxtxq, "rxq"))
2566 else if (!strcmp(res->rxtxq, "txq"))
2569 printf("Unknown parameter\n");
2573 if (isrx && rx_queue_id_is_invalid(res->qid))
2575 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2578 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2579 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2585 port->nb_rx_desc[res->qid] = res->size;
2587 port->nb_tx_desc[res->qid] = res->size;
2589 cmd_reconfig_device_queue(res->portid, 0, 1);
2592 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2593 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2595 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2596 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2598 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2599 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2601 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2602 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2604 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2605 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2607 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2608 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2609 rsize, "ring_size");
2610 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2611 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2614 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2615 .f = cmd_config_rxtx_ring_size_parsed,
2617 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2619 (void *)&cmd_config_rxtx_ring_size_port,
2620 (void *)&cmd_config_rxtx_ring_size_config,
2621 (void *)&cmd_config_rxtx_ring_size_portid,
2622 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2623 (void *)&cmd_config_rxtx_ring_size_qid,
2624 (void *)&cmd_config_rxtx_ring_size_rsize,
2625 (void *)&cmd_config_rxtx_ring_size_size,
2630 /* *** configure port rxq/txq start/stop *** */
2631 struct cmd_config_rxtx_queue {
2632 cmdline_fixed_string_t port;
2634 cmdline_fixed_string_t rxtxq;
2636 cmdline_fixed_string_t opname;
2640 cmd_config_rxtx_queue_parsed(void *parsed_result,
2641 __rte_unused struct cmdline *cl,
2642 __rte_unused void *data)
2644 struct cmd_config_rxtx_queue *res = parsed_result;
2649 if (test_done == 0) {
2650 printf("Please stop forwarding first\n");
2654 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2657 if (port_is_started(res->portid) != 1) {
2658 printf("Please start port %u first\n", res->portid);
2662 if (!strcmp(res->rxtxq, "rxq"))
2664 else if (!strcmp(res->rxtxq, "txq"))
2667 printf("Unknown parameter\n");
2671 if (isrx && rx_queue_id_is_invalid(res->qid))
2673 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2676 if (!strcmp(res->opname, "start"))
2678 else if (!strcmp(res->opname, "stop"))
2681 printf("Unknown parameter\n");
2685 if (isstart && isrx)
2686 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2687 else if (!isstart && isrx)
2688 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2689 else if (isstart && !isrx)
2690 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2692 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2694 if (ret == -ENOTSUP)
2695 printf("Function not supported in PMD driver\n");
2698 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2699 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2700 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2701 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2702 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2703 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2704 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2705 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2706 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2707 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2710 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2711 .f = cmd_config_rxtx_queue_parsed,
2713 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2715 (void *)&cmd_config_rxtx_queue_port,
2716 (void *)&cmd_config_rxtx_queue_portid,
2717 (void *)&cmd_config_rxtx_queue_rxtxq,
2718 (void *)&cmd_config_rxtx_queue_qid,
2719 (void *)&cmd_config_rxtx_queue_opname,
2724 /* *** configure port rxq/txq deferred start on/off *** */
2725 struct cmd_config_deferred_start_rxtx_queue {
2726 cmdline_fixed_string_t port;
2728 cmdline_fixed_string_t rxtxq;
2730 cmdline_fixed_string_t opname;
2731 cmdline_fixed_string_t state;
2735 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2736 __rte_unused struct cmdline *cl,
2737 __rte_unused void *data)
2739 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2740 struct rte_port *port;
2743 uint8_t needreconfig = 0;
2745 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2748 if (port_is_started(res->port_id) != 0) {
2749 printf("Please stop port %u first\n", res->port_id);
2753 port = &ports[res->port_id];
2755 isrx = !strcmp(res->rxtxq, "rxq");
2757 if (isrx && rx_queue_id_is_invalid(res->qid))
2759 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2762 ison = !strcmp(res->state, "on");
2764 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2765 port->rx_conf[res->qid].rx_deferred_start = ison;
2767 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2768 port->tx_conf[res->qid].tx_deferred_start = ison;
2773 cmd_reconfig_device_queue(res->port_id, 0, 1);
2776 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2777 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2779 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2780 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2782 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2783 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2785 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2786 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2788 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2789 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2790 opname, "deferred_start");
2791 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2792 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2795 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2796 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2798 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2800 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2801 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2802 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2803 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2804 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2805 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2810 /* *** configure port rxq/txq setup *** */
2811 struct cmd_setup_rxtx_queue {
2812 cmdline_fixed_string_t port;
2814 cmdline_fixed_string_t rxtxq;
2816 cmdline_fixed_string_t setup;
2819 /* Common CLI fields for queue setup */
2820 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2821 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2822 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2823 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2824 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2825 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2826 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2827 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2828 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2829 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2832 cmd_setup_rxtx_queue_parsed(
2833 void *parsed_result,
2834 __rte_unused struct cmdline *cl,
2835 __rte_unused void *data)
2837 struct cmd_setup_rxtx_queue *res = parsed_result;
2838 struct rte_port *port;
2839 struct rte_mempool *mp;
2840 unsigned int socket_id;
2844 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2847 if (res->portid == (portid_t)RTE_PORT_ALL) {
2848 printf("Invalid port id\n");
2852 if (!strcmp(res->rxtxq, "rxq"))
2854 else if (!strcmp(res->rxtxq, "txq"))
2857 printf("Unknown parameter\n");
2861 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2862 printf("Invalid rx queue\n");
2864 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2865 printf("Invalid tx queue\n");
2869 port = &ports[res->portid];
2871 socket_id = rxring_numa[res->portid];
2872 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2873 socket_id = port->socket_id;
2875 mp = mbuf_pool_find(socket_id);
2877 printf("Failed to setup RX queue: "
2878 "No mempool allocation"
2879 " on the socket %d\n",
2880 rxring_numa[res->portid]);
2883 ret = rte_eth_rx_queue_setup(res->portid,
2885 port->nb_rx_desc[res->qid],
2887 &port->rx_conf[res->qid],
2890 printf("Failed to setup RX queue\n");
2892 socket_id = txring_numa[res->portid];
2893 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2894 socket_id = port->socket_id;
2896 ret = rte_eth_tx_queue_setup(res->portid,
2898 port->nb_tx_desc[res->qid],
2900 &port->tx_conf[res->qid]);
2902 printf("Failed to setup TX queue\n");
2906 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2907 .f = cmd_setup_rxtx_queue_parsed,
2909 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2911 (void *)&cmd_setup_rxtx_queue_port,
2912 (void *)&cmd_setup_rxtx_queue_portid,
2913 (void *)&cmd_setup_rxtx_queue_rxtxq,
2914 (void *)&cmd_setup_rxtx_queue_qid,
2915 (void *)&cmd_setup_rxtx_queue_setup,
2921 /* *** Configure RSS RETA *** */
2922 struct cmd_config_rss_reta {
2923 cmdline_fixed_string_t port;
2924 cmdline_fixed_string_t keyword;
2926 cmdline_fixed_string_t name;
2927 cmdline_fixed_string_t list_name;
2928 cmdline_fixed_string_t list_of_items;
2932 parse_reta_config(const char *str,
2933 struct rte_eth_rss_reta_entry64 *reta_conf,
2934 uint16_t nb_entries)
2938 uint16_t hash_index, idx, shift;
2941 const char *p, *p0 = str;
2948 unsigned long int_fld[_NUM_FLD];
2949 char *str_fld[_NUM_FLD];
2951 while ((p = strchr(p0,'(')) != NULL) {
2953 if((p0 = strchr(p,')')) == NULL)
2957 if(size >= sizeof(s))
2960 snprintf(s, sizeof(s), "%.*s", size, p);
2961 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2963 for (i = 0; i < _NUM_FLD; i++) {
2965 int_fld[i] = strtoul(str_fld[i], &end, 0);
2966 if (errno != 0 || end == str_fld[i] ||
2971 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2972 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2974 if (hash_index >= nb_entries) {
2975 printf("Invalid RETA hash index=%d\n", hash_index);
2979 idx = hash_index / RTE_RETA_GROUP_SIZE;
2980 shift = hash_index % RTE_RETA_GROUP_SIZE;
2981 reta_conf[idx].mask |= (1ULL << shift);
2982 reta_conf[idx].reta[shift] = nb_queue;
2989 cmd_set_rss_reta_parsed(void *parsed_result,
2990 __rte_unused struct cmdline *cl,
2991 __rte_unused void *data)
2994 struct rte_eth_dev_info dev_info;
2995 struct rte_eth_rss_reta_entry64 reta_conf[8];
2996 struct cmd_config_rss_reta *res = parsed_result;
2998 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3002 if (dev_info.reta_size == 0) {
3003 printf("Redirection table size is 0 which is "
3004 "invalid for RSS\n");
3007 printf("The reta size of port %d is %u\n",
3008 res->port_id, dev_info.reta_size);
3009 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3010 printf("Currently do not support more than %u entries of "
3011 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3015 memset(reta_conf, 0, sizeof(reta_conf));
3016 if (!strcmp(res->list_name, "reta")) {
3017 if (parse_reta_config(res->list_of_items, reta_conf,
3018 dev_info.reta_size)) {
3019 printf("Invalid RSS Redirection Table "
3020 "config entered\n");
3023 ret = rte_eth_dev_rss_reta_update(res->port_id,
3024 reta_conf, dev_info.reta_size);
3026 printf("Bad redirection table parameter, "
3027 "return code = %d \n", ret);
3031 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3032 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3033 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3034 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3035 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3036 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3037 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3038 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3039 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3040 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3041 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3042 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3044 cmdline_parse_inst_t cmd_config_rss_reta = {
3045 .f = cmd_set_rss_reta_parsed,
3047 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3049 (void *)&cmd_config_rss_reta_port,
3050 (void *)&cmd_config_rss_reta_keyword,
3051 (void *)&cmd_config_rss_reta_port_id,
3052 (void *)&cmd_config_rss_reta_name,
3053 (void *)&cmd_config_rss_reta_list_name,
3054 (void *)&cmd_config_rss_reta_list_of_items,
3059 /* *** SHOW PORT RETA INFO *** */
3060 struct cmd_showport_reta {
3061 cmdline_fixed_string_t show;
3062 cmdline_fixed_string_t port;
3064 cmdline_fixed_string_t rss;
3065 cmdline_fixed_string_t reta;
3067 cmdline_fixed_string_t list_of_items;
3071 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3072 uint16_t nb_entries,
3076 const char *p, *p0 = str;
3081 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3082 RTE_RETA_GROUP_SIZE;
3085 p = strchr(p0, '(');
3089 p0 = strchr(p, ')');
3093 if (size >= sizeof(s)) {
3094 printf("The string size exceeds the internal buffer size\n");
3097 snprintf(s, sizeof(s), "%.*s", size, p);
3098 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3099 if (ret <= 0 || ret != num) {
3100 printf("The bits of masks do not match the number of "
3101 "reta entries: %u\n", num);
3104 for (i = 0; i < ret; i++)
3105 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3111 cmd_showport_reta_parsed(void *parsed_result,
3112 __rte_unused struct cmdline *cl,
3113 __rte_unused void *data)
3115 struct cmd_showport_reta *res = parsed_result;
3116 struct rte_eth_rss_reta_entry64 reta_conf[8];
3117 struct rte_eth_dev_info dev_info;
3118 uint16_t max_reta_size;
3121 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3125 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3126 if (res->size == 0 || res->size > max_reta_size) {
3127 printf("Invalid redirection table size: %u (1-%u)\n",
3128 res->size, max_reta_size);
3132 memset(reta_conf, 0, sizeof(reta_conf));
3133 if (showport_parse_reta_config(reta_conf, res->size,
3134 res->list_of_items) < 0) {
3135 printf("Invalid string: %s for reta masks\n",
3136 res->list_of_items);
3139 port_rss_reta_info(res->port_id, reta_conf, res->size);
3142 cmdline_parse_token_string_t cmd_showport_reta_show =
3143 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3144 cmdline_parse_token_string_t cmd_showport_reta_port =
3145 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3146 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3147 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3148 cmdline_parse_token_string_t cmd_showport_reta_rss =
3149 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3150 cmdline_parse_token_string_t cmd_showport_reta_reta =
3151 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3152 cmdline_parse_token_num_t cmd_showport_reta_size =
3153 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3154 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3155 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3156 list_of_items, NULL);
3158 cmdline_parse_inst_t cmd_showport_reta = {
3159 .f = cmd_showport_reta_parsed,
3161 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3163 (void *)&cmd_showport_reta_show,
3164 (void *)&cmd_showport_reta_port,
3165 (void *)&cmd_showport_reta_port_id,
3166 (void *)&cmd_showport_reta_rss,
3167 (void *)&cmd_showport_reta_reta,
3168 (void *)&cmd_showport_reta_size,
3169 (void *)&cmd_showport_reta_list_of_items,
3174 /* *** Show RSS hash configuration *** */
3175 struct cmd_showport_rss_hash {
3176 cmdline_fixed_string_t show;
3177 cmdline_fixed_string_t port;
3179 cmdline_fixed_string_t rss_hash;
3180 cmdline_fixed_string_t rss_type;
3181 cmdline_fixed_string_t key; /* optional argument */
3184 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3185 __rte_unused struct cmdline *cl,
3188 struct cmd_showport_rss_hash *res = parsed_result;
3190 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3193 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3194 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3195 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3196 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3197 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3198 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3199 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3200 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3202 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3203 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3205 cmdline_parse_inst_t cmd_showport_rss_hash = {
3206 .f = cmd_showport_rss_hash_parsed,
3208 .help_str = "show port <port_id> rss-hash",
3210 (void *)&cmd_showport_rss_hash_show,
3211 (void *)&cmd_showport_rss_hash_port,
3212 (void *)&cmd_showport_rss_hash_port_id,
3213 (void *)&cmd_showport_rss_hash_rss_hash,
3218 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3219 .f = cmd_showport_rss_hash_parsed,
3221 .help_str = "show port <port_id> rss-hash key",
3223 (void *)&cmd_showport_rss_hash_show,
3224 (void *)&cmd_showport_rss_hash_port,
3225 (void *)&cmd_showport_rss_hash_port_id,
3226 (void *)&cmd_showport_rss_hash_rss_hash,
3227 (void *)&cmd_showport_rss_hash_rss_key,
3232 /* *** Configure DCB *** */
3233 struct cmd_config_dcb {
3234 cmdline_fixed_string_t port;
3235 cmdline_fixed_string_t config;
3237 cmdline_fixed_string_t dcb;
3238 cmdline_fixed_string_t vt;
3239 cmdline_fixed_string_t vt_en;
3241 cmdline_fixed_string_t pfc;
3242 cmdline_fixed_string_t pfc_en;
3246 cmd_config_dcb_parsed(void *parsed_result,
3247 __rte_unused struct cmdline *cl,
3248 __rte_unused void *data)
3250 struct cmd_config_dcb *res = parsed_result;
3251 portid_t port_id = res->port_id;
3252 struct rte_port *port;
3256 port = &ports[port_id];
3257 /** Check if the port is not started **/
3258 if (port->port_status != RTE_PORT_STOPPED) {
3259 printf("Please stop port %d first\n", port_id);
3263 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3264 printf("The invalid number of traffic class,"
3265 " only 4 or 8 allowed.\n");
3269 if (nb_fwd_lcores < res->num_tcs) {
3270 printf("nb_cores shouldn't be less than number of TCs.\n");
3273 if (!strncmp(res->pfc_en, "on", 2))
3278 /* DCB in VT mode */
3279 if (!strncmp(res->vt_en, "on", 2))
3280 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3281 (enum rte_eth_nb_tcs)res->num_tcs,
3284 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3285 (enum rte_eth_nb_tcs)res->num_tcs,
3290 printf("Cannot initialize network ports.\n");
3294 cmd_reconfig_device_queue(port_id, 1, 1);
3297 cmdline_parse_token_string_t cmd_config_dcb_port =
3298 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3299 cmdline_parse_token_string_t cmd_config_dcb_config =
3300 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3301 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3302 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3303 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3304 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3305 cmdline_parse_token_string_t cmd_config_dcb_vt =
3306 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3307 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3308 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3309 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3310 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3311 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3312 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3313 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3314 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3316 cmdline_parse_inst_t cmd_config_dcb = {
3317 .f = cmd_config_dcb_parsed,
3319 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3321 (void *)&cmd_config_dcb_port,
3322 (void *)&cmd_config_dcb_config,
3323 (void *)&cmd_config_dcb_port_id,
3324 (void *)&cmd_config_dcb_dcb,
3325 (void *)&cmd_config_dcb_vt,
3326 (void *)&cmd_config_dcb_vt_en,
3327 (void *)&cmd_config_dcb_num_tcs,
3328 (void *)&cmd_config_dcb_pfc,
3329 (void *)&cmd_config_dcb_pfc_en,
3334 /* *** configure number of packets per burst *** */
3335 struct cmd_config_burst {
3336 cmdline_fixed_string_t port;
3337 cmdline_fixed_string_t keyword;
3338 cmdline_fixed_string_t all;
3339 cmdline_fixed_string_t name;
3344 cmd_config_burst_parsed(void *parsed_result,
3345 __rte_unused struct cmdline *cl,
3346 __rte_unused void *data)
3348 struct cmd_config_burst *res = parsed_result;
3349 struct rte_eth_dev_info dev_info;
3350 uint16_t rec_nb_pkts;
3353 if (!all_ports_stopped()) {
3354 printf("Please stop all ports first\n");
3358 if (!strcmp(res->name, "burst")) {
3359 if (res->value == 0) {
3360 /* If user gives a value of zero, query the PMD for
3361 * its recommended Rx burst size. Testpmd uses a single
3362 * size for all ports, so assume all ports are the same
3363 * NIC model and use the values from Port 0.
3365 ret = eth_dev_info_get_print_err(0, &dev_info);
3369 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3371 if (rec_nb_pkts == 0) {
3372 printf("PMD does not recommend a burst size.\n"
3373 "User provided value must be between"
3374 " 1 and %d\n", MAX_PKT_BURST);
3376 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3377 printf("PMD recommended burst size of %d"
3378 " exceeds maximum value of %d\n",
3379 rec_nb_pkts, MAX_PKT_BURST);
3382 printf("Using PMD-provided burst value of %d\n",
3384 nb_pkt_per_burst = rec_nb_pkts;
3385 } else if (res->value > MAX_PKT_BURST) {
3386 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3389 nb_pkt_per_burst = res->value;
3391 printf("Unknown parameter\n");
3397 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3400 cmdline_parse_token_string_t cmd_config_burst_port =
3401 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3402 cmdline_parse_token_string_t cmd_config_burst_keyword =
3403 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3404 cmdline_parse_token_string_t cmd_config_burst_all =
3405 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3406 cmdline_parse_token_string_t cmd_config_burst_name =
3407 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3408 cmdline_parse_token_num_t cmd_config_burst_value =
3409 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3411 cmdline_parse_inst_t cmd_config_burst = {
3412 .f = cmd_config_burst_parsed,
3414 .help_str = "port config all burst <value>",
3416 (void *)&cmd_config_burst_port,
3417 (void *)&cmd_config_burst_keyword,
3418 (void *)&cmd_config_burst_all,
3419 (void *)&cmd_config_burst_name,
3420 (void *)&cmd_config_burst_value,
3425 /* *** configure rx/tx queues *** */
3426 struct cmd_config_thresh {
3427 cmdline_fixed_string_t port;
3428 cmdline_fixed_string_t keyword;
3429 cmdline_fixed_string_t all;
3430 cmdline_fixed_string_t name;
3435 cmd_config_thresh_parsed(void *parsed_result,
3436 __rte_unused struct cmdline *cl,
3437 __rte_unused void *data)
3439 struct cmd_config_thresh *res = parsed_result;
3441 if (!all_ports_stopped()) {
3442 printf("Please stop all ports first\n");
3446 if (!strcmp(res->name, "txpt"))
3447 tx_pthresh = res->value;
3448 else if(!strcmp(res->name, "txht"))
3449 tx_hthresh = res->value;
3450 else if(!strcmp(res->name, "txwt"))
3451 tx_wthresh = res->value;
3452 else if(!strcmp(res->name, "rxpt"))
3453 rx_pthresh = res->value;
3454 else if(!strcmp(res->name, "rxht"))
3455 rx_hthresh = res->value;
3456 else if(!strcmp(res->name, "rxwt"))
3457 rx_wthresh = res->value;
3459 printf("Unknown parameter\n");
3465 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3468 cmdline_parse_token_string_t cmd_config_thresh_port =
3469 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3470 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3471 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3472 cmdline_parse_token_string_t cmd_config_thresh_all =
3473 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3474 cmdline_parse_token_string_t cmd_config_thresh_name =
3475 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3476 "txpt#txht#txwt#rxpt#rxht#rxwt");
3477 cmdline_parse_token_num_t cmd_config_thresh_value =
3478 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3480 cmdline_parse_inst_t cmd_config_thresh = {
3481 .f = cmd_config_thresh_parsed,
3483 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3485 (void *)&cmd_config_thresh_port,
3486 (void *)&cmd_config_thresh_keyword,
3487 (void *)&cmd_config_thresh_all,
3488 (void *)&cmd_config_thresh_name,
3489 (void *)&cmd_config_thresh_value,
3494 /* *** configure free/rs threshold *** */
3495 struct cmd_config_threshold {
3496 cmdline_fixed_string_t port;
3497 cmdline_fixed_string_t keyword;
3498 cmdline_fixed_string_t all;
3499 cmdline_fixed_string_t name;
3504 cmd_config_threshold_parsed(void *parsed_result,
3505 __rte_unused struct cmdline *cl,
3506 __rte_unused void *data)
3508 struct cmd_config_threshold *res = parsed_result;
3510 if (!all_ports_stopped()) {
3511 printf("Please stop all ports first\n");
3515 if (!strcmp(res->name, "txfreet"))
3516 tx_free_thresh = res->value;
3517 else if (!strcmp(res->name, "txrst"))
3518 tx_rs_thresh = res->value;
3519 else if (!strcmp(res->name, "rxfreet"))
3520 rx_free_thresh = res->value;
3522 printf("Unknown parameter\n");
3528 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3531 cmdline_parse_token_string_t cmd_config_threshold_port =
3532 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3533 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3534 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3536 cmdline_parse_token_string_t cmd_config_threshold_all =
3537 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3538 cmdline_parse_token_string_t cmd_config_threshold_name =
3539 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3540 "txfreet#txrst#rxfreet");
3541 cmdline_parse_token_num_t cmd_config_threshold_value =
3542 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3544 cmdline_parse_inst_t cmd_config_threshold = {
3545 .f = cmd_config_threshold_parsed,
3547 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3549 (void *)&cmd_config_threshold_port,
3550 (void *)&cmd_config_threshold_keyword,
3551 (void *)&cmd_config_threshold_all,
3552 (void *)&cmd_config_threshold_name,
3553 (void *)&cmd_config_threshold_value,
3559 struct cmd_stop_result {
3560 cmdline_fixed_string_t stop;
3563 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3564 __rte_unused struct cmdline *cl,
3565 __rte_unused void *data)
3567 stop_packet_forwarding();
3570 cmdline_parse_token_string_t cmd_stop_stop =
3571 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3573 cmdline_parse_inst_t cmd_stop = {
3574 .f = cmd_stop_parsed,
3576 .help_str = "stop: Stop packet forwarding",
3578 (void *)&cmd_stop_stop,
3583 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3586 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3587 unsigned int *parsed_items, int check_unique_values)
3589 unsigned int nb_item;
3597 * First parse all items in the list and store their value.
3602 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3604 if ((c >= '0') && (c <= '9')) {
3605 value = (unsigned int) (value * 10 + (c - '0'));
3610 printf("character %c is not a decimal digit\n", c);
3614 printf("No valid value before comma\n");
3617 if (nb_item < max_items) {
3618 parsed_items[nb_item] = value;
3624 if (nb_item >= max_items) {
3625 printf("Number of %s = %u > %u (maximum items)\n",
3626 item_name, nb_item + 1, max_items);
3629 parsed_items[nb_item++] = value;
3630 if (! check_unique_values)
3634 * Then, check that all values in the list are differents.
3635 * No optimization here...
3637 for (i = 0; i < nb_item; i++) {
3638 for (j = i + 1; j < nb_item; j++) {
3639 if (parsed_items[j] == parsed_items[i]) {
3640 printf("duplicated %s %u at index %u and %u\n",
3641 item_name, parsed_items[i], i, j);
3649 struct cmd_set_list_result {
3650 cmdline_fixed_string_t cmd_keyword;
3651 cmdline_fixed_string_t list_name;
3652 cmdline_fixed_string_t list_of_items;
3655 static void cmd_set_list_parsed(void *parsed_result,
3656 __rte_unused struct cmdline *cl,
3657 __rte_unused void *data)
3659 struct cmd_set_list_result *res;
3661 unsigned int lcorelist[RTE_MAX_LCORE];
3662 unsigned int portlist[RTE_MAX_ETHPORTS];
3664 unsigned int nb_item;
3666 if (test_done == 0) {
3667 printf("Please stop forwarding first\n");
3671 res = parsed_result;
3672 if (!strcmp(res->list_name, "corelist")) {
3673 nb_item = parse_item_list(res->list_of_items, "core",
3675 parsed_items.lcorelist, 1);
3677 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3682 if (!strcmp(res->list_name, "portlist")) {
3683 nb_item = parse_item_list(res->list_of_items, "port",
3685 parsed_items.portlist, 1);
3687 set_fwd_ports_list(parsed_items.portlist, nb_item);
3693 cmdline_parse_token_string_t cmd_set_list_keyword =
3694 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3696 cmdline_parse_token_string_t cmd_set_list_name =
3697 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3698 "corelist#portlist");
3699 cmdline_parse_token_string_t cmd_set_list_of_items =
3700 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3703 cmdline_parse_inst_t cmd_set_fwd_list = {
3704 .f = cmd_set_list_parsed,
3706 .help_str = "set corelist|portlist <list0[,list1]*>",
3708 (void *)&cmd_set_list_keyword,
3709 (void *)&cmd_set_list_name,
3710 (void *)&cmd_set_list_of_items,
3715 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3717 struct cmd_setmask_result {
3718 cmdline_fixed_string_t set;
3719 cmdline_fixed_string_t mask;
3723 static void cmd_set_mask_parsed(void *parsed_result,
3724 __rte_unused struct cmdline *cl,
3725 __rte_unused void *data)
3727 struct cmd_setmask_result *res = parsed_result;
3729 if (test_done == 0) {
3730 printf("Please stop forwarding first\n");
3733 if (!strcmp(res->mask, "coremask")) {
3734 set_fwd_lcores_mask(res->hexavalue);
3736 } else if (!strcmp(res->mask, "portmask")) {
3737 set_fwd_ports_mask(res->hexavalue);
3742 cmdline_parse_token_string_t cmd_setmask_set =
3743 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3744 cmdline_parse_token_string_t cmd_setmask_mask =
3745 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3746 "coremask#portmask");
3747 cmdline_parse_token_num_t cmd_setmask_value =
3748 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3750 cmdline_parse_inst_t cmd_set_fwd_mask = {
3751 .f = cmd_set_mask_parsed,
3753 .help_str = "set coremask|portmask <hexadecimal value>",
3755 (void *)&cmd_setmask_set,
3756 (void *)&cmd_setmask_mask,
3757 (void *)&cmd_setmask_value,
3763 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3765 struct cmd_set_result {
3766 cmdline_fixed_string_t set;
3767 cmdline_fixed_string_t what;
3771 static void cmd_set_parsed(void *parsed_result,
3772 __rte_unused struct cmdline *cl,
3773 __rte_unused void *data)
3775 struct cmd_set_result *res = parsed_result;
3776 if (!strcmp(res->what, "nbport")) {
3777 set_fwd_ports_number(res->value);
3779 } else if (!strcmp(res->what, "nbcore")) {
3780 set_fwd_lcores_number(res->value);
3782 } else if (!strcmp(res->what, "burst"))
3783 set_nb_pkt_per_burst(res->value);
3784 else if (!strcmp(res->what, "verbose"))
3785 set_verbose_level(res->value);
3788 cmdline_parse_token_string_t cmd_set_set =
3789 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3790 cmdline_parse_token_string_t cmd_set_what =
3791 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3792 "nbport#nbcore#burst#verbose");
3793 cmdline_parse_token_num_t cmd_set_value =
3794 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3796 cmdline_parse_inst_t cmd_set_numbers = {
3797 .f = cmd_set_parsed,
3799 .help_str = "set nbport|nbcore|burst|verbose <value>",
3801 (void *)&cmd_set_set,
3802 (void *)&cmd_set_what,
3803 (void *)&cmd_set_value,
3808 /* *** SET LOG LEVEL CONFIGURATION *** */
3810 struct cmd_set_log_result {
3811 cmdline_fixed_string_t set;
3812 cmdline_fixed_string_t log;
3813 cmdline_fixed_string_t type;
3818 cmd_set_log_parsed(void *parsed_result,
3819 __rte_unused struct cmdline *cl,
3820 __rte_unused void *data)
3822 struct cmd_set_log_result *res;
3825 res = parsed_result;
3826 if (!strcmp(res->type, "global"))
3827 rte_log_set_global_level(res->level);
3829 ret = rte_log_set_level_regexp(res->type, res->level);
3831 printf("Unable to set log level\n");
3835 cmdline_parse_token_string_t cmd_set_log_set =
3836 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3837 cmdline_parse_token_string_t cmd_set_log_log =
3838 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3839 cmdline_parse_token_string_t cmd_set_log_type =
3840 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3841 cmdline_parse_token_num_t cmd_set_log_level =
3842 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3844 cmdline_parse_inst_t cmd_set_log = {
3845 .f = cmd_set_log_parsed,
3847 .help_str = "set log global|<type> <level>",
3849 (void *)&cmd_set_log_set,
3850 (void *)&cmd_set_log_log,
3851 (void *)&cmd_set_log_type,
3852 (void *)&cmd_set_log_level,
3857 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3859 struct cmd_set_txpkts_result {
3860 cmdline_fixed_string_t cmd_keyword;
3861 cmdline_fixed_string_t txpkts;
3862 cmdline_fixed_string_t seg_lengths;
3866 cmd_set_txpkts_parsed(void *parsed_result,
3867 __rte_unused struct cmdline *cl,
3868 __rte_unused void *data)
3870 struct cmd_set_txpkts_result *res;
3871 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3872 unsigned int nb_segs;
3874 res = parsed_result;
3875 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3876 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3878 set_tx_pkt_segments(seg_lengths, nb_segs);
3881 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3882 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3883 cmd_keyword, "set");
3884 cmdline_parse_token_string_t cmd_set_txpkts_name =
3885 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3887 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3888 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3891 cmdline_parse_inst_t cmd_set_txpkts = {
3892 .f = cmd_set_txpkts_parsed,
3894 .help_str = "set txpkts <len0[,len1]*>",
3896 (void *)&cmd_set_txpkts_keyword,
3897 (void *)&cmd_set_txpkts_name,
3898 (void *)&cmd_set_txpkts_lengths,
3903 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3905 struct cmd_set_txsplit_result {
3906 cmdline_fixed_string_t cmd_keyword;
3907 cmdline_fixed_string_t txsplit;
3908 cmdline_fixed_string_t mode;
3912 cmd_set_txsplit_parsed(void *parsed_result,
3913 __rte_unused struct cmdline *cl,
3914 __rte_unused void *data)
3916 struct cmd_set_txsplit_result *res;
3918 res = parsed_result;
3919 set_tx_pkt_split(res->mode);
3922 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3923 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3924 cmd_keyword, "set");
3925 cmdline_parse_token_string_t cmd_set_txsplit_name =
3926 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3927 txsplit, "txsplit");
3928 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3929 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3932 cmdline_parse_inst_t cmd_set_txsplit = {
3933 .f = cmd_set_txsplit_parsed,
3935 .help_str = "set txsplit on|off|rand",
3937 (void *)&cmd_set_txsplit_keyword,
3938 (void *)&cmd_set_txsplit_name,
3939 (void *)&cmd_set_txsplit_mode,
3944 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
3946 struct cmd_set_txtimes_result {
3947 cmdline_fixed_string_t cmd_keyword;
3948 cmdline_fixed_string_t txtimes;
3949 cmdline_fixed_string_t tx_times;
3953 cmd_set_txtimes_parsed(void *parsed_result,
3954 __rte_unused struct cmdline *cl,
3955 __rte_unused void *data)
3957 struct cmd_set_txtimes_result *res;
3958 unsigned int tx_times[2] = {0, 0};
3959 unsigned int n_times;
3961 res = parsed_result;
3962 n_times = parse_item_list(res->tx_times, "tx times",
3965 set_tx_pkt_times(tx_times);
3968 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
3969 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3970 cmd_keyword, "set");
3971 cmdline_parse_token_string_t cmd_set_txtimes_name =
3972 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3973 txtimes, "txtimes");
3974 cmdline_parse_token_string_t cmd_set_txtimes_value =
3975 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3978 cmdline_parse_inst_t cmd_set_txtimes = {
3979 .f = cmd_set_txtimes_parsed,
3981 .help_str = "set txtimes <inter_burst>,<intra_burst>",
3983 (void *)&cmd_set_txtimes_keyword,
3984 (void *)&cmd_set_txtimes_name,
3985 (void *)&cmd_set_txtimes_value,
3990 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3991 struct cmd_rx_vlan_filter_all_result {
3992 cmdline_fixed_string_t rx_vlan;
3993 cmdline_fixed_string_t what;
3994 cmdline_fixed_string_t all;
3999 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4000 __rte_unused struct cmdline *cl,
4001 __rte_unused void *data)
4003 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4005 if (!strcmp(res->what, "add"))
4006 rx_vlan_all_filter_set(res->port_id, 1);
4008 rx_vlan_all_filter_set(res->port_id, 0);
4011 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4012 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4013 rx_vlan, "rx_vlan");
4014 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4015 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4017 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4018 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4020 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4021 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4024 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4025 .f = cmd_rx_vlan_filter_all_parsed,
4027 .help_str = "rx_vlan add|rm all <port_id>: "
4028 "Add/Remove all identifiers to/from the set of VLAN "
4029 "identifiers filtered by a port",
4031 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4032 (void *)&cmd_rx_vlan_filter_all_what,
4033 (void *)&cmd_rx_vlan_filter_all_all,
4034 (void *)&cmd_rx_vlan_filter_all_portid,
4039 /* *** VLAN OFFLOAD SET ON A PORT *** */
4040 struct cmd_vlan_offload_result {
4041 cmdline_fixed_string_t vlan;
4042 cmdline_fixed_string_t set;
4043 cmdline_fixed_string_t vlan_type;
4044 cmdline_fixed_string_t what;
4045 cmdline_fixed_string_t on;
4046 cmdline_fixed_string_t port_id;
4050 cmd_vlan_offload_parsed(void *parsed_result,
4051 __rte_unused struct cmdline *cl,
4052 __rte_unused void *data)
4055 struct cmd_vlan_offload_result *res = parsed_result;
4058 portid_t port_id = 0;
4062 len = strnlen(str, STR_TOKEN_SIZE);
4064 /* Get port_id first */
4072 tmp = strtoul(str, NULL, 0);
4073 /* If port_id greater that what portid_t can represent, return */
4074 if(tmp >= RTE_MAX_ETHPORTS)
4076 port_id = (portid_t)tmp;
4078 if (!strcmp(res->on, "on"))
4083 if (!strcmp(res->what, "strip"))
4084 rx_vlan_strip_set(port_id, on);
4085 else if(!strcmp(res->what, "stripq")){
4086 uint16_t queue_id = 0;
4088 /* No queue_id, return */
4090 printf("must specify (port,queue_id)\n");
4093 tmp = strtoul(str + i + 1, NULL, 0);
4094 /* If queue_id greater that what 16-bits can represent, return */
4098 queue_id = (uint16_t)tmp;
4099 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4101 else if (!strcmp(res->what, "filter"))
4102 rx_vlan_filter_set(port_id, on);
4103 else if (!strcmp(res->what, "qinq_strip"))
4104 rx_vlan_qinq_strip_set(port_id, on);
4106 vlan_extend_set(port_id, on);
4111 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4112 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4114 cmdline_parse_token_string_t cmd_vlan_offload_set =
4115 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4117 cmdline_parse_token_string_t cmd_vlan_offload_what =
4118 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4119 what, "strip#filter#qinq_strip#extend#stripq");
4120 cmdline_parse_token_string_t cmd_vlan_offload_on =
4121 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4123 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4124 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4127 cmdline_parse_inst_t cmd_vlan_offload = {
4128 .f = cmd_vlan_offload_parsed,
4130 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4131 "<port_id[,queue_id]>: "
4132 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4134 (void *)&cmd_vlan_offload_vlan,
4135 (void *)&cmd_vlan_offload_set,
4136 (void *)&cmd_vlan_offload_what,
4137 (void *)&cmd_vlan_offload_on,
4138 (void *)&cmd_vlan_offload_portid,
4143 /* *** VLAN TPID SET ON A PORT *** */
4144 struct cmd_vlan_tpid_result {
4145 cmdline_fixed_string_t vlan;
4146 cmdline_fixed_string_t set;
4147 cmdline_fixed_string_t vlan_type;
4148 cmdline_fixed_string_t what;
4154 cmd_vlan_tpid_parsed(void *parsed_result,
4155 __rte_unused struct cmdline *cl,
4156 __rte_unused void *data)
4158 struct cmd_vlan_tpid_result *res = parsed_result;
4159 enum rte_vlan_type vlan_type;
4161 if (!strcmp(res->vlan_type, "inner"))
4162 vlan_type = ETH_VLAN_TYPE_INNER;
4163 else if (!strcmp(res->vlan_type, "outer"))
4164 vlan_type = ETH_VLAN_TYPE_OUTER;
4166 printf("Unknown vlan type\n");
4169 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4172 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4173 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4175 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4176 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4178 cmdline_parse_token_string_t cmd_vlan_type =
4179 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4180 vlan_type, "inner#outer");
4181 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4182 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4184 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4185 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4187 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4188 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4191 cmdline_parse_inst_t cmd_vlan_tpid = {
4192 .f = cmd_vlan_tpid_parsed,
4194 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4195 "Set the VLAN Ether type",
4197 (void *)&cmd_vlan_tpid_vlan,
4198 (void *)&cmd_vlan_tpid_set,
4199 (void *)&cmd_vlan_type,
4200 (void *)&cmd_vlan_tpid_what,
4201 (void *)&cmd_vlan_tpid_tpid,
4202 (void *)&cmd_vlan_tpid_portid,
4207 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4208 struct cmd_rx_vlan_filter_result {
4209 cmdline_fixed_string_t rx_vlan;
4210 cmdline_fixed_string_t what;
4216 cmd_rx_vlan_filter_parsed(void *parsed_result,
4217 __rte_unused struct cmdline *cl,
4218 __rte_unused void *data)
4220 struct cmd_rx_vlan_filter_result *res = parsed_result;
4222 if (!strcmp(res->what, "add"))
4223 rx_vft_set(res->port_id, res->vlan_id, 1);
4225 rx_vft_set(res->port_id, res->vlan_id, 0);
4228 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4229 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4230 rx_vlan, "rx_vlan");
4231 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4232 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4234 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4235 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4237 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4238 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4241 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4242 .f = cmd_rx_vlan_filter_parsed,
4244 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4245 "Add/Remove a VLAN identifier to/from the set of VLAN "
4246 "identifiers filtered by a port",
4248 (void *)&cmd_rx_vlan_filter_rx_vlan,
4249 (void *)&cmd_rx_vlan_filter_what,
4250 (void *)&cmd_rx_vlan_filter_vlanid,
4251 (void *)&cmd_rx_vlan_filter_portid,
4256 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4257 struct cmd_tx_vlan_set_result {
4258 cmdline_fixed_string_t tx_vlan;
4259 cmdline_fixed_string_t set;
4265 cmd_tx_vlan_set_parsed(void *parsed_result,
4266 __rte_unused struct cmdline *cl,
4267 __rte_unused void *data)
4269 struct cmd_tx_vlan_set_result *res = parsed_result;
4271 if (!port_is_stopped(res->port_id)) {
4272 printf("Please stop port %d first\n", res->port_id);
4276 tx_vlan_set(res->port_id, res->vlan_id);
4278 cmd_reconfig_device_queue(res->port_id, 1, 1);
4281 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4282 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4283 tx_vlan, "tx_vlan");
4284 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4285 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4287 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4288 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4290 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4291 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4294 cmdline_parse_inst_t cmd_tx_vlan_set = {
4295 .f = cmd_tx_vlan_set_parsed,
4297 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4298 "Enable hardware insertion of a single VLAN header "
4299 "with a given TAG Identifier in packets sent on a port",
4301 (void *)&cmd_tx_vlan_set_tx_vlan,
4302 (void *)&cmd_tx_vlan_set_set,
4303 (void *)&cmd_tx_vlan_set_portid,
4304 (void *)&cmd_tx_vlan_set_vlanid,
4309 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4310 struct cmd_tx_vlan_set_qinq_result {
4311 cmdline_fixed_string_t tx_vlan;
4312 cmdline_fixed_string_t set;
4315 uint16_t vlan_id_outer;
4319 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4320 __rte_unused struct cmdline *cl,
4321 __rte_unused void *data)
4323 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4325 if (!port_is_stopped(res->port_id)) {
4326 printf("Please stop port %d first\n", res->port_id);
4330 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4332 cmd_reconfig_device_queue(res->port_id, 1, 1);
4335 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4336 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4337 tx_vlan, "tx_vlan");
4338 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4339 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4341 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4342 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4344 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4345 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4347 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4348 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4349 vlan_id_outer, UINT16);
4351 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4352 .f = cmd_tx_vlan_set_qinq_parsed,
4354 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4355 "Enable hardware insertion of double VLAN header "
4356 "with given TAG Identifiers in packets sent on a port",
4358 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4359 (void *)&cmd_tx_vlan_set_qinq_set,
4360 (void *)&cmd_tx_vlan_set_qinq_portid,
4361 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4362 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4367 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4368 struct cmd_tx_vlan_set_pvid_result {
4369 cmdline_fixed_string_t tx_vlan;
4370 cmdline_fixed_string_t set;
4371 cmdline_fixed_string_t pvid;
4374 cmdline_fixed_string_t mode;
4378 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4379 __rte_unused struct cmdline *cl,
4380 __rte_unused void *data)
4382 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4384 if (strcmp(res->mode, "on") == 0)
4385 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4387 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4390 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4391 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4392 tx_vlan, "tx_vlan");
4393 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4394 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4396 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4397 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4399 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4400 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4402 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4403 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4405 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4406 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4409 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4410 .f = cmd_tx_vlan_set_pvid_parsed,
4412 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4414 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4415 (void *)&cmd_tx_vlan_set_pvid_set,
4416 (void *)&cmd_tx_vlan_set_pvid_pvid,
4417 (void *)&cmd_tx_vlan_set_pvid_port_id,
4418 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4419 (void *)&cmd_tx_vlan_set_pvid_mode,
4424 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4425 struct cmd_tx_vlan_reset_result {
4426 cmdline_fixed_string_t tx_vlan;
4427 cmdline_fixed_string_t reset;
4432 cmd_tx_vlan_reset_parsed(void *parsed_result,
4433 __rte_unused struct cmdline *cl,
4434 __rte_unused void *data)
4436 struct cmd_tx_vlan_reset_result *res = parsed_result;
4438 if (!port_is_stopped(res->port_id)) {
4439 printf("Please stop port %d first\n", res->port_id);
4443 tx_vlan_reset(res->port_id);
4445 cmd_reconfig_device_queue(res->port_id, 1, 1);
4448 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4449 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4450 tx_vlan, "tx_vlan");
4451 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4452 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4454 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4455 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4458 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4459 .f = cmd_tx_vlan_reset_parsed,
4461 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4462 "VLAN header in packets sent on a port",
4464 (void *)&cmd_tx_vlan_reset_tx_vlan,
4465 (void *)&cmd_tx_vlan_reset_reset,
4466 (void *)&cmd_tx_vlan_reset_portid,
4472 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4473 struct cmd_csum_result {
4474 cmdline_fixed_string_t csum;
4475 cmdline_fixed_string_t mode;
4476 cmdline_fixed_string_t proto;
4477 cmdline_fixed_string_t hwsw;
4482 csum_show(int port_id)
4484 struct rte_eth_dev_info dev_info;
4485 uint64_t tx_offloads;
4488 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4489 printf("Parse tunnel is %s\n",
4490 (ports[port_id].parse_tunnel) ? "on" : "off");
4491 printf("IP checksum offload is %s\n",
4492 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4493 printf("UDP checksum offload is %s\n",
4494 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4495 printf("TCP checksum offload is %s\n",
4496 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4497 printf("SCTP checksum offload is %s\n",
4498 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4499 printf("Outer-Ip checksum offload is %s\n",
4500 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4501 printf("Outer-Udp checksum offload is %s\n",
4502 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4504 /* display warnings if configuration is not supported by the NIC */
4505 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4509 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4510 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4511 printf("Warning: hardware IP checksum enabled but not "
4512 "supported by port %d\n", port_id);
4514 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4515 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4516 printf("Warning: hardware UDP checksum enabled but not "
4517 "supported by port %d\n", port_id);
4519 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4520 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4521 printf("Warning: hardware TCP checksum enabled but not "
4522 "supported by port %d\n", port_id);
4524 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4525 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4526 printf("Warning: hardware SCTP checksum enabled but not "
4527 "supported by port %d\n", port_id);
4529 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4530 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4531 printf("Warning: hardware outer IP checksum enabled but not "
4532 "supported by port %d\n", port_id);
4534 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4535 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4537 printf("Warning: hardware outer UDP checksum enabled but not "
4538 "supported by port %d\n", port_id);
4543 cmd_config_queue_tx_offloads(struct rte_port *port)
4547 /* Apply queue tx offloads configuration */
4548 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4549 port->tx_conf[k].offloads =
4550 port->dev_conf.txmode.offloads;
4554 cmd_csum_parsed(void *parsed_result,
4555 __rte_unused struct cmdline *cl,
4556 __rte_unused void *data)
4558 struct cmd_csum_result *res = parsed_result;
4560 uint64_t csum_offloads = 0;
4561 struct rte_eth_dev_info dev_info;
4564 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4565 printf("invalid port %d\n", res->port_id);
4568 if (!port_is_stopped(res->port_id)) {
4569 printf("Please stop port %d first\n", res->port_id);
4573 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4577 if (!strcmp(res->mode, "set")) {
4579 if (!strcmp(res->hwsw, "hw"))
4582 if (!strcmp(res->proto, "ip")) {
4583 if (hw == 0 || (dev_info.tx_offload_capa &
4584 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4585 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4587 printf("IP checksum offload is not supported "
4588 "by port %u\n", res->port_id);
4590 } else if (!strcmp(res->proto, "udp")) {
4591 if (hw == 0 || (dev_info.tx_offload_capa &
4592 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4593 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4595 printf("UDP checksum offload is not supported "
4596 "by port %u\n", res->port_id);
4598 } else if (!strcmp(res->proto, "tcp")) {
4599 if (hw == 0 || (dev_info.tx_offload_capa &
4600 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4601 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4603 printf("TCP checksum offload is not supported "
4604 "by port %u\n", res->port_id);
4606 } else if (!strcmp(res->proto, "sctp")) {
4607 if (hw == 0 || (dev_info.tx_offload_capa &
4608 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4609 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4611 printf("SCTP checksum offload is not supported "
4612 "by port %u\n", res->port_id);
4614 } else if (!strcmp(res->proto, "outer-ip")) {
4615 if (hw == 0 || (dev_info.tx_offload_capa &
4616 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4618 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4620 printf("Outer IP checksum offload is not "
4621 "supported by port %u\n", res->port_id);
4623 } else if (!strcmp(res->proto, "outer-udp")) {
4624 if (hw == 0 || (dev_info.tx_offload_capa &
4625 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4627 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4629 printf("Outer UDP checksum offload is not "
4630 "supported by port %u\n", res->port_id);
4635 ports[res->port_id].dev_conf.txmode.offloads |=
4638 ports[res->port_id].dev_conf.txmode.offloads &=
4641 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4643 csum_show(res->port_id);
4645 cmd_reconfig_device_queue(res->port_id, 1, 1);
4648 cmdline_parse_token_string_t cmd_csum_csum =
4649 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4651 cmdline_parse_token_string_t cmd_csum_mode =
4652 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4654 cmdline_parse_token_string_t cmd_csum_proto =
4655 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4656 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4657 cmdline_parse_token_string_t cmd_csum_hwsw =
4658 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4660 cmdline_parse_token_num_t cmd_csum_portid =
4661 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4664 cmdline_parse_inst_t cmd_csum_set = {
4665 .f = cmd_csum_parsed,
4667 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4668 "Enable/Disable hardware calculation of L3/L4 checksum when "
4669 "using csum forward engine",
4671 (void *)&cmd_csum_csum,
4672 (void *)&cmd_csum_mode,
4673 (void *)&cmd_csum_proto,
4674 (void *)&cmd_csum_hwsw,
4675 (void *)&cmd_csum_portid,
4680 cmdline_parse_token_string_t cmd_csum_mode_show =
4681 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4684 cmdline_parse_inst_t cmd_csum_show = {
4685 .f = cmd_csum_parsed,
4687 .help_str = "csum show <port_id>: Show checksum offload configuration",
4689 (void *)&cmd_csum_csum,
4690 (void *)&cmd_csum_mode_show,
4691 (void *)&cmd_csum_portid,
4696 /* Enable/disable tunnel parsing */
4697 struct cmd_csum_tunnel_result {
4698 cmdline_fixed_string_t csum;
4699 cmdline_fixed_string_t parse;
4700 cmdline_fixed_string_t onoff;
4705 cmd_csum_tunnel_parsed(void *parsed_result,
4706 __rte_unused struct cmdline *cl,
4707 __rte_unused void *data)
4709 struct cmd_csum_tunnel_result *res = parsed_result;
4711 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4714 if (!strcmp(res->onoff, "on"))
4715 ports[res->port_id].parse_tunnel = 1;
4717 ports[res->port_id].parse_tunnel = 0;
4719 csum_show(res->port_id);
4722 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4723 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4725 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4726 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4727 parse, "parse-tunnel");
4728 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4729 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4731 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4732 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4735 cmdline_parse_inst_t cmd_csum_tunnel = {
4736 .f = cmd_csum_tunnel_parsed,
4738 .help_str = "csum parse-tunnel on|off <port_id>: "
4739 "Enable/Disable parsing of tunnels for csum engine",
4741 (void *)&cmd_csum_tunnel_csum,
4742 (void *)&cmd_csum_tunnel_parse,
4743 (void *)&cmd_csum_tunnel_onoff,
4744 (void *)&cmd_csum_tunnel_portid,
4749 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4750 struct cmd_tso_set_result {
4751 cmdline_fixed_string_t tso;
4752 cmdline_fixed_string_t mode;
4758 cmd_tso_set_parsed(void *parsed_result,
4759 __rte_unused struct cmdline *cl,
4760 __rte_unused void *data)
4762 struct cmd_tso_set_result *res = parsed_result;
4763 struct rte_eth_dev_info dev_info;
4766 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4768 if (!port_is_stopped(res->port_id)) {
4769 printf("Please stop port %d first\n", res->port_id);
4773 if (!strcmp(res->mode, "set"))
4774 ports[res->port_id].tso_segsz = res->tso_segsz;
4776 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4780 if ((ports[res->port_id].tso_segsz != 0) &&
4781 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4782 printf("Error: TSO is not supported by port %d\n",
4787 if (ports[res->port_id].tso_segsz == 0) {
4788 ports[res->port_id].dev_conf.txmode.offloads &=
4789 ~DEV_TX_OFFLOAD_TCP_TSO;
4790 printf("TSO for non-tunneled packets is disabled\n");
4792 ports[res->port_id].dev_conf.txmode.offloads |=
4793 DEV_TX_OFFLOAD_TCP_TSO;
4794 printf("TSO segment size for non-tunneled packets is %d\n",
4795 ports[res->port_id].tso_segsz);
4797 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4799 /* display warnings if configuration is not supported by the NIC */
4800 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4804 if ((ports[res->port_id].tso_segsz != 0) &&
4805 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4806 printf("Warning: TSO enabled but not "
4807 "supported by port %d\n", res->port_id);
4810 cmd_reconfig_device_queue(res->port_id, 1, 1);
4813 cmdline_parse_token_string_t cmd_tso_set_tso =
4814 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4816 cmdline_parse_token_string_t cmd_tso_set_mode =
4817 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4819 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4820 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4822 cmdline_parse_token_num_t cmd_tso_set_portid =
4823 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4826 cmdline_parse_inst_t cmd_tso_set = {
4827 .f = cmd_tso_set_parsed,
4829 .help_str = "tso set <tso_segsz> <port_id>: "
4830 "Set TSO segment size of non-tunneled packets for csum engine "
4833 (void *)&cmd_tso_set_tso,
4834 (void *)&cmd_tso_set_mode,
4835 (void *)&cmd_tso_set_tso_segsz,
4836 (void *)&cmd_tso_set_portid,
4841 cmdline_parse_token_string_t cmd_tso_show_mode =
4842 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4846 cmdline_parse_inst_t cmd_tso_show = {
4847 .f = cmd_tso_set_parsed,
4849 .help_str = "tso show <port_id>: "
4850 "Show TSO segment size of non-tunneled packets for csum engine",
4852 (void *)&cmd_tso_set_tso,
4853 (void *)&cmd_tso_show_mode,
4854 (void *)&cmd_tso_set_portid,
4859 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4860 struct cmd_tunnel_tso_set_result {
4861 cmdline_fixed_string_t tso;
4862 cmdline_fixed_string_t mode;
4867 static struct rte_eth_dev_info
4868 check_tunnel_tso_nic_support(portid_t port_id)
4870 struct rte_eth_dev_info dev_info;
4872 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4875 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4876 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4877 "not enabled for port %d\n", port_id);
4878 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4879 printf("Warning: GRE TUNNEL TSO not supported therefore "
4880 "not enabled for port %d\n", port_id);
4881 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4882 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4883 "not enabled for port %d\n", port_id);
4884 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4885 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4886 "not enabled for port %d\n", port_id);
4887 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4888 printf("Warning: IP TUNNEL TSO not supported therefore "
4889 "not enabled for port %d\n", port_id);
4890 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4891 printf("Warning: UDP TUNNEL TSO not supported therefore "
4892 "not enabled for port %d\n", port_id);
4897 cmd_tunnel_tso_set_parsed(void *parsed_result,
4898 __rte_unused struct cmdline *cl,
4899 __rte_unused void *data)
4901 struct cmd_tunnel_tso_set_result *res = parsed_result;
4902 struct rte_eth_dev_info dev_info;
4904 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4906 if (!port_is_stopped(res->port_id)) {
4907 printf("Please stop port %d first\n", res->port_id);
4911 if (!strcmp(res->mode, "set"))
4912 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4914 dev_info = check_tunnel_tso_nic_support(res->port_id);
4915 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4916 ports[res->port_id].dev_conf.txmode.offloads &=
4917 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4918 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4919 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4920 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4921 DEV_TX_OFFLOAD_IP_TNL_TSO |
4922 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4923 printf("TSO for tunneled packets is disabled\n");
4925 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4926 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4927 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4928 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4929 DEV_TX_OFFLOAD_IP_TNL_TSO |
4930 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4932 ports[res->port_id].dev_conf.txmode.offloads |=
4933 (tso_offloads & dev_info.tx_offload_capa);
4934 printf("TSO segment size for tunneled packets is %d\n",
4935 ports[res->port_id].tunnel_tso_segsz);
4937 /* Below conditions are needed to make it work:
4938 * (1) tunnel TSO is supported by the NIC;
4939 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4941 * (3) for tunneled pkts with outer L3 of IPv4,
4942 * "csum set outer-ip" must be set to hw, because after tso,
4943 * total_len of outer IP header is changed, and the checksum
4944 * of outer IP header calculated by sw should be wrong; that
4945 * is not necessary for IPv6 tunneled pkts because there's no
4946 * checksum in IP header anymore.
4949 if (!ports[res->port_id].parse_tunnel)
4950 printf("Warning: csum parse_tunnel must be set "
4951 "so that tunneled packets are recognized\n");
4952 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4953 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4954 printf("Warning: csum set outer-ip must be set to hw "
4955 "if outer L3 is IPv4; not necessary for IPv6\n");
4958 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4959 cmd_reconfig_device_queue(res->port_id, 1, 1);
4962 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4963 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4965 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4966 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4968 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4969 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4971 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4972 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4975 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4976 .f = cmd_tunnel_tso_set_parsed,
4978 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4979 "Set TSO segment size of tunneled packets for csum engine "
4982 (void *)&cmd_tunnel_tso_set_tso,
4983 (void *)&cmd_tunnel_tso_set_mode,
4984 (void *)&cmd_tunnel_tso_set_tso_segsz,
4985 (void *)&cmd_tunnel_tso_set_portid,
4990 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4991 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4995 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4996 .f = cmd_tunnel_tso_set_parsed,
4998 .help_str = "tunnel_tso show <port_id> "
4999 "Show TSO segment size of tunneled packets for csum engine",
5001 (void *)&cmd_tunnel_tso_set_tso,
5002 (void *)&cmd_tunnel_tso_show_mode,
5003 (void *)&cmd_tunnel_tso_set_portid,
5008 /* *** SET GRO FOR A PORT *** */
5009 struct cmd_gro_enable_result {
5010 cmdline_fixed_string_t cmd_set;
5011 cmdline_fixed_string_t cmd_port;
5012 cmdline_fixed_string_t cmd_keyword;
5013 cmdline_fixed_string_t cmd_onoff;
5018 cmd_gro_enable_parsed(void *parsed_result,
5019 __rte_unused struct cmdline *cl,
5020 __rte_unused void *data)
5022 struct cmd_gro_enable_result *res;
5024 res = parsed_result;
5025 if (!strcmp(res->cmd_keyword, "gro"))
5026 setup_gro(res->cmd_onoff, res->cmd_pid);
5029 cmdline_parse_token_string_t cmd_gro_enable_set =
5030 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5032 cmdline_parse_token_string_t cmd_gro_enable_port =
5033 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5034 cmd_keyword, "port");
5035 cmdline_parse_token_num_t cmd_gro_enable_pid =
5036 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5038 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5039 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5040 cmd_keyword, "gro");
5041 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5042 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5043 cmd_onoff, "on#off");
5045 cmdline_parse_inst_t cmd_gro_enable = {
5046 .f = cmd_gro_enable_parsed,
5048 .help_str = "set port <port_id> gro on|off",
5050 (void *)&cmd_gro_enable_set,
5051 (void *)&cmd_gro_enable_port,
5052 (void *)&cmd_gro_enable_pid,
5053 (void *)&cmd_gro_enable_keyword,
5054 (void *)&cmd_gro_enable_onoff,
5059 /* *** DISPLAY GRO CONFIGURATION *** */
5060 struct cmd_gro_show_result {
5061 cmdline_fixed_string_t cmd_show;
5062 cmdline_fixed_string_t cmd_port;
5063 cmdline_fixed_string_t cmd_keyword;
5068 cmd_gro_show_parsed(void *parsed_result,
5069 __rte_unused struct cmdline *cl,
5070 __rte_unused void *data)
5072 struct cmd_gro_show_result *res;
5074 res = parsed_result;
5075 if (!strcmp(res->cmd_keyword, "gro"))
5076 show_gro(res->cmd_pid);
5079 cmdline_parse_token_string_t cmd_gro_show_show =
5080 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5082 cmdline_parse_token_string_t cmd_gro_show_port =
5083 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5085 cmdline_parse_token_num_t cmd_gro_show_pid =
5086 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5088 cmdline_parse_token_string_t cmd_gro_show_keyword =
5089 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5090 cmd_keyword, "gro");
5092 cmdline_parse_inst_t cmd_gro_show = {
5093 .f = cmd_gro_show_parsed,
5095 .help_str = "show port <port_id> gro",
5097 (void *)&cmd_gro_show_show,
5098 (void *)&cmd_gro_show_port,
5099 (void *)&cmd_gro_show_pid,
5100 (void *)&cmd_gro_show_keyword,
5105 /* *** SET FLUSH CYCLES FOR GRO *** */
5106 struct cmd_gro_flush_result {
5107 cmdline_fixed_string_t cmd_set;
5108 cmdline_fixed_string_t cmd_keyword;
5109 cmdline_fixed_string_t cmd_flush;
5114 cmd_gro_flush_parsed(void *parsed_result,
5115 __rte_unused struct cmdline *cl,
5116 __rte_unused void *data)
5118 struct cmd_gro_flush_result *res;
5120 res = parsed_result;
5121 if ((!strcmp(res->cmd_keyword, "gro")) &&
5122 (!strcmp(res->cmd_flush, "flush")))
5123 setup_gro_flush_cycles(res->cmd_cycles);
5126 cmdline_parse_token_string_t cmd_gro_flush_set =
5127 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5129 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5130 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5131 cmd_keyword, "gro");
5132 cmdline_parse_token_string_t cmd_gro_flush_flush =
5133 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5134 cmd_flush, "flush");
5135 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5136 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5139 cmdline_parse_inst_t cmd_gro_flush = {
5140 .f = cmd_gro_flush_parsed,
5142 .help_str = "set gro flush <cycles>",
5144 (void *)&cmd_gro_flush_set,
5145 (void *)&cmd_gro_flush_keyword,
5146 (void *)&cmd_gro_flush_flush,
5147 (void *)&cmd_gro_flush_cycles,
5152 /* *** ENABLE/DISABLE GSO *** */
5153 struct cmd_gso_enable_result {
5154 cmdline_fixed_string_t cmd_set;
5155 cmdline_fixed_string_t cmd_port;
5156 cmdline_fixed_string_t cmd_keyword;
5157 cmdline_fixed_string_t cmd_mode;
5162 cmd_gso_enable_parsed(void *parsed_result,
5163 __rte_unused struct cmdline *cl,
5164 __rte_unused void *data)
5166 struct cmd_gso_enable_result *res;
5168 res = parsed_result;
5169 if (!strcmp(res->cmd_keyword, "gso"))
5170 setup_gso(res->cmd_mode, res->cmd_pid);
5173 cmdline_parse_token_string_t cmd_gso_enable_set =
5174 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5176 cmdline_parse_token_string_t cmd_gso_enable_port =
5177 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5179 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5180 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5181 cmd_keyword, "gso");
5182 cmdline_parse_token_string_t cmd_gso_enable_mode =
5183 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5184 cmd_mode, "on#off");
5185 cmdline_parse_token_num_t cmd_gso_enable_pid =
5186 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5189 cmdline_parse_inst_t cmd_gso_enable = {
5190 .f = cmd_gso_enable_parsed,
5192 .help_str = "set port <port_id> gso on|off",
5194 (void *)&cmd_gso_enable_set,
5195 (void *)&cmd_gso_enable_port,
5196 (void *)&cmd_gso_enable_pid,
5197 (void *)&cmd_gso_enable_keyword,
5198 (void *)&cmd_gso_enable_mode,
5203 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5204 struct cmd_gso_size_result {
5205 cmdline_fixed_string_t cmd_set;
5206 cmdline_fixed_string_t cmd_keyword;
5207 cmdline_fixed_string_t cmd_segsz;
5212 cmd_gso_size_parsed(void *parsed_result,
5213 __rte_unused struct cmdline *cl,
5214 __rte_unused void *data)
5216 struct cmd_gso_size_result *res = parsed_result;
5218 if (test_done == 0) {
5219 printf("Before setting GSO segsz, please first"
5220 " stop forwarding\n");
5224 if (!strcmp(res->cmd_keyword, "gso") &&
5225 !strcmp(res->cmd_segsz, "segsz")) {
5226 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5227 printf("gso_size should be larger than %zu."
5228 " Please input a legal value\n",
5229 RTE_GSO_SEG_SIZE_MIN);
5231 gso_max_segment_size = res->cmd_size;
5235 cmdline_parse_token_string_t cmd_gso_size_set =
5236 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5238 cmdline_parse_token_string_t cmd_gso_size_keyword =
5239 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5240 cmd_keyword, "gso");
5241 cmdline_parse_token_string_t cmd_gso_size_segsz =
5242 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5243 cmd_segsz, "segsz");
5244 cmdline_parse_token_num_t cmd_gso_size_size =
5245 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5248 cmdline_parse_inst_t cmd_gso_size = {
5249 .f = cmd_gso_size_parsed,
5251 .help_str = "set gso segsz <length>",
5253 (void *)&cmd_gso_size_set,
5254 (void *)&cmd_gso_size_keyword,
5255 (void *)&cmd_gso_size_segsz,
5256 (void *)&cmd_gso_size_size,
5261 /* *** SHOW GSO CONFIGURATION *** */
5262 struct cmd_gso_show_result {
5263 cmdline_fixed_string_t cmd_show;
5264 cmdline_fixed_string_t cmd_port;
5265 cmdline_fixed_string_t cmd_keyword;
5270 cmd_gso_show_parsed(void *parsed_result,
5271 __rte_unused struct cmdline *cl,
5272 __rte_unused void *data)
5274 struct cmd_gso_show_result *res = parsed_result;
5276 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5277 printf("invalid port id %u\n", res->cmd_pid);
5280 if (!strcmp(res->cmd_keyword, "gso")) {
5281 if (gso_ports[res->cmd_pid].enable) {
5282 printf("Max GSO'd packet size: %uB\n"
5283 "Supported GSO types: TCP/IPv4, "
5284 "UDP/IPv4, VxLAN with inner "
5285 "TCP/IPv4 packet, GRE with inner "
5286 "TCP/IPv4 packet\n",
5287 gso_max_segment_size);
5289 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5293 cmdline_parse_token_string_t cmd_gso_show_show =
5294 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5296 cmdline_parse_token_string_t cmd_gso_show_port =
5297 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5299 cmdline_parse_token_string_t cmd_gso_show_keyword =
5300 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5301 cmd_keyword, "gso");
5302 cmdline_parse_token_num_t cmd_gso_show_pid =
5303 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5306 cmdline_parse_inst_t cmd_gso_show = {
5307 .f = cmd_gso_show_parsed,
5309 .help_str = "show port <port_id> gso",
5311 (void *)&cmd_gso_show_show,
5312 (void *)&cmd_gso_show_port,
5313 (void *)&cmd_gso_show_pid,
5314 (void *)&cmd_gso_show_keyword,
5319 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5320 struct cmd_set_flush_rx {
5321 cmdline_fixed_string_t set;
5322 cmdline_fixed_string_t flush_rx;
5323 cmdline_fixed_string_t mode;
5327 cmd_set_flush_rx_parsed(void *parsed_result,
5328 __rte_unused struct cmdline *cl,
5329 __rte_unused void *data)
5331 struct cmd_set_flush_rx *res = parsed_result;
5332 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5335 cmdline_parse_token_string_t cmd_setflushrx_set =
5336 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5338 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5339 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5340 flush_rx, "flush_rx");
5341 cmdline_parse_token_string_t cmd_setflushrx_mode =
5342 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5346 cmdline_parse_inst_t cmd_set_flush_rx = {
5347 .f = cmd_set_flush_rx_parsed,
5348 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5351 (void *)&cmd_setflushrx_set,
5352 (void *)&cmd_setflushrx_flush_rx,
5353 (void *)&cmd_setflushrx_mode,
5358 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5359 struct cmd_set_link_check {
5360 cmdline_fixed_string_t set;
5361 cmdline_fixed_string_t link_check;
5362 cmdline_fixed_string_t mode;
5366 cmd_set_link_check_parsed(void *parsed_result,
5367 __rte_unused struct cmdline *cl,
5368 __rte_unused void *data)
5370 struct cmd_set_link_check *res = parsed_result;
5371 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5374 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5375 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5377 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5378 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5379 link_check, "link_check");
5380 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5381 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5385 cmdline_parse_inst_t cmd_set_link_check = {
5386 .f = cmd_set_link_check_parsed,
5387 .help_str = "set link_check on|off: Enable/Disable link status check "
5388 "when starting/stopping a port",
5391 (void *)&cmd_setlinkcheck_set,
5392 (void *)&cmd_setlinkcheck_link_check,
5393 (void *)&cmd_setlinkcheck_mode,
5398 /* *** SET NIC BYPASS MODE *** */
5399 struct cmd_set_bypass_mode_result {
5400 cmdline_fixed_string_t set;
5401 cmdline_fixed_string_t bypass;
5402 cmdline_fixed_string_t mode;
5403 cmdline_fixed_string_t value;
5408 cmd_set_bypass_mode_parsed(void *parsed_result,
5409 __rte_unused struct cmdline *cl,
5410 __rte_unused void *data)
5412 struct cmd_set_bypass_mode_result *res = parsed_result;
5413 portid_t port_id = res->port_id;
5414 int32_t rc = -EINVAL;
5416 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5417 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5419 if (!strcmp(res->value, "bypass"))
5420 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5421 else if (!strcmp(res->value, "isolate"))
5422 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5424 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5426 /* Set the bypass mode for the relevant port. */
5427 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5430 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5433 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5434 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5436 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5437 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5439 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5440 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5442 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5443 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5444 value, "normal#bypass#isolate");
5445 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5446 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5449 cmdline_parse_inst_t cmd_set_bypass_mode = {
5450 .f = cmd_set_bypass_mode_parsed,
5451 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5452 "Set the NIC bypass mode for port_id",
5455 (void *)&cmd_setbypass_mode_set,
5456 (void *)&cmd_setbypass_mode_bypass,
5457 (void *)&cmd_setbypass_mode_mode,
5458 (void *)&cmd_setbypass_mode_value,
5459 (void *)&cmd_setbypass_mode_port,
5464 /* *** SET NIC BYPASS EVENT *** */
5465 struct cmd_set_bypass_event_result {
5466 cmdline_fixed_string_t set;
5467 cmdline_fixed_string_t bypass;
5468 cmdline_fixed_string_t event;
5469 cmdline_fixed_string_t event_value;
5470 cmdline_fixed_string_t mode;
5471 cmdline_fixed_string_t mode_value;
5476 cmd_set_bypass_event_parsed(void *parsed_result,
5477 __rte_unused struct cmdline *cl,
5478 __rte_unused void *data)
5480 int32_t rc = -EINVAL;
5481 struct cmd_set_bypass_event_result *res = parsed_result;
5482 portid_t port_id = res->port_id;
5484 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5485 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5486 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5488 if (!strcmp(res->event_value, "timeout"))
5489 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5490 else if (!strcmp(res->event_value, "os_on"))
5491 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5492 else if (!strcmp(res->event_value, "os_off"))
5493 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5494 else if (!strcmp(res->event_value, "power_on"))
5495 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5496 else if (!strcmp(res->event_value, "power_off"))
5497 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5499 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5501 if (!strcmp(res->mode_value, "bypass"))
5502 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5503 else if (!strcmp(res->mode_value, "isolate"))
5504 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5506 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5508 /* Set the watchdog timeout. */
5509 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5512 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5513 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5517 printf("Failed to set timeout value %u "
5518 "for port %d, errto code: %d.\n",
5519 bypass_timeout, port_id, rc);
5523 /* Set the bypass event to transition to bypass mode. */
5524 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5529 printf("\t Failed to set bypass event for port = %d.\n",
5533 cmdline_parse_token_string_t cmd_setbypass_event_set =
5534 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5536 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5537 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5539 cmdline_parse_token_string_t cmd_setbypass_event_event =
5540 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5542 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5543 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5544 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5545 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5546 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5548 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5549 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5550 mode_value, "normal#bypass#isolate");
5551 cmdline_parse_token_num_t cmd_setbypass_event_port =
5552 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5555 cmdline_parse_inst_t cmd_set_bypass_event = {
5556 .f = cmd_set_bypass_event_parsed,
5557 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5558 "power_off mode normal|bypass|isolate <port_id>: "
5559 "Set the NIC bypass event mode for port_id",
5562 (void *)&cmd_setbypass_event_set,
5563 (void *)&cmd_setbypass_event_bypass,
5564 (void *)&cmd_setbypass_event_event,
5565 (void *)&cmd_setbypass_event_event_value,
5566 (void *)&cmd_setbypass_event_mode,
5567 (void *)&cmd_setbypass_event_mode_value,
5568 (void *)&cmd_setbypass_event_port,
5574 /* *** SET NIC BYPASS TIMEOUT *** */
5575 struct cmd_set_bypass_timeout_result {
5576 cmdline_fixed_string_t set;
5577 cmdline_fixed_string_t bypass;
5578 cmdline_fixed_string_t timeout;
5579 cmdline_fixed_string_t value;
5583 cmd_set_bypass_timeout_parsed(void *parsed_result,
5584 __rte_unused struct cmdline *cl,
5585 __rte_unused void *data)
5587 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5589 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5590 if (!strcmp(res->value, "1.5"))
5591 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5592 else if (!strcmp(res->value, "2"))
5593 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5594 else if (!strcmp(res->value, "3"))
5595 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5596 else if (!strcmp(res->value, "4"))
5597 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5598 else if (!strcmp(res->value, "8"))
5599 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5600 else if (!strcmp(res->value, "16"))
5601 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5602 else if (!strcmp(res->value, "32"))
5603 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5605 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5609 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5610 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5612 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5613 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5615 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5616 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5617 timeout, "timeout");
5618 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5619 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5620 value, "0#1.5#2#3#4#8#16#32");
5622 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5623 .f = cmd_set_bypass_timeout_parsed,
5624 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5625 "Set the NIC bypass watchdog timeout in seconds",
5628 (void *)&cmd_setbypass_timeout_set,
5629 (void *)&cmd_setbypass_timeout_bypass,
5630 (void *)&cmd_setbypass_timeout_timeout,
5631 (void *)&cmd_setbypass_timeout_value,
5636 /* *** SHOW NIC BYPASS MODE *** */
5637 struct cmd_show_bypass_config_result {
5638 cmdline_fixed_string_t show;
5639 cmdline_fixed_string_t bypass;
5640 cmdline_fixed_string_t config;
5645 cmd_show_bypass_config_parsed(void *parsed_result,
5646 __rte_unused struct cmdline *cl,
5647 __rte_unused void *data)
5649 struct cmd_show_bypass_config_result *res = parsed_result;
5650 portid_t port_id = res->port_id;
5652 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5653 uint32_t event_mode;
5654 uint32_t bypass_mode;
5655 uint32_t timeout = bypass_timeout;
5658 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5659 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5660 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5661 {"UNKNOWN", "normal", "bypass", "isolate"};
5662 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5670 /* Display the bypass mode.*/
5671 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5672 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5676 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5677 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5679 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5682 /* Display the bypass timeout.*/
5683 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5684 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5686 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5688 /* Display the bypass events and associated modes. */
5689 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5691 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5692 printf("\tFailed to get bypass mode for event = %s\n",
5695 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5696 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5698 printf("\tbypass event: %-16s = %s\n", events[i],
5704 printf("\tFailed to get bypass configuration for port = %d\n",
5708 cmdline_parse_token_string_t cmd_showbypass_config_show =
5709 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5711 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5712 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5714 cmdline_parse_token_string_t cmd_showbypass_config_config =
5715 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5717 cmdline_parse_token_num_t cmd_showbypass_config_port =
5718 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5721 cmdline_parse_inst_t cmd_show_bypass_config = {
5722 .f = cmd_show_bypass_config_parsed,
5723 .help_str = "show bypass config <port_id>: "
5724 "Show the NIC bypass config for port_id",
5727 (void *)&cmd_showbypass_config_show,
5728 (void *)&cmd_showbypass_config_bypass,
5729 (void *)&cmd_showbypass_config_config,
5730 (void *)&cmd_showbypass_config_port,
5735 #ifdef RTE_LIBRTE_PMD_BOND
5736 /* *** SET BONDING MODE *** */
5737 struct cmd_set_bonding_mode_result {
5738 cmdline_fixed_string_t set;
5739 cmdline_fixed_string_t bonding;
5740 cmdline_fixed_string_t mode;
5745 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5746 __rte_unused struct cmdline *cl,
5747 __rte_unused void *data)
5749 struct cmd_set_bonding_mode_result *res = parsed_result;
5750 portid_t port_id = res->port_id;
5752 /* Set the bonding mode for the relevant port. */
5753 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5754 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5757 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5758 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5760 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5761 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5762 bonding, "bonding");
5763 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5764 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5766 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5767 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5769 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5770 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5773 cmdline_parse_inst_t cmd_set_bonding_mode = {
5774 .f = cmd_set_bonding_mode_parsed,
5775 .help_str = "set bonding mode <mode_value> <port_id>: "
5776 "Set the bonding mode for port_id",
5779 (void *) &cmd_setbonding_mode_set,
5780 (void *) &cmd_setbonding_mode_bonding,
5781 (void *) &cmd_setbonding_mode_mode,
5782 (void *) &cmd_setbonding_mode_value,
5783 (void *) &cmd_setbonding_mode_port,
5788 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5789 struct cmd_set_bonding_lacp_dedicated_queues_result {
5790 cmdline_fixed_string_t set;
5791 cmdline_fixed_string_t bonding;
5792 cmdline_fixed_string_t lacp;
5793 cmdline_fixed_string_t dedicated_queues;
5795 cmdline_fixed_string_t mode;
5798 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5799 __rte_unused struct cmdline *cl,
5800 __rte_unused void *data)
5802 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5803 portid_t port_id = res->port_id;
5804 struct rte_port *port;
5806 port = &ports[port_id];
5808 /** Check if the port is not started **/
5809 if (port->port_status != RTE_PORT_STOPPED) {
5810 printf("Please stop port %d first\n", port_id);
5814 if (!strcmp(res->mode, "enable")) {
5815 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5816 printf("Dedicate queues for LACP control packets"
5819 printf("Enabling dedicate queues for LACP control "
5820 "packets on port %d failed\n", port_id);
5821 } else if (!strcmp(res->mode, "disable")) {
5822 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5823 printf("Dedicated queues for LACP control packets "
5826 printf("Disabling dedicated queues for LACP control "
5827 "traffic on port %d failed\n", port_id);
5831 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5832 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5834 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5835 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5836 bonding, "bonding");
5837 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5838 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5840 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5841 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5842 dedicated_queues, "dedicated_queues");
5843 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5844 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5846 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5847 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5848 mode, "enable#disable");
5850 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5851 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5852 .help_str = "set bonding lacp dedicated_queues <port_id> "
5854 "Enable/disable dedicated queues for LACP control traffic for port_id",
5857 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5858 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5859 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5860 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5861 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5862 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5867 /* *** SET BALANCE XMIT POLICY *** */
5868 struct cmd_set_bonding_balance_xmit_policy_result {
5869 cmdline_fixed_string_t set;
5870 cmdline_fixed_string_t bonding;
5871 cmdline_fixed_string_t balance_xmit_policy;
5873 cmdline_fixed_string_t policy;
5876 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5877 __rte_unused struct cmdline *cl,
5878 __rte_unused void *data)
5880 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5881 portid_t port_id = res->port_id;
5884 if (!strcmp(res->policy, "l2")) {
5885 policy = BALANCE_XMIT_POLICY_LAYER2;
5886 } else if (!strcmp(res->policy, "l23")) {
5887 policy = BALANCE_XMIT_POLICY_LAYER23;
5888 } else if (!strcmp(res->policy, "l34")) {
5889 policy = BALANCE_XMIT_POLICY_LAYER34;
5891 printf("\t Invalid xmit policy selection");
5895 /* Set the bonding mode for the relevant port. */
5896 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5897 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5902 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5903 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5905 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5906 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5907 bonding, "bonding");
5908 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5909 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5910 balance_xmit_policy, "balance_xmit_policy");
5911 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5912 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5914 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5915 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5916 policy, "l2#l23#l34");
5918 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5919 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5920 .help_str = "set bonding balance_xmit_policy <port_id> "
5922 "Set the bonding balance_xmit_policy for port_id",
5925 (void *)&cmd_setbonding_balance_xmit_policy_set,
5926 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5927 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5928 (void *)&cmd_setbonding_balance_xmit_policy_port,
5929 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5934 /* *** SHOW NIC BONDING CONFIGURATION *** */
5935 struct cmd_show_bonding_config_result {
5936 cmdline_fixed_string_t show;
5937 cmdline_fixed_string_t bonding;
5938 cmdline_fixed_string_t config;
5942 static void cmd_show_bonding_config_parsed(void *parsed_result,
5943 __rte_unused struct cmdline *cl,
5944 __rte_unused void *data)
5946 struct cmd_show_bonding_config_result *res = parsed_result;
5947 int bonding_mode, agg_mode;
5948 portid_t slaves[RTE_MAX_ETHPORTS];
5949 int num_slaves, num_active_slaves;
5952 portid_t port_id = res->port_id;
5954 /* Display the bonding mode.*/
5955 bonding_mode = rte_eth_bond_mode_get(port_id);
5956 if (bonding_mode < 0) {
5957 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5960 printf("\tBonding mode: %d\n", bonding_mode);
5962 if (bonding_mode == BONDING_MODE_BALANCE) {
5963 int balance_xmit_policy;
5965 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5966 if (balance_xmit_policy < 0) {
5967 printf("\tFailed to get balance xmit policy for port = %d\n",
5971 printf("\tBalance Xmit Policy: ");
5973 switch (balance_xmit_policy) {
5974 case BALANCE_XMIT_POLICY_LAYER2:
5975 printf("BALANCE_XMIT_POLICY_LAYER2");
5977 case BALANCE_XMIT_POLICY_LAYER23:
5978 printf("BALANCE_XMIT_POLICY_LAYER23");
5980 case BALANCE_XMIT_POLICY_LAYER34:
5981 printf("BALANCE_XMIT_POLICY_LAYER34");
5988 if (bonding_mode == BONDING_MODE_8023AD) {
5989 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5990 printf("\tIEEE802.3AD Aggregator Mode: ");
5993 printf("bandwidth");
6005 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6007 if (num_slaves < 0) {
6008 printf("\tFailed to get slave list for port = %d\n", port_id);
6011 if (num_slaves > 0) {
6012 printf("\tSlaves (%d): [", num_slaves);
6013 for (i = 0; i < num_slaves - 1; i++)
6014 printf("%d ", slaves[i]);
6016 printf("%d]\n", slaves[num_slaves - 1]);
6018 printf("\tSlaves: []\n");
6022 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6025 if (num_active_slaves < 0) {
6026 printf("\tFailed to get active slave list for port = %d\n", port_id);
6029 if (num_active_slaves > 0) {
6030 printf("\tActive Slaves (%d): [", num_active_slaves);
6031 for (i = 0; i < num_active_slaves - 1; i++)
6032 printf("%d ", slaves[i]);
6034 printf("%d]\n", slaves[num_active_slaves - 1]);
6037 printf("\tActive Slaves: []\n");
6041 primary_id = rte_eth_bond_primary_get(port_id);
6042 if (primary_id < 0) {
6043 printf("\tFailed to get primary slave for port = %d\n", port_id);
6046 printf("\tPrimary: [%d]\n", primary_id);
6050 cmdline_parse_token_string_t cmd_showbonding_config_show =
6051 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6053 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6054 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6055 bonding, "bonding");
6056 cmdline_parse_token_string_t cmd_showbonding_config_config =
6057 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6059 cmdline_parse_token_num_t cmd_showbonding_config_port =
6060 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6063 cmdline_parse_inst_t cmd_show_bonding_config = {
6064 .f = cmd_show_bonding_config_parsed,
6065 .help_str = "show bonding config <port_id>: "
6066 "Show the bonding config for port_id",
6069 (void *)&cmd_showbonding_config_show,
6070 (void *)&cmd_showbonding_config_bonding,
6071 (void *)&cmd_showbonding_config_config,
6072 (void *)&cmd_showbonding_config_port,
6077 /* *** SET BONDING PRIMARY *** */
6078 struct cmd_set_bonding_primary_result {
6079 cmdline_fixed_string_t set;
6080 cmdline_fixed_string_t bonding;
6081 cmdline_fixed_string_t primary;
6086 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6087 __rte_unused struct cmdline *cl,
6088 __rte_unused void *data)
6090 struct cmd_set_bonding_primary_result *res = parsed_result;
6091 portid_t master_port_id = res->port_id;
6092 portid_t slave_port_id = res->slave_id;
6094 /* Set the primary slave for a bonded device. */
6095 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6096 printf("\t Failed to set primary slave for port = %d.\n",
6103 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6104 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6106 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6107 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6108 bonding, "bonding");
6109 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6110 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6111 primary, "primary");
6112 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6113 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6115 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6116 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6119 cmdline_parse_inst_t cmd_set_bonding_primary = {
6120 .f = cmd_set_bonding_primary_parsed,
6121 .help_str = "set bonding primary <slave_id> <port_id>: "
6122 "Set the primary slave for port_id",
6125 (void *)&cmd_setbonding_primary_set,
6126 (void *)&cmd_setbonding_primary_bonding,
6127 (void *)&cmd_setbonding_primary_primary,
6128 (void *)&cmd_setbonding_primary_slave,
6129 (void *)&cmd_setbonding_primary_port,
6134 /* *** ADD SLAVE *** */
6135 struct cmd_add_bonding_slave_result {
6136 cmdline_fixed_string_t add;
6137 cmdline_fixed_string_t bonding;
6138 cmdline_fixed_string_t slave;
6143 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6144 __rte_unused struct cmdline *cl,
6145 __rte_unused void *data)
6147 struct cmd_add_bonding_slave_result *res = parsed_result;
6148 portid_t master_port_id = res->port_id;
6149 portid_t slave_port_id = res->slave_id;
6151 /* add the slave for a bonded device. */
6152 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6153 printf("\t Failed to add slave %d to master port = %d.\n",
6154 slave_port_id, master_port_id);
6158 set_port_slave_flag(slave_port_id);
6161 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6162 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6164 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6165 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6166 bonding, "bonding");
6167 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6168 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6170 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6171 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6173 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6174 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6177 cmdline_parse_inst_t cmd_add_bonding_slave = {
6178 .f = cmd_add_bonding_slave_parsed,
6179 .help_str = "add bonding slave <slave_id> <port_id>: "
6180 "Add a slave device to a bonded device",
6183 (void *)&cmd_addbonding_slave_add,
6184 (void *)&cmd_addbonding_slave_bonding,
6185 (void *)&cmd_addbonding_slave_slave,
6186 (void *)&cmd_addbonding_slave_slaveid,
6187 (void *)&cmd_addbonding_slave_port,
6192 /* *** REMOVE SLAVE *** */
6193 struct cmd_remove_bonding_slave_result {
6194 cmdline_fixed_string_t remove;
6195 cmdline_fixed_string_t bonding;
6196 cmdline_fixed_string_t slave;
6201 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6202 __rte_unused struct cmdline *cl,
6203 __rte_unused void *data)
6205 struct cmd_remove_bonding_slave_result *res = parsed_result;
6206 portid_t master_port_id = res->port_id;
6207 portid_t slave_port_id = res->slave_id;
6209 /* remove the slave from a bonded device. */
6210 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6211 printf("\t Failed to remove slave %d from master port = %d.\n",
6212 slave_port_id, master_port_id);
6216 clear_port_slave_flag(slave_port_id);
6219 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6220 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6222 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6223 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6224 bonding, "bonding");
6225 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6226 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6228 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6229 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6231 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6232 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6235 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6236 .f = cmd_remove_bonding_slave_parsed,
6237 .help_str = "remove bonding slave <slave_id> <port_id>: "
6238 "Remove a slave device from a bonded device",
6241 (void *)&cmd_removebonding_slave_remove,
6242 (void *)&cmd_removebonding_slave_bonding,
6243 (void *)&cmd_removebonding_slave_slave,
6244 (void *)&cmd_removebonding_slave_slaveid,
6245 (void *)&cmd_removebonding_slave_port,
6250 /* *** CREATE BONDED DEVICE *** */
6251 struct cmd_create_bonded_device_result {
6252 cmdline_fixed_string_t create;
6253 cmdline_fixed_string_t bonded;
6254 cmdline_fixed_string_t device;
6259 static int bond_dev_num = 0;
6261 static void cmd_create_bonded_device_parsed(void *parsed_result,
6262 __rte_unused struct cmdline *cl,
6263 __rte_unused void *data)
6265 struct cmd_create_bonded_device_result *res = parsed_result;
6266 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6270 if (test_done == 0) {
6271 printf("Please stop forwarding first\n");
6275 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6278 /* Create a new bonded device. */
6279 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6281 printf("\t Failed to create bonded device.\n");
6284 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6287 /* Update number of ports */
6288 nb_ports = rte_eth_dev_count_avail();
6289 reconfig(port_id, res->socket);
6290 ret = rte_eth_promiscuous_enable(port_id);
6292 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6293 port_id, rte_strerror(-ret));
6295 ports[port_id].need_setup = 0;
6296 ports[port_id].port_status = RTE_PORT_STOPPED;
6301 cmdline_parse_token_string_t cmd_createbonded_device_create =
6302 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6304 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6305 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6307 cmdline_parse_token_string_t cmd_createbonded_device_device =
6308 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6310 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6311 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6313 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6314 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6317 cmdline_parse_inst_t cmd_create_bonded_device = {
6318 .f = cmd_create_bonded_device_parsed,
6319 .help_str = "create bonded device <mode> <socket>: "
6320 "Create a new bonded device with specific bonding mode and socket",
6323 (void *)&cmd_createbonded_device_create,
6324 (void *)&cmd_createbonded_device_bonded,
6325 (void *)&cmd_createbonded_device_device,
6326 (void *)&cmd_createbonded_device_mode,
6327 (void *)&cmd_createbonded_device_socket,
6332 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6333 struct cmd_set_bond_mac_addr_result {
6334 cmdline_fixed_string_t set;
6335 cmdline_fixed_string_t bonding;
6336 cmdline_fixed_string_t mac_addr;
6338 struct rte_ether_addr address;
6341 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6342 __rte_unused struct cmdline *cl,
6343 __rte_unused void *data)
6345 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6348 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6351 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6353 /* check the return value and print it if is < 0 */
6355 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6358 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6359 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6360 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6361 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6363 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6364 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6366 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6367 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6369 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6370 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6372 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6373 .f = cmd_set_bond_mac_addr_parsed,
6375 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6377 (void *)&cmd_set_bond_mac_addr_set,
6378 (void *)&cmd_set_bond_mac_addr_bonding,
6379 (void *)&cmd_set_bond_mac_addr_mac,
6380 (void *)&cmd_set_bond_mac_addr_portnum,
6381 (void *)&cmd_set_bond_mac_addr_addr,
6387 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6388 struct cmd_set_bond_mon_period_result {
6389 cmdline_fixed_string_t set;
6390 cmdline_fixed_string_t bonding;
6391 cmdline_fixed_string_t mon_period;
6396 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6397 __rte_unused struct cmdline *cl,
6398 __rte_unused void *data)
6400 struct cmd_set_bond_mon_period_result *res = parsed_result;
6403 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6405 /* check the return value and print it if is < 0 */
6407 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6410 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6411 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6413 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6414 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6415 bonding, "bonding");
6416 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6417 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6418 mon_period, "mon_period");
6419 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6420 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6422 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6423 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6426 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6427 .f = cmd_set_bond_mon_period_parsed,
6429 .help_str = "set bonding mon_period <port_id> <period_ms>",
6431 (void *)&cmd_set_bond_mon_period_set,
6432 (void *)&cmd_set_bond_mon_period_bonding,
6433 (void *)&cmd_set_bond_mon_period_mon_period,
6434 (void *)&cmd_set_bond_mon_period_portnum,
6435 (void *)&cmd_set_bond_mon_period_period_ms,
6442 struct cmd_set_bonding_agg_mode_policy_result {
6443 cmdline_fixed_string_t set;
6444 cmdline_fixed_string_t bonding;
6445 cmdline_fixed_string_t agg_mode;
6447 cmdline_fixed_string_t policy;
6452 cmd_set_bonding_agg_mode(void *parsed_result,
6453 __rte_unused struct cmdline *cl,
6454 __rte_unused void *data)
6456 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6457 uint8_t policy = AGG_BANDWIDTH;
6459 if (!strcmp(res->policy, "bandwidth"))
6460 policy = AGG_BANDWIDTH;
6461 else if (!strcmp(res->policy, "stable"))
6462 policy = AGG_STABLE;
6463 else if (!strcmp(res->policy, "count"))
6466 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6470 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6471 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6473 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6474 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6475 bonding, "bonding");
6477 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6478 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6479 agg_mode, "agg_mode");
6481 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6482 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6485 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6486 TOKEN_STRING_INITIALIZER(
6487 struct cmd_set_bonding_balance_xmit_policy_result,
6488 policy, "stable#bandwidth#count");
6490 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6491 .f = cmd_set_bonding_agg_mode,
6493 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6495 (void *)&cmd_set_bonding_agg_mode_set,
6496 (void *)&cmd_set_bonding_agg_mode_bonding,
6497 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6498 (void *)&cmd_set_bonding_agg_mode_portnum,
6499 (void *)&cmd_set_bonding_agg_mode_policy_string,
6505 #endif /* RTE_LIBRTE_PMD_BOND */
6507 /* *** SET FORWARDING MODE *** */
6508 struct cmd_set_fwd_mode_result {
6509 cmdline_fixed_string_t set;
6510 cmdline_fixed_string_t fwd;
6511 cmdline_fixed_string_t mode;
6514 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6515 __rte_unused struct cmdline *cl,
6516 __rte_unused void *data)
6518 struct cmd_set_fwd_mode_result *res = parsed_result;
6521 set_pkt_forwarding_mode(res->mode);
6524 cmdline_parse_token_string_t cmd_setfwd_set =
6525 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6526 cmdline_parse_token_string_t cmd_setfwd_fwd =
6527 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6528 cmdline_parse_token_string_t cmd_setfwd_mode =
6529 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6530 "" /* defined at init */);
6532 cmdline_parse_inst_t cmd_set_fwd_mode = {
6533 .f = cmd_set_fwd_mode_parsed,
6535 .help_str = NULL, /* defined at init */
6537 (void *)&cmd_setfwd_set,
6538 (void *)&cmd_setfwd_fwd,
6539 (void *)&cmd_setfwd_mode,
6544 static void cmd_set_fwd_mode_init(void)
6547 static char token[128];
6548 static char help[256];
6549 cmdline_parse_token_string_t *token_struct;
6551 modes = list_pkt_forwarding_modes();
6552 snprintf(help, sizeof(help), "set fwd %s: "
6553 "Set packet forwarding mode", modes);
6554 cmd_set_fwd_mode.help_str = help;
6556 /* string token separator is # */
6557 for (c = token; *modes != '\0'; modes++)
6562 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6563 token_struct->string_data.str = token;
6566 /* *** SET RETRY FORWARDING MODE *** */
6567 struct cmd_set_fwd_retry_mode_result {
6568 cmdline_fixed_string_t set;
6569 cmdline_fixed_string_t fwd;
6570 cmdline_fixed_string_t mode;
6571 cmdline_fixed_string_t retry;
6574 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6575 __rte_unused struct cmdline *cl,
6576 __rte_unused void *data)
6578 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6581 set_pkt_forwarding_mode(res->mode);
6584 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6585 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6587 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6588 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6590 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6591 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6593 "" /* defined at init */);
6594 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6595 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6598 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6599 .f = cmd_set_fwd_retry_mode_parsed,
6601 .help_str = NULL, /* defined at init */
6603 (void *)&cmd_setfwd_retry_set,
6604 (void *)&cmd_setfwd_retry_fwd,
6605 (void *)&cmd_setfwd_retry_mode,
6606 (void *)&cmd_setfwd_retry_retry,
6611 static void cmd_set_fwd_retry_mode_init(void)
6614 static char token[128];
6615 static char help[256];
6616 cmdline_parse_token_string_t *token_struct;
6618 modes = list_pkt_forwarding_retry_modes();
6619 snprintf(help, sizeof(help), "set fwd %s retry: "
6620 "Set packet forwarding mode with retry", modes);
6621 cmd_set_fwd_retry_mode.help_str = help;
6623 /* string token separator is # */
6624 for (c = token; *modes != '\0'; modes++)
6629 token_struct = (cmdline_parse_token_string_t *)
6630 cmd_set_fwd_retry_mode.tokens[2];
6631 token_struct->string_data.str = token;
6634 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6635 struct cmd_set_burst_tx_retry_result {
6636 cmdline_fixed_string_t set;
6637 cmdline_fixed_string_t burst;
6638 cmdline_fixed_string_t tx;
6639 cmdline_fixed_string_t delay;
6641 cmdline_fixed_string_t retry;
6645 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6646 __rte_unused struct cmdline *cl,
6647 __rte_unused void *data)
6649 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6651 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6652 && !strcmp(res->tx, "tx")) {
6653 if (!strcmp(res->delay, "delay"))
6654 burst_tx_delay_time = res->time;
6655 if (!strcmp(res->retry, "retry"))
6656 burst_tx_retry_num = res->retry_num;
6661 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6662 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6663 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6664 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6666 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6667 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6668 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6669 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6670 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6671 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6672 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6673 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6674 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6675 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6677 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6678 .f = cmd_set_burst_tx_retry_parsed,
6679 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6681 (void *)&cmd_set_burst_tx_retry_set,
6682 (void *)&cmd_set_burst_tx_retry_burst,
6683 (void *)&cmd_set_burst_tx_retry_tx,
6684 (void *)&cmd_set_burst_tx_retry_delay,
6685 (void *)&cmd_set_burst_tx_retry_time,
6686 (void *)&cmd_set_burst_tx_retry_retry,
6687 (void *)&cmd_set_burst_tx_retry_retry_num,
6692 /* *** SET PROMISC MODE *** */
6693 struct cmd_set_promisc_mode_result {
6694 cmdline_fixed_string_t set;
6695 cmdline_fixed_string_t promisc;
6696 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6697 uint16_t port_num; /* valid if "allports" argument == 0 */
6698 cmdline_fixed_string_t mode;
6701 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6702 __rte_unused struct cmdline *cl,
6705 struct cmd_set_promisc_mode_result *res = parsed_result;
6709 if (!strcmp(res->mode, "on"))
6716 RTE_ETH_FOREACH_DEV(i)
6717 eth_set_promisc_mode(i, enable);
6719 eth_set_promisc_mode(res->port_num, enable);
6723 cmdline_parse_token_string_t cmd_setpromisc_set =
6724 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6725 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6726 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6728 cmdline_parse_token_string_t cmd_setpromisc_portall =
6729 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6731 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6732 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6734 cmdline_parse_token_string_t cmd_setpromisc_mode =
6735 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6738 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6739 .f = cmd_set_promisc_mode_parsed,
6741 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6743 (void *)&cmd_setpromisc_set,
6744 (void *)&cmd_setpromisc_promisc,
6745 (void *)&cmd_setpromisc_portall,
6746 (void *)&cmd_setpromisc_mode,
6751 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6752 .f = cmd_set_promisc_mode_parsed,
6754 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6756 (void *)&cmd_setpromisc_set,
6757 (void *)&cmd_setpromisc_promisc,
6758 (void *)&cmd_setpromisc_portnum,
6759 (void *)&cmd_setpromisc_mode,
6764 /* *** SET ALLMULTI MODE *** */
6765 struct cmd_set_allmulti_mode_result {
6766 cmdline_fixed_string_t set;
6767 cmdline_fixed_string_t allmulti;
6768 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6769 uint16_t port_num; /* valid if "allports" argument == 0 */
6770 cmdline_fixed_string_t mode;
6773 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6774 __rte_unused struct cmdline *cl,
6777 struct cmd_set_allmulti_mode_result *res = parsed_result;
6781 if (!strcmp(res->mode, "on"))
6788 RTE_ETH_FOREACH_DEV(i) {
6789 eth_set_allmulticast_mode(i, enable);
6793 eth_set_allmulticast_mode(res->port_num, enable);
6797 cmdline_parse_token_string_t cmd_setallmulti_set =
6798 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6799 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6800 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6802 cmdline_parse_token_string_t cmd_setallmulti_portall =
6803 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6805 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6806 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6808 cmdline_parse_token_string_t cmd_setallmulti_mode =
6809 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6812 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6813 .f = cmd_set_allmulti_mode_parsed,
6815 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6817 (void *)&cmd_setallmulti_set,
6818 (void *)&cmd_setallmulti_allmulti,
6819 (void *)&cmd_setallmulti_portall,
6820 (void *)&cmd_setallmulti_mode,
6825 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6826 .f = cmd_set_allmulti_mode_parsed,
6828 .help_str = "set allmulti <port_id> on|off: "
6829 "Set allmulti mode on port_id",
6831 (void *)&cmd_setallmulti_set,
6832 (void *)&cmd_setallmulti_allmulti,
6833 (void *)&cmd_setallmulti_portnum,
6834 (void *)&cmd_setallmulti_mode,
6839 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6840 struct cmd_link_flow_ctrl_set_result {
6841 cmdline_fixed_string_t set;
6842 cmdline_fixed_string_t flow_ctrl;
6843 cmdline_fixed_string_t rx;
6844 cmdline_fixed_string_t rx_lfc_mode;
6845 cmdline_fixed_string_t tx;
6846 cmdline_fixed_string_t tx_lfc_mode;
6847 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6848 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6849 cmdline_fixed_string_t autoneg_str;
6850 cmdline_fixed_string_t autoneg;
6851 cmdline_fixed_string_t hw_str;
6852 uint32_t high_water;
6853 cmdline_fixed_string_t lw_str;
6855 cmdline_fixed_string_t pt_str;
6856 uint16_t pause_time;
6857 cmdline_fixed_string_t xon_str;
6862 cmdline_parse_token_string_t cmd_lfc_set_set =
6863 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6865 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6866 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6867 flow_ctrl, "flow_ctrl");
6868 cmdline_parse_token_string_t cmd_lfc_set_rx =
6869 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6871 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6872 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6873 rx_lfc_mode, "on#off");
6874 cmdline_parse_token_string_t cmd_lfc_set_tx =
6875 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6877 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6878 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6879 tx_lfc_mode, "on#off");
6880 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6881 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6882 hw_str, "high_water");
6883 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6884 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6885 high_water, UINT32);
6886 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6887 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6888 lw_str, "low_water");
6889 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6890 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6892 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6893 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6894 pt_str, "pause_time");
6895 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6896 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6897 pause_time, UINT16);
6898 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6899 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6900 xon_str, "send_xon");
6901 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6902 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6904 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6905 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6906 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6907 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6908 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6909 mac_ctrl_frame_fwd_mode, "on#off");
6910 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6911 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6912 autoneg_str, "autoneg");
6913 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6914 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6916 cmdline_parse_token_num_t cmd_lfc_set_portid =
6917 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6920 /* forward declaration */
6922 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6925 cmdline_parse_inst_t cmd_link_flow_control_set = {
6926 .f = cmd_link_flow_ctrl_set_parsed,
6928 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6929 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6930 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6932 (void *)&cmd_lfc_set_set,
6933 (void *)&cmd_lfc_set_flow_ctrl,
6934 (void *)&cmd_lfc_set_rx,
6935 (void *)&cmd_lfc_set_rx_mode,
6936 (void *)&cmd_lfc_set_tx,
6937 (void *)&cmd_lfc_set_tx_mode,
6938 (void *)&cmd_lfc_set_high_water,
6939 (void *)&cmd_lfc_set_low_water,
6940 (void *)&cmd_lfc_set_pause_time,
6941 (void *)&cmd_lfc_set_send_xon,
6942 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6943 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6944 (void *)&cmd_lfc_set_autoneg_str,
6945 (void *)&cmd_lfc_set_autoneg,
6946 (void *)&cmd_lfc_set_portid,
6951 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6952 .f = cmd_link_flow_ctrl_set_parsed,
6953 .data = (void *)&cmd_link_flow_control_set_rx,
6954 .help_str = "set flow_ctrl rx on|off <port_id>: "
6955 "Change rx flow control parameter",
6957 (void *)&cmd_lfc_set_set,
6958 (void *)&cmd_lfc_set_flow_ctrl,
6959 (void *)&cmd_lfc_set_rx,
6960 (void *)&cmd_lfc_set_rx_mode,
6961 (void *)&cmd_lfc_set_portid,
6966 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6967 .f = cmd_link_flow_ctrl_set_parsed,
6968 .data = (void *)&cmd_link_flow_control_set_tx,
6969 .help_str = "set flow_ctrl tx on|off <port_id>: "
6970 "Change tx flow control parameter",
6972 (void *)&cmd_lfc_set_set,
6973 (void *)&cmd_lfc_set_flow_ctrl,
6974 (void *)&cmd_lfc_set_tx,
6975 (void *)&cmd_lfc_set_tx_mode,
6976 (void *)&cmd_lfc_set_portid,
6981 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6982 .f = cmd_link_flow_ctrl_set_parsed,
6983 .data = (void *)&cmd_link_flow_control_set_hw,
6984 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6985 "Change high water flow control parameter",
6987 (void *)&cmd_lfc_set_set,
6988 (void *)&cmd_lfc_set_flow_ctrl,
6989 (void *)&cmd_lfc_set_high_water_str,
6990 (void *)&cmd_lfc_set_high_water,
6991 (void *)&cmd_lfc_set_portid,
6996 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6997 .f = cmd_link_flow_ctrl_set_parsed,
6998 .data = (void *)&cmd_link_flow_control_set_lw,
6999 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7000 "Change low water flow control parameter",
7002 (void *)&cmd_lfc_set_set,
7003 (void *)&cmd_lfc_set_flow_ctrl,
7004 (void *)&cmd_lfc_set_low_water_str,
7005 (void *)&cmd_lfc_set_low_water,
7006 (void *)&cmd_lfc_set_portid,
7011 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7012 .f = cmd_link_flow_ctrl_set_parsed,
7013 .data = (void *)&cmd_link_flow_control_set_pt,
7014 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7015 "Change pause time flow control parameter",
7017 (void *)&cmd_lfc_set_set,
7018 (void *)&cmd_lfc_set_flow_ctrl,
7019 (void *)&cmd_lfc_set_pause_time_str,
7020 (void *)&cmd_lfc_set_pause_time,
7021 (void *)&cmd_lfc_set_portid,
7026 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7027 .f = cmd_link_flow_ctrl_set_parsed,
7028 .data = (void *)&cmd_link_flow_control_set_xon,
7029 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7030 "Change send_xon flow control parameter",
7032 (void *)&cmd_lfc_set_set,
7033 (void *)&cmd_lfc_set_flow_ctrl,
7034 (void *)&cmd_lfc_set_send_xon_str,
7035 (void *)&cmd_lfc_set_send_xon,
7036 (void *)&cmd_lfc_set_portid,
7041 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7042 .f = cmd_link_flow_ctrl_set_parsed,
7043 .data = (void *)&cmd_link_flow_control_set_macfwd,
7044 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7045 "Change mac ctrl fwd flow control parameter",
7047 (void *)&cmd_lfc_set_set,
7048 (void *)&cmd_lfc_set_flow_ctrl,
7049 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7050 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7051 (void *)&cmd_lfc_set_portid,
7056 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7057 .f = cmd_link_flow_ctrl_set_parsed,
7058 .data = (void *)&cmd_link_flow_control_set_autoneg,
7059 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7060 "Change autoneg flow control parameter",
7062 (void *)&cmd_lfc_set_set,
7063 (void *)&cmd_lfc_set_flow_ctrl,
7064 (void *)&cmd_lfc_set_autoneg_str,
7065 (void *)&cmd_lfc_set_autoneg,
7066 (void *)&cmd_lfc_set_portid,
7072 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7073 __rte_unused struct cmdline *cl,
7076 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7077 cmdline_parse_inst_t *cmd = data;
7078 struct rte_eth_fc_conf fc_conf;
7084 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7085 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7086 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7087 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7089 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7090 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7093 /* Partial command line, retrieve current configuration */
7095 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7097 printf("cannot get current flow ctrl parameters, return"
7098 "code = %d\n", ret);
7102 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7103 (fc_conf.mode == RTE_FC_FULL))
7105 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7106 (fc_conf.mode == RTE_FC_FULL))
7110 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7111 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7113 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7114 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7116 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7118 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7119 fc_conf.high_water = res->high_water;
7121 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7122 fc_conf.low_water = res->low_water;
7124 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7125 fc_conf.pause_time = res->pause_time;
7127 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7128 fc_conf.send_xon = res->send_xon;
7130 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7131 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7132 fc_conf.mac_ctrl_frame_fwd = 1;
7134 fc_conf.mac_ctrl_frame_fwd = 0;
7137 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7138 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7140 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7142 printf("bad flow contrl parameter, return code = %d \n", ret);
7145 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7146 struct cmd_priority_flow_ctrl_set_result {
7147 cmdline_fixed_string_t set;
7148 cmdline_fixed_string_t pfc_ctrl;
7149 cmdline_fixed_string_t rx;
7150 cmdline_fixed_string_t rx_pfc_mode;
7151 cmdline_fixed_string_t tx;
7152 cmdline_fixed_string_t tx_pfc_mode;
7153 uint32_t high_water;
7155 uint16_t pause_time;
7161 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7162 __rte_unused struct cmdline *cl,
7163 __rte_unused void *data)
7165 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7166 struct rte_eth_pfc_conf pfc_conf;
7167 int rx_fc_enable, tx_fc_enable;
7171 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7172 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7173 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7174 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7176 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7177 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7180 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7181 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7182 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7183 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7184 pfc_conf.fc.high_water = res->high_water;
7185 pfc_conf.fc.low_water = res->low_water;
7186 pfc_conf.fc.pause_time = res->pause_time;
7187 pfc_conf.priority = res->priority;
7189 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7191 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7194 cmdline_parse_token_string_t cmd_pfc_set_set =
7195 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7197 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7198 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7199 pfc_ctrl, "pfc_ctrl");
7200 cmdline_parse_token_string_t cmd_pfc_set_rx =
7201 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7203 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7204 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7205 rx_pfc_mode, "on#off");
7206 cmdline_parse_token_string_t cmd_pfc_set_tx =
7207 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7209 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7210 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7211 tx_pfc_mode, "on#off");
7212 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7213 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7214 high_water, UINT32);
7215 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7216 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7218 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7219 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7220 pause_time, UINT16);
7221 cmdline_parse_token_num_t cmd_pfc_set_priority =
7222 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7224 cmdline_parse_token_num_t cmd_pfc_set_portid =
7225 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7228 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7229 .f = cmd_priority_flow_ctrl_set_parsed,
7231 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7232 "<pause_time> <priority> <port_id>: "
7233 "Configure the Ethernet priority flow control",
7235 (void *)&cmd_pfc_set_set,
7236 (void *)&cmd_pfc_set_flow_ctrl,
7237 (void *)&cmd_pfc_set_rx,
7238 (void *)&cmd_pfc_set_rx_mode,
7239 (void *)&cmd_pfc_set_tx,
7240 (void *)&cmd_pfc_set_tx_mode,
7241 (void *)&cmd_pfc_set_high_water,
7242 (void *)&cmd_pfc_set_low_water,
7243 (void *)&cmd_pfc_set_pause_time,
7244 (void *)&cmd_pfc_set_priority,
7245 (void *)&cmd_pfc_set_portid,
7250 /* *** RESET CONFIGURATION *** */
7251 struct cmd_reset_result {
7252 cmdline_fixed_string_t reset;
7253 cmdline_fixed_string_t def;
7256 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7258 __rte_unused void *data)
7260 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7261 set_def_fwd_config();
7264 cmdline_parse_token_string_t cmd_reset_set =
7265 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7266 cmdline_parse_token_string_t cmd_reset_def =
7267 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7270 cmdline_parse_inst_t cmd_reset = {
7271 .f = cmd_reset_parsed,
7273 .help_str = "set default: Reset default forwarding configuration",
7275 (void *)&cmd_reset_set,
7276 (void *)&cmd_reset_def,
7281 /* *** START FORWARDING *** */
7282 struct cmd_start_result {
7283 cmdline_fixed_string_t start;
7286 cmdline_parse_token_string_t cmd_start_start =
7287 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7289 static void cmd_start_parsed(__rte_unused void *parsed_result,
7290 __rte_unused struct cmdline *cl,
7291 __rte_unused void *data)
7293 start_packet_forwarding(0);
7296 cmdline_parse_inst_t cmd_start = {
7297 .f = cmd_start_parsed,
7299 .help_str = "start: Start packet forwarding",
7301 (void *)&cmd_start_start,
7306 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7307 struct cmd_start_tx_first_result {
7308 cmdline_fixed_string_t start;
7309 cmdline_fixed_string_t tx_first;
7313 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7314 __rte_unused struct cmdline *cl,
7315 __rte_unused void *data)
7317 start_packet_forwarding(1);
7320 cmdline_parse_token_string_t cmd_start_tx_first_start =
7321 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7323 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7324 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7325 tx_first, "tx_first");
7327 cmdline_parse_inst_t cmd_start_tx_first = {
7328 .f = cmd_start_tx_first_parsed,
7330 .help_str = "start tx_first: Start packet forwarding, "
7331 "after sending 1 burst of packets",
7333 (void *)&cmd_start_tx_first_start,
7334 (void *)&cmd_start_tx_first_tx_first,
7339 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7340 struct cmd_start_tx_first_n_result {
7341 cmdline_fixed_string_t start;
7342 cmdline_fixed_string_t tx_first;
7347 cmd_start_tx_first_n_parsed(void *parsed_result,
7348 __rte_unused struct cmdline *cl,
7349 __rte_unused void *data)
7351 struct cmd_start_tx_first_n_result *res = parsed_result;
7353 start_packet_forwarding(res->tx_num);
7356 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7357 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7359 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7360 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7361 tx_first, "tx_first");
7362 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7363 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7366 cmdline_parse_inst_t cmd_start_tx_first_n = {
7367 .f = cmd_start_tx_first_n_parsed,
7369 .help_str = "start tx_first <num>: "
7370 "packet forwarding, after sending <num> bursts of packets",
7372 (void *)&cmd_start_tx_first_n_start,
7373 (void *)&cmd_start_tx_first_n_tx_first,
7374 (void *)&cmd_start_tx_first_n_tx_num,
7379 /* *** SET LINK UP *** */
7380 struct cmd_set_link_up_result {
7381 cmdline_fixed_string_t set;
7382 cmdline_fixed_string_t link_up;
7383 cmdline_fixed_string_t port;
7387 cmdline_parse_token_string_t cmd_set_link_up_set =
7388 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7389 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7390 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7392 cmdline_parse_token_string_t cmd_set_link_up_port =
7393 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7394 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7395 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7397 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7398 __rte_unused struct cmdline *cl,
7399 __rte_unused void *data)
7401 struct cmd_set_link_up_result *res = parsed_result;
7402 dev_set_link_up(res->port_id);
7405 cmdline_parse_inst_t cmd_set_link_up = {
7406 .f = cmd_set_link_up_parsed,
7408 .help_str = "set link-up port <port id>",
7410 (void *)&cmd_set_link_up_set,
7411 (void *)&cmd_set_link_up_link_up,
7412 (void *)&cmd_set_link_up_port,
7413 (void *)&cmd_set_link_up_port_id,
7418 /* *** SET LINK DOWN *** */
7419 struct cmd_set_link_down_result {
7420 cmdline_fixed_string_t set;
7421 cmdline_fixed_string_t link_down;
7422 cmdline_fixed_string_t port;
7426 cmdline_parse_token_string_t cmd_set_link_down_set =
7427 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7428 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7429 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7431 cmdline_parse_token_string_t cmd_set_link_down_port =
7432 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7433 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7434 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7436 static void cmd_set_link_down_parsed(
7437 __rte_unused void *parsed_result,
7438 __rte_unused struct cmdline *cl,
7439 __rte_unused void *data)
7441 struct cmd_set_link_down_result *res = parsed_result;
7442 dev_set_link_down(res->port_id);
7445 cmdline_parse_inst_t cmd_set_link_down = {
7446 .f = cmd_set_link_down_parsed,
7448 .help_str = "set link-down port <port id>",
7450 (void *)&cmd_set_link_down_set,
7451 (void *)&cmd_set_link_down_link_down,
7452 (void *)&cmd_set_link_down_port,
7453 (void *)&cmd_set_link_down_port_id,
7458 /* *** SHOW CFG *** */
7459 struct cmd_showcfg_result {
7460 cmdline_fixed_string_t show;
7461 cmdline_fixed_string_t cfg;
7462 cmdline_fixed_string_t what;
7465 static void cmd_showcfg_parsed(void *parsed_result,
7466 __rte_unused struct cmdline *cl,
7467 __rte_unused void *data)
7469 struct cmd_showcfg_result *res = parsed_result;
7470 if (!strcmp(res->what, "rxtx"))
7471 rxtx_config_display();
7472 else if (!strcmp(res->what, "cores"))
7473 fwd_lcores_config_display();
7474 else if (!strcmp(res->what, "fwd"))
7475 pkt_fwd_config_display(&cur_fwd_config);
7476 else if (!strcmp(res->what, "txpkts"))
7477 show_tx_pkt_segments();
7478 else if (!strcmp(res->what, "txtimes"))
7479 show_tx_pkt_times();
7482 cmdline_parse_token_string_t cmd_showcfg_show =
7483 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7484 cmdline_parse_token_string_t cmd_showcfg_port =
7485 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7486 cmdline_parse_token_string_t cmd_showcfg_what =
7487 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7488 "rxtx#cores#fwd#txpkts#txtimes");
7490 cmdline_parse_inst_t cmd_showcfg = {
7491 .f = cmd_showcfg_parsed,
7493 .help_str = "show config rxtx|cores|fwd|txpkts|txtimes",
7495 (void *)&cmd_showcfg_show,
7496 (void *)&cmd_showcfg_port,
7497 (void *)&cmd_showcfg_what,
7502 /* *** SHOW ALL PORT INFO *** */
7503 struct cmd_showportall_result {
7504 cmdline_fixed_string_t show;
7505 cmdline_fixed_string_t port;
7506 cmdline_fixed_string_t what;
7507 cmdline_fixed_string_t all;
7510 static void cmd_showportall_parsed(void *parsed_result,
7511 __rte_unused struct cmdline *cl,
7512 __rte_unused void *data)
7516 struct cmd_showportall_result *res = parsed_result;
7517 if (!strcmp(res->show, "clear")) {
7518 if (!strcmp(res->what, "stats"))
7519 RTE_ETH_FOREACH_DEV(i)
7521 else if (!strcmp(res->what, "xstats"))
7522 RTE_ETH_FOREACH_DEV(i)
7523 nic_xstats_clear(i);
7524 } else if (!strcmp(res->what, "info"))
7525 RTE_ETH_FOREACH_DEV(i)
7526 port_infos_display(i);
7527 else if (!strcmp(res->what, "summary")) {
7528 port_summary_header_display();
7529 RTE_ETH_FOREACH_DEV(i)
7530 port_summary_display(i);
7532 else if (!strcmp(res->what, "stats"))
7533 RTE_ETH_FOREACH_DEV(i)
7534 nic_stats_display(i);
7535 else if (!strcmp(res->what, "xstats"))
7536 RTE_ETH_FOREACH_DEV(i)
7537 nic_xstats_display(i);
7538 else if (!strcmp(res->what, "fdir"))
7539 RTE_ETH_FOREACH_DEV(i)
7541 else if (!strcmp(res->what, "stat_qmap"))
7542 RTE_ETH_FOREACH_DEV(i)
7543 nic_stats_mapping_display(i);
7544 else if (!strcmp(res->what, "dcb_tc"))
7545 RTE_ETH_FOREACH_DEV(i)
7546 port_dcb_info_display(i);
7547 else if (!strcmp(res->what, "cap"))
7548 RTE_ETH_FOREACH_DEV(i)
7549 port_offload_cap_display(i);
7552 cmdline_parse_token_string_t cmd_showportall_show =
7553 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7555 cmdline_parse_token_string_t cmd_showportall_port =
7556 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7557 cmdline_parse_token_string_t cmd_showportall_what =
7558 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7559 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7560 cmdline_parse_token_string_t cmd_showportall_all =
7561 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7562 cmdline_parse_inst_t cmd_showportall = {
7563 .f = cmd_showportall_parsed,
7565 .help_str = "show|clear port "
7566 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7568 (void *)&cmd_showportall_show,
7569 (void *)&cmd_showportall_port,
7570 (void *)&cmd_showportall_what,
7571 (void *)&cmd_showportall_all,
7576 /* *** SHOW PORT INFO *** */
7577 struct cmd_showport_result {
7578 cmdline_fixed_string_t show;
7579 cmdline_fixed_string_t port;
7580 cmdline_fixed_string_t what;
7584 static void cmd_showport_parsed(void *parsed_result,
7585 __rte_unused struct cmdline *cl,
7586 __rte_unused void *data)
7588 struct cmd_showport_result *res = parsed_result;
7589 if (!strcmp(res->show, "clear")) {
7590 if (!strcmp(res->what, "stats"))
7591 nic_stats_clear(res->portnum);
7592 else if (!strcmp(res->what, "xstats"))
7593 nic_xstats_clear(res->portnum);
7594 } else if (!strcmp(res->what, "info"))
7595 port_infos_display(res->portnum);
7596 else if (!strcmp(res->what, "summary")) {
7597 port_summary_header_display();
7598 port_summary_display(res->portnum);
7600 else if (!strcmp(res->what, "stats"))
7601 nic_stats_display(res->portnum);
7602 else if (!strcmp(res->what, "xstats"))
7603 nic_xstats_display(res->portnum);
7604 else if (!strcmp(res->what, "fdir"))
7605 fdir_get_infos(res->portnum);
7606 else if (!strcmp(res->what, "stat_qmap"))
7607 nic_stats_mapping_display(res->portnum);
7608 else if (!strcmp(res->what, "dcb_tc"))
7609 port_dcb_info_display(res->portnum);
7610 else if (!strcmp(res->what, "cap"))
7611 port_offload_cap_display(res->portnum);
7614 cmdline_parse_token_string_t cmd_showport_show =
7615 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7617 cmdline_parse_token_string_t cmd_showport_port =
7618 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7619 cmdline_parse_token_string_t cmd_showport_what =
7620 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7621 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7622 cmdline_parse_token_num_t cmd_showport_portnum =
7623 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7625 cmdline_parse_inst_t cmd_showport = {
7626 .f = cmd_showport_parsed,
7628 .help_str = "show|clear port "
7629 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7632 (void *)&cmd_showport_show,
7633 (void *)&cmd_showport_port,
7634 (void *)&cmd_showport_what,
7635 (void *)&cmd_showport_portnum,
7640 /* *** SHOW DEVICE INFO *** */
7641 struct cmd_showdevice_result {
7642 cmdline_fixed_string_t show;
7643 cmdline_fixed_string_t device;
7644 cmdline_fixed_string_t what;
7645 cmdline_fixed_string_t identifier;
7648 static void cmd_showdevice_parsed(void *parsed_result,
7649 __rte_unused struct cmdline *cl,
7650 __rte_unused void *data)
7652 struct cmd_showdevice_result *res = parsed_result;
7653 if (!strcmp(res->what, "info")) {
7654 if (!strcmp(res->identifier, "all"))
7655 device_infos_display(NULL);
7657 device_infos_display(res->identifier);
7661 cmdline_parse_token_string_t cmd_showdevice_show =
7662 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7664 cmdline_parse_token_string_t cmd_showdevice_device =
7665 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7666 cmdline_parse_token_string_t cmd_showdevice_what =
7667 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7669 cmdline_parse_token_string_t cmd_showdevice_identifier =
7670 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7673 cmdline_parse_inst_t cmd_showdevice = {
7674 .f = cmd_showdevice_parsed,
7676 .help_str = "show device info <identifier>|all",
7678 (void *)&cmd_showdevice_show,
7679 (void *)&cmd_showdevice_device,
7680 (void *)&cmd_showdevice_what,
7681 (void *)&cmd_showdevice_identifier,
7685 /* *** SHOW QUEUE INFO *** */
7686 struct cmd_showqueue_result {
7687 cmdline_fixed_string_t show;
7688 cmdline_fixed_string_t type;
7689 cmdline_fixed_string_t what;
7695 cmd_showqueue_parsed(void *parsed_result,
7696 __rte_unused struct cmdline *cl,
7697 __rte_unused void *data)
7699 struct cmd_showqueue_result *res = parsed_result;
7701 if (!strcmp(res->type, "rxq"))
7702 rx_queue_infos_display(res->portnum, res->queuenum);
7703 else if (!strcmp(res->type, "txq"))
7704 tx_queue_infos_display(res->portnum, res->queuenum);
7707 cmdline_parse_token_string_t cmd_showqueue_show =
7708 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7709 cmdline_parse_token_string_t cmd_showqueue_type =
7710 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7711 cmdline_parse_token_string_t cmd_showqueue_what =
7712 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7713 cmdline_parse_token_num_t cmd_showqueue_portnum =
7714 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7715 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7716 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7718 cmdline_parse_inst_t cmd_showqueue = {
7719 .f = cmd_showqueue_parsed,
7721 .help_str = "show rxq|txq info <port_id> <queue_id>",
7723 (void *)&cmd_showqueue_show,
7724 (void *)&cmd_showqueue_type,
7725 (void *)&cmd_showqueue_what,
7726 (void *)&cmd_showqueue_portnum,
7727 (void *)&cmd_showqueue_queuenum,
7732 /* show/clear fwd engine statistics */
7734 cmdline_fixed_string_t action;
7735 cmdline_fixed_string_t fwd;
7736 cmdline_fixed_string_t stats;
7737 cmdline_fixed_string_t all;
7740 cmdline_parse_token_string_t cmd_fwd_action =
7741 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7742 cmdline_parse_token_string_t cmd_fwd_fwd =
7743 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7744 cmdline_parse_token_string_t cmd_fwd_stats =
7745 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7746 cmdline_parse_token_string_t cmd_fwd_all =
7747 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7750 cmd_showfwdall_parsed(void *parsed_result,
7751 __rte_unused struct cmdline *cl,
7752 __rte_unused void *data)
7754 struct fwd_result *res = parsed_result;
7756 if (!strcmp(res->action, "show"))
7757 fwd_stats_display();
7762 static cmdline_parse_inst_t cmd_showfwdall = {
7763 .f = cmd_showfwdall_parsed,
7765 .help_str = "show|clear fwd stats all",
7767 (void *)&cmd_fwd_action,
7768 (void *)&cmd_fwd_fwd,
7769 (void *)&cmd_fwd_stats,
7770 (void *)&cmd_fwd_all,
7775 /* *** READ PORT REGISTER *** */
7776 struct cmd_read_reg_result {
7777 cmdline_fixed_string_t read;
7778 cmdline_fixed_string_t reg;
7784 cmd_read_reg_parsed(void *parsed_result,
7785 __rte_unused struct cmdline *cl,
7786 __rte_unused void *data)
7788 struct cmd_read_reg_result *res = parsed_result;
7789 port_reg_display(res->port_id, res->reg_off);
7792 cmdline_parse_token_string_t cmd_read_reg_read =
7793 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7794 cmdline_parse_token_string_t cmd_read_reg_reg =
7795 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7796 cmdline_parse_token_num_t cmd_read_reg_port_id =
7797 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7798 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7799 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7801 cmdline_parse_inst_t cmd_read_reg = {
7802 .f = cmd_read_reg_parsed,
7804 .help_str = "read reg <port_id> <reg_off>",
7806 (void *)&cmd_read_reg_read,
7807 (void *)&cmd_read_reg_reg,
7808 (void *)&cmd_read_reg_port_id,
7809 (void *)&cmd_read_reg_reg_off,
7814 /* *** READ PORT REGISTER BIT FIELD *** */
7815 struct cmd_read_reg_bit_field_result {
7816 cmdline_fixed_string_t read;
7817 cmdline_fixed_string_t regfield;
7825 cmd_read_reg_bit_field_parsed(void *parsed_result,
7826 __rte_unused struct cmdline *cl,
7827 __rte_unused void *data)
7829 struct cmd_read_reg_bit_field_result *res = parsed_result;
7830 port_reg_bit_field_display(res->port_id, res->reg_off,
7831 res->bit1_pos, res->bit2_pos);
7834 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7835 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7837 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7838 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7839 regfield, "regfield");
7840 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7841 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7843 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7844 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7846 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7847 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7849 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7850 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7853 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7854 .f = cmd_read_reg_bit_field_parsed,
7856 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7857 "Read register bit field between bit_x and bit_y included",
7859 (void *)&cmd_read_reg_bit_field_read,
7860 (void *)&cmd_read_reg_bit_field_regfield,
7861 (void *)&cmd_read_reg_bit_field_port_id,
7862 (void *)&cmd_read_reg_bit_field_reg_off,
7863 (void *)&cmd_read_reg_bit_field_bit1_pos,
7864 (void *)&cmd_read_reg_bit_field_bit2_pos,
7869 /* *** READ PORT REGISTER BIT *** */
7870 struct cmd_read_reg_bit_result {
7871 cmdline_fixed_string_t read;
7872 cmdline_fixed_string_t regbit;
7879 cmd_read_reg_bit_parsed(void *parsed_result,
7880 __rte_unused struct cmdline *cl,
7881 __rte_unused void *data)
7883 struct cmd_read_reg_bit_result *res = parsed_result;
7884 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7887 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7888 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7889 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7890 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7892 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7893 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7894 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7895 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7896 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7897 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7899 cmdline_parse_inst_t cmd_read_reg_bit = {
7900 .f = cmd_read_reg_bit_parsed,
7902 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7904 (void *)&cmd_read_reg_bit_read,
7905 (void *)&cmd_read_reg_bit_regbit,
7906 (void *)&cmd_read_reg_bit_port_id,
7907 (void *)&cmd_read_reg_bit_reg_off,
7908 (void *)&cmd_read_reg_bit_bit_pos,
7913 /* *** WRITE PORT REGISTER *** */
7914 struct cmd_write_reg_result {
7915 cmdline_fixed_string_t write;
7916 cmdline_fixed_string_t reg;
7923 cmd_write_reg_parsed(void *parsed_result,
7924 __rte_unused struct cmdline *cl,
7925 __rte_unused void *data)
7927 struct cmd_write_reg_result *res = parsed_result;
7928 port_reg_set(res->port_id, res->reg_off, res->value);
7931 cmdline_parse_token_string_t cmd_write_reg_write =
7932 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7933 cmdline_parse_token_string_t cmd_write_reg_reg =
7934 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7935 cmdline_parse_token_num_t cmd_write_reg_port_id =
7936 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7937 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7938 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7939 cmdline_parse_token_num_t cmd_write_reg_value =
7940 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7942 cmdline_parse_inst_t cmd_write_reg = {
7943 .f = cmd_write_reg_parsed,
7945 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7947 (void *)&cmd_write_reg_write,
7948 (void *)&cmd_write_reg_reg,
7949 (void *)&cmd_write_reg_port_id,
7950 (void *)&cmd_write_reg_reg_off,
7951 (void *)&cmd_write_reg_value,
7956 /* *** WRITE PORT REGISTER BIT FIELD *** */
7957 struct cmd_write_reg_bit_field_result {
7958 cmdline_fixed_string_t write;
7959 cmdline_fixed_string_t regfield;
7968 cmd_write_reg_bit_field_parsed(void *parsed_result,
7969 __rte_unused struct cmdline *cl,
7970 __rte_unused void *data)
7972 struct cmd_write_reg_bit_field_result *res = parsed_result;
7973 port_reg_bit_field_set(res->port_id, res->reg_off,
7974 res->bit1_pos, res->bit2_pos, res->value);
7977 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7978 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7980 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7981 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7982 regfield, "regfield");
7983 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7984 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7986 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7987 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7989 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7990 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7992 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7993 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7995 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7996 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7999 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8000 .f = cmd_write_reg_bit_field_parsed,
8002 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8004 "Set register bit field between bit_x and bit_y included",
8006 (void *)&cmd_write_reg_bit_field_write,
8007 (void *)&cmd_write_reg_bit_field_regfield,
8008 (void *)&cmd_write_reg_bit_field_port_id,
8009 (void *)&cmd_write_reg_bit_field_reg_off,
8010 (void *)&cmd_write_reg_bit_field_bit1_pos,
8011 (void *)&cmd_write_reg_bit_field_bit2_pos,
8012 (void *)&cmd_write_reg_bit_field_value,
8017 /* *** WRITE PORT REGISTER BIT *** */
8018 struct cmd_write_reg_bit_result {
8019 cmdline_fixed_string_t write;
8020 cmdline_fixed_string_t regbit;
8028 cmd_write_reg_bit_parsed(void *parsed_result,
8029 __rte_unused struct cmdline *cl,
8030 __rte_unused void *data)
8032 struct cmd_write_reg_bit_result *res = parsed_result;
8033 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8036 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8037 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8039 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8040 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8042 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8043 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
8044 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8045 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
8046 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8047 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
8048 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8049 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
8051 cmdline_parse_inst_t cmd_write_reg_bit = {
8052 .f = cmd_write_reg_bit_parsed,
8054 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8057 (void *)&cmd_write_reg_bit_write,
8058 (void *)&cmd_write_reg_bit_regbit,
8059 (void *)&cmd_write_reg_bit_port_id,
8060 (void *)&cmd_write_reg_bit_reg_off,
8061 (void *)&cmd_write_reg_bit_bit_pos,
8062 (void *)&cmd_write_reg_bit_value,
8067 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8068 struct cmd_read_rxd_txd_result {
8069 cmdline_fixed_string_t read;
8070 cmdline_fixed_string_t rxd_txd;
8077 cmd_read_rxd_txd_parsed(void *parsed_result,
8078 __rte_unused struct cmdline *cl,
8079 __rte_unused void *data)
8081 struct cmd_read_rxd_txd_result *res = parsed_result;
8083 if (!strcmp(res->rxd_txd, "rxd"))
8084 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8085 else if (!strcmp(res->rxd_txd, "txd"))
8086 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8089 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8090 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8091 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8092 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8094 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8095 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8096 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8097 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8098 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8099 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8101 cmdline_parse_inst_t cmd_read_rxd_txd = {
8102 .f = cmd_read_rxd_txd_parsed,
8104 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8106 (void *)&cmd_read_rxd_txd_read,
8107 (void *)&cmd_read_rxd_txd_rxd_txd,
8108 (void *)&cmd_read_rxd_txd_port_id,
8109 (void *)&cmd_read_rxd_txd_queue_id,
8110 (void *)&cmd_read_rxd_txd_desc_id,
8116 struct cmd_quit_result {
8117 cmdline_fixed_string_t quit;
8120 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8122 __rte_unused void *data)
8127 cmdline_parse_token_string_t cmd_quit_quit =
8128 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8130 cmdline_parse_inst_t cmd_quit = {
8131 .f = cmd_quit_parsed,
8133 .help_str = "quit: Exit application",
8135 (void *)&cmd_quit_quit,
8140 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8141 struct cmd_mac_addr_result {
8142 cmdline_fixed_string_t mac_addr_cmd;
8143 cmdline_fixed_string_t what;
8145 struct rte_ether_addr address;
8148 static void cmd_mac_addr_parsed(void *parsed_result,
8149 __rte_unused struct cmdline *cl,
8150 __rte_unused void *data)
8152 struct cmd_mac_addr_result *res = parsed_result;
8155 if (strcmp(res->what, "add") == 0)
8156 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8157 else if (strcmp(res->what, "set") == 0)
8158 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8161 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8163 /* check the return value and print it if is < 0 */
8165 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8169 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8170 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8172 cmdline_parse_token_string_t cmd_mac_addr_what =
8173 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8175 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8176 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8178 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8179 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8181 cmdline_parse_inst_t cmd_mac_addr = {
8182 .f = cmd_mac_addr_parsed,
8184 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8185 "Add/Remove/Set MAC address on port_id",
8187 (void *)&cmd_mac_addr_cmd,
8188 (void *)&cmd_mac_addr_what,
8189 (void *)&cmd_mac_addr_portnum,
8190 (void *)&cmd_mac_addr_addr,
8195 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8196 struct cmd_eth_peer_result {
8197 cmdline_fixed_string_t set;
8198 cmdline_fixed_string_t eth_peer;
8200 cmdline_fixed_string_t peer_addr;
8203 static void cmd_set_eth_peer_parsed(void *parsed_result,
8204 __rte_unused struct cmdline *cl,
8205 __rte_unused void *data)
8207 struct cmd_eth_peer_result *res = parsed_result;
8209 if (test_done == 0) {
8210 printf("Please stop forwarding first\n");
8213 if (!strcmp(res->eth_peer, "eth-peer")) {
8214 set_fwd_eth_peer(res->port_id, res->peer_addr);
8218 cmdline_parse_token_string_t cmd_eth_peer_set =
8219 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8220 cmdline_parse_token_string_t cmd_eth_peer =
8221 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8222 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8223 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8224 cmdline_parse_token_string_t cmd_eth_peer_addr =
8225 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8227 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8228 .f = cmd_set_eth_peer_parsed,
8230 .help_str = "set eth-peer <port_id> <peer_mac>",
8232 (void *)&cmd_eth_peer_set,
8233 (void *)&cmd_eth_peer,
8234 (void *)&cmd_eth_peer_port_id,
8235 (void *)&cmd_eth_peer_addr,
8240 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8241 struct cmd_set_qmap_result {
8242 cmdline_fixed_string_t set;
8243 cmdline_fixed_string_t qmap;
8244 cmdline_fixed_string_t what;
8251 cmd_set_qmap_parsed(void *parsed_result,
8252 __rte_unused struct cmdline *cl,
8253 __rte_unused void *data)
8255 struct cmd_set_qmap_result *res = parsed_result;
8256 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8258 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8261 cmdline_parse_token_string_t cmd_setqmap_set =
8262 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8264 cmdline_parse_token_string_t cmd_setqmap_qmap =
8265 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8267 cmdline_parse_token_string_t cmd_setqmap_what =
8268 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8270 cmdline_parse_token_num_t cmd_setqmap_portid =
8271 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8273 cmdline_parse_token_num_t cmd_setqmap_queueid =
8274 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8276 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8277 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8280 cmdline_parse_inst_t cmd_set_qmap = {
8281 .f = cmd_set_qmap_parsed,
8283 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8284 "Set statistics mapping value on tx|rx queue_id of port_id",
8286 (void *)&cmd_setqmap_set,
8287 (void *)&cmd_setqmap_qmap,
8288 (void *)&cmd_setqmap_what,
8289 (void *)&cmd_setqmap_portid,
8290 (void *)&cmd_setqmap_queueid,
8291 (void *)&cmd_setqmap_mapvalue,
8296 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8297 struct cmd_set_xstats_hide_zero_result {
8298 cmdline_fixed_string_t keyword;
8299 cmdline_fixed_string_t name;
8300 cmdline_fixed_string_t on_off;
8304 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8305 __rte_unused struct cmdline *cl,
8306 __rte_unused void *data)
8308 struct cmd_set_xstats_hide_zero_result *res;
8309 uint16_t on_off = 0;
8311 res = parsed_result;
8312 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8313 set_xstats_hide_zero(on_off);
8316 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8317 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8319 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8320 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8321 name, "xstats-hide-zero");
8322 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8323 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8326 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8327 .f = cmd_set_xstats_hide_zero_parsed,
8329 .help_str = "set xstats-hide-zero on|off",
8331 (void *)&cmd_set_xstats_hide_zero_keyword,
8332 (void *)&cmd_set_xstats_hide_zero_name,
8333 (void *)&cmd_set_xstats_hide_zero_on_off,
8338 /* *** CONFIGURE UNICAST HASH TABLE *** */
8339 struct cmd_set_uc_hash_table {
8340 cmdline_fixed_string_t set;
8341 cmdline_fixed_string_t port;
8343 cmdline_fixed_string_t what;
8344 struct rte_ether_addr address;
8345 cmdline_fixed_string_t mode;
8349 cmd_set_uc_hash_parsed(void *parsed_result,
8350 __rte_unused struct cmdline *cl,
8351 __rte_unused void *data)
8354 struct cmd_set_uc_hash_table *res = parsed_result;
8356 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8358 if (strcmp(res->what, "uta") == 0)
8359 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8360 &res->address,(uint8_t)is_on);
8362 printf("bad unicast hash table parameter, return code = %d \n", ret);
8366 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8367 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8369 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8370 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8372 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8373 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8375 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8376 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8378 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8379 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8381 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8382 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8385 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8386 .f = cmd_set_uc_hash_parsed,
8388 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8390 (void *)&cmd_set_uc_hash_set,
8391 (void *)&cmd_set_uc_hash_port,
8392 (void *)&cmd_set_uc_hash_portid,
8393 (void *)&cmd_set_uc_hash_what,
8394 (void *)&cmd_set_uc_hash_mac,
8395 (void *)&cmd_set_uc_hash_mode,
8400 struct cmd_set_uc_all_hash_table {
8401 cmdline_fixed_string_t set;
8402 cmdline_fixed_string_t port;
8404 cmdline_fixed_string_t what;
8405 cmdline_fixed_string_t value;
8406 cmdline_fixed_string_t mode;
8410 cmd_set_uc_all_hash_parsed(void *parsed_result,
8411 __rte_unused struct cmdline *cl,
8412 __rte_unused void *data)
8415 struct cmd_set_uc_all_hash_table *res = parsed_result;
8417 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8419 if ((strcmp(res->what, "uta") == 0) &&
8420 (strcmp(res->value, "all") == 0))
8421 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8423 printf("bad unicast hash table parameter,"
8424 "return code = %d \n", ret);
8427 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8428 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8430 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8431 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8433 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8434 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8436 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8437 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8439 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8440 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8442 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8443 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8446 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8447 .f = cmd_set_uc_all_hash_parsed,
8449 .help_str = "set port <port_id> uta all on|off",
8451 (void *)&cmd_set_uc_all_hash_set,
8452 (void *)&cmd_set_uc_all_hash_port,
8453 (void *)&cmd_set_uc_all_hash_portid,
8454 (void *)&cmd_set_uc_all_hash_what,
8455 (void *)&cmd_set_uc_all_hash_value,
8456 (void *)&cmd_set_uc_all_hash_mode,
8461 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8462 struct cmd_set_vf_macvlan_filter {
8463 cmdline_fixed_string_t set;
8464 cmdline_fixed_string_t port;
8466 cmdline_fixed_string_t vf;
8468 struct rte_ether_addr address;
8469 cmdline_fixed_string_t filter_type;
8470 cmdline_fixed_string_t mode;
8474 cmd_set_vf_macvlan_parsed(void *parsed_result,
8475 __rte_unused struct cmdline *cl,
8476 __rte_unused void *data)
8479 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8480 struct rte_eth_mac_filter filter;
8482 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8484 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8486 /* set VF MAC filter */
8490 filter.dst_id = res->vf_id;
8492 if (!strcmp(res->filter_type, "exact-mac"))
8493 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8494 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8495 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8496 else if (!strcmp(res->filter_type, "hashmac"))
8497 filter.filter_type = RTE_MAC_HASH_MATCH;
8498 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8499 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8501 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8504 ret = rte_eth_dev_filter_ctrl(res->port_id,
8505 RTE_ETH_FILTER_MACVLAN,
8509 ret = rte_eth_dev_filter_ctrl(res->port_id,
8510 RTE_ETH_FILTER_MACVLAN,
8511 RTE_ETH_FILTER_DELETE,
8515 printf("bad set MAC hash parameter, return code = %d\n", ret);
8519 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8520 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8522 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8523 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8525 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8526 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8528 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8529 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8531 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8532 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8534 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8535 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8537 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8538 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8539 filter_type, "exact-mac#exact-mac-vlan"
8540 "#hashmac#hashmac-vlan");
8541 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8542 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8545 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8546 .f = cmd_set_vf_macvlan_parsed,
8548 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8549 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8550 "Exact match rule: exact match of MAC or MAC and VLAN; "
8551 "hash match rule: hash match of MAC and exact match of VLAN",
8553 (void *)&cmd_set_vf_macvlan_set,
8554 (void *)&cmd_set_vf_macvlan_port,
8555 (void *)&cmd_set_vf_macvlan_portid,
8556 (void *)&cmd_set_vf_macvlan_vf,
8557 (void *)&cmd_set_vf_macvlan_vf_id,
8558 (void *)&cmd_set_vf_macvlan_mac,
8559 (void *)&cmd_set_vf_macvlan_filter_type,
8560 (void *)&cmd_set_vf_macvlan_mode,
8565 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8566 struct cmd_set_vf_traffic {
8567 cmdline_fixed_string_t set;
8568 cmdline_fixed_string_t port;
8570 cmdline_fixed_string_t vf;
8572 cmdline_fixed_string_t what;
8573 cmdline_fixed_string_t mode;
8577 cmd_set_vf_traffic_parsed(void *parsed_result,
8578 __rte_unused struct cmdline *cl,
8579 __rte_unused void *data)
8581 struct cmd_set_vf_traffic *res = parsed_result;
8582 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8583 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8585 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8588 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8589 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8591 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8592 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8594 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8595 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8597 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8598 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8600 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8601 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8603 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8604 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8606 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8607 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8610 cmdline_parse_inst_t cmd_set_vf_traffic = {
8611 .f = cmd_set_vf_traffic_parsed,
8613 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8615 (void *)&cmd_setvf_traffic_set,
8616 (void *)&cmd_setvf_traffic_port,
8617 (void *)&cmd_setvf_traffic_portid,
8618 (void *)&cmd_setvf_traffic_vf,
8619 (void *)&cmd_setvf_traffic_vfid,
8620 (void *)&cmd_setvf_traffic_what,
8621 (void *)&cmd_setvf_traffic_mode,
8626 /* *** CONFIGURE VF RECEIVE MODE *** */
8627 struct cmd_set_vf_rxmode {
8628 cmdline_fixed_string_t set;
8629 cmdline_fixed_string_t port;
8631 cmdline_fixed_string_t vf;
8633 cmdline_fixed_string_t what;
8634 cmdline_fixed_string_t mode;
8635 cmdline_fixed_string_t on;
8639 cmd_set_vf_rxmode_parsed(void *parsed_result,
8640 __rte_unused struct cmdline *cl,
8641 __rte_unused void *data)
8644 uint16_t vf_rxmode = 0;
8645 struct cmd_set_vf_rxmode *res = parsed_result;
8647 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8648 if (!strcmp(res->what,"rxmode")) {
8649 if (!strcmp(res->mode, "AUPE"))
8650 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8651 else if (!strcmp(res->mode, "ROPE"))
8652 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8653 else if (!strcmp(res->mode, "BAM"))
8654 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8655 else if (!strncmp(res->mode, "MPE",3))
8656 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8659 RTE_SET_USED(is_on);
8661 #ifdef RTE_LIBRTE_IXGBE_PMD
8662 if (ret == -ENOTSUP)
8663 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8664 vf_rxmode, (uint8_t)is_on);
8666 #ifdef RTE_LIBRTE_BNXT_PMD
8667 if (ret == -ENOTSUP)
8668 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8669 vf_rxmode, (uint8_t)is_on);
8672 printf("bad VF receive mode parameter, return code = %d \n",
8676 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8677 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8679 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8680 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8682 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8683 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8685 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8686 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8688 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8689 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8691 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8692 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8694 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8695 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8696 mode, "AUPE#ROPE#BAM#MPE");
8697 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8698 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8701 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8702 .f = cmd_set_vf_rxmode_parsed,
8704 .help_str = "set port <port_id> vf <vf_id> rxmode "
8705 "AUPE|ROPE|BAM|MPE on|off",
8707 (void *)&cmd_set_vf_rxmode_set,
8708 (void *)&cmd_set_vf_rxmode_port,
8709 (void *)&cmd_set_vf_rxmode_portid,
8710 (void *)&cmd_set_vf_rxmode_vf,
8711 (void *)&cmd_set_vf_rxmode_vfid,
8712 (void *)&cmd_set_vf_rxmode_what,
8713 (void *)&cmd_set_vf_rxmode_mode,
8714 (void *)&cmd_set_vf_rxmode_on,
8719 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8720 struct cmd_vf_mac_addr_result {
8721 cmdline_fixed_string_t mac_addr_cmd;
8722 cmdline_fixed_string_t what;
8723 cmdline_fixed_string_t port;
8725 cmdline_fixed_string_t vf;
8727 struct rte_ether_addr address;
8730 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8731 __rte_unused struct cmdline *cl,
8732 __rte_unused void *data)
8734 struct cmd_vf_mac_addr_result *res = parsed_result;
8737 if (strcmp(res->what, "add") != 0)
8740 #ifdef RTE_LIBRTE_I40E_PMD
8741 if (ret == -ENOTSUP)
8742 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8745 #ifdef RTE_LIBRTE_BNXT_PMD
8746 if (ret == -ENOTSUP)
8747 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8752 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8756 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8757 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8758 mac_addr_cmd,"mac_addr");
8759 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8760 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8762 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8763 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8765 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8766 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8768 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8769 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8771 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8772 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8774 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8775 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8778 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8779 .f = cmd_vf_mac_addr_parsed,
8781 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8782 "Add MAC address filtering for a VF on port_id",
8784 (void *)&cmd_vf_mac_addr_cmd,
8785 (void *)&cmd_vf_mac_addr_what,
8786 (void *)&cmd_vf_mac_addr_port,
8787 (void *)&cmd_vf_mac_addr_portnum,
8788 (void *)&cmd_vf_mac_addr_vf,
8789 (void *)&cmd_vf_mac_addr_vfnum,
8790 (void *)&cmd_vf_mac_addr_addr,
8795 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8796 struct cmd_vf_rx_vlan_filter {
8797 cmdline_fixed_string_t rx_vlan;
8798 cmdline_fixed_string_t what;
8800 cmdline_fixed_string_t port;
8802 cmdline_fixed_string_t vf;
8807 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8808 __rte_unused struct cmdline *cl,
8809 __rte_unused void *data)
8811 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8814 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8816 #ifdef RTE_LIBRTE_IXGBE_PMD
8817 if (ret == -ENOTSUP)
8818 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8819 res->vlan_id, res->vf_mask, is_add);
8821 #ifdef RTE_LIBRTE_I40E_PMD
8822 if (ret == -ENOTSUP)
8823 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8824 res->vlan_id, res->vf_mask, is_add);
8826 #ifdef RTE_LIBRTE_BNXT_PMD
8827 if (ret == -ENOTSUP)
8828 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8829 res->vlan_id, res->vf_mask, is_add);
8836 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8837 res->vlan_id, res->vf_mask);
8840 printf("invalid port_id %d\n", res->port_id);
8843 printf("function not implemented or supported\n");
8846 printf("programming error: (%s)\n", strerror(-ret));
8850 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8851 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8852 rx_vlan, "rx_vlan");
8853 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8854 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8856 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8857 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8859 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8860 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8862 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8863 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8865 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8866 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8868 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8869 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8872 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8873 .f = cmd_vf_rx_vlan_filter_parsed,
8875 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8876 "(vf_mask = hexadecimal VF mask)",
8878 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8879 (void *)&cmd_vf_rx_vlan_filter_what,
8880 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8881 (void *)&cmd_vf_rx_vlan_filter_port,
8882 (void *)&cmd_vf_rx_vlan_filter_portid,
8883 (void *)&cmd_vf_rx_vlan_filter_vf,
8884 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8889 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8890 struct cmd_queue_rate_limit_result {
8891 cmdline_fixed_string_t set;
8892 cmdline_fixed_string_t port;
8894 cmdline_fixed_string_t queue;
8896 cmdline_fixed_string_t rate;
8900 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8901 __rte_unused struct cmdline *cl,
8902 __rte_unused void *data)
8904 struct cmd_queue_rate_limit_result *res = parsed_result;
8907 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8908 && (strcmp(res->queue, "queue") == 0)
8909 && (strcmp(res->rate, "rate") == 0))
8910 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8913 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8917 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8918 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8920 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8921 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8923 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8924 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8926 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8927 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8929 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8930 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8932 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8933 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8935 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8936 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8939 cmdline_parse_inst_t cmd_queue_rate_limit = {
8940 .f = cmd_queue_rate_limit_parsed,
8942 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8943 "Set rate limit for a queue on port_id",
8945 (void *)&cmd_queue_rate_limit_set,
8946 (void *)&cmd_queue_rate_limit_port,
8947 (void *)&cmd_queue_rate_limit_portnum,
8948 (void *)&cmd_queue_rate_limit_queue,
8949 (void *)&cmd_queue_rate_limit_queuenum,
8950 (void *)&cmd_queue_rate_limit_rate,
8951 (void *)&cmd_queue_rate_limit_ratenum,
8956 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8957 struct cmd_vf_rate_limit_result {
8958 cmdline_fixed_string_t set;
8959 cmdline_fixed_string_t port;
8961 cmdline_fixed_string_t vf;
8963 cmdline_fixed_string_t rate;
8965 cmdline_fixed_string_t q_msk;
8969 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8970 __rte_unused struct cmdline *cl,
8971 __rte_unused void *data)
8973 struct cmd_vf_rate_limit_result *res = parsed_result;
8976 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8977 && (strcmp(res->vf, "vf") == 0)
8978 && (strcmp(res->rate, "rate") == 0)
8979 && (strcmp(res->q_msk, "queue_mask") == 0))
8980 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8981 res->rate_num, res->q_msk_val);
8983 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8987 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8988 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8990 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8991 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8993 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8994 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8996 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8997 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8999 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9000 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9002 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9003 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9005 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9006 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9008 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9009 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9010 q_msk, "queue_mask");
9011 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9012 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9015 cmdline_parse_inst_t cmd_vf_rate_limit = {
9016 .f = cmd_vf_rate_limit_parsed,
9018 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9019 "queue_mask <queue_mask_value>: "
9020 "Set rate limit for queues of VF on port_id",
9022 (void *)&cmd_vf_rate_limit_set,
9023 (void *)&cmd_vf_rate_limit_port,
9024 (void *)&cmd_vf_rate_limit_portnum,
9025 (void *)&cmd_vf_rate_limit_vf,
9026 (void *)&cmd_vf_rate_limit_vfnum,
9027 (void *)&cmd_vf_rate_limit_rate,
9028 (void *)&cmd_vf_rate_limit_ratenum,
9029 (void *)&cmd_vf_rate_limit_q_msk,
9030 (void *)&cmd_vf_rate_limit_q_msk_val,
9035 /* *** ADD TUNNEL FILTER OF A PORT *** */
9036 struct cmd_tunnel_filter_result {
9037 cmdline_fixed_string_t cmd;
9038 cmdline_fixed_string_t what;
9040 struct rte_ether_addr outer_mac;
9041 struct rte_ether_addr inner_mac;
9042 cmdline_ipaddr_t ip_value;
9043 uint16_t inner_vlan;
9044 cmdline_fixed_string_t tunnel_type;
9045 cmdline_fixed_string_t filter_type;
9051 cmd_tunnel_filter_parsed(void *parsed_result,
9052 __rte_unused struct cmdline *cl,
9053 __rte_unused void *data)
9055 struct cmd_tunnel_filter_result *res = parsed_result;
9056 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
9059 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
9061 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
9062 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
9063 tunnel_filter_conf.inner_vlan = res->inner_vlan;
9065 if (res->ip_value.family == AF_INET) {
9066 tunnel_filter_conf.ip_addr.ipv4_addr =
9067 res->ip_value.addr.ipv4.s_addr;
9068 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
9070 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
9071 &(res->ip_value.addr.ipv6),
9072 sizeof(struct in6_addr));
9073 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
9076 if (!strcmp(res->filter_type, "imac-ivlan"))
9077 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
9078 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
9079 tunnel_filter_conf.filter_type =
9080 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
9081 else if (!strcmp(res->filter_type, "imac-tenid"))
9082 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
9083 else if (!strcmp(res->filter_type, "imac"))
9084 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
9085 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
9086 tunnel_filter_conf.filter_type =
9087 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
9088 else if (!strcmp(res->filter_type, "oip"))
9089 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9090 else if (!strcmp(res->filter_type, "iip"))
9091 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9093 printf("The filter type is not supported");
9097 if (!strcmp(res->tunnel_type, "vxlan"))
9098 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9099 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9100 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9101 else if (!strcmp(res->tunnel_type, "nvgre"))
9102 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9103 else if (!strcmp(res->tunnel_type, "ipingre"))
9104 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9106 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9110 tunnel_filter_conf.tenant_id = res->tenant_id;
9111 tunnel_filter_conf.queue_id = res->queue_num;
9112 if (!strcmp(res->what, "add"))
9113 ret = rte_eth_dev_filter_ctrl(res->port_id,
9114 RTE_ETH_FILTER_TUNNEL,
9116 &tunnel_filter_conf);
9118 ret = rte_eth_dev_filter_ctrl(res->port_id,
9119 RTE_ETH_FILTER_TUNNEL,
9120 RTE_ETH_FILTER_DELETE,
9121 &tunnel_filter_conf);
9123 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9127 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9128 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9129 cmd, "tunnel_filter");
9130 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9131 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9133 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9134 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9136 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9137 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9139 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9140 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9142 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9143 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9144 inner_vlan, UINT16);
9145 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9146 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9148 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9149 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9150 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9152 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9153 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9154 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9155 "imac#omac-imac-tenid");
9156 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9157 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9159 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9160 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9163 cmdline_parse_inst_t cmd_tunnel_filter = {
9164 .f = cmd_tunnel_filter_parsed,
9166 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9167 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9168 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9169 "<queue_id>: Add/Rm tunnel filter of a port",
9171 (void *)&cmd_tunnel_filter_cmd,
9172 (void *)&cmd_tunnel_filter_what,
9173 (void *)&cmd_tunnel_filter_port_id,
9174 (void *)&cmd_tunnel_filter_outer_mac,
9175 (void *)&cmd_tunnel_filter_inner_mac,
9176 (void *)&cmd_tunnel_filter_ip_value,
9177 (void *)&cmd_tunnel_filter_innner_vlan,
9178 (void *)&cmd_tunnel_filter_tunnel_type,
9179 (void *)&cmd_tunnel_filter_filter_type,
9180 (void *)&cmd_tunnel_filter_tenant_id,
9181 (void *)&cmd_tunnel_filter_queue_num,
9186 /* *** CONFIGURE TUNNEL UDP PORT *** */
9187 struct cmd_tunnel_udp_config {
9188 cmdline_fixed_string_t cmd;
9189 cmdline_fixed_string_t what;
9195 cmd_tunnel_udp_config_parsed(void *parsed_result,
9196 __rte_unused struct cmdline *cl,
9197 __rte_unused void *data)
9199 struct cmd_tunnel_udp_config *res = parsed_result;
9200 struct rte_eth_udp_tunnel tunnel_udp;
9203 tunnel_udp.udp_port = res->udp_port;
9205 if (!strcmp(res->cmd, "rx_vxlan_port"))
9206 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9208 if (!strcmp(res->what, "add"))
9209 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9212 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9216 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9219 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9220 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9221 cmd, "rx_vxlan_port");
9222 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9223 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9225 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9226 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9228 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9229 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9232 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9233 .f = cmd_tunnel_udp_config_parsed,
9235 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9236 "Add/Remove a tunneling UDP port filter",
9238 (void *)&cmd_tunnel_udp_config_cmd,
9239 (void *)&cmd_tunnel_udp_config_what,
9240 (void *)&cmd_tunnel_udp_config_udp_port,
9241 (void *)&cmd_tunnel_udp_config_port_id,
9246 struct cmd_config_tunnel_udp_port {
9247 cmdline_fixed_string_t port;
9248 cmdline_fixed_string_t config;
9250 cmdline_fixed_string_t udp_tunnel_port;
9251 cmdline_fixed_string_t action;
9252 cmdline_fixed_string_t tunnel_type;
9257 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9258 __rte_unused struct cmdline *cl,
9259 __rte_unused void *data)
9261 struct cmd_config_tunnel_udp_port *res = parsed_result;
9262 struct rte_eth_udp_tunnel tunnel_udp;
9265 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9268 tunnel_udp.udp_port = res->udp_port;
9270 if (!strcmp(res->tunnel_type, "vxlan")) {
9271 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9272 } else if (!strcmp(res->tunnel_type, "geneve")) {
9273 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9274 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9275 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9277 printf("Invalid tunnel type\n");
9281 if (!strcmp(res->action, "add"))
9282 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9285 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9289 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9292 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9293 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9295 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9296 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9298 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9299 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9301 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9302 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9305 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9306 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9308 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9309 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9310 "vxlan#geneve#vxlan-gpe");
9311 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9312 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9315 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9316 .f = cmd_cfg_tunnel_udp_port_parsed,
9318 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9320 (void *)&cmd_config_tunnel_udp_port_port,
9321 (void *)&cmd_config_tunnel_udp_port_config,
9322 (void *)&cmd_config_tunnel_udp_port_port_id,
9323 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9324 (void *)&cmd_config_tunnel_udp_port_action,
9325 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9326 (void *)&cmd_config_tunnel_udp_port_value,
9331 /* *** GLOBAL CONFIG *** */
9332 struct cmd_global_config_result {
9333 cmdline_fixed_string_t cmd;
9335 cmdline_fixed_string_t cfg_type;
9340 cmd_global_config_parsed(void *parsed_result,
9341 __rte_unused struct cmdline *cl,
9342 __rte_unused void *data)
9344 struct cmd_global_config_result *res = parsed_result;
9345 struct rte_eth_global_cfg conf;
9348 memset(&conf, 0, sizeof(conf));
9349 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9350 conf.cfg.gre_key_len = res->len;
9351 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9352 RTE_ETH_FILTER_SET, &conf);
9353 #ifdef RTE_LIBRTE_I40E_PMD
9354 if (ret == -ENOTSUP)
9355 ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len);
9358 printf("Global config error\n");
9361 cmdline_parse_token_string_t cmd_global_config_cmd =
9362 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9364 cmdline_parse_token_num_t cmd_global_config_port_id =
9365 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9367 cmdline_parse_token_string_t cmd_global_config_type =
9368 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9369 cfg_type, "gre-key-len");
9370 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9371 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9374 cmdline_parse_inst_t cmd_global_config = {
9375 .f = cmd_global_config_parsed,
9376 .data = (void *)NULL,
9377 .help_str = "global_config <port_id> gre-key-len <key_len>",
9379 (void *)&cmd_global_config_cmd,
9380 (void *)&cmd_global_config_port_id,
9381 (void *)&cmd_global_config_type,
9382 (void *)&cmd_global_config_gre_key_len,
9387 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9388 struct cmd_set_mirror_mask_result {
9389 cmdline_fixed_string_t set;
9390 cmdline_fixed_string_t port;
9392 cmdline_fixed_string_t mirror;
9394 cmdline_fixed_string_t what;
9395 cmdline_fixed_string_t value;
9396 cmdline_fixed_string_t dstpool;
9398 cmdline_fixed_string_t on;
9401 cmdline_parse_token_string_t cmd_mirror_mask_set =
9402 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9404 cmdline_parse_token_string_t cmd_mirror_mask_port =
9405 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9407 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9408 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9410 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9411 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9412 mirror, "mirror-rule");
9413 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9414 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9416 cmdline_parse_token_string_t cmd_mirror_mask_what =
9417 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9418 what, "pool-mirror-up#pool-mirror-down"
9420 cmdline_parse_token_string_t cmd_mirror_mask_value =
9421 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9423 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9424 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9425 dstpool, "dst-pool");
9426 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9427 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9429 cmdline_parse_token_string_t cmd_mirror_mask_on =
9430 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9434 cmd_set_mirror_mask_parsed(void *parsed_result,
9435 __rte_unused struct cmdline *cl,
9436 __rte_unused void *data)
9439 struct cmd_set_mirror_mask_result *res = parsed_result;
9440 struct rte_eth_mirror_conf mr_conf;
9442 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9444 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9446 mr_conf.dst_pool = res->dstpool_id;
9448 if (!strcmp(res->what, "pool-mirror-up")) {
9449 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9450 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9451 } else if (!strcmp(res->what, "pool-mirror-down")) {
9452 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9453 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9454 } else if (!strcmp(res->what, "vlan-mirror")) {
9455 mr_conf.rule_type = ETH_MIRROR_VLAN;
9456 nb_item = parse_item_list(res->value, "vlan",
9457 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9461 for (i = 0; i < nb_item; i++) {
9462 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9463 printf("Invalid vlan_id: must be < 4096\n");
9467 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9468 mr_conf.vlan.vlan_mask |= 1ULL << i;
9472 if (!strcmp(res->on, "on"))
9473 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9476 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9479 printf("mirror rule add error: (%s)\n", strerror(-ret));
9482 cmdline_parse_inst_t cmd_set_mirror_mask = {
9483 .f = cmd_set_mirror_mask_parsed,
9485 .help_str = "set port <port_id> mirror-rule <rule_id> "
9486 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9487 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9489 (void *)&cmd_mirror_mask_set,
9490 (void *)&cmd_mirror_mask_port,
9491 (void *)&cmd_mirror_mask_portid,
9492 (void *)&cmd_mirror_mask_mirror,
9493 (void *)&cmd_mirror_mask_ruleid,
9494 (void *)&cmd_mirror_mask_what,
9495 (void *)&cmd_mirror_mask_value,
9496 (void *)&cmd_mirror_mask_dstpool,
9497 (void *)&cmd_mirror_mask_poolid,
9498 (void *)&cmd_mirror_mask_on,
9503 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9504 struct cmd_set_mirror_link_result {
9505 cmdline_fixed_string_t set;
9506 cmdline_fixed_string_t port;
9508 cmdline_fixed_string_t mirror;
9510 cmdline_fixed_string_t what;
9511 cmdline_fixed_string_t dstpool;
9513 cmdline_fixed_string_t on;
9516 cmdline_parse_token_string_t cmd_mirror_link_set =
9517 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9519 cmdline_parse_token_string_t cmd_mirror_link_port =
9520 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9522 cmdline_parse_token_num_t cmd_mirror_link_portid =
9523 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9525 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9526 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9527 mirror, "mirror-rule");
9528 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9529 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9531 cmdline_parse_token_string_t cmd_mirror_link_what =
9532 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9533 what, "uplink-mirror#downlink-mirror");
9534 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9535 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9536 dstpool, "dst-pool");
9537 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9538 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9540 cmdline_parse_token_string_t cmd_mirror_link_on =
9541 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9545 cmd_set_mirror_link_parsed(void *parsed_result,
9546 __rte_unused struct cmdline *cl,
9547 __rte_unused void *data)
9550 struct cmd_set_mirror_link_result *res = parsed_result;
9551 struct rte_eth_mirror_conf mr_conf;
9553 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9554 if (!strcmp(res->what, "uplink-mirror"))
9555 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9557 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9559 mr_conf.dst_pool = res->dstpool_id;
9561 if (!strcmp(res->on, "on"))
9562 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9565 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9568 /* check the return value and print it if is < 0 */
9570 printf("mirror rule add error: (%s)\n", strerror(-ret));
9574 cmdline_parse_inst_t cmd_set_mirror_link = {
9575 .f = cmd_set_mirror_link_parsed,
9577 .help_str = "set port <port_id> mirror-rule <rule_id> "
9578 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9580 (void *)&cmd_mirror_link_set,
9581 (void *)&cmd_mirror_link_port,
9582 (void *)&cmd_mirror_link_portid,
9583 (void *)&cmd_mirror_link_mirror,
9584 (void *)&cmd_mirror_link_ruleid,
9585 (void *)&cmd_mirror_link_what,
9586 (void *)&cmd_mirror_link_dstpool,
9587 (void *)&cmd_mirror_link_poolid,
9588 (void *)&cmd_mirror_link_on,
9593 /* *** RESET VM MIRROR RULE *** */
9594 struct cmd_rm_mirror_rule_result {
9595 cmdline_fixed_string_t reset;
9596 cmdline_fixed_string_t port;
9598 cmdline_fixed_string_t mirror;
9602 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9603 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9605 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9606 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9608 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9609 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9611 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9612 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9613 mirror, "mirror-rule");
9614 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9615 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9619 cmd_reset_mirror_rule_parsed(void *parsed_result,
9620 __rte_unused struct cmdline *cl,
9621 __rte_unused void *data)
9624 struct cmd_set_mirror_link_result *res = parsed_result;
9626 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9628 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9631 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9632 .f = cmd_reset_mirror_rule_parsed,
9634 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9636 (void *)&cmd_rm_mirror_rule_reset,
9637 (void *)&cmd_rm_mirror_rule_port,
9638 (void *)&cmd_rm_mirror_rule_portid,
9639 (void *)&cmd_rm_mirror_rule_mirror,
9640 (void *)&cmd_rm_mirror_rule_ruleid,
9645 /* ******************************************************************************** */
9647 struct cmd_dump_result {
9648 cmdline_fixed_string_t dump;
9652 dump_struct_sizes(void)
9654 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9655 DUMP_SIZE(struct rte_mbuf);
9656 DUMP_SIZE(struct rte_mempool);
9657 DUMP_SIZE(struct rte_ring);
9662 /* Dump the socket memory statistics on console */
9664 dump_socket_mem(FILE *f)
9666 struct rte_malloc_socket_stats socket_stats;
9671 unsigned int n_alloc = 0;
9672 unsigned int n_free = 0;
9673 static size_t last_allocs;
9674 static size_t last_total;
9677 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9678 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9679 !socket_stats.heap_totalsz_bytes)
9681 total += socket_stats.heap_totalsz_bytes;
9682 alloc += socket_stats.heap_allocsz_bytes;
9683 free += socket_stats.heap_freesz_bytes;
9684 n_alloc += socket_stats.alloc_count;
9685 n_free += socket_stats.free_count;
9687 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9689 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9690 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9691 (double)socket_stats.heap_allocsz_bytes * 100 /
9692 (double)socket_stats.heap_totalsz_bytes,
9693 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9694 socket_stats.alloc_count,
9695 socket_stats.free_count);
9698 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9699 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9700 (double)alloc * 100 / (double)total,
9701 (double)free / (1024 * 1024),
9704 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9705 ((double)total - (double)last_total) / (1024 * 1024),
9706 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9707 last_allocs = alloc;
9711 static void cmd_dump_parsed(void *parsed_result,
9712 __rte_unused struct cmdline *cl,
9713 __rte_unused void *data)
9715 struct cmd_dump_result *res = parsed_result;
9717 if (!strcmp(res->dump, "dump_physmem"))
9718 rte_dump_physmem_layout(stdout);
9719 else if (!strcmp(res->dump, "dump_socket_mem"))
9720 dump_socket_mem(stdout);
9721 else if (!strcmp(res->dump, "dump_memzone"))
9722 rte_memzone_dump(stdout);
9723 else if (!strcmp(res->dump, "dump_struct_sizes"))
9724 dump_struct_sizes();
9725 else if (!strcmp(res->dump, "dump_ring"))
9726 rte_ring_list_dump(stdout);
9727 else if (!strcmp(res->dump, "dump_mempool"))
9728 rte_mempool_list_dump(stdout);
9729 else if (!strcmp(res->dump, "dump_devargs"))
9730 rte_devargs_dump(stdout);
9731 else if (!strcmp(res->dump, "dump_log_types"))
9732 rte_log_dump(stdout);
9735 cmdline_parse_token_string_t cmd_dump_dump =
9736 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9740 "dump_struct_sizes#"
9746 cmdline_parse_inst_t cmd_dump = {
9747 .f = cmd_dump_parsed, /* function to call */
9748 .data = NULL, /* 2nd arg of func */
9749 .help_str = "Dump status",
9750 .tokens = { /* token list, NULL terminated */
9751 (void *)&cmd_dump_dump,
9756 /* ******************************************************************************** */
9758 struct cmd_dump_one_result {
9759 cmdline_fixed_string_t dump;
9760 cmdline_fixed_string_t name;
9763 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9764 __rte_unused void *data)
9766 struct cmd_dump_one_result *res = parsed_result;
9768 if (!strcmp(res->dump, "dump_ring")) {
9770 r = rte_ring_lookup(res->name);
9772 cmdline_printf(cl, "Cannot find ring\n");
9775 rte_ring_dump(stdout, r);
9776 } else if (!strcmp(res->dump, "dump_mempool")) {
9777 struct rte_mempool *mp;
9778 mp = rte_mempool_lookup(res->name);
9780 cmdline_printf(cl, "Cannot find mempool\n");
9783 rte_mempool_dump(stdout, mp);
9787 cmdline_parse_token_string_t cmd_dump_one_dump =
9788 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9789 "dump_ring#dump_mempool");
9791 cmdline_parse_token_string_t cmd_dump_one_name =
9792 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9794 cmdline_parse_inst_t cmd_dump_one = {
9795 .f = cmd_dump_one_parsed, /* function to call */
9796 .data = NULL, /* 2nd arg of func */
9797 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9798 .tokens = { /* token list, NULL terminated */
9799 (void *)&cmd_dump_one_dump,
9800 (void *)&cmd_dump_one_name,
9805 /* *** Add/Del syn filter *** */
9806 struct cmd_syn_filter_result {
9807 cmdline_fixed_string_t filter;
9809 cmdline_fixed_string_t ops;
9810 cmdline_fixed_string_t priority;
9811 cmdline_fixed_string_t high;
9812 cmdline_fixed_string_t queue;
9817 cmd_syn_filter_parsed(void *parsed_result,
9818 __rte_unused struct cmdline *cl,
9819 __rte_unused void *data)
9821 struct cmd_syn_filter_result *res = parsed_result;
9822 struct rte_eth_syn_filter syn_filter;
9825 ret = rte_eth_dev_filter_supported(res->port_id,
9826 RTE_ETH_FILTER_SYN);
9828 printf("syn filter is not supported on port %u.\n",
9833 memset(&syn_filter, 0, sizeof(syn_filter));
9835 if (!strcmp(res->ops, "add")) {
9836 if (!strcmp(res->high, "high"))
9837 syn_filter.hig_pri = 1;
9839 syn_filter.hig_pri = 0;
9841 syn_filter.queue = res->queue_id;
9842 ret = rte_eth_dev_filter_ctrl(res->port_id,
9847 ret = rte_eth_dev_filter_ctrl(res->port_id,
9849 RTE_ETH_FILTER_DELETE,
9853 printf("syn filter programming error: (%s)\n",
9857 cmdline_parse_token_string_t cmd_syn_filter_filter =
9858 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9859 filter, "syn_filter");
9860 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9861 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9863 cmdline_parse_token_string_t cmd_syn_filter_ops =
9864 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9866 cmdline_parse_token_string_t cmd_syn_filter_priority =
9867 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9868 priority, "priority");
9869 cmdline_parse_token_string_t cmd_syn_filter_high =
9870 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9872 cmdline_parse_token_string_t cmd_syn_filter_queue =
9873 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9875 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9876 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9879 cmdline_parse_inst_t cmd_syn_filter = {
9880 .f = cmd_syn_filter_parsed,
9882 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9883 "<queue_id>: Add/Delete syn filter",
9885 (void *)&cmd_syn_filter_filter,
9886 (void *)&cmd_syn_filter_port_id,
9887 (void *)&cmd_syn_filter_ops,
9888 (void *)&cmd_syn_filter_priority,
9889 (void *)&cmd_syn_filter_high,
9890 (void *)&cmd_syn_filter_queue,
9891 (void *)&cmd_syn_filter_queue_id,
9896 /* *** queue region set *** */
9897 struct cmd_queue_region_result {
9898 cmdline_fixed_string_t set;
9899 cmdline_fixed_string_t port;
9901 cmdline_fixed_string_t cmd;
9902 cmdline_fixed_string_t region;
9904 cmdline_fixed_string_t queue_start_index;
9906 cmdline_fixed_string_t queue_num;
9907 uint8_t queue_num_value;
9911 cmd_queue_region_parsed(void *parsed_result,
9912 __rte_unused struct cmdline *cl,
9913 __rte_unused void *data)
9915 struct cmd_queue_region_result *res = parsed_result;
9917 #ifdef RTE_LIBRTE_I40E_PMD
9918 struct rte_pmd_i40e_queue_region_conf region_conf;
9919 enum rte_pmd_i40e_queue_region_op op_type;
9922 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9925 #ifdef RTE_LIBRTE_I40E_PMD
9926 memset(®ion_conf, 0, sizeof(region_conf));
9927 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9928 region_conf.region_id = res->region_id;
9929 region_conf.queue_num = res->queue_num_value;
9930 region_conf.queue_start_index = res->queue_id;
9932 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9933 op_type, ®ion_conf);
9940 printf("function not implemented or supported\n");
9943 printf("queue region config error: (%s)\n", strerror(-ret));
9947 cmdline_parse_token_string_t cmd_queue_region_set =
9948 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9950 cmdline_parse_token_string_t cmd_queue_region_port =
9951 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9952 cmdline_parse_token_num_t cmd_queue_region_port_id =
9953 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9955 cmdline_parse_token_string_t cmd_queue_region_cmd =
9956 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9957 cmd, "queue-region");
9958 cmdline_parse_token_string_t cmd_queue_region_id =
9959 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9960 region, "region_id");
9961 cmdline_parse_token_num_t cmd_queue_region_index =
9962 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9964 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9965 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9966 queue_start_index, "queue_start_index");
9967 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9968 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9970 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9971 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9972 queue_num, "queue_num");
9973 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9974 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9975 queue_num_value, UINT8);
9977 cmdline_parse_inst_t cmd_queue_region = {
9978 .f = cmd_queue_region_parsed,
9980 .help_str = "set port <port_id> queue-region region_id <value> "
9981 "queue_start_index <value> queue_num <value>: Set a queue region",
9983 (void *)&cmd_queue_region_set,
9984 (void *)&cmd_queue_region_port,
9985 (void *)&cmd_queue_region_port_id,
9986 (void *)&cmd_queue_region_cmd,
9987 (void *)&cmd_queue_region_id,
9988 (void *)&cmd_queue_region_index,
9989 (void *)&cmd_queue_region_queue_start_index,
9990 (void *)&cmd_queue_region_queue_id,
9991 (void *)&cmd_queue_region_queue_num,
9992 (void *)&cmd_queue_region_queue_num_value,
9997 /* *** queue region and flowtype set *** */
9998 struct cmd_region_flowtype_result {
9999 cmdline_fixed_string_t set;
10000 cmdline_fixed_string_t port;
10002 cmdline_fixed_string_t cmd;
10003 cmdline_fixed_string_t region;
10005 cmdline_fixed_string_t flowtype;
10006 uint8_t flowtype_id;
10010 cmd_region_flowtype_parsed(void *parsed_result,
10011 __rte_unused struct cmdline *cl,
10012 __rte_unused void *data)
10014 struct cmd_region_flowtype_result *res = parsed_result;
10015 int ret = -ENOTSUP;
10016 #ifdef RTE_LIBRTE_I40E_PMD
10017 struct rte_pmd_i40e_queue_region_conf region_conf;
10018 enum rte_pmd_i40e_queue_region_op op_type;
10021 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10024 #ifdef RTE_LIBRTE_I40E_PMD
10025 memset(®ion_conf, 0, sizeof(region_conf));
10027 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10028 region_conf.region_id = res->region_id;
10029 region_conf.hw_flowtype = res->flowtype_id;
10031 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10032 op_type, ®ion_conf);
10039 printf("function not implemented or supported\n");
10042 printf("region flowtype config error: (%s)\n", strerror(-ret));
10046 cmdline_parse_token_string_t cmd_region_flowtype_set =
10047 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10049 cmdline_parse_token_string_t cmd_region_flowtype_port =
10050 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10052 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10053 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10055 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10056 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10057 cmd, "queue-region");
10058 cmdline_parse_token_string_t cmd_region_flowtype_index =
10059 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10060 region, "region_id");
10061 cmdline_parse_token_num_t cmd_region_flowtype_id =
10062 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10064 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10065 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10066 flowtype, "flowtype");
10067 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10068 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10069 flowtype_id, UINT8);
10070 cmdline_parse_inst_t cmd_region_flowtype = {
10071 .f = cmd_region_flowtype_parsed,
10073 .help_str = "set port <port_id> queue-region region_id <value> "
10074 "flowtype <value>: Set a flowtype region index",
10076 (void *)&cmd_region_flowtype_set,
10077 (void *)&cmd_region_flowtype_port,
10078 (void *)&cmd_region_flowtype_port_index,
10079 (void *)&cmd_region_flowtype_cmd,
10080 (void *)&cmd_region_flowtype_index,
10081 (void *)&cmd_region_flowtype_id,
10082 (void *)&cmd_region_flowtype_flow_index,
10083 (void *)&cmd_region_flowtype_flow_id,
10088 /* *** User Priority (UP) to queue region (region_id) set *** */
10089 struct cmd_user_priority_region_result {
10090 cmdline_fixed_string_t set;
10091 cmdline_fixed_string_t port;
10093 cmdline_fixed_string_t cmd;
10094 cmdline_fixed_string_t user_priority;
10095 uint8_t user_priority_id;
10096 cmdline_fixed_string_t region;
10101 cmd_user_priority_region_parsed(void *parsed_result,
10102 __rte_unused struct cmdline *cl,
10103 __rte_unused void *data)
10105 struct cmd_user_priority_region_result *res = parsed_result;
10106 int ret = -ENOTSUP;
10107 #ifdef RTE_LIBRTE_I40E_PMD
10108 struct rte_pmd_i40e_queue_region_conf region_conf;
10109 enum rte_pmd_i40e_queue_region_op op_type;
10112 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10115 #ifdef RTE_LIBRTE_I40E_PMD
10116 memset(®ion_conf, 0, sizeof(region_conf));
10117 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10118 region_conf.user_priority = res->user_priority_id;
10119 region_conf.region_id = res->region_id;
10121 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10122 op_type, ®ion_conf);
10129 printf("function not implemented or supported\n");
10132 printf("user_priority region config error: (%s)\n",
10137 cmdline_parse_token_string_t cmd_user_priority_region_set =
10138 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10140 cmdline_parse_token_string_t cmd_user_priority_region_port =
10141 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10143 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10144 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10146 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10147 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10148 cmd, "queue-region");
10149 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10150 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10151 user_priority, "UP");
10152 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10153 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10154 user_priority_id, UINT8);
10155 cmdline_parse_token_string_t cmd_user_priority_region_region =
10156 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10157 region, "region_id");
10158 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10159 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10162 cmdline_parse_inst_t cmd_user_priority_region = {
10163 .f = cmd_user_priority_region_parsed,
10165 .help_str = "set port <port_id> queue-region UP <value> "
10166 "region_id <value>: Set the mapping of User Priority (UP) "
10167 "to queue region (region_id) ",
10169 (void *)&cmd_user_priority_region_set,
10170 (void *)&cmd_user_priority_region_port,
10171 (void *)&cmd_user_priority_region_port_index,
10172 (void *)&cmd_user_priority_region_cmd,
10173 (void *)&cmd_user_priority_region_UP,
10174 (void *)&cmd_user_priority_region_UP_id,
10175 (void *)&cmd_user_priority_region_region,
10176 (void *)&cmd_user_priority_region_region_id,
10181 /* *** flush all queue region related configuration *** */
10182 struct cmd_flush_queue_region_result {
10183 cmdline_fixed_string_t set;
10184 cmdline_fixed_string_t port;
10186 cmdline_fixed_string_t cmd;
10187 cmdline_fixed_string_t flush;
10188 cmdline_fixed_string_t what;
10192 cmd_flush_queue_region_parsed(void *parsed_result,
10193 __rte_unused struct cmdline *cl,
10194 __rte_unused void *data)
10196 struct cmd_flush_queue_region_result *res = parsed_result;
10197 int ret = -ENOTSUP;
10198 #ifdef RTE_LIBRTE_I40E_PMD
10199 struct rte_pmd_i40e_queue_region_conf region_conf;
10200 enum rte_pmd_i40e_queue_region_op op_type;
10203 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10206 #ifdef RTE_LIBRTE_I40E_PMD
10207 memset(®ion_conf, 0, sizeof(region_conf));
10209 if (strcmp(res->what, "on") == 0)
10210 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10212 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10214 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10215 op_type, ®ion_conf);
10222 printf("function not implemented or supported\n");
10225 printf("queue region config flush error: (%s)\n",
10230 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10231 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10233 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10234 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10236 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10237 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10239 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10240 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10241 cmd, "queue-region");
10242 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10243 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10245 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10246 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10249 cmdline_parse_inst_t cmd_flush_queue_region = {
10250 .f = cmd_flush_queue_region_parsed,
10252 .help_str = "set port <port_id> queue-region flush on|off"
10253 ": flush all queue region related configuration",
10255 (void *)&cmd_flush_queue_region_set,
10256 (void *)&cmd_flush_queue_region_port,
10257 (void *)&cmd_flush_queue_region_port_index,
10258 (void *)&cmd_flush_queue_region_cmd,
10259 (void *)&cmd_flush_queue_region_flush,
10260 (void *)&cmd_flush_queue_region_what,
10265 /* *** get all queue region related configuration info *** */
10266 struct cmd_show_queue_region_info {
10267 cmdline_fixed_string_t show;
10268 cmdline_fixed_string_t port;
10270 cmdline_fixed_string_t cmd;
10274 cmd_show_queue_region_info_parsed(void *parsed_result,
10275 __rte_unused struct cmdline *cl,
10276 __rte_unused void *data)
10278 struct cmd_show_queue_region_info *res = parsed_result;
10279 int ret = -ENOTSUP;
10280 #ifdef RTE_LIBRTE_I40E_PMD
10281 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10282 enum rte_pmd_i40e_queue_region_op op_type;
10285 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10288 #ifdef RTE_LIBRTE_I40E_PMD
10289 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10291 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10293 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10294 op_type, &rte_pmd_regions);
10296 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10303 printf("function not implemented or supported\n");
10306 printf("queue region config info show error: (%s)\n",
10311 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10312 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10314 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10315 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10317 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10318 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10320 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10321 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10322 cmd, "queue-region");
10324 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10325 .f = cmd_show_queue_region_info_parsed,
10327 .help_str = "show port <port_id> queue-region"
10328 ": show all queue region related configuration info",
10330 (void *)&cmd_show_queue_region_info_get,
10331 (void *)&cmd_show_queue_region_info_port,
10332 (void *)&cmd_show_queue_region_info_port_index,
10333 (void *)&cmd_show_queue_region_info_cmd,
10338 /* *** ADD/REMOVE A 2tuple FILTER *** */
10339 struct cmd_2tuple_filter_result {
10340 cmdline_fixed_string_t filter;
10342 cmdline_fixed_string_t ops;
10343 cmdline_fixed_string_t dst_port;
10344 uint16_t dst_port_value;
10345 cmdline_fixed_string_t protocol;
10346 uint8_t protocol_value;
10347 cmdline_fixed_string_t mask;
10348 uint8_t mask_value;
10349 cmdline_fixed_string_t tcp_flags;
10350 uint8_t tcp_flags_value;
10351 cmdline_fixed_string_t priority;
10352 uint8_t priority_value;
10353 cmdline_fixed_string_t queue;
10358 cmd_2tuple_filter_parsed(void *parsed_result,
10359 __rte_unused struct cmdline *cl,
10360 __rte_unused void *data)
10362 struct rte_eth_ntuple_filter filter;
10363 struct cmd_2tuple_filter_result *res = parsed_result;
10366 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10368 printf("ntuple filter is not supported on port %u.\n",
10373 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10375 filter.flags = RTE_2TUPLE_FLAGS;
10376 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10377 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10378 filter.proto = res->protocol_value;
10379 filter.priority = res->priority_value;
10380 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10381 printf("nonzero tcp_flags is only meaningful"
10382 " when protocol is TCP.\n");
10385 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10386 printf("invalid TCP flags.\n");
10390 if (res->tcp_flags_value != 0) {
10391 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10392 filter.tcp_flags = res->tcp_flags_value;
10395 /* need convert to big endian. */
10396 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10397 filter.queue = res->queue_id;
10399 if (!strcmp(res->ops, "add"))
10400 ret = rte_eth_dev_filter_ctrl(res->port_id,
10401 RTE_ETH_FILTER_NTUPLE,
10402 RTE_ETH_FILTER_ADD,
10405 ret = rte_eth_dev_filter_ctrl(res->port_id,
10406 RTE_ETH_FILTER_NTUPLE,
10407 RTE_ETH_FILTER_DELETE,
10410 printf("2tuple filter programming error: (%s)\n",
10415 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10416 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10417 filter, "2tuple_filter");
10418 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10419 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10421 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10422 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10424 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10425 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10426 dst_port, "dst_port");
10427 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10428 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10429 dst_port_value, UINT16);
10430 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10431 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10432 protocol, "protocol");
10433 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10434 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10435 protocol_value, UINT8);
10436 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10437 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10439 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10440 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10442 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10443 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10444 tcp_flags, "tcp_flags");
10445 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10446 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10447 tcp_flags_value, UINT8);
10448 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10449 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10450 priority, "priority");
10451 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10452 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10453 priority_value, UINT8);
10454 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10455 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10457 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10458 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10461 cmdline_parse_inst_t cmd_2tuple_filter = {
10462 .f = cmd_2tuple_filter_parsed,
10464 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10465 "<value> mask <value> tcp_flags <value> priority <value> queue "
10466 "<queue_id>: Add a 2tuple filter",
10468 (void *)&cmd_2tuple_filter_filter,
10469 (void *)&cmd_2tuple_filter_port_id,
10470 (void *)&cmd_2tuple_filter_ops,
10471 (void *)&cmd_2tuple_filter_dst_port,
10472 (void *)&cmd_2tuple_filter_dst_port_value,
10473 (void *)&cmd_2tuple_filter_protocol,
10474 (void *)&cmd_2tuple_filter_protocol_value,
10475 (void *)&cmd_2tuple_filter_mask,
10476 (void *)&cmd_2tuple_filter_mask_value,
10477 (void *)&cmd_2tuple_filter_tcp_flags,
10478 (void *)&cmd_2tuple_filter_tcp_flags_value,
10479 (void *)&cmd_2tuple_filter_priority,
10480 (void *)&cmd_2tuple_filter_priority_value,
10481 (void *)&cmd_2tuple_filter_queue,
10482 (void *)&cmd_2tuple_filter_queue_id,
10487 /* *** ADD/REMOVE A 5tuple FILTER *** */
10488 struct cmd_5tuple_filter_result {
10489 cmdline_fixed_string_t filter;
10491 cmdline_fixed_string_t ops;
10492 cmdline_fixed_string_t dst_ip;
10493 cmdline_ipaddr_t dst_ip_value;
10494 cmdline_fixed_string_t src_ip;
10495 cmdline_ipaddr_t src_ip_value;
10496 cmdline_fixed_string_t dst_port;
10497 uint16_t dst_port_value;
10498 cmdline_fixed_string_t src_port;
10499 uint16_t src_port_value;
10500 cmdline_fixed_string_t protocol;
10501 uint8_t protocol_value;
10502 cmdline_fixed_string_t mask;
10503 uint8_t mask_value;
10504 cmdline_fixed_string_t tcp_flags;
10505 uint8_t tcp_flags_value;
10506 cmdline_fixed_string_t priority;
10507 uint8_t priority_value;
10508 cmdline_fixed_string_t queue;
10513 cmd_5tuple_filter_parsed(void *parsed_result,
10514 __rte_unused struct cmdline *cl,
10515 __rte_unused void *data)
10517 struct rte_eth_ntuple_filter filter;
10518 struct cmd_5tuple_filter_result *res = parsed_result;
10521 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10523 printf("ntuple filter is not supported on port %u.\n",
10528 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10530 filter.flags = RTE_5TUPLE_FLAGS;
10531 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10532 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10533 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10534 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10535 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10536 filter.proto = res->protocol_value;
10537 filter.priority = res->priority_value;
10538 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10539 printf("nonzero tcp_flags is only meaningful"
10540 " when protocol is TCP.\n");
10543 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10544 printf("invalid TCP flags.\n");
10548 if (res->tcp_flags_value != 0) {
10549 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10550 filter.tcp_flags = res->tcp_flags_value;
10553 if (res->dst_ip_value.family == AF_INET)
10554 /* no need to convert, already big endian. */
10555 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10557 if (filter.dst_ip_mask == 0) {
10558 printf("can not support ipv6 involved compare.\n");
10564 if (res->src_ip_value.family == AF_INET)
10565 /* no need to convert, already big endian. */
10566 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10568 if (filter.src_ip_mask == 0) {
10569 printf("can not support ipv6 involved compare.\n");
10574 /* need convert to big endian. */
10575 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10576 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10577 filter.queue = res->queue_id;
10579 if (!strcmp(res->ops, "add"))
10580 ret = rte_eth_dev_filter_ctrl(res->port_id,
10581 RTE_ETH_FILTER_NTUPLE,
10582 RTE_ETH_FILTER_ADD,
10585 ret = rte_eth_dev_filter_ctrl(res->port_id,
10586 RTE_ETH_FILTER_NTUPLE,
10587 RTE_ETH_FILTER_DELETE,
10590 printf("5tuple filter programming error: (%s)\n",
10594 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10595 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10596 filter, "5tuple_filter");
10597 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10598 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10600 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10601 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10603 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10604 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10606 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10607 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10609 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10610 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10612 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10613 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10615 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10616 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10617 dst_port, "dst_port");
10618 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10619 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10620 dst_port_value, UINT16);
10621 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10622 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10623 src_port, "src_port");
10624 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10625 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10626 src_port_value, UINT16);
10627 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10628 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10629 protocol, "protocol");
10630 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10631 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10632 protocol_value, UINT8);
10633 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10634 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10636 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10637 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10639 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10640 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10641 tcp_flags, "tcp_flags");
10642 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10643 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10644 tcp_flags_value, UINT8);
10645 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10646 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10647 priority, "priority");
10648 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10649 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10650 priority_value, UINT8);
10651 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10652 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10654 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10655 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10658 cmdline_parse_inst_t cmd_5tuple_filter = {
10659 .f = cmd_5tuple_filter_parsed,
10661 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10662 "src_ip <value> dst_port <value> src_port <value> "
10663 "protocol <value> mask <value> tcp_flags <value> "
10664 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10666 (void *)&cmd_5tuple_filter_filter,
10667 (void *)&cmd_5tuple_filter_port_id,
10668 (void *)&cmd_5tuple_filter_ops,
10669 (void *)&cmd_5tuple_filter_dst_ip,
10670 (void *)&cmd_5tuple_filter_dst_ip_value,
10671 (void *)&cmd_5tuple_filter_src_ip,
10672 (void *)&cmd_5tuple_filter_src_ip_value,
10673 (void *)&cmd_5tuple_filter_dst_port,
10674 (void *)&cmd_5tuple_filter_dst_port_value,
10675 (void *)&cmd_5tuple_filter_src_port,
10676 (void *)&cmd_5tuple_filter_src_port_value,
10677 (void *)&cmd_5tuple_filter_protocol,
10678 (void *)&cmd_5tuple_filter_protocol_value,
10679 (void *)&cmd_5tuple_filter_mask,
10680 (void *)&cmd_5tuple_filter_mask_value,
10681 (void *)&cmd_5tuple_filter_tcp_flags,
10682 (void *)&cmd_5tuple_filter_tcp_flags_value,
10683 (void *)&cmd_5tuple_filter_priority,
10684 (void *)&cmd_5tuple_filter_priority_value,
10685 (void *)&cmd_5tuple_filter_queue,
10686 (void *)&cmd_5tuple_filter_queue_id,
10691 /* *** ADD/REMOVE A flex FILTER *** */
10692 struct cmd_flex_filter_result {
10693 cmdline_fixed_string_t filter;
10694 cmdline_fixed_string_t ops;
10696 cmdline_fixed_string_t len;
10698 cmdline_fixed_string_t bytes;
10699 cmdline_fixed_string_t bytes_value;
10700 cmdline_fixed_string_t mask;
10701 cmdline_fixed_string_t mask_value;
10702 cmdline_fixed_string_t priority;
10703 uint8_t priority_value;
10704 cmdline_fixed_string_t queue;
10708 static int xdigit2val(unsigned char c)
10713 else if (isupper(c))
10714 val = c - 'A' + 10;
10716 val = c - 'a' + 10;
10721 cmd_flex_filter_parsed(void *parsed_result,
10722 __rte_unused struct cmdline *cl,
10723 __rte_unused void *data)
10726 struct rte_eth_flex_filter filter;
10727 struct cmd_flex_filter_result *res = parsed_result;
10728 char *bytes_ptr, *mask_ptr;
10729 uint16_t len, i, j = 0;
10734 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10735 printf("the len exceed the max length 128\n");
10738 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10739 filter.len = res->len_value;
10740 filter.priority = res->priority_value;
10741 filter.queue = res->queue_id;
10742 bytes_ptr = res->bytes_value;
10743 mask_ptr = res->mask_value;
10745 /* translate bytes string to array. */
10746 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10747 (bytes_ptr[1] == 'X')))
10749 len = strnlen(bytes_ptr, res->len_value * 2);
10750 if (len == 0 || (len % 8 != 0)) {
10751 printf("please check len and bytes input\n");
10754 for (i = 0; i < len; i++) {
10756 if (isxdigit(c) == 0) {
10757 /* invalid characters. */
10758 printf("invalid input\n");
10761 val = xdigit2val(c);
10764 filter.bytes[j] = byte;
10765 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10772 /* translate mask string to uint8_t array. */
10773 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10774 (mask_ptr[1] == 'X')))
10776 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10778 printf("invalid input\n");
10783 for (i = 0; i < len; i++) {
10785 if (isxdigit(c) == 0) {
10786 /* invalid characters. */
10787 printf("invalid input\n");
10790 val = xdigit2val(c);
10793 filter.mask[j] = byte;
10794 printf("mask[%d]:%02x ", j, filter.mask[j]);
10802 if (!strcmp(res->ops, "add"))
10803 ret = rte_eth_dev_filter_ctrl(res->port_id,
10804 RTE_ETH_FILTER_FLEXIBLE,
10805 RTE_ETH_FILTER_ADD,
10808 ret = rte_eth_dev_filter_ctrl(res->port_id,
10809 RTE_ETH_FILTER_FLEXIBLE,
10810 RTE_ETH_FILTER_DELETE,
10814 printf("flex filter setting error: (%s)\n", strerror(-ret));
10817 cmdline_parse_token_string_t cmd_flex_filter_filter =
10818 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10819 filter, "flex_filter");
10820 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10821 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10823 cmdline_parse_token_string_t cmd_flex_filter_ops =
10824 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10826 cmdline_parse_token_string_t cmd_flex_filter_len =
10827 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10829 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10830 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10832 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10833 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10835 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10836 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10837 bytes_value, NULL);
10838 cmdline_parse_token_string_t cmd_flex_filter_mask =
10839 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10841 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10842 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10844 cmdline_parse_token_string_t cmd_flex_filter_priority =
10845 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10846 priority, "priority");
10847 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10848 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10849 priority_value, UINT8);
10850 cmdline_parse_token_string_t cmd_flex_filter_queue =
10851 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10853 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10854 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10856 cmdline_parse_inst_t cmd_flex_filter = {
10857 .f = cmd_flex_filter_parsed,
10859 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10860 "<value> mask <value> priority <value> queue <queue_id>: "
10861 "Add/Del a flex filter",
10863 (void *)&cmd_flex_filter_filter,
10864 (void *)&cmd_flex_filter_port_id,
10865 (void *)&cmd_flex_filter_ops,
10866 (void *)&cmd_flex_filter_len,
10867 (void *)&cmd_flex_filter_len_value,
10868 (void *)&cmd_flex_filter_bytes,
10869 (void *)&cmd_flex_filter_bytes_value,
10870 (void *)&cmd_flex_filter_mask,
10871 (void *)&cmd_flex_filter_mask_value,
10872 (void *)&cmd_flex_filter_priority,
10873 (void *)&cmd_flex_filter_priority_value,
10874 (void *)&cmd_flex_filter_queue,
10875 (void *)&cmd_flex_filter_queue_id,
10880 /* *** Filters Control *** */
10882 /* *** deal with ethertype filter *** */
10883 struct cmd_ethertype_filter_result {
10884 cmdline_fixed_string_t filter;
10886 cmdline_fixed_string_t ops;
10887 cmdline_fixed_string_t mac;
10888 struct rte_ether_addr mac_addr;
10889 cmdline_fixed_string_t ethertype;
10890 uint16_t ethertype_value;
10891 cmdline_fixed_string_t drop;
10892 cmdline_fixed_string_t queue;
10896 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10897 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10898 filter, "ethertype_filter");
10899 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10900 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10902 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10903 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10905 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10906 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10907 mac, "mac_addr#mac_ignr");
10908 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10909 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10911 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10912 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10913 ethertype, "ethertype");
10914 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10915 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10916 ethertype_value, UINT16);
10917 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10918 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10920 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10921 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10923 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10924 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10928 cmd_ethertype_filter_parsed(void *parsed_result,
10929 __rte_unused struct cmdline *cl,
10930 __rte_unused void *data)
10932 struct cmd_ethertype_filter_result *res = parsed_result;
10933 struct rte_eth_ethertype_filter filter;
10936 ret = rte_eth_dev_filter_supported(res->port_id,
10937 RTE_ETH_FILTER_ETHERTYPE);
10939 printf("ethertype filter is not supported on port %u.\n",
10944 memset(&filter, 0, sizeof(filter));
10945 if (!strcmp(res->mac, "mac_addr")) {
10946 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10947 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10948 sizeof(struct rte_ether_addr));
10950 if (!strcmp(res->drop, "drop"))
10951 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10952 filter.ether_type = res->ethertype_value;
10953 filter.queue = res->queue_id;
10955 if (!strcmp(res->ops, "add"))
10956 ret = rte_eth_dev_filter_ctrl(res->port_id,
10957 RTE_ETH_FILTER_ETHERTYPE,
10958 RTE_ETH_FILTER_ADD,
10961 ret = rte_eth_dev_filter_ctrl(res->port_id,
10962 RTE_ETH_FILTER_ETHERTYPE,
10963 RTE_ETH_FILTER_DELETE,
10966 printf("ethertype filter programming error: (%s)\n",
10970 cmdline_parse_inst_t cmd_ethertype_filter = {
10971 .f = cmd_ethertype_filter_parsed,
10973 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10974 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10975 "Add or delete an ethertype filter entry",
10977 (void *)&cmd_ethertype_filter_filter,
10978 (void *)&cmd_ethertype_filter_port_id,
10979 (void *)&cmd_ethertype_filter_ops,
10980 (void *)&cmd_ethertype_filter_mac,
10981 (void *)&cmd_ethertype_filter_mac_addr,
10982 (void *)&cmd_ethertype_filter_ethertype,
10983 (void *)&cmd_ethertype_filter_ethertype_value,
10984 (void *)&cmd_ethertype_filter_drop,
10985 (void *)&cmd_ethertype_filter_queue,
10986 (void *)&cmd_ethertype_filter_queue_id,
10991 /* *** deal with flow director filter *** */
10992 struct cmd_flow_director_result {
10993 cmdline_fixed_string_t flow_director_filter;
10995 cmdline_fixed_string_t mode;
10996 cmdline_fixed_string_t mode_value;
10997 cmdline_fixed_string_t ops;
10998 cmdline_fixed_string_t flow;
10999 cmdline_fixed_string_t flow_type;
11000 cmdline_fixed_string_t ether;
11001 uint16_t ether_type;
11002 cmdline_fixed_string_t src;
11003 cmdline_ipaddr_t ip_src;
11005 cmdline_fixed_string_t dst;
11006 cmdline_ipaddr_t ip_dst;
11008 cmdline_fixed_string_t verify_tag;
11009 uint32_t verify_tag_value;
11010 cmdline_fixed_string_t tos;
11012 cmdline_fixed_string_t proto;
11013 uint8_t proto_value;
11014 cmdline_fixed_string_t ttl;
11016 cmdline_fixed_string_t vlan;
11017 uint16_t vlan_value;
11018 cmdline_fixed_string_t flexbytes;
11019 cmdline_fixed_string_t flexbytes_value;
11020 cmdline_fixed_string_t pf_vf;
11021 cmdline_fixed_string_t drop;
11022 cmdline_fixed_string_t queue;
11024 cmdline_fixed_string_t fd_id;
11025 uint32_t fd_id_value;
11026 cmdline_fixed_string_t mac;
11027 struct rte_ether_addr mac_addr;
11028 cmdline_fixed_string_t tunnel;
11029 cmdline_fixed_string_t tunnel_type;
11030 cmdline_fixed_string_t tunnel_id;
11031 uint32_t tunnel_id_value;
11032 cmdline_fixed_string_t packet;
11037 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
11040 const char *p, *p0 = q_arg;
11042 unsigned long int_fld;
11043 char *str_fld[max_num];
11048 p = strchr(p0, '(');
11052 p0 = strchr(p, ')');
11057 if (size >= sizeof(s))
11060 snprintf(s, sizeof(s), "%.*s", size, p);
11061 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11062 if (ret < 0 || ret > max_num)
11064 for (i = 0; i < ret; i++) {
11066 int_fld = strtoul(str_fld[i], &end, 0);
11067 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
11069 flexbytes[i] = (uint8_t)int_fld;
11075 str2flowtype(char *string)
11078 static const struct {
11081 } flowtype_str[] = {
11082 {"raw", RTE_ETH_FLOW_RAW},
11083 {"ipv4", RTE_ETH_FLOW_IPV4},
11084 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11085 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11086 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11087 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11088 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11089 {"ipv6", RTE_ETH_FLOW_IPV6},
11090 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11091 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11092 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11093 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11094 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11095 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11098 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
11099 if (!strcmp(flowtype_str[i].str, string))
11100 return flowtype_str[i].type;
11103 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
11104 return (uint16_t)atoi(string);
11106 return RTE_ETH_FLOW_UNKNOWN;
11109 static enum rte_eth_fdir_tunnel_type
11110 str2fdir_tunneltype(char *string)
11114 static const struct {
11116 enum rte_eth_fdir_tunnel_type type;
11117 } tunneltype_str[] = {
11118 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
11119 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
11122 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
11123 if (!strcmp(tunneltype_str[i].str, string))
11124 return tunneltype_str[i].type;
11126 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
11129 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
11131 if ((ip_addr).family == AF_INET) \
11132 (ip) = (ip_addr).addr.ipv4.s_addr; \
11134 printf("invalid parameter.\n"); \
11139 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
11141 if ((ip_addr).family == AF_INET6) \
11142 rte_memcpy(&(ip), \
11143 &((ip_addr).addr.ipv6), \
11144 sizeof(struct in6_addr)); \
11146 printf("invalid parameter.\n"); \
11152 cmd_flow_director_filter_parsed(void *parsed_result,
11153 __rte_unused struct cmdline *cl,
11154 __rte_unused void *data)
11156 struct cmd_flow_director_result *res = parsed_result;
11157 struct rte_eth_fdir_filter entry;
11158 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11160 unsigned long vf_id;
11163 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11165 printf("flow director is not supported on port %u.\n",
11169 memset(flexbytes, 0, sizeof(flexbytes));
11170 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11172 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11173 if (strcmp(res->mode_value, "MAC-VLAN")) {
11174 printf("Please set mode to MAC-VLAN.\n");
11177 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11178 if (strcmp(res->mode_value, "Tunnel")) {
11179 printf("Please set mode to Tunnel.\n");
11183 if (!strcmp(res->mode_value, "raw")) {
11184 #ifdef RTE_LIBRTE_I40E_PMD
11185 struct rte_pmd_i40e_flow_type_mapping
11186 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11187 struct rte_pmd_i40e_pkt_template_conf conf;
11188 uint16_t flow_type = str2flowtype(res->flow_type);
11189 uint16_t i, port = res->port_id;
11192 memset(&conf, 0, sizeof(conf));
11194 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11195 printf("Invalid flow type specified.\n");
11198 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11202 if (mapping[flow_type].pctype == 0ULL) {
11203 printf("Invalid flow type specified.\n");
11206 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11207 if (mapping[flow_type].pctype & (1ULL << i)) {
11208 conf.input.pctype = i;
11213 conf.input.packet = open_file(res->filepath,
11214 &conf.input.length);
11215 if (!conf.input.packet)
11217 if (!strcmp(res->drop, "drop"))
11218 conf.action.behavior =
11219 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11221 conf.action.behavior =
11222 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11223 conf.action.report_status =
11224 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11225 conf.action.rx_queue = res->queue_id;
11226 conf.soft_id = res->fd_id_value;
11227 add = strcmp(res->ops, "del") ? 1 : 0;
11228 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11232 printf("flow director config error: (%s)\n",
11234 close_file(conf.input.packet);
11237 } else if (strcmp(res->mode_value, "IP")) {
11238 printf("Please set mode to IP or raw.\n");
11241 entry.input.flow_type = str2flowtype(res->flow_type);
11244 ret = parse_flexbytes(res->flexbytes_value,
11246 RTE_ETH_FDIR_MAX_FLEXLEN);
11248 printf("error: Cannot parse flexbytes input.\n");
11252 switch (entry.input.flow_type) {
11253 case RTE_ETH_FLOW_FRAG_IPV4:
11254 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11255 entry.input.flow.ip4_flow.proto = res->proto_value;
11257 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11258 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11259 IPV4_ADDR_TO_UINT(res->ip_dst,
11260 entry.input.flow.ip4_flow.dst_ip);
11261 IPV4_ADDR_TO_UINT(res->ip_src,
11262 entry.input.flow.ip4_flow.src_ip);
11263 entry.input.flow.ip4_flow.tos = res->tos_value;
11264 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11265 /* need convert to big endian. */
11266 entry.input.flow.udp4_flow.dst_port =
11267 rte_cpu_to_be_16(res->port_dst);
11268 entry.input.flow.udp4_flow.src_port =
11269 rte_cpu_to_be_16(res->port_src);
11271 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11272 IPV4_ADDR_TO_UINT(res->ip_dst,
11273 entry.input.flow.sctp4_flow.ip.dst_ip);
11274 IPV4_ADDR_TO_UINT(res->ip_src,
11275 entry.input.flow.sctp4_flow.ip.src_ip);
11276 entry.input.flow.ip4_flow.tos = res->tos_value;
11277 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11278 /* need convert to big endian. */
11279 entry.input.flow.sctp4_flow.dst_port =
11280 rte_cpu_to_be_16(res->port_dst);
11281 entry.input.flow.sctp4_flow.src_port =
11282 rte_cpu_to_be_16(res->port_src);
11283 entry.input.flow.sctp4_flow.verify_tag =
11284 rte_cpu_to_be_32(res->verify_tag_value);
11286 case RTE_ETH_FLOW_FRAG_IPV6:
11287 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11288 entry.input.flow.ipv6_flow.proto = res->proto_value;
11290 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11291 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11292 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11293 entry.input.flow.ipv6_flow.dst_ip);
11294 IPV6_ADDR_TO_ARRAY(res->ip_src,
11295 entry.input.flow.ipv6_flow.src_ip);
11296 entry.input.flow.ipv6_flow.tc = res->tos_value;
11297 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11298 /* need convert to big endian. */
11299 entry.input.flow.udp6_flow.dst_port =
11300 rte_cpu_to_be_16(res->port_dst);
11301 entry.input.flow.udp6_flow.src_port =
11302 rte_cpu_to_be_16(res->port_src);
11304 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11305 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11306 entry.input.flow.sctp6_flow.ip.dst_ip);
11307 IPV6_ADDR_TO_ARRAY(res->ip_src,
11308 entry.input.flow.sctp6_flow.ip.src_ip);
11309 entry.input.flow.ipv6_flow.tc = res->tos_value;
11310 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11311 /* need convert to big endian. */
11312 entry.input.flow.sctp6_flow.dst_port =
11313 rte_cpu_to_be_16(res->port_dst);
11314 entry.input.flow.sctp6_flow.src_port =
11315 rte_cpu_to_be_16(res->port_src);
11316 entry.input.flow.sctp6_flow.verify_tag =
11317 rte_cpu_to_be_32(res->verify_tag_value);
11319 case RTE_ETH_FLOW_L2_PAYLOAD:
11320 entry.input.flow.l2_flow.ether_type =
11321 rte_cpu_to_be_16(res->ether_type);
11327 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11328 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11330 sizeof(struct rte_ether_addr));
11332 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11333 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11335 sizeof(struct rte_ether_addr));
11336 entry.input.flow.tunnel_flow.tunnel_type =
11337 str2fdir_tunneltype(res->tunnel_type);
11338 entry.input.flow.tunnel_flow.tunnel_id =
11339 rte_cpu_to_be_32(res->tunnel_id_value);
11342 rte_memcpy(entry.input.flow_ext.flexbytes,
11344 RTE_ETH_FDIR_MAX_FLEXLEN);
11346 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11348 entry.action.flex_off = 0; /*use 0 by default */
11349 if (!strcmp(res->drop, "drop"))
11350 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11352 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11354 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11355 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11356 if (!strcmp(res->pf_vf, "pf"))
11357 entry.input.flow_ext.is_vf = 0;
11358 else if (!strncmp(res->pf_vf, "vf", 2)) {
11359 struct rte_eth_dev_info dev_info;
11361 ret = eth_dev_info_get_print_err(res->port_id,
11367 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11368 if (errno != 0 || *end != '\0' ||
11369 vf_id >= dev_info.max_vfs) {
11370 printf("invalid parameter %s.\n", res->pf_vf);
11373 entry.input.flow_ext.is_vf = 1;
11374 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11376 printf("invalid parameter %s.\n", res->pf_vf);
11381 /* set to report FD ID by default */
11382 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11383 entry.action.rx_queue = res->queue_id;
11384 entry.soft_id = res->fd_id_value;
11385 if (!strcmp(res->ops, "add"))
11386 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11387 RTE_ETH_FILTER_ADD, &entry);
11388 else if (!strcmp(res->ops, "del"))
11389 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11390 RTE_ETH_FILTER_DELETE, &entry);
11392 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11393 RTE_ETH_FILTER_UPDATE, &entry);
11395 printf("flow director programming error: (%s)\n",
11399 cmdline_parse_token_string_t cmd_flow_director_filter =
11400 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11401 flow_director_filter, "flow_director_filter");
11402 cmdline_parse_token_num_t cmd_flow_director_port_id =
11403 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11405 cmdline_parse_token_string_t cmd_flow_director_ops =
11406 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11407 ops, "add#del#update");
11408 cmdline_parse_token_string_t cmd_flow_director_flow =
11409 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11411 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11412 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11414 cmdline_parse_token_string_t cmd_flow_director_ether =
11415 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11417 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11418 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11419 ether_type, UINT16);
11420 cmdline_parse_token_string_t cmd_flow_director_src =
11421 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11423 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11424 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11426 cmdline_parse_token_num_t cmd_flow_director_port_src =
11427 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11429 cmdline_parse_token_string_t cmd_flow_director_dst =
11430 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11432 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11433 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11435 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11436 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11438 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11439 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11440 verify_tag, "verify_tag");
11441 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11442 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11443 verify_tag_value, UINT32);
11444 cmdline_parse_token_string_t cmd_flow_director_tos =
11445 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11447 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11448 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11450 cmdline_parse_token_string_t cmd_flow_director_proto =
11451 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11453 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11454 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11455 proto_value, UINT8);
11456 cmdline_parse_token_string_t cmd_flow_director_ttl =
11457 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11459 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11460 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11462 cmdline_parse_token_string_t cmd_flow_director_vlan =
11463 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11465 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11466 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11467 vlan_value, UINT16);
11468 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11469 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11470 flexbytes, "flexbytes");
11471 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11472 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11473 flexbytes_value, NULL);
11474 cmdline_parse_token_string_t cmd_flow_director_drop =
11475 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11477 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11478 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11480 cmdline_parse_token_string_t cmd_flow_director_queue =
11481 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11483 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11484 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11486 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11487 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11489 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11490 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11491 fd_id_value, UINT32);
11493 cmdline_parse_token_string_t cmd_flow_director_mode =
11494 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11496 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11497 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11499 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11500 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11501 mode_value, "MAC-VLAN");
11502 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11503 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11504 mode_value, "Tunnel");
11505 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11506 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11507 mode_value, "raw");
11508 cmdline_parse_token_string_t cmd_flow_director_mac =
11509 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11511 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11512 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11514 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11515 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11517 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11518 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11519 tunnel_type, "NVGRE#VxLAN");
11520 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11521 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11522 tunnel_id, "tunnel-id");
11523 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11524 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11525 tunnel_id_value, UINT32);
11526 cmdline_parse_token_string_t cmd_flow_director_packet =
11527 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11529 cmdline_parse_token_string_t cmd_flow_director_filepath =
11530 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11533 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11534 .f = cmd_flow_director_filter_parsed,
11536 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11537 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11538 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11539 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11540 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11541 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11542 "fd_id <fd_id_value>: "
11543 "Add or delete an ip flow director entry on NIC",
11545 (void *)&cmd_flow_director_filter,
11546 (void *)&cmd_flow_director_port_id,
11547 (void *)&cmd_flow_director_mode,
11548 (void *)&cmd_flow_director_mode_ip,
11549 (void *)&cmd_flow_director_ops,
11550 (void *)&cmd_flow_director_flow,
11551 (void *)&cmd_flow_director_flow_type,
11552 (void *)&cmd_flow_director_src,
11553 (void *)&cmd_flow_director_ip_src,
11554 (void *)&cmd_flow_director_dst,
11555 (void *)&cmd_flow_director_ip_dst,
11556 (void *)&cmd_flow_director_tos,
11557 (void *)&cmd_flow_director_tos_value,
11558 (void *)&cmd_flow_director_proto,
11559 (void *)&cmd_flow_director_proto_value,
11560 (void *)&cmd_flow_director_ttl,
11561 (void *)&cmd_flow_director_ttl_value,
11562 (void *)&cmd_flow_director_vlan,
11563 (void *)&cmd_flow_director_vlan_value,
11564 (void *)&cmd_flow_director_flexbytes,
11565 (void *)&cmd_flow_director_flexbytes_value,
11566 (void *)&cmd_flow_director_drop,
11567 (void *)&cmd_flow_director_pf_vf,
11568 (void *)&cmd_flow_director_queue,
11569 (void *)&cmd_flow_director_queue_id,
11570 (void *)&cmd_flow_director_fd_id,
11571 (void *)&cmd_flow_director_fd_id_value,
11576 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11577 .f = cmd_flow_director_filter_parsed,
11579 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11580 "director entry on NIC",
11582 (void *)&cmd_flow_director_filter,
11583 (void *)&cmd_flow_director_port_id,
11584 (void *)&cmd_flow_director_mode,
11585 (void *)&cmd_flow_director_mode_ip,
11586 (void *)&cmd_flow_director_ops,
11587 (void *)&cmd_flow_director_flow,
11588 (void *)&cmd_flow_director_flow_type,
11589 (void *)&cmd_flow_director_src,
11590 (void *)&cmd_flow_director_ip_src,
11591 (void *)&cmd_flow_director_port_src,
11592 (void *)&cmd_flow_director_dst,
11593 (void *)&cmd_flow_director_ip_dst,
11594 (void *)&cmd_flow_director_port_dst,
11595 (void *)&cmd_flow_director_tos,
11596 (void *)&cmd_flow_director_tos_value,
11597 (void *)&cmd_flow_director_ttl,
11598 (void *)&cmd_flow_director_ttl_value,
11599 (void *)&cmd_flow_director_vlan,
11600 (void *)&cmd_flow_director_vlan_value,
11601 (void *)&cmd_flow_director_flexbytes,
11602 (void *)&cmd_flow_director_flexbytes_value,
11603 (void *)&cmd_flow_director_drop,
11604 (void *)&cmd_flow_director_pf_vf,
11605 (void *)&cmd_flow_director_queue,
11606 (void *)&cmd_flow_director_queue_id,
11607 (void *)&cmd_flow_director_fd_id,
11608 (void *)&cmd_flow_director_fd_id_value,
11613 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11614 .f = cmd_flow_director_filter_parsed,
11616 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11617 "director entry on NIC",
11619 (void *)&cmd_flow_director_filter,
11620 (void *)&cmd_flow_director_port_id,
11621 (void *)&cmd_flow_director_mode,
11622 (void *)&cmd_flow_director_mode_ip,
11623 (void *)&cmd_flow_director_ops,
11624 (void *)&cmd_flow_director_flow,
11625 (void *)&cmd_flow_director_flow_type,
11626 (void *)&cmd_flow_director_src,
11627 (void *)&cmd_flow_director_ip_src,
11628 (void *)&cmd_flow_director_port_src,
11629 (void *)&cmd_flow_director_dst,
11630 (void *)&cmd_flow_director_ip_dst,
11631 (void *)&cmd_flow_director_port_dst,
11632 (void *)&cmd_flow_director_verify_tag,
11633 (void *)&cmd_flow_director_verify_tag_value,
11634 (void *)&cmd_flow_director_tos,
11635 (void *)&cmd_flow_director_tos_value,
11636 (void *)&cmd_flow_director_ttl,
11637 (void *)&cmd_flow_director_ttl_value,
11638 (void *)&cmd_flow_director_vlan,
11639 (void *)&cmd_flow_director_vlan_value,
11640 (void *)&cmd_flow_director_flexbytes,
11641 (void *)&cmd_flow_director_flexbytes_value,
11642 (void *)&cmd_flow_director_drop,
11643 (void *)&cmd_flow_director_pf_vf,
11644 (void *)&cmd_flow_director_queue,
11645 (void *)&cmd_flow_director_queue_id,
11646 (void *)&cmd_flow_director_fd_id,
11647 (void *)&cmd_flow_director_fd_id_value,
11652 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11653 .f = cmd_flow_director_filter_parsed,
11655 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11656 "director entry on NIC",
11658 (void *)&cmd_flow_director_filter,
11659 (void *)&cmd_flow_director_port_id,
11660 (void *)&cmd_flow_director_mode,
11661 (void *)&cmd_flow_director_mode_ip,
11662 (void *)&cmd_flow_director_ops,
11663 (void *)&cmd_flow_director_flow,
11664 (void *)&cmd_flow_director_flow_type,
11665 (void *)&cmd_flow_director_ether,
11666 (void *)&cmd_flow_director_ether_type,
11667 (void *)&cmd_flow_director_flexbytes,
11668 (void *)&cmd_flow_director_flexbytes_value,
11669 (void *)&cmd_flow_director_drop,
11670 (void *)&cmd_flow_director_pf_vf,
11671 (void *)&cmd_flow_director_queue,
11672 (void *)&cmd_flow_director_queue_id,
11673 (void *)&cmd_flow_director_fd_id,
11674 (void *)&cmd_flow_director_fd_id_value,
11679 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11680 .f = cmd_flow_director_filter_parsed,
11682 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11683 "director entry on NIC",
11685 (void *)&cmd_flow_director_filter,
11686 (void *)&cmd_flow_director_port_id,
11687 (void *)&cmd_flow_director_mode,
11688 (void *)&cmd_flow_director_mode_mac_vlan,
11689 (void *)&cmd_flow_director_ops,
11690 (void *)&cmd_flow_director_mac,
11691 (void *)&cmd_flow_director_mac_addr,
11692 (void *)&cmd_flow_director_vlan,
11693 (void *)&cmd_flow_director_vlan_value,
11694 (void *)&cmd_flow_director_flexbytes,
11695 (void *)&cmd_flow_director_flexbytes_value,
11696 (void *)&cmd_flow_director_drop,
11697 (void *)&cmd_flow_director_queue,
11698 (void *)&cmd_flow_director_queue_id,
11699 (void *)&cmd_flow_director_fd_id,
11700 (void *)&cmd_flow_director_fd_id_value,
11705 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11706 .f = cmd_flow_director_filter_parsed,
11708 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11709 "director entry on NIC",
11711 (void *)&cmd_flow_director_filter,
11712 (void *)&cmd_flow_director_port_id,
11713 (void *)&cmd_flow_director_mode,
11714 (void *)&cmd_flow_director_mode_tunnel,
11715 (void *)&cmd_flow_director_ops,
11716 (void *)&cmd_flow_director_mac,
11717 (void *)&cmd_flow_director_mac_addr,
11718 (void *)&cmd_flow_director_vlan,
11719 (void *)&cmd_flow_director_vlan_value,
11720 (void *)&cmd_flow_director_tunnel,
11721 (void *)&cmd_flow_director_tunnel_type,
11722 (void *)&cmd_flow_director_tunnel_id,
11723 (void *)&cmd_flow_director_tunnel_id_value,
11724 (void *)&cmd_flow_director_flexbytes,
11725 (void *)&cmd_flow_director_flexbytes_value,
11726 (void *)&cmd_flow_director_drop,
11727 (void *)&cmd_flow_director_queue,
11728 (void *)&cmd_flow_director_queue_id,
11729 (void *)&cmd_flow_director_fd_id,
11730 (void *)&cmd_flow_director_fd_id_value,
11735 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11736 .f = cmd_flow_director_filter_parsed,
11738 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11739 "director entry on NIC",
11741 (void *)&cmd_flow_director_filter,
11742 (void *)&cmd_flow_director_port_id,
11743 (void *)&cmd_flow_director_mode,
11744 (void *)&cmd_flow_director_mode_raw,
11745 (void *)&cmd_flow_director_ops,
11746 (void *)&cmd_flow_director_flow,
11747 (void *)&cmd_flow_director_flow_type,
11748 (void *)&cmd_flow_director_drop,
11749 (void *)&cmd_flow_director_queue,
11750 (void *)&cmd_flow_director_queue_id,
11751 (void *)&cmd_flow_director_fd_id,
11752 (void *)&cmd_flow_director_fd_id_value,
11753 (void *)&cmd_flow_director_packet,
11754 (void *)&cmd_flow_director_filepath,
11759 struct cmd_flush_flow_director_result {
11760 cmdline_fixed_string_t flush_flow_director;
11764 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11765 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11766 flush_flow_director, "flush_flow_director");
11767 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11768 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11772 cmd_flush_flow_director_parsed(void *parsed_result,
11773 __rte_unused struct cmdline *cl,
11774 __rte_unused void *data)
11776 struct cmd_flow_director_result *res = parsed_result;
11779 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11781 printf("flow director is not supported on port %u.\n",
11786 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11787 RTE_ETH_FILTER_FLUSH, NULL);
11789 printf("flow director table flushing error: (%s)\n",
11793 cmdline_parse_inst_t cmd_flush_flow_director = {
11794 .f = cmd_flush_flow_director_parsed,
11796 .help_str = "flush_flow_director <port_id>: "
11797 "Flush all flow director entries of a device on NIC",
11799 (void *)&cmd_flush_flow_director_flush,
11800 (void *)&cmd_flush_flow_director_port_id,
11805 /* *** deal with flow director mask *** */
11806 struct cmd_flow_director_mask_result {
11807 cmdline_fixed_string_t flow_director_mask;
11809 cmdline_fixed_string_t mode;
11810 cmdline_fixed_string_t mode_value;
11811 cmdline_fixed_string_t vlan;
11812 uint16_t vlan_mask;
11813 cmdline_fixed_string_t src_mask;
11814 cmdline_ipaddr_t ipv4_src;
11815 cmdline_ipaddr_t ipv6_src;
11817 cmdline_fixed_string_t dst_mask;
11818 cmdline_ipaddr_t ipv4_dst;
11819 cmdline_ipaddr_t ipv6_dst;
11821 cmdline_fixed_string_t mac;
11822 uint8_t mac_addr_byte_mask;
11823 cmdline_fixed_string_t tunnel_id;
11824 uint32_t tunnel_id_mask;
11825 cmdline_fixed_string_t tunnel_type;
11826 uint8_t tunnel_type_mask;
11830 cmd_flow_director_mask_parsed(void *parsed_result,
11831 __rte_unused struct cmdline *cl,
11832 __rte_unused void *data)
11834 struct cmd_flow_director_mask_result *res = parsed_result;
11835 struct rte_eth_fdir_masks *mask;
11836 struct rte_port *port;
11838 port = &ports[res->port_id];
11839 /** Check if the port is not started **/
11840 if (port->port_status != RTE_PORT_STOPPED) {
11841 printf("Please stop port %d first\n", res->port_id);
11845 mask = &port->dev_conf.fdir_conf.mask;
11847 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11848 if (strcmp(res->mode_value, "MAC-VLAN")) {
11849 printf("Please set mode to MAC-VLAN.\n");
11853 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11854 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11855 if (strcmp(res->mode_value, "Tunnel")) {
11856 printf("Please set mode to Tunnel.\n");
11860 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11861 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11862 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11863 mask->tunnel_type_mask = res->tunnel_type_mask;
11865 if (strcmp(res->mode_value, "IP")) {
11866 printf("Please set mode to IP.\n");
11870 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11871 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11872 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11873 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11874 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11875 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11876 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11879 cmd_reconfig_device_queue(res->port_id, 1, 1);
11882 cmdline_parse_token_string_t cmd_flow_director_mask =
11883 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11884 flow_director_mask, "flow_director_mask");
11885 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11886 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11888 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11889 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11891 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11892 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11893 vlan_mask, UINT16);
11894 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11895 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11896 src_mask, "src_mask");
11897 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11898 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11900 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11901 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11903 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11904 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11906 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11907 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11908 dst_mask, "dst_mask");
11909 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11910 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11912 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11913 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11915 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11916 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11919 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11920 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11922 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11923 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11925 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11926 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11927 mode_value, "MAC-VLAN");
11928 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11929 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11930 mode_value, "Tunnel");
11931 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11932 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11934 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11935 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11936 mac_addr_byte_mask, UINT8);
11937 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11938 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11939 tunnel_type, "tunnel-type");
11940 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11941 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11942 tunnel_type_mask, UINT8);
11943 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11944 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11945 tunnel_id, "tunnel-id");
11946 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11947 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11948 tunnel_id_mask, UINT32);
11950 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11951 .f = cmd_flow_director_mask_parsed,
11953 .help_str = "flow_director_mask ... : "
11954 "Set IP mode flow director's mask on NIC",
11956 (void *)&cmd_flow_director_mask,
11957 (void *)&cmd_flow_director_mask_port_id,
11958 (void *)&cmd_flow_director_mask_mode,
11959 (void *)&cmd_flow_director_mask_mode_ip,
11960 (void *)&cmd_flow_director_mask_vlan,
11961 (void *)&cmd_flow_director_mask_vlan_value,
11962 (void *)&cmd_flow_director_mask_src,
11963 (void *)&cmd_flow_director_mask_ipv4_src,
11964 (void *)&cmd_flow_director_mask_ipv6_src,
11965 (void *)&cmd_flow_director_mask_port_src,
11966 (void *)&cmd_flow_director_mask_dst,
11967 (void *)&cmd_flow_director_mask_ipv4_dst,
11968 (void *)&cmd_flow_director_mask_ipv6_dst,
11969 (void *)&cmd_flow_director_mask_port_dst,
11974 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11975 .f = cmd_flow_director_mask_parsed,
11977 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11978 "flow director's mask on NIC",
11980 (void *)&cmd_flow_director_mask,
11981 (void *)&cmd_flow_director_mask_port_id,
11982 (void *)&cmd_flow_director_mask_mode,
11983 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11984 (void *)&cmd_flow_director_mask_vlan,
11985 (void *)&cmd_flow_director_mask_vlan_value,
11990 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11991 .f = cmd_flow_director_mask_parsed,
11993 .help_str = "flow_director_mask ... : Set tunnel mode "
11994 "flow director's mask on NIC",
11996 (void *)&cmd_flow_director_mask,
11997 (void *)&cmd_flow_director_mask_port_id,
11998 (void *)&cmd_flow_director_mask_mode,
11999 (void *)&cmd_flow_director_mask_mode_tunnel,
12000 (void *)&cmd_flow_director_mask_vlan,
12001 (void *)&cmd_flow_director_mask_vlan_value,
12002 (void *)&cmd_flow_director_mask_mac,
12003 (void *)&cmd_flow_director_mask_mac_value,
12004 (void *)&cmd_flow_director_mask_tunnel_type,
12005 (void *)&cmd_flow_director_mask_tunnel_type_value,
12006 (void *)&cmd_flow_director_mask_tunnel_id,
12007 (void *)&cmd_flow_director_mask_tunnel_id_value,
12012 /* *** deal with flow director mask on flexible payload *** */
12013 struct cmd_flow_director_flex_mask_result {
12014 cmdline_fixed_string_t flow_director_flexmask;
12016 cmdline_fixed_string_t flow;
12017 cmdline_fixed_string_t flow_type;
12018 cmdline_fixed_string_t mask;
12022 cmd_flow_director_flex_mask_parsed(void *parsed_result,
12023 __rte_unused struct cmdline *cl,
12024 __rte_unused void *data)
12026 struct cmd_flow_director_flex_mask_result *res = parsed_result;
12027 struct rte_eth_fdir_info fdir_info;
12028 struct rte_eth_fdir_flex_mask flex_mask;
12029 struct rte_port *port;
12030 uint64_t flow_type_mask;
12034 port = &ports[res->port_id];
12035 /** Check if the port is not started **/
12036 if (port->port_status != RTE_PORT_STOPPED) {
12037 printf("Please stop port %d first\n", res->port_id);
12041 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
12042 ret = parse_flexbytes(res->mask,
12044 RTE_ETH_FDIR_MAX_FLEXLEN);
12046 printf("error: Cannot parse mask input.\n");
12050 memset(&fdir_info, 0, sizeof(fdir_info));
12051 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12052 RTE_ETH_FILTER_INFO, &fdir_info);
12054 printf("Cannot get FDir filter info\n");
12058 if (!strcmp(res->flow_type, "none")) {
12059 /* means don't specify the flow type */
12060 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
12061 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
12062 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
12063 0, sizeof(struct rte_eth_fdir_flex_mask));
12064 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
12065 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
12067 sizeof(struct rte_eth_fdir_flex_mask));
12068 cmd_reconfig_device_queue(res->port_id, 1, 1);
12071 flow_type_mask = fdir_info.flow_types_mask[0];
12072 if (!strcmp(res->flow_type, "all")) {
12073 if (!flow_type_mask) {
12074 printf("No flow type supported\n");
12077 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
12078 if (flow_type_mask & (1ULL << i)) {
12079 flex_mask.flow_type = i;
12080 fdir_set_flex_mask(res->port_id, &flex_mask);
12083 cmd_reconfig_device_queue(res->port_id, 1, 1);
12086 flex_mask.flow_type = str2flowtype(res->flow_type);
12087 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
12088 printf("Flow type %s not supported on port %d\n",
12089 res->flow_type, res->port_id);
12092 fdir_set_flex_mask(res->port_id, &flex_mask);
12093 cmd_reconfig_device_queue(res->port_id, 1, 1);
12096 cmdline_parse_token_string_t cmd_flow_director_flexmask =
12097 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12098 flow_director_flexmask,
12099 "flow_director_flex_mask");
12100 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
12101 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12103 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
12104 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12106 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
12107 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12108 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
12109 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
12110 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
12111 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12114 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
12115 .f = cmd_flow_director_flex_mask_parsed,
12117 .help_str = "flow_director_flex_mask ... : "
12118 "Set flow director's flex mask on NIC",
12120 (void *)&cmd_flow_director_flexmask,
12121 (void *)&cmd_flow_director_flexmask_port_id,
12122 (void *)&cmd_flow_director_flexmask_flow,
12123 (void *)&cmd_flow_director_flexmask_flow_type,
12124 (void *)&cmd_flow_director_flexmask_mask,
12129 /* *** deal with flow director flexible payload configuration *** */
12130 struct cmd_flow_director_flexpayload_result {
12131 cmdline_fixed_string_t flow_director_flexpayload;
12133 cmdline_fixed_string_t payload_layer;
12134 cmdline_fixed_string_t payload_cfg;
12138 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
12141 const char *p, *p0 = q_arg;
12143 unsigned long int_fld;
12144 char *str_fld[max_num];
12149 p = strchr(p0, '(');
12153 p0 = strchr(p, ')');
12158 if (size >= sizeof(s))
12161 snprintf(s, sizeof(s), "%.*s", size, p);
12162 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12163 if (ret < 0 || ret > max_num)
12165 for (i = 0; i < ret; i++) {
12167 int_fld = strtoul(str_fld[i], &end, 0);
12168 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12170 offsets[i] = (uint16_t)int_fld;
12176 cmd_flow_director_flxpld_parsed(void *parsed_result,
12177 __rte_unused struct cmdline *cl,
12178 __rte_unused void *data)
12180 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12181 struct rte_eth_flex_payload_cfg flex_cfg;
12182 struct rte_port *port;
12185 port = &ports[res->port_id];
12186 /** Check if the port is not started **/
12187 if (port->port_status != RTE_PORT_STOPPED) {
12188 printf("Please stop port %d first\n", res->port_id);
12192 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12194 if (!strcmp(res->payload_layer, "raw"))
12195 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12196 else if (!strcmp(res->payload_layer, "l2"))
12197 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12198 else if (!strcmp(res->payload_layer, "l3"))
12199 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12200 else if (!strcmp(res->payload_layer, "l4"))
12201 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12203 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12204 RTE_ETH_FDIR_MAX_FLEXLEN);
12206 printf("error: Cannot parse flex payload input.\n");
12210 fdir_set_flex_payload(res->port_id, &flex_cfg);
12211 cmd_reconfig_device_queue(res->port_id, 1, 1);
12214 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12215 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12216 flow_director_flexpayload,
12217 "flow_director_flex_payload");
12218 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12219 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12221 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12222 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12223 payload_layer, "raw#l2#l3#l4");
12224 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12225 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12226 payload_cfg, NULL);
12228 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12229 .f = cmd_flow_director_flxpld_parsed,
12231 .help_str = "flow_director_flexpayload ... : "
12232 "Set flow director's flex payload on NIC",
12234 (void *)&cmd_flow_director_flexpayload,
12235 (void *)&cmd_flow_director_flexpayload_port_id,
12236 (void *)&cmd_flow_director_flexpayload_payload_layer,
12237 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12242 /* Generic flow interface command. */
12243 extern cmdline_parse_inst_t cmd_flow;
12245 /* *** Classification Filters Control *** */
12246 /* *** Get symmetric hash enable per port *** */
12247 struct cmd_get_sym_hash_ena_per_port_result {
12248 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12253 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12254 __rte_unused struct cmdline *cl,
12255 __rte_unused void *data)
12257 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12258 struct rte_eth_hash_filter_info info;
12261 if (rte_eth_dev_filter_supported(res->port_id,
12262 RTE_ETH_FILTER_HASH) < 0) {
12263 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12268 memset(&info, 0, sizeof(info));
12269 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12270 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12271 RTE_ETH_FILTER_GET, &info);
12274 printf("Cannot get symmetric hash enable per port "
12275 "on port %u\n", res->port_id);
12279 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12280 "enabled" : "disabled", res->port_id);
12283 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12284 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12285 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12286 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12287 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12290 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12291 .f = cmd_get_sym_hash_per_port_parsed,
12293 .help_str = "get_sym_hash_ena_per_port <port_id>",
12295 (void *)&cmd_get_sym_hash_ena_per_port_all,
12296 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12301 /* *** Set symmetric hash enable per port *** */
12302 struct cmd_set_sym_hash_ena_per_port_result {
12303 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12304 cmdline_fixed_string_t enable;
12309 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12310 __rte_unused struct cmdline *cl,
12311 __rte_unused void *data)
12313 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12314 struct rte_eth_hash_filter_info info;
12317 if (rte_eth_dev_filter_supported(res->port_id,
12318 RTE_ETH_FILTER_HASH) < 0) {
12319 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12324 memset(&info, 0, sizeof(info));
12325 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12326 if (!strcmp(res->enable, "enable"))
12327 info.info.enable = 1;
12328 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12329 RTE_ETH_FILTER_SET, &info);
12331 printf("Cannot set symmetric hash enable per port on "
12332 "port %u\n", res->port_id);
12335 printf("Symmetric hash has been set to %s on port %u\n",
12336 res->enable, res->port_id);
12339 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12340 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12341 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12342 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12343 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12345 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12346 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12347 enable, "enable#disable");
12349 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12350 .f = cmd_set_sym_hash_per_port_parsed,
12352 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12354 (void *)&cmd_set_sym_hash_ena_per_port_all,
12355 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12356 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12361 /* Get global config of hash function */
12362 struct cmd_get_hash_global_config_result {
12363 cmdline_fixed_string_t get_hash_global_config;
12368 flowtype_to_str(uint16_t ftype)
12374 } ftype_table[] = {
12375 {"ipv4", RTE_ETH_FLOW_IPV4},
12376 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12377 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12378 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12379 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12380 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12381 {"ipv6", RTE_ETH_FLOW_IPV6},
12382 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12383 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12384 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12385 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12386 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12387 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12388 {"port", RTE_ETH_FLOW_PORT},
12389 {"vxlan", RTE_ETH_FLOW_VXLAN},
12390 {"geneve", RTE_ETH_FLOW_GENEVE},
12391 {"nvgre", RTE_ETH_FLOW_NVGRE},
12392 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12395 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12396 if (ftype_table[i].ftype == ftype)
12397 return ftype_table[i].str;
12404 cmd_get_hash_global_config_parsed(void *parsed_result,
12405 __rte_unused struct cmdline *cl,
12406 __rte_unused void *data)
12408 struct cmd_get_hash_global_config_result *res = parsed_result;
12409 struct rte_eth_hash_filter_info info;
12410 uint32_t idx, offset;
12415 if (rte_eth_dev_filter_supported(res->port_id,
12416 RTE_ETH_FILTER_HASH) < 0) {
12417 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12422 memset(&info, 0, sizeof(info));
12423 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12424 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12425 RTE_ETH_FILTER_GET, &info);
12427 printf("Cannot get hash global configurations by port %d\n",
12432 switch (info.info.global_conf.hash_func) {
12433 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12434 printf("Hash function is Toeplitz\n");
12436 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12437 printf("Hash function is Simple XOR\n");
12439 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12440 printf("Hash function is Symmetric Toeplitz\n");
12443 printf("Unknown hash function\n");
12447 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12448 idx = i / UINT64_BIT;
12449 offset = i % UINT64_BIT;
12450 if (!(info.info.global_conf.valid_bit_mask[idx] &
12453 str = flowtype_to_str(i);
12456 printf("Symmetric hash is %s globally for flow type %s "
12458 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12459 (1ULL << offset)) ? "enabled" : "disabled"), str,
12464 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12465 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12466 get_hash_global_config, "get_hash_global_config");
12467 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12468 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12471 cmdline_parse_inst_t cmd_get_hash_global_config = {
12472 .f = cmd_get_hash_global_config_parsed,
12474 .help_str = "get_hash_global_config <port_id>",
12476 (void *)&cmd_get_hash_global_config_all,
12477 (void *)&cmd_get_hash_global_config_port_id,
12482 /* Set global config of hash function */
12483 struct cmd_set_hash_global_config_result {
12484 cmdline_fixed_string_t set_hash_global_config;
12486 cmdline_fixed_string_t hash_func;
12487 cmdline_fixed_string_t flow_type;
12488 cmdline_fixed_string_t enable;
12492 cmd_set_hash_global_config_parsed(void *parsed_result,
12493 __rte_unused struct cmdline *cl,
12494 __rte_unused void *data)
12496 struct cmd_set_hash_global_config_result *res = parsed_result;
12497 struct rte_eth_hash_filter_info info;
12498 uint32_t ftype, idx, offset;
12501 if (rte_eth_dev_filter_supported(res->port_id,
12502 RTE_ETH_FILTER_HASH) < 0) {
12503 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12507 memset(&info, 0, sizeof(info));
12508 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12509 if (!strcmp(res->hash_func, "toeplitz"))
12510 info.info.global_conf.hash_func =
12511 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12512 else if (!strcmp(res->hash_func, "simple_xor"))
12513 info.info.global_conf.hash_func =
12514 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12515 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12516 info.info.global_conf.hash_func =
12517 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12518 else if (!strcmp(res->hash_func, "default"))
12519 info.info.global_conf.hash_func =
12520 RTE_ETH_HASH_FUNCTION_DEFAULT;
12522 ftype = str2flowtype(res->flow_type);
12523 idx = ftype / UINT64_BIT;
12524 offset = ftype % UINT64_BIT;
12525 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12526 if (!strcmp(res->enable, "enable"))
12527 info.info.global_conf.sym_hash_enable_mask[idx] |=
12529 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12530 RTE_ETH_FILTER_SET, &info);
12532 printf("Cannot set global hash configurations by port %d\n",
12535 printf("Global hash configurations have been set "
12536 "successfully by port %d\n", res->port_id);
12539 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12540 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12541 set_hash_global_config, "set_hash_global_config");
12542 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12543 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12545 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12546 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12547 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12548 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12549 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12551 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12552 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12553 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12554 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12555 enable, "enable#disable");
12557 cmdline_parse_inst_t cmd_set_hash_global_config = {
12558 .f = cmd_set_hash_global_config_parsed,
12560 .help_str = "set_hash_global_config <port_id> "
12561 "toeplitz|simple_xor|symmetric_toeplitz|default "
12562 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12563 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12564 "l2_payload enable|disable",
12566 (void *)&cmd_set_hash_global_config_all,
12567 (void *)&cmd_set_hash_global_config_port_id,
12568 (void *)&cmd_set_hash_global_config_hash_func,
12569 (void *)&cmd_set_hash_global_config_flow_type,
12570 (void *)&cmd_set_hash_global_config_enable,
12575 /* Set hash input set */
12576 struct cmd_set_hash_input_set_result {
12577 cmdline_fixed_string_t set_hash_input_set;
12579 cmdline_fixed_string_t flow_type;
12580 cmdline_fixed_string_t inset_field;
12581 cmdline_fixed_string_t select;
12584 static enum rte_eth_input_set_field
12585 str2inset(char *string)
12589 static const struct {
12591 enum rte_eth_input_set_field inset;
12592 } inset_table[] = {
12593 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12594 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12595 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12596 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12597 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12598 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12599 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12600 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12601 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12602 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12603 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12604 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12605 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12606 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12607 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12608 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12609 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12610 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12611 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12612 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12613 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12614 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12615 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12616 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12617 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12618 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12619 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12620 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12621 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12622 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12623 {"none", RTE_ETH_INPUT_SET_NONE},
12626 for (i = 0; i < RTE_DIM(inset_table); i++) {
12627 if (!strcmp(string, inset_table[i].str))
12628 return inset_table[i].inset;
12631 return RTE_ETH_INPUT_SET_UNKNOWN;
12635 cmd_set_hash_input_set_parsed(void *parsed_result,
12636 __rte_unused struct cmdline *cl,
12637 __rte_unused void *data)
12639 struct cmd_set_hash_input_set_result *res = parsed_result;
12640 struct rte_eth_hash_filter_info info;
12642 memset(&info, 0, sizeof(info));
12643 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12644 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12645 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12646 info.info.input_set_conf.inset_size = 1;
12647 if (!strcmp(res->select, "select"))
12648 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12649 else if (!strcmp(res->select, "add"))
12650 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12651 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12652 RTE_ETH_FILTER_SET, &info);
12655 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12656 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12657 set_hash_input_set, "set_hash_input_set");
12658 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12659 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12661 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12662 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12664 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12665 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12667 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12668 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12669 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12670 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12671 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12673 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12674 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12675 select, "select#add");
12677 cmdline_parse_inst_t cmd_set_hash_input_set = {
12678 .f = cmd_set_hash_input_set_parsed,
12680 .help_str = "set_hash_input_set <port_id> "
12681 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12682 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12683 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12684 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12685 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12686 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12687 "fld-7th|fld-8th|none select|add",
12689 (void *)&cmd_set_hash_input_set_cmd,
12690 (void *)&cmd_set_hash_input_set_port_id,
12691 (void *)&cmd_set_hash_input_set_flow_type,
12692 (void *)&cmd_set_hash_input_set_field,
12693 (void *)&cmd_set_hash_input_set_select,
12698 /* Set flow director input set */
12699 struct cmd_set_fdir_input_set_result {
12700 cmdline_fixed_string_t set_fdir_input_set;
12702 cmdline_fixed_string_t flow_type;
12703 cmdline_fixed_string_t inset_field;
12704 cmdline_fixed_string_t select;
12708 cmd_set_fdir_input_set_parsed(void *parsed_result,
12709 __rte_unused struct cmdline *cl,
12710 __rte_unused void *data)
12712 struct cmd_set_fdir_input_set_result *res = parsed_result;
12713 struct rte_eth_fdir_filter_info info;
12715 memset(&info, 0, sizeof(info));
12716 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12717 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12718 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12719 info.info.input_set_conf.inset_size = 1;
12720 if (!strcmp(res->select, "select"))
12721 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12722 else if (!strcmp(res->select, "add"))
12723 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12724 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12725 RTE_ETH_FILTER_SET, &info);
12728 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12729 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12730 set_fdir_input_set, "set_fdir_input_set");
12731 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12732 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12734 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12735 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12737 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12738 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12739 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12740 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12742 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12743 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12744 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12745 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12746 "sctp-veri-tag#none");
12747 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12748 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12749 select, "select#add");
12751 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12752 .f = cmd_set_fdir_input_set_parsed,
12754 .help_str = "set_fdir_input_set <port_id> "
12755 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12756 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12757 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12758 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12759 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12760 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12761 "sctp-veri-tag|none select|add",
12763 (void *)&cmd_set_fdir_input_set_cmd,
12764 (void *)&cmd_set_fdir_input_set_port_id,
12765 (void *)&cmd_set_fdir_input_set_flow_type,
12766 (void *)&cmd_set_fdir_input_set_field,
12767 (void *)&cmd_set_fdir_input_set_select,
12772 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12773 struct cmd_mcast_addr_result {
12774 cmdline_fixed_string_t mcast_addr_cmd;
12775 cmdline_fixed_string_t what;
12777 struct rte_ether_addr mc_addr;
12780 static void cmd_mcast_addr_parsed(void *parsed_result,
12781 __rte_unused struct cmdline *cl,
12782 __rte_unused void *data)
12784 struct cmd_mcast_addr_result *res = parsed_result;
12786 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12787 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12788 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12789 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12790 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12793 if (strcmp(res->what, "add") == 0)
12794 mcast_addr_add(res->port_num, &res->mc_addr);
12796 mcast_addr_remove(res->port_num, &res->mc_addr);
12799 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12800 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12801 mcast_addr_cmd, "mcast_addr");
12802 cmdline_parse_token_string_t cmd_mcast_addr_what =
12803 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12805 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12806 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12807 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12808 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12810 cmdline_parse_inst_t cmd_mcast_addr = {
12811 .f = cmd_mcast_addr_parsed,
12813 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12814 "Add/Remove multicast MAC address on port_id",
12816 (void *)&cmd_mcast_addr_cmd,
12817 (void *)&cmd_mcast_addr_what,
12818 (void *)&cmd_mcast_addr_portnum,
12819 (void *)&cmd_mcast_addr_addr,
12824 /* l2 tunnel config
12825 * only support E-tag now.
12828 /* Ether type config */
12829 struct cmd_config_l2_tunnel_eth_type_result {
12830 cmdline_fixed_string_t port;
12831 cmdline_fixed_string_t config;
12832 cmdline_fixed_string_t all;
12834 cmdline_fixed_string_t l2_tunnel;
12835 cmdline_fixed_string_t l2_tunnel_type;
12836 cmdline_fixed_string_t eth_type;
12837 uint16_t eth_type_val;
12840 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12841 TOKEN_STRING_INITIALIZER
12842 (struct cmd_config_l2_tunnel_eth_type_result,
12844 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12845 TOKEN_STRING_INITIALIZER
12846 (struct cmd_config_l2_tunnel_eth_type_result,
12848 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12849 TOKEN_STRING_INITIALIZER
12850 (struct cmd_config_l2_tunnel_eth_type_result,
12852 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12853 TOKEN_NUM_INITIALIZER
12854 (struct cmd_config_l2_tunnel_eth_type_result,
12856 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12857 TOKEN_STRING_INITIALIZER
12858 (struct cmd_config_l2_tunnel_eth_type_result,
12859 l2_tunnel, "l2-tunnel");
12860 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12861 TOKEN_STRING_INITIALIZER
12862 (struct cmd_config_l2_tunnel_eth_type_result,
12863 l2_tunnel_type, "E-tag");
12864 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12865 TOKEN_STRING_INITIALIZER
12866 (struct cmd_config_l2_tunnel_eth_type_result,
12867 eth_type, "ether-type");
12868 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12869 TOKEN_NUM_INITIALIZER
12870 (struct cmd_config_l2_tunnel_eth_type_result,
12871 eth_type_val, UINT16);
12873 static enum rte_eth_tunnel_type
12874 str2fdir_l2_tunnel_type(char *string)
12878 static const struct {
12880 enum rte_eth_tunnel_type type;
12881 } l2_tunnel_type_str[] = {
12882 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12885 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12886 if (!strcmp(l2_tunnel_type_str[i].str, string))
12887 return l2_tunnel_type_str[i].type;
12889 return RTE_TUNNEL_TYPE_NONE;
12892 /* ether type config for all ports */
12894 cmd_config_l2_tunnel_eth_type_all_parsed
12895 (void *parsed_result,
12896 __rte_unused struct cmdline *cl,
12897 __rte_unused void *data)
12899 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12900 struct rte_eth_l2_tunnel_conf entry;
12903 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12904 entry.ether_type = res->eth_type_val;
12906 RTE_ETH_FOREACH_DEV(pid) {
12907 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12911 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12912 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12914 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12916 (void *)&cmd_config_l2_tunnel_eth_type_port,
12917 (void *)&cmd_config_l2_tunnel_eth_type_config,
12918 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12919 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12920 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12921 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12922 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12927 /* ether type config for a specific port */
12929 cmd_config_l2_tunnel_eth_type_specific_parsed(
12930 void *parsed_result,
12931 __rte_unused struct cmdline *cl,
12932 __rte_unused void *data)
12934 struct cmd_config_l2_tunnel_eth_type_result *res =
12936 struct rte_eth_l2_tunnel_conf entry;
12938 if (port_id_is_invalid(res->id, ENABLED_WARN))
12941 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12942 entry.ether_type = res->eth_type_val;
12944 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12947 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12948 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12950 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12952 (void *)&cmd_config_l2_tunnel_eth_type_port,
12953 (void *)&cmd_config_l2_tunnel_eth_type_config,
12954 (void *)&cmd_config_l2_tunnel_eth_type_id,
12955 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12956 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12957 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12958 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12963 /* Enable/disable l2 tunnel */
12964 struct cmd_config_l2_tunnel_en_dis_result {
12965 cmdline_fixed_string_t port;
12966 cmdline_fixed_string_t config;
12967 cmdline_fixed_string_t all;
12969 cmdline_fixed_string_t l2_tunnel;
12970 cmdline_fixed_string_t l2_tunnel_type;
12971 cmdline_fixed_string_t en_dis;
12974 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12975 TOKEN_STRING_INITIALIZER
12976 (struct cmd_config_l2_tunnel_en_dis_result,
12978 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12979 TOKEN_STRING_INITIALIZER
12980 (struct cmd_config_l2_tunnel_en_dis_result,
12982 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12983 TOKEN_STRING_INITIALIZER
12984 (struct cmd_config_l2_tunnel_en_dis_result,
12986 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12987 TOKEN_NUM_INITIALIZER
12988 (struct cmd_config_l2_tunnel_en_dis_result,
12990 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12991 TOKEN_STRING_INITIALIZER
12992 (struct cmd_config_l2_tunnel_en_dis_result,
12993 l2_tunnel, "l2-tunnel");
12994 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12995 TOKEN_STRING_INITIALIZER
12996 (struct cmd_config_l2_tunnel_en_dis_result,
12997 l2_tunnel_type, "E-tag");
12998 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12999 TOKEN_STRING_INITIALIZER
13000 (struct cmd_config_l2_tunnel_en_dis_result,
13001 en_dis, "enable#disable");
13003 /* enable/disable l2 tunnel for all ports */
13005 cmd_config_l2_tunnel_en_dis_all_parsed(
13006 void *parsed_result,
13007 __rte_unused struct cmdline *cl,
13008 __rte_unused void *data)
13010 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
13011 struct rte_eth_l2_tunnel_conf entry;
13015 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13017 if (!strcmp("enable", res->en_dis))
13022 RTE_ETH_FOREACH_DEV(pid) {
13023 rte_eth_dev_l2_tunnel_offload_set(pid,
13025 ETH_L2_TUNNEL_ENABLE_MASK,
13030 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
13031 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
13033 .help_str = "port config all l2-tunnel E-tag enable|disable",
13035 (void *)&cmd_config_l2_tunnel_en_dis_port,
13036 (void *)&cmd_config_l2_tunnel_en_dis_config,
13037 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
13038 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13039 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13040 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13045 /* enable/disable l2 tunnel for a port */
13047 cmd_config_l2_tunnel_en_dis_specific_parsed(
13048 void *parsed_result,
13049 __rte_unused struct cmdline *cl,
13050 __rte_unused void *data)
13052 struct cmd_config_l2_tunnel_en_dis_result *res =
13054 struct rte_eth_l2_tunnel_conf entry;
13056 if (port_id_is_invalid(res->id, ENABLED_WARN))
13059 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13061 if (!strcmp("enable", res->en_dis))
13062 rte_eth_dev_l2_tunnel_offload_set(res->id,
13064 ETH_L2_TUNNEL_ENABLE_MASK,
13067 rte_eth_dev_l2_tunnel_offload_set(res->id,
13069 ETH_L2_TUNNEL_ENABLE_MASK,
13073 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
13074 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
13076 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
13078 (void *)&cmd_config_l2_tunnel_en_dis_port,
13079 (void *)&cmd_config_l2_tunnel_en_dis_config,
13080 (void *)&cmd_config_l2_tunnel_en_dis_id,
13081 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13082 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13083 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13088 /* E-tag configuration */
13090 /* Common result structure for all E-tag configuration */
13091 struct cmd_config_e_tag_result {
13092 cmdline_fixed_string_t e_tag;
13093 cmdline_fixed_string_t set;
13094 cmdline_fixed_string_t insertion;
13095 cmdline_fixed_string_t stripping;
13096 cmdline_fixed_string_t forwarding;
13097 cmdline_fixed_string_t filter;
13098 cmdline_fixed_string_t add;
13099 cmdline_fixed_string_t del;
13100 cmdline_fixed_string_t on;
13101 cmdline_fixed_string_t off;
13102 cmdline_fixed_string_t on_off;
13103 cmdline_fixed_string_t port_tag_id;
13104 uint32_t port_tag_id_val;
13105 cmdline_fixed_string_t e_tag_id;
13106 uint16_t e_tag_id_val;
13107 cmdline_fixed_string_t dst_pool;
13108 uint8_t dst_pool_val;
13109 cmdline_fixed_string_t port;
13111 cmdline_fixed_string_t vf;
13115 /* Common CLI fields for all E-tag configuration */
13116 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
13117 TOKEN_STRING_INITIALIZER
13118 (struct cmd_config_e_tag_result,
13120 cmdline_parse_token_string_t cmd_config_e_tag_set =
13121 TOKEN_STRING_INITIALIZER
13122 (struct cmd_config_e_tag_result,
13124 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
13125 TOKEN_STRING_INITIALIZER
13126 (struct cmd_config_e_tag_result,
13127 insertion, "insertion");
13128 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
13129 TOKEN_STRING_INITIALIZER
13130 (struct cmd_config_e_tag_result,
13131 stripping, "stripping");
13132 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
13133 TOKEN_STRING_INITIALIZER
13134 (struct cmd_config_e_tag_result,
13135 forwarding, "forwarding");
13136 cmdline_parse_token_string_t cmd_config_e_tag_filter =
13137 TOKEN_STRING_INITIALIZER
13138 (struct cmd_config_e_tag_result,
13140 cmdline_parse_token_string_t cmd_config_e_tag_add =
13141 TOKEN_STRING_INITIALIZER
13142 (struct cmd_config_e_tag_result,
13144 cmdline_parse_token_string_t cmd_config_e_tag_del =
13145 TOKEN_STRING_INITIALIZER
13146 (struct cmd_config_e_tag_result,
13148 cmdline_parse_token_string_t cmd_config_e_tag_on =
13149 TOKEN_STRING_INITIALIZER
13150 (struct cmd_config_e_tag_result,
13152 cmdline_parse_token_string_t cmd_config_e_tag_off =
13153 TOKEN_STRING_INITIALIZER
13154 (struct cmd_config_e_tag_result,
13156 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13157 TOKEN_STRING_INITIALIZER
13158 (struct cmd_config_e_tag_result,
13160 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13161 TOKEN_STRING_INITIALIZER
13162 (struct cmd_config_e_tag_result,
13163 port_tag_id, "port-tag-id");
13164 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13165 TOKEN_NUM_INITIALIZER
13166 (struct cmd_config_e_tag_result,
13167 port_tag_id_val, UINT32);
13168 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13169 TOKEN_STRING_INITIALIZER
13170 (struct cmd_config_e_tag_result,
13171 e_tag_id, "e-tag-id");
13172 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13173 TOKEN_NUM_INITIALIZER
13174 (struct cmd_config_e_tag_result,
13175 e_tag_id_val, UINT16);
13176 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13177 TOKEN_STRING_INITIALIZER
13178 (struct cmd_config_e_tag_result,
13179 dst_pool, "dst-pool");
13180 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13181 TOKEN_NUM_INITIALIZER
13182 (struct cmd_config_e_tag_result,
13183 dst_pool_val, UINT8);
13184 cmdline_parse_token_string_t cmd_config_e_tag_port =
13185 TOKEN_STRING_INITIALIZER
13186 (struct cmd_config_e_tag_result,
13188 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13189 TOKEN_NUM_INITIALIZER
13190 (struct cmd_config_e_tag_result,
13192 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13193 TOKEN_STRING_INITIALIZER
13194 (struct cmd_config_e_tag_result,
13196 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13197 TOKEN_NUM_INITIALIZER
13198 (struct cmd_config_e_tag_result,
13201 /* E-tag insertion configuration */
13203 cmd_config_e_tag_insertion_en_parsed(
13204 void *parsed_result,
13205 __rte_unused struct cmdline *cl,
13206 __rte_unused void *data)
13208 struct cmd_config_e_tag_result *res =
13210 struct rte_eth_l2_tunnel_conf entry;
13212 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13215 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13216 entry.tunnel_id = res->port_tag_id_val;
13217 entry.vf_id = res->vf_id;
13218 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13220 ETH_L2_TUNNEL_INSERTION_MASK,
13225 cmd_config_e_tag_insertion_dis_parsed(
13226 void *parsed_result,
13227 __rte_unused struct cmdline *cl,
13228 __rte_unused void *data)
13230 struct cmd_config_e_tag_result *res =
13232 struct rte_eth_l2_tunnel_conf entry;
13234 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13237 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13238 entry.vf_id = res->vf_id;
13240 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13242 ETH_L2_TUNNEL_INSERTION_MASK,
13246 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13247 .f = cmd_config_e_tag_insertion_en_parsed,
13249 .help_str = "E-tag ... : E-tag insertion enable",
13251 (void *)&cmd_config_e_tag_e_tag,
13252 (void *)&cmd_config_e_tag_set,
13253 (void *)&cmd_config_e_tag_insertion,
13254 (void *)&cmd_config_e_tag_on,
13255 (void *)&cmd_config_e_tag_port_tag_id,
13256 (void *)&cmd_config_e_tag_port_tag_id_val,
13257 (void *)&cmd_config_e_tag_port,
13258 (void *)&cmd_config_e_tag_port_id,
13259 (void *)&cmd_config_e_tag_vf,
13260 (void *)&cmd_config_e_tag_vf_id,
13265 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13266 .f = cmd_config_e_tag_insertion_dis_parsed,
13268 .help_str = "E-tag ... : E-tag insertion disable",
13270 (void *)&cmd_config_e_tag_e_tag,
13271 (void *)&cmd_config_e_tag_set,
13272 (void *)&cmd_config_e_tag_insertion,
13273 (void *)&cmd_config_e_tag_off,
13274 (void *)&cmd_config_e_tag_port,
13275 (void *)&cmd_config_e_tag_port_id,
13276 (void *)&cmd_config_e_tag_vf,
13277 (void *)&cmd_config_e_tag_vf_id,
13282 /* E-tag stripping configuration */
13284 cmd_config_e_tag_stripping_parsed(
13285 void *parsed_result,
13286 __rte_unused struct cmdline *cl,
13287 __rte_unused void *data)
13289 struct cmd_config_e_tag_result *res =
13291 struct rte_eth_l2_tunnel_conf entry;
13293 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13296 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13298 if (!strcmp(res->on_off, "on"))
13299 rte_eth_dev_l2_tunnel_offload_set
13302 ETH_L2_TUNNEL_STRIPPING_MASK,
13305 rte_eth_dev_l2_tunnel_offload_set
13308 ETH_L2_TUNNEL_STRIPPING_MASK,
13312 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13313 .f = cmd_config_e_tag_stripping_parsed,
13315 .help_str = "E-tag ... : E-tag stripping enable/disable",
13317 (void *)&cmd_config_e_tag_e_tag,
13318 (void *)&cmd_config_e_tag_set,
13319 (void *)&cmd_config_e_tag_stripping,
13320 (void *)&cmd_config_e_tag_on_off,
13321 (void *)&cmd_config_e_tag_port,
13322 (void *)&cmd_config_e_tag_port_id,
13327 /* E-tag forwarding configuration */
13329 cmd_config_e_tag_forwarding_parsed(
13330 void *parsed_result,
13331 __rte_unused struct cmdline *cl,
13332 __rte_unused void *data)
13334 struct cmd_config_e_tag_result *res = parsed_result;
13335 struct rte_eth_l2_tunnel_conf entry;
13337 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13340 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13342 if (!strcmp(res->on_off, "on"))
13343 rte_eth_dev_l2_tunnel_offload_set
13346 ETH_L2_TUNNEL_FORWARDING_MASK,
13349 rte_eth_dev_l2_tunnel_offload_set
13352 ETH_L2_TUNNEL_FORWARDING_MASK,
13356 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13357 .f = cmd_config_e_tag_forwarding_parsed,
13359 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13361 (void *)&cmd_config_e_tag_e_tag,
13362 (void *)&cmd_config_e_tag_set,
13363 (void *)&cmd_config_e_tag_forwarding,
13364 (void *)&cmd_config_e_tag_on_off,
13365 (void *)&cmd_config_e_tag_port,
13366 (void *)&cmd_config_e_tag_port_id,
13371 /* E-tag filter configuration */
13373 cmd_config_e_tag_filter_add_parsed(
13374 void *parsed_result,
13375 __rte_unused struct cmdline *cl,
13376 __rte_unused void *data)
13378 struct cmd_config_e_tag_result *res = parsed_result;
13379 struct rte_eth_l2_tunnel_conf entry;
13382 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13385 if (res->e_tag_id_val > 0x3fff) {
13386 printf("e-tag-id must be equal or less than 0x3fff.\n");
13390 ret = rte_eth_dev_filter_supported(res->port_id,
13391 RTE_ETH_FILTER_L2_TUNNEL);
13393 printf("E-tag filter is not supported on port %u.\n",
13398 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13399 entry.tunnel_id = res->e_tag_id_val;
13400 entry.pool = res->dst_pool_val;
13402 ret = rte_eth_dev_filter_ctrl(res->port_id,
13403 RTE_ETH_FILTER_L2_TUNNEL,
13404 RTE_ETH_FILTER_ADD,
13407 printf("E-tag filter programming error: (%s)\n",
13411 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13412 .f = cmd_config_e_tag_filter_add_parsed,
13414 .help_str = "E-tag ... : E-tag filter add",
13416 (void *)&cmd_config_e_tag_e_tag,
13417 (void *)&cmd_config_e_tag_set,
13418 (void *)&cmd_config_e_tag_filter,
13419 (void *)&cmd_config_e_tag_add,
13420 (void *)&cmd_config_e_tag_e_tag_id,
13421 (void *)&cmd_config_e_tag_e_tag_id_val,
13422 (void *)&cmd_config_e_tag_dst_pool,
13423 (void *)&cmd_config_e_tag_dst_pool_val,
13424 (void *)&cmd_config_e_tag_port,
13425 (void *)&cmd_config_e_tag_port_id,
13431 cmd_config_e_tag_filter_del_parsed(
13432 void *parsed_result,
13433 __rte_unused struct cmdline *cl,
13434 __rte_unused void *data)
13436 struct cmd_config_e_tag_result *res = parsed_result;
13437 struct rte_eth_l2_tunnel_conf entry;
13440 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13443 if (res->e_tag_id_val > 0x3fff) {
13444 printf("e-tag-id must be less than 0x3fff.\n");
13448 ret = rte_eth_dev_filter_supported(res->port_id,
13449 RTE_ETH_FILTER_L2_TUNNEL);
13451 printf("E-tag filter is not supported on port %u.\n",
13456 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13457 entry.tunnel_id = res->e_tag_id_val;
13459 ret = rte_eth_dev_filter_ctrl(res->port_id,
13460 RTE_ETH_FILTER_L2_TUNNEL,
13461 RTE_ETH_FILTER_DELETE,
13464 printf("E-tag filter programming error: (%s)\n",
13468 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13469 .f = cmd_config_e_tag_filter_del_parsed,
13471 .help_str = "E-tag ... : E-tag filter delete",
13473 (void *)&cmd_config_e_tag_e_tag,
13474 (void *)&cmd_config_e_tag_set,
13475 (void *)&cmd_config_e_tag_filter,
13476 (void *)&cmd_config_e_tag_del,
13477 (void *)&cmd_config_e_tag_e_tag_id,
13478 (void *)&cmd_config_e_tag_e_tag_id_val,
13479 (void *)&cmd_config_e_tag_port,
13480 (void *)&cmd_config_e_tag_port_id,
13485 /* vf vlan anti spoof configuration */
13487 /* Common result structure for vf vlan anti spoof */
13488 struct cmd_vf_vlan_anti_spoof_result {
13489 cmdline_fixed_string_t set;
13490 cmdline_fixed_string_t vf;
13491 cmdline_fixed_string_t vlan;
13492 cmdline_fixed_string_t antispoof;
13495 cmdline_fixed_string_t on_off;
13498 /* Common CLI fields for vf vlan anti spoof enable disable */
13499 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13500 TOKEN_STRING_INITIALIZER
13501 (struct cmd_vf_vlan_anti_spoof_result,
13503 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13504 TOKEN_STRING_INITIALIZER
13505 (struct cmd_vf_vlan_anti_spoof_result,
13507 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13508 TOKEN_STRING_INITIALIZER
13509 (struct cmd_vf_vlan_anti_spoof_result,
13511 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13512 TOKEN_STRING_INITIALIZER
13513 (struct cmd_vf_vlan_anti_spoof_result,
13514 antispoof, "antispoof");
13515 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13516 TOKEN_NUM_INITIALIZER
13517 (struct cmd_vf_vlan_anti_spoof_result,
13519 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13520 TOKEN_NUM_INITIALIZER
13521 (struct cmd_vf_vlan_anti_spoof_result,
13523 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13524 TOKEN_STRING_INITIALIZER
13525 (struct cmd_vf_vlan_anti_spoof_result,
13529 cmd_set_vf_vlan_anti_spoof_parsed(
13530 void *parsed_result,
13531 __rte_unused struct cmdline *cl,
13532 __rte_unused void *data)
13534 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13535 int ret = -ENOTSUP;
13537 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13539 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13542 #ifdef RTE_LIBRTE_IXGBE_PMD
13543 if (ret == -ENOTSUP)
13544 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13545 res->vf_id, is_on);
13547 #ifdef RTE_LIBRTE_I40E_PMD
13548 if (ret == -ENOTSUP)
13549 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13550 res->vf_id, is_on);
13552 #ifdef RTE_LIBRTE_BNXT_PMD
13553 if (ret == -ENOTSUP)
13554 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13555 res->vf_id, is_on);
13562 printf("invalid vf_id %d\n", res->vf_id);
13565 printf("invalid port_id %d\n", res->port_id);
13568 printf("function not implemented\n");
13571 printf("programming error: (%s)\n", strerror(-ret));
13575 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13576 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13578 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13580 (void *)&cmd_vf_vlan_anti_spoof_set,
13581 (void *)&cmd_vf_vlan_anti_spoof_vf,
13582 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13583 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13584 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13585 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13586 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13591 /* vf mac anti spoof configuration */
13593 /* Common result structure for vf mac anti spoof */
13594 struct cmd_vf_mac_anti_spoof_result {
13595 cmdline_fixed_string_t set;
13596 cmdline_fixed_string_t vf;
13597 cmdline_fixed_string_t mac;
13598 cmdline_fixed_string_t antispoof;
13601 cmdline_fixed_string_t on_off;
13604 /* Common CLI fields for vf mac anti spoof enable disable */
13605 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13606 TOKEN_STRING_INITIALIZER
13607 (struct cmd_vf_mac_anti_spoof_result,
13609 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13610 TOKEN_STRING_INITIALIZER
13611 (struct cmd_vf_mac_anti_spoof_result,
13613 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13614 TOKEN_STRING_INITIALIZER
13615 (struct cmd_vf_mac_anti_spoof_result,
13617 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13618 TOKEN_STRING_INITIALIZER
13619 (struct cmd_vf_mac_anti_spoof_result,
13620 antispoof, "antispoof");
13621 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13622 TOKEN_NUM_INITIALIZER
13623 (struct cmd_vf_mac_anti_spoof_result,
13625 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13626 TOKEN_NUM_INITIALIZER
13627 (struct cmd_vf_mac_anti_spoof_result,
13629 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13630 TOKEN_STRING_INITIALIZER
13631 (struct cmd_vf_mac_anti_spoof_result,
13635 cmd_set_vf_mac_anti_spoof_parsed(
13636 void *parsed_result,
13637 __rte_unused struct cmdline *cl,
13638 __rte_unused void *data)
13640 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13641 int ret = -ENOTSUP;
13643 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13645 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13648 #ifdef RTE_LIBRTE_IXGBE_PMD
13649 if (ret == -ENOTSUP)
13650 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13651 res->vf_id, is_on);
13653 #ifdef RTE_LIBRTE_I40E_PMD
13654 if (ret == -ENOTSUP)
13655 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13656 res->vf_id, is_on);
13658 #ifdef RTE_LIBRTE_BNXT_PMD
13659 if (ret == -ENOTSUP)
13660 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13661 res->vf_id, is_on);
13668 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13671 printf("invalid port_id %d\n", res->port_id);
13674 printf("function not implemented\n");
13677 printf("programming error: (%s)\n", strerror(-ret));
13681 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13682 .f = cmd_set_vf_mac_anti_spoof_parsed,
13684 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13686 (void *)&cmd_vf_mac_anti_spoof_set,
13687 (void *)&cmd_vf_mac_anti_spoof_vf,
13688 (void *)&cmd_vf_mac_anti_spoof_mac,
13689 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13690 (void *)&cmd_vf_mac_anti_spoof_port_id,
13691 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13692 (void *)&cmd_vf_mac_anti_spoof_on_off,
13697 /* vf vlan strip queue configuration */
13699 /* Common result structure for vf mac anti spoof */
13700 struct cmd_vf_vlan_stripq_result {
13701 cmdline_fixed_string_t set;
13702 cmdline_fixed_string_t vf;
13703 cmdline_fixed_string_t vlan;
13704 cmdline_fixed_string_t stripq;
13707 cmdline_fixed_string_t on_off;
13710 /* Common CLI fields for vf vlan strip enable disable */
13711 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13712 TOKEN_STRING_INITIALIZER
13713 (struct cmd_vf_vlan_stripq_result,
13715 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13716 TOKEN_STRING_INITIALIZER
13717 (struct cmd_vf_vlan_stripq_result,
13719 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13720 TOKEN_STRING_INITIALIZER
13721 (struct cmd_vf_vlan_stripq_result,
13723 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13724 TOKEN_STRING_INITIALIZER
13725 (struct cmd_vf_vlan_stripq_result,
13727 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13728 TOKEN_NUM_INITIALIZER
13729 (struct cmd_vf_vlan_stripq_result,
13731 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13732 TOKEN_NUM_INITIALIZER
13733 (struct cmd_vf_vlan_stripq_result,
13735 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13736 TOKEN_STRING_INITIALIZER
13737 (struct cmd_vf_vlan_stripq_result,
13741 cmd_set_vf_vlan_stripq_parsed(
13742 void *parsed_result,
13743 __rte_unused struct cmdline *cl,
13744 __rte_unused void *data)
13746 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13747 int ret = -ENOTSUP;
13749 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13751 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13754 #ifdef RTE_LIBRTE_IXGBE_PMD
13755 if (ret == -ENOTSUP)
13756 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13757 res->vf_id, is_on);
13759 #ifdef RTE_LIBRTE_I40E_PMD
13760 if (ret == -ENOTSUP)
13761 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13762 res->vf_id, is_on);
13764 #ifdef RTE_LIBRTE_BNXT_PMD
13765 if (ret == -ENOTSUP)
13766 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13767 res->vf_id, is_on);
13774 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13777 printf("invalid port_id %d\n", res->port_id);
13780 printf("function not implemented\n");
13783 printf("programming error: (%s)\n", strerror(-ret));
13787 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13788 .f = cmd_set_vf_vlan_stripq_parsed,
13790 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13792 (void *)&cmd_vf_vlan_stripq_set,
13793 (void *)&cmd_vf_vlan_stripq_vf,
13794 (void *)&cmd_vf_vlan_stripq_vlan,
13795 (void *)&cmd_vf_vlan_stripq_stripq,
13796 (void *)&cmd_vf_vlan_stripq_port_id,
13797 (void *)&cmd_vf_vlan_stripq_vf_id,
13798 (void *)&cmd_vf_vlan_stripq_on_off,
13803 /* vf vlan insert configuration */
13805 /* Common result structure for vf vlan insert */
13806 struct cmd_vf_vlan_insert_result {
13807 cmdline_fixed_string_t set;
13808 cmdline_fixed_string_t vf;
13809 cmdline_fixed_string_t vlan;
13810 cmdline_fixed_string_t insert;
13816 /* Common CLI fields for vf vlan insert enable disable */
13817 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13818 TOKEN_STRING_INITIALIZER
13819 (struct cmd_vf_vlan_insert_result,
13821 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13822 TOKEN_STRING_INITIALIZER
13823 (struct cmd_vf_vlan_insert_result,
13825 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13826 TOKEN_STRING_INITIALIZER
13827 (struct cmd_vf_vlan_insert_result,
13829 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13830 TOKEN_STRING_INITIALIZER
13831 (struct cmd_vf_vlan_insert_result,
13833 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13834 TOKEN_NUM_INITIALIZER
13835 (struct cmd_vf_vlan_insert_result,
13837 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13838 TOKEN_NUM_INITIALIZER
13839 (struct cmd_vf_vlan_insert_result,
13841 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13842 TOKEN_NUM_INITIALIZER
13843 (struct cmd_vf_vlan_insert_result,
13847 cmd_set_vf_vlan_insert_parsed(
13848 void *parsed_result,
13849 __rte_unused struct cmdline *cl,
13850 __rte_unused void *data)
13852 struct cmd_vf_vlan_insert_result *res = parsed_result;
13853 int ret = -ENOTSUP;
13855 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13858 #ifdef RTE_LIBRTE_IXGBE_PMD
13859 if (ret == -ENOTSUP)
13860 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13863 #ifdef RTE_LIBRTE_I40E_PMD
13864 if (ret == -ENOTSUP)
13865 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13868 #ifdef RTE_LIBRTE_BNXT_PMD
13869 if (ret == -ENOTSUP)
13870 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13878 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13881 printf("invalid port_id %d\n", res->port_id);
13884 printf("function not implemented\n");
13887 printf("programming error: (%s)\n", strerror(-ret));
13891 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13892 .f = cmd_set_vf_vlan_insert_parsed,
13894 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13896 (void *)&cmd_vf_vlan_insert_set,
13897 (void *)&cmd_vf_vlan_insert_vf,
13898 (void *)&cmd_vf_vlan_insert_vlan,
13899 (void *)&cmd_vf_vlan_insert_insert,
13900 (void *)&cmd_vf_vlan_insert_port_id,
13901 (void *)&cmd_vf_vlan_insert_vf_id,
13902 (void *)&cmd_vf_vlan_insert_vlan_id,
13907 /* tx loopback configuration */
13909 /* Common result structure for tx loopback */
13910 struct cmd_tx_loopback_result {
13911 cmdline_fixed_string_t set;
13912 cmdline_fixed_string_t tx;
13913 cmdline_fixed_string_t loopback;
13915 cmdline_fixed_string_t on_off;
13918 /* Common CLI fields for tx loopback enable disable */
13919 cmdline_parse_token_string_t cmd_tx_loopback_set =
13920 TOKEN_STRING_INITIALIZER
13921 (struct cmd_tx_loopback_result,
13923 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13924 TOKEN_STRING_INITIALIZER
13925 (struct cmd_tx_loopback_result,
13927 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13928 TOKEN_STRING_INITIALIZER
13929 (struct cmd_tx_loopback_result,
13930 loopback, "loopback");
13931 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13932 TOKEN_NUM_INITIALIZER
13933 (struct cmd_tx_loopback_result,
13935 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13936 TOKEN_STRING_INITIALIZER
13937 (struct cmd_tx_loopback_result,
13941 cmd_set_tx_loopback_parsed(
13942 void *parsed_result,
13943 __rte_unused struct cmdline *cl,
13944 __rte_unused void *data)
13946 struct cmd_tx_loopback_result *res = parsed_result;
13947 int ret = -ENOTSUP;
13949 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13951 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13954 #ifdef RTE_LIBRTE_IXGBE_PMD
13955 if (ret == -ENOTSUP)
13956 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13958 #ifdef RTE_LIBRTE_I40E_PMD
13959 if (ret == -ENOTSUP)
13960 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13962 #ifdef RTE_LIBRTE_BNXT_PMD
13963 if (ret == -ENOTSUP)
13964 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13966 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13967 if (ret == -ENOTSUP)
13968 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13975 printf("invalid is_on %d\n", is_on);
13978 printf("invalid port_id %d\n", res->port_id);
13981 printf("function not implemented\n");
13984 printf("programming error: (%s)\n", strerror(-ret));
13988 cmdline_parse_inst_t cmd_set_tx_loopback = {
13989 .f = cmd_set_tx_loopback_parsed,
13991 .help_str = "set tx loopback <port_id> on|off",
13993 (void *)&cmd_tx_loopback_set,
13994 (void *)&cmd_tx_loopback_tx,
13995 (void *)&cmd_tx_loopback_loopback,
13996 (void *)&cmd_tx_loopback_port_id,
13997 (void *)&cmd_tx_loopback_on_off,
14002 /* all queues drop enable configuration */
14004 /* Common result structure for all queues drop enable */
14005 struct cmd_all_queues_drop_en_result {
14006 cmdline_fixed_string_t set;
14007 cmdline_fixed_string_t all;
14008 cmdline_fixed_string_t queues;
14009 cmdline_fixed_string_t drop;
14011 cmdline_fixed_string_t on_off;
14014 /* Common CLI fields for tx loopback enable disable */
14015 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
14016 TOKEN_STRING_INITIALIZER
14017 (struct cmd_all_queues_drop_en_result,
14019 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
14020 TOKEN_STRING_INITIALIZER
14021 (struct cmd_all_queues_drop_en_result,
14023 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
14024 TOKEN_STRING_INITIALIZER
14025 (struct cmd_all_queues_drop_en_result,
14027 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
14028 TOKEN_STRING_INITIALIZER
14029 (struct cmd_all_queues_drop_en_result,
14031 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
14032 TOKEN_NUM_INITIALIZER
14033 (struct cmd_all_queues_drop_en_result,
14035 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
14036 TOKEN_STRING_INITIALIZER
14037 (struct cmd_all_queues_drop_en_result,
14041 cmd_set_all_queues_drop_en_parsed(
14042 void *parsed_result,
14043 __rte_unused struct cmdline *cl,
14044 __rte_unused void *data)
14046 struct cmd_all_queues_drop_en_result *res = parsed_result;
14047 int ret = -ENOTSUP;
14048 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14050 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14053 #ifdef RTE_LIBRTE_IXGBE_PMD
14054 if (ret == -ENOTSUP)
14055 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
14057 #ifdef RTE_LIBRTE_BNXT_PMD
14058 if (ret == -ENOTSUP)
14059 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
14065 printf("invalid is_on %d\n", is_on);
14068 printf("invalid port_id %d\n", res->port_id);
14071 printf("function not implemented\n");
14074 printf("programming error: (%s)\n", strerror(-ret));
14078 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
14079 .f = cmd_set_all_queues_drop_en_parsed,
14081 .help_str = "set all queues drop <port_id> on|off",
14083 (void *)&cmd_all_queues_drop_en_set,
14084 (void *)&cmd_all_queues_drop_en_all,
14085 (void *)&cmd_all_queues_drop_en_queues,
14086 (void *)&cmd_all_queues_drop_en_drop,
14087 (void *)&cmd_all_queues_drop_en_port_id,
14088 (void *)&cmd_all_queues_drop_en_on_off,
14093 /* vf split drop enable configuration */
14095 /* Common result structure for vf split drop enable */
14096 struct cmd_vf_split_drop_en_result {
14097 cmdline_fixed_string_t set;
14098 cmdline_fixed_string_t vf;
14099 cmdline_fixed_string_t split;
14100 cmdline_fixed_string_t drop;
14103 cmdline_fixed_string_t on_off;
14106 /* Common CLI fields for vf split drop enable disable */
14107 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
14108 TOKEN_STRING_INITIALIZER
14109 (struct cmd_vf_split_drop_en_result,
14111 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
14112 TOKEN_STRING_INITIALIZER
14113 (struct cmd_vf_split_drop_en_result,
14115 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
14116 TOKEN_STRING_INITIALIZER
14117 (struct cmd_vf_split_drop_en_result,
14119 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
14120 TOKEN_STRING_INITIALIZER
14121 (struct cmd_vf_split_drop_en_result,
14123 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
14124 TOKEN_NUM_INITIALIZER
14125 (struct cmd_vf_split_drop_en_result,
14127 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
14128 TOKEN_NUM_INITIALIZER
14129 (struct cmd_vf_split_drop_en_result,
14131 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
14132 TOKEN_STRING_INITIALIZER
14133 (struct cmd_vf_split_drop_en_result,
14137 cmd_set_vf_split_drop_en_parsed(
14138 void *parsed_result,
14139 __rte_unused struct cmdline *cl,
14140 __rte_unused void *data)
14142 struct cmd_vf_split_drop_en_result *res = parsed_result;
14143 int ret = -ENOTSUP;
14144 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14146 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14149 #ifdef RTE_LIBRTE_IXGBE_PMD
14150 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14157 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14160 printf("invalid port_id %d\n", res->port_id);
14163 printf("not supported on port %d\n", res->port_id);
14166 printf("programming error: (%s)\n", strerror(-ret));
14170 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14171 .f = cmd_set_vf_split_drop_en_parsed,
14173 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14175 (void *)&cmd_vf_split_drop_en_set,
14176 (void *)&cmd_vf_split_drop_en_vf,
14177 (void *)&cmd_vf_split_drop_en_split,
14178 (void *)&cmd_vf_split_drop_en_drop,
14179 (void *)&cmd_vf_split_drop_en_port_id,
14180 (void *)&cmd_vf_split_drop_en_vf_id,
14181 (void *)&cmd_vf_split_drop_en_on_off,
14186 /* vf mac address configuration */
14188 /* Common result structure for vf mac address */
14189 struct cmd_set_vf_mac_addr_result {
14190 cmdline_fixed_string_t set;
14191 cmdline_fixed_string_t vf;
14192 cmdline_fixed_string_t mac;
14193 cmdline_fixed_string_t addr;
14196 struct rte_ether_addr mac_addr;
14200 /* Common CLI fields for vf split drop enable disable */
14201 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14202 TOKEN_STRING_INITIALIZER
14203 (struct cmd_set_vf_mac_addr_result,
14205 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14206 TOKEN_STRING_INITIALIZER
14207 (struct cmd_set_vf_mac_addr_result,
14209 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14210 TOKEN_STRING_INITIALIZER
14211 (struct cmd_set_vf_mac_addr_result,
14213 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14214 TOKEN_STRING_INITIALIZER
14215 (struct cmd_set_vf_mac_addr_result,
14217 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14218 TOKEN_NUM_INITIALIZER
14219 (struct cmd_set_vf_mac_addr_result,
14221 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14222 TOKEN_NUM_INITIALIZER
14223 (struct cmd_set_vf_mac_addr_result,
14225 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14226 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14230 cmd_set_vf_mac_addr_parsed(
14231 void *parsed_result,
14232 __rte_unused struct cmdline *cl,
14233 __rte_unused void *data)
14235 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14236 int ret = -ENOTSUP;
14238 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14241 #ifdef RTE_LIBRTE_IXGBE_PMD
14242 if (ret == -ENOTSUP)
14243 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14246 #ifdef RTE_LIBRTE_I40E_PMD
14247 if (ret == -ENOTSUP)
14248 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14251 #ifdef RTE_LIBRTE_BNXT_PMD
14252 if (ret == -ENOTSUP)
14253 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14261 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14264 printf("invalid port_id %d\n", res->port_id);
14267 printf("function not implemented\n");
14270 printf("programming error: (%s)\n", strerror(-ret));
14274 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14275 .f = cmd_set_vf_mac_addr_parsed,
14277 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14279 (void *)&cmd_set_vf_mac_addr_set,
14280 (void *)&cmd_set_vf_mac_addr_vf,
14281 (void *)&cmd_set_vf_mac_addr_mac,
14282 (void *)&cmd_set_vf_mac_addr_addr,
14283 (void *)&cmd_set_vf_mac_addr_port_id,
14284 (void *)&cmd_set_vf_mac_addr_vf_id,
14285 (void *)&cmd_set_vf_mac_addr_mac_addr,
14290 /* MACsec configuration */
14292 /* Common result structure for MACsec offload enable */
14293 struct cmd_macsec_offload_on_result {
14294 cmdline_fixed_string_t set;
14295 cmdline_fixed_string_t macsec;
14296 cmdline_fixed_string_t offload;
14298 cmdline_fixed_string_t on;
14299 cmdline_fixed_string_t encrypt;
14300 cmdline_fixed_string_t en_on_off;
14301 cmdline_fixed_string_t replay_protect;
14302 cmdline_fixed_string_t rp_on_off;
14305 /* Common CLI fields for MACsec offload disable */
14306 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14307 TOKEN_STRING_INITIALIZER
14308 (struct cmd_macsec_offload_on_result,
14310 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14311 TOKEN_STRING_INITIALIZER
14312 (struct cmd_macsec_offload_on_result,
14314 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14315 TOKEN_STRING_INITIALIZER
14316 (struct cmd_macsec_offload_on_result,
14317 offload, "offload");
14318 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14319 TOKEN_NUM_INITIALIZER
14320 (struct cmd_macsec_offload_on_result,
14322 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14323 TOKEN_STRING_INITIALIZER
14324 (struct cmd_macsec_offload_on_result,
14326 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14327 TOKEN_STRING_INITIALIZER
14328 (struct cmd_macsec_offload_on_result,
14329 encrypt, "encrypt");
14330 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14331 TOKEN_STRING_INITIALIZER
14332 (struct cmd_macsec_offload_on_result,
14333 en_on_off, "on#off");
14334 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14335 TOKEN_STRING_INITIALIZER
14336 (struct cmd_macsec_offload_on_result,
14337 replay_protect, "replay-protect");
14338 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14339 TOKEN_STRING_INITIALIZER
14340 (struct cmd_macsec_offload_on_result,
14341 rp_on_off, "on#off");
14344 cmd_set_macsec_offload_on_parsed(
14345 void *parsed_result,
14346 __rte_unused struct cmdline *cl,
14347 __rte_unused void *data)
14349 struct cmd_macsec_offload_on_result *res = parsed_result;
14350 int ret = -ENOTSUP;
14351 portid_t port_id = res->port_id;
14352 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14353 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14354 struct rte_eth_dev_info dev_info;
14356 if (port_id_is_invalid(port_id, ENABLED_WARN))
14358 if (!port_is_stopped(port_id)) {
14359 printf("Please stop port %d first\n", port_id);
14363 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14367 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14368 #ifdef RTE_LIBRTE_IXGBE_PMD
14369 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14377 ports[port_id].dev_conf.txmode.offloads |=
14378 DEV_TX_OFFLOAD_MACSEC_INSERT;
14379 cmd_reconfig_device_queue(port_id, 1, 1);
14382 printf("invalid port_id %d\n", port_id);
14385 printf("not supported on port %d\n", port_id);
14388 printf("programming error: (%s)\n", strerror(-ret));
14392 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14393 .f = cmd_set_macsec_offload_on_parsed,
14395 .help_str = "set macsec offload <port_id> on "
14396 "encrypt on|off replay-protect on|off",
14398 (void *)&cmd_macsec_offload_on_set,
14399 (void *)&cmd_macsec_offload_on_macsec,
14400 (void *)&cmd_macsec_offload_on_offload,
14401 (void *)&cmd_macsec_offload_on_port_id,
14402 (void *)&cmd_macsec_offload_on_on,
14403 (void *)&cmd_macsec_offload_on_encrypt,
14404 (void *)&cmd_macsec_offload_on_en_on_off,
14405 (void *)&cmd_macsec_offload_on_replay_protect,
14406 (void *)&cmd_macsec_offload_on_rp_on_off,
14411 /* Common result structure for MACsec offload disable */
14412 struct cmd_macsec_offload_off_result {
14413 cmdline_fixed_string_t set;
14414 cmdline_fixed_string_t macsec;
14415 cmdline_fixed_string_t offload;
14417 cmdline_fixed_string_t off;
14420 /* Common CLI fields for MACsec offload disable */
14421 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14422 TOKEN_STRING_INITIALIZER
14423 (struct cmd_macsec_offload_off_result,
14425 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14426 TOKEN_STRING_INITIALIZER
14427 (struct cmd_macsec_offload_off_result,
14429 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14430 TOKEN_STRING_INITIALIZER
14431 (struct cmd_macsec_offload_off_result,
14432 offload, "offload");
14433 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14434 TOKEN_NUM_INITIALIZER
14435 (struct cmd_macsec_offload_off_result,
14437 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14438 TOKEN_STRING_INITIALIZER
14439 (struct cmd_macsec_offload_off_result,
14443 cmd_set_macsec_offload_off_parsed(
14444 void *parsed_result,
14445 __rte_unused struct cmdline *cl,
14446 __rte_unused void *data)
14448 struct cmd_macsec_offload_off_result *res = parsed_result;
14449 int ret = -ENOTSUP;
14450 struct rte_eth_dev_info dev_info;
14451 portid_t port_id = res->port_id;
14453 if (port_id_is_invalid(port_id, ENABLED_WARN))
14455 if (!port_is_stopped(port_id)) {
14456 printf("Please stop port %d first\n", port_id);
14460 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14464 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14465 #ifdef RTE_LIBRTE_IXGBE_PMD
14466 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14471 ports[port_id].dev_conf.txmode.offloads &=
14472 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14473 cmd_reconfig_device_queue(port_id, 1, 1);
14476 printf("invalid port_id %d\n", port_id);
14479 printf("not supported on port %d\n", port_id);
14482 printf("programming error: (%s)\n", strerror(-ret));
14486 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14487 .f = cmd_set_macsec_offload_off_parsed,
14489 .help_str = "set macsec offload <port_id> off",
14491 (void *)&cmd_macsec_offload_off_set,
14492 (void *)&cmd_macsec_offload_off_macsec,
14493 (void *)&cmd_macsec_offload_off_offload,
14494 (void *)&cmd_macsec_offload_off_port_id,
14495 (void *)&cmd_macsec_offload_off_off,
14500 /* Common result structure for MACsec secure connection configure */
14501 struct cmd_macsec_sc_result {
14502 cmdline_fixed_string_t set;
14503 cmdline_fixed_string_t macsec;
14504 cmdline_fixed_string_t sc;
14505 cmdline_fixed_string_t tx_rx;
14507 struct rte_ether_addr mac;
14511 /* Common CLI fields for MACsec secure connection configure */
14512 cmdline_parse_token_string_t cmd_macsec_sc_set =
14513 TOKEN_STRING_INITIALIZER
14514 (struct cmd_macsec_sc_result,
14516 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14517 TOKEN_STRING_INITIALIZER
14518 (struct cmd_macsec_sc_result,
14520 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14521 TOKEN_STRING_INITIALIZER
14522 (struct cmd_macsec_sc_result,
14524 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14525 TOKEN_STRING_INITIALIZER
14526 (struct cmd_macsec_sc_result,
14528 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14529 TOKEN_NUM_INITIALIZER
14530 (struct cmd_macsec_sc_result,
14532 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14533 TOKEN_ETHERADDR_INITIALIZER
14534 (struct cmd_macsec_sc_result,
14536 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14537 TOKEN_NUM_INITIALIZER
14538 (struct cmd_macsec_sc_result,
14542 cmd_set_macsec_sc_parsed(
14543 void *parsed_result,
14544 __rte_unused struct cmdline *cl,
14545 __rte_unused void *data)
14547 struct cmd_macsec_sc_result *res = parsed_result;
14548 int ret = -ENOTSUP;
14549 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14551 #ifdef RTE_LIBRTE_IXGBE_PMD
14553 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14554 res->mac.addr_bytes) :
14555 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14556 res->mac.addr_bytes, res->pi);
14558 RTE_SET_USED(is_tx);
14564 printf("invalid port_id %d\n", res->port_id);
14567 printf("not supported on port %d\n", res->port_id);
14570 printf("programming error: (%s)\n", strerror(-ret));
14574 cmdline_parse_inst_t cmd_set_macsec_sc = {
14575 .f = cmd_set_macsec_sc_parsed,
14577 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14579 (void *)&cmd_macsec_sc_set,
14580 (void *)&cmd_macsec_sc_macsec,
14581 (void *)&cmd_macsec_sc_sc,
14582 (void *)&cmd_macsec_sc_tx_rx,
14583 (void *)&cmd_macsec_sc_port_id,
14584 (void *)&cmd_macsec_sc_mac,
14585 (void *)&cmd_macsec_sc_pi,
14590 /* Common result structure for MACsec secure connection configure */
14591 struct cmd_macsec_sa_result {
14592 cmdline_fixed_string_t set;
14593 cmdline_fixed_string_t macsec;
14594 cmdline_fixed_string_t sa;
14595 cmdline_fixed_string_t tx_rx;
14600 cmdline_fixed_string_t key;
14603 /* Common CLI fields for MACsec secure connection configure */
14604 cmdline_parse_token_string_t cmd_macsec_sa_set =
14605 TOKEN_STRING_INITIALIZER
14606 (struct cmd_macsec_sa_result,
14608 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14609 TOKEN_STRING_INITIALIZER
14610 (struct cmd_macsec_sa_result,
14612 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14613 TOKEN_STRING_INITIALIZER
14614 (struct cmd_macsec_sa_result,
14616 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14617 TOKEN_STRING_INITIALIZER
14618 (struct cmd_macsec_sa_result,
14620 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14621 TOKEN_NUM_INITIALIZER
14622 (struct cmd_macsec_sa_result,
14624 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14625 TOKEN_NUM_INITIALIZER
14626 (struct cmd_macsec_sa_result,
14628 cmdline_parse_token_num_t cmd_macsec_sa_an =
14629 TOKEN_NUM_INITIALIZER
14630 (struct cmd_macsec_sa_result,
14632 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14633 TOKEN_NUM_INITIALIZER
14634 (struct cmd_macsec_sa_result,
14636 cmdline_parse_token_string_t cmd_macsec_sa_key =
14637 TOKEN_STRING_INITIALIZER
14638 (struct cmd_macsec_sa_result,
14642 cmd_set_macsec_sa_parsed(
14643 void *parsed_result,
14644 __rte_unused struct cmdline *cl,
14645 __rte_unused void *data)
14647 struct cmd_macsec_sa_result *res = parsed_result;
14648 int ret = -ENOTSUP;
14649 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14650 uint8_t key[16] = { 0 };
14656 key_len = strlen(res->key) / 2;
14660 for (i = 0; i < key_len; i++) {
14661 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14664 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14667 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14670 #ifdef RTE_LIBRTE_IXGBE_PMD
14672 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14673 res->idx, res->an, res->pn, key) :
14674 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14675 res->idx, res->an, res->pn, key);
14677 RTE_SET_USED(is_tx);
14684 printf("invalid idx %d or an %d\n", res->idx, res->an);
14687 printf("invalid port_id %d\n", res->port_id);
14690 printf("not supported on port %d\n", res->port_id);
14693 printf("programming error: (%s)\n", strerror(-ret));
14697 cmdline_parse_inst_t cmd_set_macsec_sa = {
14698 .f = cmd_set_macsec_sa_parsed,
14700 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14702 (void *)&cmd_macsec_sa_set,
14703 (void *)&cmd_macsec_sa_macsec,
14704 (void *)&cmd_macsec_sa_sa,
14705 (void *)&cmd_macsec_sa_tx_rx,
14706 (void *)&cmd_macsec_sa_port_id,
14707 (void *)&cmd_macsec_sa_idx,
14708 (void *)&cmd_macsec_sa_an,
14709 (void *)&cmd_macsec_sa_pn,
14710 (void *)&cmd_macsec_sa_key,
14715 /* VF unicast promiscuous mode configuration */
14717 /* Common result structure for VF unicast promiscuous mode */
14718 struct cmd_vf_promisc_result {
14719 cmdline_fixed_string_t set;
14720 cmdline_fixed_string_t vf;
14721 cmdline_fixed_string_t promisc;
14724 cmdline_fixed_string_t on_off;
14727 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14728 cmdline_parse_token_string_t cmd_vf_promisc_set =
14729 TOKEN_STRING_INITIALIZER
14730 (struct cmd_vf_promisc_result,
14732 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14733 TOKEN_STRING_INITIALIZER
14734 (struct cmd_vf_promisc_result,
14736 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14737 TOKEN_STRING_INITIALIZER
14738 (struct cmd_vf_promisc_result,
14739 promisc, "promisc");
14740 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14741 TOKEN_NUM_INITIALIZER
14742 (struct cmd_vf_promisc_result,
14744 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14745 TOKEN_NUM_INITIALIZER
14746 (struct cmd_vf_promisc_result,
14748 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14749 TOKEN_STRING_INITIALIZER
14750 (struct cmd_vf_promisc_result,
14754 cmd_set_vf_promisc_parsed(
14755 void *parsed_result,
14756 __rte_unused struct cmdline *cl,
14757 __rte_unused void *data)
14759 struct cmd_vf_promisc_result *res = parsed_result;
14760 int ret = -ENOTSUP;
14762 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14764 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14767 #ifdef RTE_LIBRTE_I40E_PMD
14768 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14769 res->vf_id, is_on);
14776 printf("invalid vf_id %d\n", res->vf_id);
14779 printf("invalid port_id %d\n", res->port_id);
14782 printf("function not implemented\n");
14785 printf("programming error: (%s)\n", strerror(-ret));
14789 cmdline_parse_inst_t cmd_set_vf_promisc = {
14790 .f = cmd_set_vf_promisc_parsed,
14792 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14793 "Set unicast promiscuous mode for a VF from the PF",
14795 (void *)&cmd_vf_promisc_set,
14796 (void *)&cmd_vf_promisc_vf,
14797 (void *)&cmd_vf_promisc_promisc,
14798 (void *)&cmd_vf_promisc_port_id,
14799 (void *)&cmd_vf_promisc_vf_id,
14800 (void *)&cmd_vf_promisc_on_off,
14805 /* VF multicast promiscuous mode configuration */
14807 /* Common result structure for VF multicast promiscuous mode */
14808 struct cmd_vf_allmulti_result {
14809 cmdline_fixed_string_t set;
14810 cmdline_fixed_string_t vf;
14811 cmdline_fixed_string_t allmulti;
14814 cmdline_fixed_string_t on_off;
14817 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14818 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14819 TOKEN_STRING_INITIALIZER
14820 (struct cmd_vf_allmulti_result,
14822 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14823 TOKEN_STRING_INITIALIZER
14824 (struct cmd_vf_allmulti_result,
14826 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14827 TOKEN_STRING_INITIALIZER
14828 (struct cmd_vf_allmulti_result,
14829 allmulti, "allmulti");
14830 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14831 TOKEN_NUM_INITIALIZER
14832 (struct cmd_vf_allmulti_result,
14834 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14835 TOKEN_NUM_INITIALIZER
14836 (struct cmd_vf_allmulti_result,
14838 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14839 TOKEN_STRING_INITIALIZER
14840 (struct cmd_vf_allmulti_result,
14844 cmd_set_vf_allmulti_parsed(
14845 void *parsed_result,
14846 __rte_unused struct cmdline *cl,
14847 __rte_unused void *data)
14849 struct cmd_vf_allmulti_result *res = parsed_result;
14850 int ret = -ENOTSUP;
14852 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14854 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14857 #ifdef RTE_LIBRTE_I40E_PMD
14858 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14859 res->vf_id, is_on);
14866 printf("invalid vf_id %d\n", res->vf_id);
14869 printf("invalid port_id %d\n", res->port_id);
14872 printf("function not implemented\n");
14875 printf("programming error: (%s)\n", strerror(-ret));
14879 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14880 .f = cmd_set_vf_allmulti_parsed,
14882 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14883 "Set multicast promiscuous mode for a VF from the PF",
14885 (void *)&cmd_vf_allmulti_set,
14886 (void *)&cmd_vf_allmulti_vf,
14887 (void *)&cmd_vf_allmulti_allmulti,
14888 (void *)&cmd_vf_allmulti_port_id,
14889 (void *)&cmd_vf_allmulti_vf_id,
14890 (void *)&cmd_vf_allmulti_on_off,
14895 /* vf broadcast mode configuration */
14897 /* Common result structure for vf broadcast */
14898 struct cmd_set_vf_broadcast_result {
14899 cmdline_fixed_string_t set;
14900 cmdline_fixed_string_t vf;
14901 cmdline_fixed_string_t broadcast;
14904 cmdline_fixed_string_t on_off;
14907 /* Common CLI fields for vf broadcast enable disable */
14908 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14909 TOKEN_STRING_INITIALIZER
14910 (struct cmd_set_vf_broadcast_result,
14912 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14913 TOKEN_STRING_INITIALIZER
14914 (struct cmd_set_vf_broadcast_result,
14916 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14917 TOKEN_STRING_INITIALIZER
14918 (struct cmd_set_vf_broadcast_result,
14919 broadcast, "broadcast");
14920 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14921 TOKEN_NUM_INITIALIZER
14922 (struct cmd_set_vf_broadcast_result,
14924 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14925 TOKEN_NUM_INITIALIZER
14926 (struct cmd_set_vf_broadcast_result,
14928 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14929 TOKEN_STRING_INITIALIZER
14930 (struct cmd_set_vf_broadcast_result,
14934 cmd_set_vf_broadcast_parsed(
14935 void *parsed_result,
14936 __rte_unused struct cmdline *cl,
14937 __rte_unused void *data)
14939 struct cmd_set_vf_broadcast_result *res = parsed_result;
14940 int ret = -ENOTSUP;
14942 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14944 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14947 #ifdef RTE_LIBRTE_I40E_PMD
14948 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14949 res->vf_id, is_on);
14956 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14959 printf("invalid port_id %d\n", res->port_id);
14962 printf("function not implemented\n");
14965 printf("programming error: (%s)\n", strerror(-ret));
14969 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14970 .f = cmd_set_vf_broadcast_parsed,
14972 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14974 (void *)&cmd_set_vf_broadcast_set,
14975 (void *)&cmd_set_vf_broadcast_vf,
14976 (void *)&cmd_set_vf_broadcast_broadcast,
14977 (void *)&cmd_set_vf_broadcast_port_id,
14978 (void *)&cmd_set_vf_broadcast_vf_id,
14979 (void *)&cmd_set_vf_broadcast_on_off,
14984 /* vf vlan tag configuration */
14986 /* Common result structure for vf vlan tag */
14987 struct cmd_set_vf_vlan_tag_result {
14988 cmdline_fixed_string_t set;
14989 cmdline_fixed_string_t vf;
14990 cmdline_fixed_string_t vlan;
14991 cmdline_fixed_string_t tag;
14994 cmdline_fixed_string_t on_off;
14997 /* Common CLI fields for vf vlan tag enable disable */
14998 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14999 TOKEN_STRING_INITIALIZER
15000 (struct cmd_set_vf_vlan_tag_result,
15002 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
15003 TOKEN_STRING_INITIALIZER
15004 (struct cmd_set_vf_vlan_tag_result,
15006 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
15007 TOKEN_STRING_INITIALIZER
15008 (struct cmd_set_vf_vlan_tag_result,
15010 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
15011 TOKEN_STRING_INITIALIZER
15012 (struct cmd_set_vf_vlan_tag_result,
15014 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
15015 TOKEN_NUM_INITIALIZER
15016 (struct cmd_set_vf_vlan_tag_result,
15018 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
15019 TOKEN_NUM_INITIALIZER
15020 (struct cmd_set_vf_vlan_tag_result,
15022 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
15023 TOKEN_STRING_INITIALIZER
15024 (struct cmd_set_vf_vlan_tag_result,
15028 cmd_set_vf_vlan_tag_parsed(
15029 void *parsed_result,
15030 __rte_unused struct cmdline *cl,
15031 __rte_unused void *data)
15033 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
15034 int ret = -ENOTSUP;
15036 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15038 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15041 #ifdef RTE_LIBRTE_I40E_PMD
15042 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
15043 res->vf_id, is_on);
15050 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15053 printf("invalid port_id %d\n", res->port_id);
15056 printf("function not implemented\n");
15059 printf("programming error: (%s)\n", strerror(-ret));
15063 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
15064 .f = cmd_set_vf_vlan_tag_parsed,
15066 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
15068 (void *)&cmd_set_vf_vlan_tag_set,
15069 (void *)&cmd_set_vf_vlan_tag_vf,
15070 (void *)&cmd_set_vf_vlan_tag_vlan,
15071 (void *)&cmd_set_vf_vlan_tag_tag,
15072 (void *)&cmd_set_vf_vlan_tag_port_id,
15073 (void *)&cmd_set_vf_vlan_tag_vf_id,
15074 (void *)&cmd_set_vf_vlan_tag_on_off,
15079 /* Common definition of VF and TC TX bandwidth configuration */
15080 struct cmd_vf_tc_bw_result {
15081 cmdline_fixed_string_t set;
15082 cmdline_fixed_string_t vf;
15083 cmdline_fixed_string_t tc;
15084 cmdline_fixed_string_t tx;
15085 cmdline_fixed_string_t min_bw;
15086 cmdline_fixed_string_t max_bw;
15087 cmdline_fixed_string_t strict_link_prio;
15092 cmdline_fixed_string_t bw_list;
15096 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
15097 TOKEN_STRING_INITIALIZER
15098 (struct cmd_vf_tc_bw_result,
15100 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
15101 TOKEN_STRING_INITIALIZER
15102 (struct cmd_vf_tc_bw_result,
15104 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
15105 TOKEN_STRING_INITIALIZER
15106 (struct cmd_vf_tc_bw_result,
15108 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
15109 TOKEN_STRING_INITIALIZER
15110 (struct cmd_vf_tc_bw_result,
15112 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
15113 TOKEN_STRING_INITIALIZER
15114 (struct cmd_vf_tc_bw_result,
15115 strict_link_prio, "strict-link-priority");
15116 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
15117 TOKEN_STRING_INITIALIZER
15118 (struct cmd_vf_tc_bw_result,
15119 min_bw, "min-bandwidth");
15120 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
15121 TOKEN_STRING_INITIALIZER
15122 (struct cmd_vf_tc_bw_result,
15123 max_bw, "max-bandwidth");
15124 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
15125 TOKEN_NUM_INITIALIZER
15126 (struct cmd_vf_tc_bw_result,
15128 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
15129 TOKEN_NUM_INITIALIZER
15130 (struct cmd_vf_tc_bw_result,
15132 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
15133 TOKEN_NUM_INITIALIZER
15134 (struct cmd_vf_tc_bw_result,
15136 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
15137 TOKEN_NUM_INITIALIZER
15138 (struct cmd_vf_tc_bw_result,
15140 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
15141 TOKEN_STRING_INITIALIZER
15142 (struct cmd_vf_tc_bw_result,
15144 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
15145 TOKEN_NUM_INITIALIZER
15146 (struct cmd_vf_tc_bw_result,
15149 /* VF max bandwidth setting */
15151 cmd_vf_max_bw_parsed(
15152 void *parsed_result,
15153 __rte_unused struct cmdline *cl,
15154 __rte_unused void *data)
15156 struct cmd_vf_tc_bw_result *res = parsed_result;
15157 int ret = -ENOTSUP;
15159 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15162 #ifdef RTE_LIBRTE_I40E_PMD
15163 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15164 res->vf_id, res->bw);
15171 printf("invalid vf_id %d or bandwidth %d\n",
15172 res->vf_id, res->bw);
15175 printf("invalid port_id %d\n", res->port_id);
15178 printf("function not implemented\n");
15181 printf("programming error: (%s)\n", strerror(-ret));
15185 cmdline_parse_inst_t cmd_vf_max_bw = {
15186 .f = cmd_vf_max_bw_parsed,
15188 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15190 (void *)&cmd_vf_tc_bw_set,
15191 (void *)&cmd_vf_tc_bw_vf,
15192 (void *)&cmd_vf_tc_bw_tx,
15193 (void *)&cmd_vf_tc_bw_max_bw,
15194 (void *)&cmd_vf_tc_bw_port_id,
15195 (void *)&cmd_vf_tc_bw_vf_id,
15196 (void *)&cmd_vf_tc_bw_bw,
15202 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15207 const char *p, *p0 = str;
15214 p = strchr(p0, '(');
15216 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15220 p0 = strchr(p, ')');
15222 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15226 if (size >= sizeof(s)) {
15227 printf("The string size exceeds the internal buffer size\n");
15230 snprintf(s, sizeof(s), "%.*s", size, p);
15231 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15233 printf("Failed to get the bandwidth list. ");
15237 for (i = 0; i < ret; i++)
15238 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15243 /* TC min bandwidth setting */
15245 cmd_vf_tc_min_bw_parsed(
15246 void *parsed_result,
15247 __rte_unused struct cmdline *cl,
15248 __rte_unused void *data)
15250 struct cmd_vf_tc_bw_result *res = parsed_result;
15253 int ret = -ENOTSUP;
15255 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15258 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15262 #ifdef RTE_LIBRTE_I40E_PMD
15263 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15271 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15274 printf("invalid port_id %d\n", res->port_id);
15277 printf("function not implemented\n");
15280 printf("programming error: (%s)\n", strerror(-ret));
15284 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15285 .f = cmd_vf_tc_min_bw_parsed,
15287 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15288 " <bw1, bw2, ...>",
15290 (void *)&cmd_vf_tc_bw_set,
15291 (void *)&cmd_vf_tc_bw_vf,
15292 (void *)&cmd_vf_tc_bw_tc,
15293 (void *)&cmd_vf_tc_bw_tx,
15294 (void *)&cmd_vf_tc_bw_min_bw,
15295 (void *)&cmd_vf_tc_bw_port_id,
15296 (void *)&cmd_vf_tc_bw_vf_id,
15297 (void *)&cmd_vf_tc_bw_bw_list,
15303 cmd_tc_min_bw_parsed(
15304 void *parsed_result,
15305 __rte_unused struct cmdline *cl,
15306 __rte_unused void *data)
15308 struct cmd_vf_tc_bw_result *res = parsed_result;
15309 struct rte_port *port;
15312 int ret = -ENOTSUP;
15314 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15317 port = &ports[res->port_id];
15318 /** Check if the port is not started **/
15319 if (port->port_status != RTE_PORT_STOPPED) {
15320 printf("Please stop port %d first\n", res->port_id);
15324 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15328 #ifdef RTE_LIBRTE_IXGBE_PMD
15329 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15336 printf("invalid bandwidth\n");
15339 printf("invalid port_id %d\n", res->port_id);
15342 printf("function not implemented\n");
15345 printf("programming error: (%s)\n", strerror(-ret));
15349 cmdline_parse_inst_t cmd_tc_min_bw = {
15350 .f = cmd_tc_min_bw_parsed,
15352 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15354 (void *)&cmd_vf_tc_bw_set,
15355 (void *)&cmd_vf_tc_bw_tc,
15356 (void *)&cmd_vf_tc_bw_tx,
15357 (void *)&cmd_vf_tc_bw_min_bw,
15358 (void *)&cmd_vf_tc_bw_port_id,
15359 (void *)&cmd_vf_tc_bw_bw_list,
15364 /* TC max bandwidth setting */
15366 cmd_vf_tc_max_bw_parsed(
15367 void *parsed_result,
15368 __rte_unused struct cmdline *cl,
15369 __rte_unused void *data)
15371 struct cmd_vf_tc_bw_result *res = parsed_result;
15372 int ret = -ENOTSUP;
15374 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15377 #ifdef RTE_LIBRTE_I40E_PMD
15378 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15379 res->tc_no, res->bw);
15386 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15387 res->vf_id, res->tc_no, res->bw);
15390 printf("invalid port_id %d\n", res->port_id);
15393 printf("function not implemented\n");
15396 printf("programming error: (%s)\n", strerror(-ret));
15400 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15401 .f = cmd_vf_tc_max_bw_parsed,
15403 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15406 (void *)&cmd_vf_tc_bw_set,
15407 (void *)&cmd_vf_tc_bw_vf,
15408 (void *)&cmd_vf_tc_bw_tc,
15409 (void *)&cmd_vf_tc_bw_tx,
15410 (void *)&cmd_vf_tc_bw_max_bw,
15411 (void *)&cmd_vf_tc_bw_port_id,
15412 (void *)&cmd_vf_tc_bw_vf_id,
15413 (void *)&cmd_vf_tc_bw_tc_no,
15414 (void *)&cmd_vf_tc_bw_bw,
15419 /** Set VXLAN encapsulation details */
15420 struct cmd_set_vxlan_result {
15421 cmdline_fixed_string_t set;
15422 cmdline_fixed_string_t vxlan;
15423 cmdline_fixed_string_t pos_token;
15424 cmdline_fixed_string_t ip_version;
15425 uint32_t vlan_present:1;
15429 cmdline_ipaddr_t ip_src;
15430 cmdline_ipaddr_t ip_dst;
15434 struct rte_ether_addr eth_src;
15435 struct rte_ether_addr eth_dst;
15438 cmdline_parse_token_string_t cmd_set_vxlan_set =
15439 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15440 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15441 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15442 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15443 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15445 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15446 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15447 "vxlan-with-vlan");
15448 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15449 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15451 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15452 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15454 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15455 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15457 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15458 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15459 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15460 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15462 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15463 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15464 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15465 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15467 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15468 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15469 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15470 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15472 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15473 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15474 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15475 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15477 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15478 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15479 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15480 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15482 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15483 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15484 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15485 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15487 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15488 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15489 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15490 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15492 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15493 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15494 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15495 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15497 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15498 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15499 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15500 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15502 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15503 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15505 static void cmd_set_vxlan_parsed(void *parsed_result,
15506 __rte_unused struct cmdline *cl,
15507 __rte_unused void *data)
15509 struct cmd_set_vxlan_result *res = parsed_result;
15514 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15517 vxlan_encap_conf.select_tos_ttl = 0;
15518 if (strcmp(res->vxlan, "vxlan") == 0)
15519 vxlan_encap_conf.select_vlan = 0;
15520 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15521 vxlan_encap_conf.select_vlan = 1;
15522 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15523 vxlan_encap_conf.select_vlan = 0;
15524 vxlan_encap_conf.select_tos_ttl = 1;
15526 if (strcmp(res->ip_version, "ipv4") == 0)
15527 vxlan_encap_conf.select_ipv4 = 1;
15528 else if (strcmp(res->ip_version, "ipv6") == 0)
15529 vxlan_encap_conf.select_ipv4 = 0;
15532 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15533 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15534 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15535 vxlan_encap_conf.ip_tos = res->tos;
15536 vxlan_encap_conf.ip_ttl = res->ttl;
15537 if (vxlan_encap_conf.select_ipv4) {
15538 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15539 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15541 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15542 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15544 if (vxlan_encap_conf.select_vlan)
15545 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15546 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15547 RTE_ETHER_ADDR_LEN);
15548 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15549 RTE_ETHER_ADDR_LEN);
15552 cmdline_parse_inst_t cmd_set_vxlan = {
15553 .f = cmd_set_vxlan_parsed,
15555 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15556 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15557 " eth-src <eth-src> eth-dst <eth-dst>",
15559 (void *)&cmd_set_vxlan_set,
15560 (void *)&cmd_set_vxlan_vxlan,
15561 (void *)&cmd_set_vxlan_ip_version,
15562 (void *)&cmd_set_vxlan_ip_version_value,
15563 (void *)&cmd_set_vxlan_vni,
15564 (void *)&cmd_set_vxlan_vni_value,
15565 (void *)&cmd_set_vxlan_udp_src,
15566 (void *)&cmd_set_vxlan_udp_src_value,
15567 (void *)&cmd_set_vxlan_udp_dst,
15568 (void *)&cmd_set_vxlan_udp_dst_value,
15569 (void *)&cmd_set_vxlan_ip_src,
15570 (void *)&cmd_set_vxlan_ip_src_value,
15571 (void *)&cmd_set_vxlan_ip_dst,
15572 (void *)&cmd_set_vxlan_ip_dst_value,
15573 (void *)&cmd_set_vxlan_eth_src,
15574 (void *)&cmd_set_vxlan_eth_src_value,
15575 (void *)&cmd_set_vxlan_eth_dst,
15576 (void *)&cmd_set_vxlan_eth_dst_value,
15581 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15582 .f = cmd_set_vxlan_parsed,
15584 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15585 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15586 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15587 " eth-dst <eth-dst>",
15589 (void *)&cmd_set_vxlan_set,
15590 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15591 (void *)&cmd_set_vxlan_ip_version,
15592 (void *)&cmd_set_vxlan_ip_version_value,
15593 (void *)&cmd_set_vxlan_vni,
15594 (void *)&cmd_set_vxlan_vni_value,
15595 (void *)&cmd_set_vxlan_udp_src,
15596 (void *)&cmd_set_vxlan_udp_src_value,
15597 (void *)&cmd_set_vxlan_udp_dst,
15598 (void *)&cmd_set_vxlan_udp_dst_value,
15599 (void *)&cmd_set_vxlan_ip_tos,
15600 (void *)&cmd_set_vxlan_ip_tos_value,
15601 (void *)&cmd_set_vxlan_ip_ttl,
15602 (void *)&cmd_set_vxlan_ip_ttl_value,
15603 (void *)&cmd_set_vxlan_ip_src,
15604 (void *)&cmd_set_vxlan_ip_src_value,
15605 (void *)&cmd_set_vxlan_ip_dst,
15606 (void *)&cmd_set_vxlan_ip_dst_value,
15607 (void *)&cmd_set_vxlan_eth_src,
15608 (void *)&cmd_set_vxlan_eth_src_value,
15609 (void *)&cmd_set_vxlan_eth_dst,
15610 (void *)&cmd_set_vxlan_eth_dst_value,
15615 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15616 .f = cmd_set_vxlan_parsed,
15618 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15619 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15620 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15623 (void *)&cmd_set_vxlan_set,
15624 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15625 (void *)&cmd_set_vxlan_ip_version,
15626 (void *)&cmd_set_vxlan_ip_version_value,
15627 (void *)&cmd_set_vxlan_vni,
15628 (void *)&cmd_set_vxlan_vni_value,
15629 (void *)&cmd_set_vxlan_udp_src,
15630 (void *)&cmd_set_vxlan_udp_src_value,
15631 (void *)&cmd_set_vxlan_udp_dst,
15632 (void *)&cmd_set_vxlan_udp_dst_value,
15633 (void *)&cmd_set_vxlan_ip_src,
15634 (void *)&cmd_set_vxlan_ip_src_value,
15635 (void *)&cmd_set_vxlan_ip_dst,
15636 (void *)&cmd_set_vxlan_ip_dst_value,
15637 (void *)&cmd_set_vxlan_vlan,
15638 (void *)&cmd_set_vxlan_vlan_value,
15639 (void *)&cmd_set_vxlan_eth_src,
15640 (void *)&cmd_set_vxlan_eth_src_value,
15641 (void *)&cmd_set_vxlan_eth_dst,
15642 (void *)&cmd_set_vxlan_eth_dst_value,
15647 /** Set NVGRE encapsulation details */
15648 struct cmd_set_nvgre_result {
15649 cmdline_fixed_string_t set;
15650 cmdline_fixed_string_t nvgre;
15651 cmdline_fixed_string_t pos_token;
15652 cmdline_fixed_string_t ip_version;
15654 cmdline_ipaddr_t ip_src;
15655 cmdline_ipaddr_t ip_dst;
15657 struct rte_ether_addr eth_src;
15658 struct rte_ether_addr eth_dst;
15661 cmdline_parse_token_string_t cmd_set_nvgre_set =
15662 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15663 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15664 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15665 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15666 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15667 "nvgre-with-vlan");
15668 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15669 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15671 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15672 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15674 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15675 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15677 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15678 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15679 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15680 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15682 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15683 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15684 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15685 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15687 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15688 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15689 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15690 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15692 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15693 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15694 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15695 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15697 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15698 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15699 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15700 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15702 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15703 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15705 static void cmd_set_nvgre_parsed(void *parsed_result,
15706 __rte_unused struct cmdline *cl,
15707 __rte_unused void *data)
15709 struct cmd_set_nvgre_result *res = parsed_result;
15711 uint32_t nvgre_tni;
15714 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15717 if (strcmp(res->nvgre, "nvgre") == 0)
15718 nvgre_encap_conf.select_vlan = 0;
15719 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15720 nvgre_encap_conf.select_vlan = 1;
15721 if (strcmp(res->ip_version, "ipv4") == 0)
15722 nvgre_encap_conf.select_ipv4 = 1;
15723 else if (strcmp(res->ip_version, "ipv6") == 0)
15724 nvgre_encap_conf.select_ipv4 = 0;
15727 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15728 if (nvgre_encap_conf.select_ipv4) {
15729 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15730 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15732 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15733 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15735 if (nvgre_encap_conf.select_vlan)
15736 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15737 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15738 RTE_ETHER_ADDR_LEN);
15739 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15740 RTE_ETHER_ADDR_LEN);
15743 cmdline_parse_inst_t cmd_set_nvgre = {
15744 .f = cmd_set_nvgre_parsed,
15746 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15747 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15748 " eth-dst <eth-dst>",
15750 (void *)&cmd_set_nvgre_set,
15751 (void *)&cmd_set_nvgre_nvgre,
15752 (void *)&cmd_set_nvgre_ip_version,
15753 (void *)&cmd_set_nvgre_ip_version_value,
15754 (void *)&cmd_set_nvgre_tni,
15755 (void *)&cmd_set_nvgre_tni_value,
15756 (void *)&cmd_set_nvgre_ip_src,
15757 (void *)&cmd_set_nvgre_ip_src_value,
15758 (void *)&cmd_set_nvgre_ip_dst,
15759 (void *)&cmd_set_nvgre_ip_dst_value,
15760 (void *)&cmd_set_nvgre_eth_src,
15761 (void *)&cmd_set_nvgre_eth_src_value,
15762 (void *)&cmd_set_nvgre_eth_dst,
15763 (void *)&cmd_set_nvgre_eth_dst_value,
15768 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15769 .f = cmd_set_nvgre_parsed,
15771 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15772 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15773 " eth-src <eth-src> eth-dst <eth-dst>",
15775 (void *)&cmd_set_nvgre_set,
15776 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15777 (void *)&cmd_set_nvgre_ip_version,
15778 (void *)&cmd_set_nvgre_ip_version_value,
15779 (void *)&cmd_set_nvgre_tni,
15780 (void *)&cmd_set_nvgre_tni_value,
15781 (void *)&cmd_set_nvgre_ip_src,
15782 (void *)&cmd_set_nvgre_ip_src_value,
15783 (void *)&cmd_set_nvgre_ip_dst,
15784 (void *)&cmd_set_nvgre_ip_dst_value,
15785 (void *)&cmd_set_nvgre_vlan,
15786 (void *)&cmd_set_nvgre_vlan_value,
15787 (void *)&cmd_set_nvgre_eth_src,
15788 (void *)&cmd_set_nvgre_eth_src_value,
15789 (void *)&cmd_set_nvgre_eth_dst,
15790 (void *)&cmd_set_nvgre_eth_dst_value,
15795 /** Set L2 encapsulation details */
15796 struct cmd_set_l2_encap_result {
15797 cmdline_fixed_string_t set;
15798 cmdline_fixed_string_t l2_encap;
15799 cmdline_fixed_string_t pos_token;
15800 cmdline_fixed_string_t ip_version;
15801 uint32_t vlan_present:1;
15803 struct rte_ether_addr eth_src;
15804 struct rte_ether_addr eth_dst;
15807 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15808 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15809 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15810 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15811 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15812 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15813 "l2_encap-with-vlan");
15814 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15815 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15817 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15818 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15820 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15821 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15823 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15824 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15825 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15826 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15828 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15829 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15830 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15831 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15833 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15834 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15836 static void cmd_set_l2_encap_parsed(void *parsed_result,
15837 __rte_unused struct cmdline *cl,
15838 __rte_unused void *data)
15840 struct cmd_set_l2_encap_result *res = parsed_result;
15842 if (strcmp(res->l2_encap, "l2_encap") == 0)
15843 l2_encap_conf.select_vlan = 0;
15844 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15845 l2_encap_conf.select_vlan = 1;
15846 if (strcmp(res->ip_version, "ipv4") == 0)
15847 l2_encap_conf.select_ipv4 = 1;
15848 else if (strcmp(res->ip_version, "ipv6") == 0)
15849 l2_encap_conf.select_ipv4 = 0;
15852 if (l2_encap_conf.select_vlan)
15853 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15854 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15855 RTE_ETHER_ADDR_LEN);
15856 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15857 RTE_ETHER_ADDR_LEN);
15860 cmdline_parse_inst_t cmd_set_l2_encap = {
15861 .f = cmd_set_l2_encap_parsed,
15863 .help_str = "set l2_encap ip-version ipv4|ipv6"
15864 " eth-src <eth-src> eth-dst <eth-dst>",
15866 (void *)&cmd_set_l2_encap_set,
15867 (void *)&cmd_set_l2_encap_l2_encap,
15868 (void *)&cmd_set_l2_encap_ip_version,
15869 (void *)&cmd_set_l2_encap_ip_version_value,
15870 (void *)&cmd_set_l2_encap_eth_src,
15871 (void *)&cmd_set_l2_encap_eth_src_value,
15872 (void *)&cmd_set_l2_encap_eth_dst,
15873 (void *)&cmd_set_l2_encap_eth_dst_value,
15878 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15879 .f = cmd_set_l2_encap_parsed,
15881 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15882 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15884 (void *)&cmd_set_l2_encap_set,
15885 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15886 (void *)&cmd_set_l2_encap_ip_version,
15887 (void *)&cmd_set_l2_encap_ip_version_value,
15888 (void *)&cmd_set_l2_encap_vlan,
15889 (void *)&cmd_set_l2_encap_vlan_value,
15890 (void *)&cmd_set_l2_encap_eth_src,
15891 (void *)&cmd_set_l2_encap_eth_src_value,
15892 (void *)&cmd_set_l2_encap_eth_dst,
15893 (void *)&cmd_set_l2_encap_eth_dst_value,
15898 /** Set L2 decapsulation details */
15899 struct cmd_set_l2_decap_result {
15900 cmdline_fixed_string_t set;
15901 cmdline_fixed_string_t l2_decap;
15902 cmdline_fixed_string_t pos_token;
15903 uint32_t vlan_present:1;
15906 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15907 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15908 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15909 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15911 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15912 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15913 "l2_decap-with-vlan");
15915 static void cmd_set_l2_decap_parsed(void *parsed_result,
15916 __rte_unused struct cmdline *cl,
15917 __rte_unused void *data)
15919 struct cmd_set_l2_decap_result *res = parsed_result;
15921 if (strcmp(res->l2_decap, "l2_decap") == 0)
15922 l2_decap_conf.select_vlan = 0;
15923 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15924 l2_decap_conf.select_vlan = 1;
15927 cmdline_parse_inst_t cmd_set_l2_decap = {
15928 .f = cmd_set_l2_decap_parsed,
15930 .help_str = "set l2_decap",
15932 (void *)&cmd_set_l2_decap_set,
15933 (void *)&cmd_set_l2_decap_l2_decap,
15938 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15939 .f = cmd_set_l2_decap_parsed,
15941 .help_str = "set l2_decap-with-vlan",
15943 (void *)&cmd_set_l2_decap_set,
15944 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15949 /** Set MPLSoGRE encapsulation details */
15950 struct cmd_set_mplsogre_encap_result {
15951 cmdline_fixed_string_t set;
15952 cmdline_fixed_string_t mplsogre;
15953 cmdline_fixed_string_t pos_token;
15954 cmdline_fixed_string_t ip_version;
15955 uint32_t vlan_present:1;
15957 cmdline_ipaddr_t ip_src;
15958 cmdline_ipaddr_t ip_dst;
15960 struct rte_ether_addr eth_src;
15961 struct rte_ether_addr eth_dst;
15964 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15965 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15967 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15968 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15970 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15971 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15972 mplsogre, "mplsogre_encap-with-vlan");
15973 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15974 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15975 pos_token, "ip-version");
15976 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15977 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15978 ip_version, "ipv4#ipv6");
15979 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15980 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15981 pos_token, "label");
15982 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15983 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15985 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15986 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15987 pos_token, "ip-src");
15988 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15989 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15990 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15991 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15992 pos_token, "ip-dst");
15993 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15994 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15995 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15996 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15997 pos_token, "vlan-tci");
15998 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15999 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
16001 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
16002 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16003 pos_token, "eth-src");
16004 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
16005 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16007 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
16008 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16009 pos_token, "eth-dst");
16010 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
16011 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16014 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
16015 __rte_unused struct cmdline *cl,
16016 __rte_unused void *data)
16018 struct cmd_set_mplsogre_encap_result *res = parsed_result;
16020 uint32_t mplsogre_label;
16023 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
16026 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
16027 mplsogre_encap_conf.select_vlan = 0;
16028 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
16029 mplsogre_encap_conf.select_vlan = 1;
16030 if (strcmp(res->ip_version, "ipv4") == 0)
16031 mplsogre_encap_conf.select_ipv4 = 1;
16032 else if (strcmp(res->ip_version, "ipv6") == 0)
16033 mplsogre_encap_conf.select_ipv4 = 0;
16036 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
16037 if (mplsogre_encap_conf.select_ipv4) {
16038 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
16039 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
16041 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
16042 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
16044 if (mplsogre_encap_conf.select_vlan)
16045 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16046 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
16047 RTE_ETHER_ADDR_LEN);
16048 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16049 RTE_ETHER_ADDR_LEN);
16052 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
16053 .f = cmd_set_mplsogre_encap_parsed,
16055 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
16056 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
16057 " eth-dst <eth-dst>",
16059 (void *)&cmd_set_mplsogre_encap_set,
16060 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
16061 (void *)&cmd_set_mplsogre_encap_ip_version,
16062 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16063 (void *)&cmd_set_mplsogre_encap_label,
16064 (void *)&cmd_set_mplsogre_encap_label_value,
16065 (void *)&cmd_set_mplsogre_encap_ip_src,
16066 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16067 (void *)&cmd_set_mplsogre_encap_ip_dst,
16068 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16069 (void *)&cmd_set_mplsogre_encap_eth_src,
16070 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16071 (void *)&cmd_set_mplsogre_encap_eth_dst,
16072 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16077 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16078 .f = cmd_set_mplsogre_encap_parsed,
16080 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16081 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16082 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16084 (void *)&cmd_set_mplsogre_encap_set,
16085 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16086 (void *)&cmd_set_mplsogre_encap_ip_version,
16087 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16088 (void *)&cmd_set_mplsogre_encap_label,
16089 (void *)&cmd_set_mplsogre_encap_label_value,
16090 (void *)&cmd_set_mplsogre_encap_ip_src,
16091 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16092 (void *)&cmd_set_mplsogre_encap_ip_dst,
16093 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16094 (void *)&cmd_set_mplsogre_encap_vlan,
16095 (void *)&cmd_set_mplsogre_encap_vlan_value,
16096 (void *)&cmd_set_mplsogre_encap_eth_src,
16097 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16098 (void *)&cmd_set_mplsogre_encap_eth_dst,
16099 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16104 /** Set MPLSoGRE decapsulation details */
16105 struct cmd_set_mplsogre_decap_result {
16106 cmdline_fixed_string_t set;
16107 cmdline_fixed_string_t mplsogre;
16108 cmdline_fixed_string_t pos_token;
16109 cmdline_fixed_string_t ip_version;
16110 uint32_t vlan_present:1;
16113 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16114 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16116 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16117 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16119 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16120 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16121 mplsogre, "mplsogre_decap-with-vlan");
16122 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16123 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16124 pos_token, "ip-version");
16125 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16126 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16127 ip_version, "ipv4#ipv6");
16129 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16130 __rte_unused struct cmdline *cl,
16131 __rte_unused void *data)
16133 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16135 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16136 mplsogre_decap_conf.select_vlan = 0;
16137 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16138 mplsogre_decap_conf.select_vlan = 1;
16139 if (strcmp(res->ip_version, "ipv4") == 0)
16140 mplsogre_decap_conf.select_ipv4 = 1;
16141 else if (strcmp(res->ip_version, "ipv6") == 0)
16142 mplsogre_decap_conf.select_ipv4 = 0;
16145 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16146 .f = cmd_set_mplsogre_decap_parsed,
16148 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16150 (void *)&cmd_set_mplsogre_decap_set,
16151 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16152 (void *)&cmd_set_mplsogre_decap_ip_version,
16153 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16158 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16159 .f = cmd_set_mplsogre_decap_parsed,
16161 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16163 (void *)&cmd_set_mplsogre_decap_set,
16164 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16165 (void *)&cmd_set_mplsogre_decap_ip_version,
16166 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16171 /** Set MPLSoUDP encapsulation details */
16172 struct cmd_set_mplsoudp_encap_result {
16173 cmdline_fixed_string_t set;
16174 cmdline_fixed_string_t mplsoudp;
16175 cmdline_fixed_string_t pos_token;
16176 cmdline_fixed_string_t ip_version;
16177 uint32_t vlan_present:1;
16181 cmdline_ipaddr_t ip_src;
16182 cmdline_ipaddr_t ip_dst;
16184 struct rte_ether_addr eth_src;
16185 struct rte_ether_addr eth_dst;
16188 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16189 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16191 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16192 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16194 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16195 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16196 mplsoudp, "mplsoudp_encap-with-vlan");
16197 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16198 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16199 pos_token, "ip-version");
16200 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16201 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16202 ip_version, "ipv4#ipv6");
16203 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16204 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16205 pos_token, "label");
16206 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16207 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16209 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16210 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16211 pos_token, "udp-src");
16212 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16213 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16215 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16216 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16217 pos_token, "udp-dst");
16218 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16219 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16221 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16222 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16223 pos_token, "ip-src");
16224 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16225 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16226 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16227 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16228 pos_token, "ip-dst");
16229 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16230 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16231 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16232 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16233 pos_token, "vlan-tci");
16234 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16235 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16237 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16238 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16239 pos_token, "eth-src");
16240 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16241 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16243 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16244 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16245 pos_token, "eth-dst");
16246 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16247 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16250 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16251 __rte_unused struct cmdline *cl,
16252 __rte_unused void *data)
16254 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16256 uint32_t mplsoudp_label;
16259 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16262 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16263 mplsoudp_encap_conf.select_vlan = 0;
16264 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16265 mplsoudp_encap_conf.select_vlan = 1;
16266 if (strcmp(res->ip_version, "ipv4") == 0)
16267 mplsoudp_encap_conf.select_ipv4 = 1;
16268 else if (strcmp(res->ip_version, "ipv6") == 0)
16269 mplsoudp_encap_conf.select_ipv4 = 0;
16272 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16273 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16274 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16275 if (mplsoudp_encap_conf.select_ipv4) {
16276 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16277 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16279 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16280 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16282 if (mplsoudp_encap_conf.select_vlan)
16283 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16284 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16285 RTE_ETHER_ADDR_LEN);
16286 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16287 RTE_ETHER_ADDR_LEN);
16290 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16291 .f = cmd_set_mplsoudp_encap_parsed,
16293 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16294 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16295 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16297 (void *)&cmd_set_mplsoudp_encap_set,
16298 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16299 (void *)&cmd_set_mplsoudp_encap_ip_version,
16300 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16301 (void *)&cmd_set_mplsoudp_encap_label,
16302 (void *)&cmd_set_mplsoudp_encap_label_value,
16303 (void *)&cmd_set_mplsoudp_encap_udp_src,
16304 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16305 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16306 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16307 (void *)&cmd_set_mplsoudp_encap_ip_src,
16308 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16309 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16310 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16311 (void *)&cmd_set_mplsoudp_encap_eth_src,
16312 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16313 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16314 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16319 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16320 .f = cmd_set_mplsoudp_encap_parsed,
16322 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16323 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16324 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16325 " eth-src <eth-src> eth-dst <eth-dst>",
16327 (void *)&cmd_set_mplsoudp_encap_set,
16328 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16329 (void *)&cmd_set_mplsoudp_encap_ip_version,
16330 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16331 (void *)&cmd_set_mplsoudp_encap_label,
16332 (void *)&cmd_set_mplsoudp_encap_label_value,
16333 (void *)&cmd_set_mplsoudp_encap_udp_src,
16334 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16335 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16336 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16337 (void *)&cmd_set_mplsoudp_encap_ip_src,
16338 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16339 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16340 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16341 (void *)&cmd_set_mplsoudp_encap_vlan,
16342 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16343 (void *)&cmd_set_mplsoudp_encap_eth_src,
16344 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16345 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16346 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16351 /** Set MPLSoUDP decapsulation details */
16352 struct cmd_set_mplsoudp_decap_result {
16353 cmdline_fixed_string_t set;
16354 cmdline_fixed_string_t mplsoudp;
16355 cmdline_fixed_string_t pos_token;
16356 cmdline_fixed_string_t ip_version;
16357 uint32_t vlan_present:1;
16360 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16361 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16363 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16364 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16366 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16367 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16368 mplsoudp, "mplsoudp_decap-with-vlan");
16369 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16370 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16371 pos_token, "ip-version");
16372 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16373 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16374 ip_version, "ipv4#ipv6");
16376 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16377 __rte_unused struct cmdline *cl,
16378 __rte_unused void *data)
16380 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16382 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16383 mplsoudp_decap_conf.select_vlan = 0;
16384 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16385 mplsoudp_decap_conf.select_vlan = 1;
16386 if (strcmp(res->ip_version, "ipv4") == 0)
16387 mplsoudp_decap_conf.select_ipv4 = 1;
16388 else if (strcmp(res->ip_version, "ipv6") == 0)
16389 mplsoudp_decap_conf.select_ipv4 = 0;
16392 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16393 .f = cmd_set_mplsoudp_decap_parsed,
16395 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16397 (void *)&cmd_set_mplsoudp_decap_set,
16398 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16399 (void *)&cmd_set_mplsoudp_decap_ip_version,
16400 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16405 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16406 .f = cmd_set_mplsoudp_decap_parsed,
16408 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16410 (void *)&cmd_set_mplsoudp_decap_set,
16411 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16412 (void *)&cmd_set_mplsoudp_decap_ip_version,
16413 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16418 /* Strict link priority scheduling mode setting */
16420 cmd_strict_link_prio_parsed(
16421 void *parsed_result,
16422 __rte_unused struct cmdline *cl,
16423 __rte_unused void *data)
16425 struct cmd_vf_tc_bw_result *res = parsed_result;
16426 int ret = -ENOTSUP;
16428 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16431 #ifdef RTE_LIBRTE_I40E_PMD
16432 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16439 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16442 printf("invalid port_id %d\n", res->port_id);
16445 printf("function not implemented\n");
16448 printf("programming error: (%s)\n", strerror(-ret));
16452 cmdline_parse_inst_t cmd_strict_link_prio = {
16453 .f = cmd_strict_link_prio_parsed,
16455 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16457 (void *)&cmd_vf_tc_bw_set,
16458 (void *)&cmd_vf_tc_bw_tx,
16459 (void *)&cmd_vf_tc_bw_strict_link_prio,
16460 (void *)&cmd_vf_tc_bw_port_id,
16461 (void *)&cmd_vf_tc_bw_tc_map,
16466 /* Load dynamic device personalization*/
16467 struct cmd_ddp_add_result {
16468 cmdline_fixed_string_t ddp;
16469 cmdline_fixed_string_t add;
16474 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16475 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16476 cmdline_parse_token_string_t cmd_ddp_add_add =
16477 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16478 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16479 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16480 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16481 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16484 cmd_ddp_add_parsed(
16485 void *parsed_result,
16486 __rte_unused struct cmdline *cl,
16487 __rte_unused void *data)
16489 struct cmd_ddp_add_result *res = parsed_result;
16495 int ret = -ENOTSUP;
16497 if (!all_ports_stopped()) {
16498 printf("Please stop all ports first\n");
16502 filepath = strdup(res->filepath);
16503 if (filepath == NULL) {
16504 printf("Failed to allocate memory\n");
16507 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16509 buff = open_file(file_fld[0], &size);
16511 free((void *)filepath);
16515 #ifdef RTE_LIBRTE_I40E_PMD
16516 if (ret == -ENOTSUP)
16517 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16519 RTE_PMD_I40E_PKG_OP_WR_ADD);
16522 if (ret == -EEXIST)
16523 printf("Profile has already existed.\n");
16525 printf("Failed to load profile.\n");
16526 else if (file_num == 2)
16527 save_file(file_fld[1], buff, size);
16530 free((void *)filepath);
16533 cmdline_parse_inst_t cmd_ddp_add = {
16534 .f = cmd_ddp_add_parsed,
16536 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16538 (void *)&cmd_ddp_add_ddp,
16539 (void *)&cmd_ddp_add_add,
16540 (void *)&cmd_ddp_add_port_id,
16541 (void *)&cmd_ddp_add_filepath,
16546 /* Delete dynamic device personalization*/
16547 struct cmd_ddp_del_result {
16548 cmdline_fixed_string_t ddp;
16549 cmdline_fixed_string_t del;
16554 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16555 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16556 cmdline_parse_token_string_t cmd_ddp_del_del =
16557 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16558 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16559 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16560 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16561 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16564 cmd_ddp_del_parsed(
16565 void *parsed_result,
16566 __rte_unused struct cmdline *cl,
16567 __rte_unused void *data)
16569 struct cmd_ddp_del_result *res = parsed_result;
16572 int ret = -ENOTSUP;
16574 if (!all_ports_stopped()) {
16575 printf("Please stop all ports first\n");
16579 buff = open_file(res->filepath, &size);
16583 #ifdef RTE_LIBRTE_I40E_PMD
16584 if (ret == -ENOTSUP)
16585 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16587 RTE_PMD_I40E_PKG_OP_WR_DEL);
16590 if (ret == -EACCES)
16591 printf("Profile does not exist.\n");
16593 printf("Failed to delete profile.\n");
16598 cmdline_parse_inst_t cmd_ddp_del = {
16599 .f = cmd_ddp_del_parsed,
16601 .help_str = "ddp del <port_id> <backup_profile_path>",
16603 (void *)&cmd_ddp_del_ddp,
16604 (void *)&cmd_ddp_del_del,
16605 (void *)&cmd_ddp_del_port_id,
16606 (void *)&cmd_ddp_del_filepath,
16611 /* Get dynamic device personalization profile info */
16612 struct cmd_ddp_info_result {
16613 cmdline_fixed_string_t ddp;
16614 cmdline_fixed_string_t get;
16615 cmdline_fixed_string_t info;
16619 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16620 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16621 cmdline_parse_token_string_t cmd_ddp_info_get =
16622 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16623 cmdline_parse_token_string_t cmd_ddp_info_info =
16624 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16625 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16626 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16629 cmd_ddp_info_parsed(
16630 void *parsed_result,
16631 __rte_unused struct cmdline *cl,
16632 __rte_unused void *data)
16634 struct cmd_ddp_info_result *res = parsed_result;
16637 int ret = -ENOTSUP;
16638 #ifdef RTE_LIBRTE_I40E_PMD
16641 uint32_t buff_size = 0;
16642 struct rte_pmd_i40e_profile_info info;
16643 uint32_t dev_num = 0;
16644 struct rte_pmd_i40e_ddp_device_id *devs;
16645 uint32_t proto_num = 0;
16646 struct rte_pmd_i40e_proto_info *proto = NULL;
16647 uint32_t pctype_num = 0;
16648 struct rte_pmd_i40e_ptype_info *pctype;
16649 uint32_t ptype_num = 0;
16650 struct rte_pmd_i40e_ptype_info *ptype;
16655 pkg = open_file(res->filepath, &pkg_size);
16659 #ifdef RTE_LIBRTE_I40E_PMD
16660 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16661 (uint8_t *)&info, sizeof(info),
16662 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16664 printf("Global Track id: 0x%x\n", info.track_id);
16665 printf("Global Version: %d.%d.%d.%d\n",
16666 info.version.major,
16667 info.version.minor,
16668 info.version.update,
16669 info.version.draft);
16670 printf("Global Package name: %s\n\n", info.name);
16673 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16674 (uint8_t *)&info, sizeof(info),
16675 RTE_PMD_I40E_PKG_INFO_HEADER);
16677 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16678 printf("i40e Profile Version: %d.%d.%d.%d\n",
16679 info.version.major,
16680 info.version.minor,
16681 info.version.update,
16682 info.version.draft);
16683 printf("i40e Profile name: %s\n\n", info.name);
16686 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16687 (uint8_t *)&buff_size, sizeof(buff_size),
16688 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16689 if (!ret && buff_size) {
16690 buff = (uint8_t *)malloc(buff_size);
16692 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16694 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16696 printf("Package Notes:\n%s\n\n", buff);
16701 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16702 (uint8_t *)&dev_num, sizeof(dev_num),
16703 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16704 if (!ret && dev_num) {
16705 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16706 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16708 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16709 (uint8_t *)devs, buff_size,
16710 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16712 printf("List of supported devices:\n");
16713 for (i = 0; i < dev_num; i++) {
16714 printf(" %04X:%04X %04X:%04X\n",
16715 devs[i].vendor_dev_id >> 16,
16716 devs[i].vendor_dev_id & 0xFFFF,
16717 devs[i].sub_vendor_dev_id >> 16,
16718 devs[i].sub_vendor_dev_id & 0xFFFF);
16726 /* get information about protocols and packet types */
16727 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16728 (uint8_t *)&proto_num, sizeof(proto_num),
16729 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16730 if (ret || !proto_num)
16731 goto no_print_return;
16733 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16734 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16736 goto no_print_return;
16738 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16740 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16742 printf("List of used protocols:\n");
16743 for (i = 0; i < proto_num; i++)
16744 printf(" %2u: %s\n", proto[i].proto_id,
16748 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16749 (uint8_t *)&pctype_num, sizeof(pctype_num),
16750 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16751 if (ret || !pctype_num)
16752 goto no_print_pctypes;
16754 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16755 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16757 goto no_print_pctypes;
16759 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16761 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16764 goto no_print_pctypes;
16767 printf("List of defined packet classification types:\n");
16768 for (i = 0; i < pctype_num; i++) {
16769 printf(" %2u:", pctype[i].ptype_id);
16770 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16771 proto_id = pctype[i].protocols[j];
16772 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16773 for (n = 0; n < proto_num; n++) {
16774 if (proto[n].proto_id == proto_id) {
16775 printf(" %s", proto[n].name);
16788 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16790 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16791 if (ret || !ptype_num)
16792 goto no_print_return;
16794 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16795 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16797 goto no_print_return;
16799 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16801 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16804 goto no_print_return;
16806 printf("List of defined packet types:\n");
16807 for (i = 0; i < ptype_num; i++) {
16808 printf(" %2u:", ptype[i].ptype_id);
16809 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16810 proto_id = ptype[i].protocols[j];
16811 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16812 for (n = 0; n < proto_num; n++) {
16813 if (proto[n].proto_id == proto_id) {
16814 printf(" %s", proto[n].name);
16830 if (ret == -ENOTSUP)
16831 printf("Function not supported in PMD driver\n");
16835 cmdline_parse_inst_t cmd_ddp_get_info = {
16836 .f = cmd_ddp_info_parsed,
16838 .help_str = "ddp get info <profile_path>",
16840 (void *)&cmd_ddp_info_ddp,
16841 (void *)&cmd_ddp_info_get,
16842 (void *)&cmd_ddp_info_info,
16843 (void *)&cmd_ddp_info_filepath,
16848 /* Get dynamic device personalization profile info list*/
16849 #define PROFILE_INFO_SIZE 48
16850 #define MAX_PROFILE_NUM 16
16852 struct cmd_ddp_get_list_result {
16853 cmdline_fixed_string_t ddp;
16854 cmdline_fixed_string_t get;
16855 cmdline_fixed_string_t list;
16859 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16860 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16861 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16862 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16863 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16864 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16865 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16866 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16869 cmd_ddp_get_list_parsed(
16870 __rte_unused void *parsed_result,
16871 __rte_unused struct cmdline *cl,
16872 __rte_unused void *data)
16874 #ifdef RTE_LIBRTE_I40E_PMD
16875 struct cmd_ddp_get_list_result *res = parsed_result;
16876 struct rte_pmd_i40e_profile_list *p_list;
16877 struct rte_pmd_i40e_profile_info *p_info;
16882 int ret = -ENOTSUP;
16884 #ifdef RTE_LIBRTE_I40E_PMD
16885 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16886 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16888 printf("%s: Failed to malloc buffer\n", __func__);
16892 if (ret == -ENOTSUP)
16893 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16894 (uint8_t *)p_list, size);
16897 p_num = p_list->p_count;
16898 printf("Profile number is: %d\n\n", p_num);
16900 for (i = 0; i < p_num; i++) {
16901 p_info = &p_list->p_info[i];
16902 printf("Profile %d:\n", i);
16903 printf("Track id: 0x%x\n", p_info->track_id);
16904 printf("Version: %d.%d.%d.%d\n",
16905 p_info->version.major,
16906 p_info->version.minor,
16907 p_info->version.update,
16908 p_info->version.draft);
16909 printf("Profile name: %s\n\n", p_info->name);
16917 printf("Failed to get ddp list\n");
16920 cmdline_parse_inst_t cmd_ddp_get_list = {
16921 .f = cmd_ddp_get_list_parsed,
16923 .help_str = "ddp get list <port_id>",
16925 (void *)&cmd_ddp_get_list_ddp,
16926 (void *)&cmd_ddp_get_list_get,
16927 (void *)&cmd_ddp_get_list_list,
16928 (void *)&cmd_ddp_get_list_port_id,
16933 /* Configure input set */
16934 struct cmd_cfg_input_set_result {
16935 cmdline_fixed_string_t port;
16936 cmdline_fixed_string_t cfg;
16938 cmdline_fixed_string_t pctype;
16940 cmdline_fixed_string_t inset_type;
16941 cmdline_fixed_string_t opt;
16942 cmdline_fixed_string_t field;
16947 cmd_cfg_input_set_parsed(
16948 __rte_unused void *parsed_result,
16949 __rte_unused struct cmdline *cl,
16950 __rte_unused void *data)
16952 #ifdef RTE_LIBRTE_I40E_PMD
16953 struct cmd_cfg_input_set_result *res = parsed_result;
16954 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16955 struct rte_pmd_i40e_inset inset;
16957 int ret = -ENOTSUP;
16959 if (!all_ports_stopped()) {
16960 printf("Please stop all ports first\n");
16964 #ifdef RTE_LIBRTE_I40E_PMD
16965 if (!strcmp(res->inset_type, "hash_inset"))
16966 inset_type = INSET_HASH;
16967 else if (!strcmp(res->inset_type, "fdir_inset"))
16968 inset_type = INSET_FDIR;
16969 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16970 inset_type = INSET_FDIR_FLX;
16971 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16972 &inset, inset_type);
16974 printf("Failed to get input set.\n");
16978 if (!strcmp(res->opt, "get")) {
16979 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16982 printf("Field index %d is enabled.\n", res->field_idx);
16984 printf("Field index %d is disabled.\n", res->field_idx);
16986 } else if (!strcmp(res->opt, "set"))
16987 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16989 else if (!strcmp(res->opt, "clear"))
16990 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16993 printf("Failed to configure input set field.\n");
16997 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16998 &inset, inset_type);
17000 printf("Failed to set input set.\n");
17005 if (ret == -ENOTSUP)
17006 printf("Function not supported\n");
17009 cmdline_parse_token_string_t cmd_cfg_input_set_port =
17010 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17012 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
17013 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17015 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
17016 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17018 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
17019 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17021 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
17022 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17024 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
17025 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17027 "hash_inset#fdir_inset#fdir_flx_inset");
17028 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
17029 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17030 opt, "get#set#clear");
17031 cmdline_parse_token_string_t cmd_cfg_input_set_field =
17032 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17034 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
17035 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17038 cmdline_parse_inst_t cmd_cfg_input_set = {
17039 .f = cmd_cfg_input_set_parsed,
17041 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17042 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
17044 (void *)&cmd_cfg_input_set_port,
17045 (void *)&cmd_cfg_input_set_cfg,
17046 (void *)&cmd_cfg_input_set_port_id,
17047 (void *)&cmd_cfg_input_set_pctype,
17048 (void *)&cmd_cfg_input_set_pctype_id,
17049 (void *)&cmd_cfg_input_set_inset_type,
17050 (void *)&cmd_cfg_input_set_opt,
17051 (void *)&cmd_cfg_input_set_field,
17052 (void *)&cmd_cfg_input_set_field_idx,
17057 /* Clear input set */
17058 struct cmd_clear_input_set_result {
17059 cmdline_fixed_string_t port;
17060 cmdline_fixed_string_t cfg;
17062 cmdline_fixed_string_t pctype;
17064 cmdline_fixed_string_t inset_type;
17065 cmdline_fixed_string_t clear;
17066 cmdline_fixed_string_t all;
17070 cmd_clear_input_set_parsed(
17071 __rte_unused void *parsed_result,
17072 __rte_unused struct cmdline *cl,
17073 __rte_unused void *data)
17075 #ifdef RTE_LIBRTE_I40E_PMD
17076 struct cmd_clear_input_set_result *res = parsed_result;
17077 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17078 struct rte_pmd_i40e_inset inset;
17080 int ret = -ENOTSUP;
17082 if (!all_ports_stopped()) {
17083 printf("Please stop all ports first\n");
17087 #ifdef RTE_LIBRTE_I40E_PMD
17088 if (!strcmp(res->inset_type, "hash_inset"))
17089 inset_type = INSET_HASH;
17090 else if (!strcmp(res->inset_type, "fdir_inset"))
17091 inset_type = INSET_FDIR;
17092 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17093 inset_type = INSET_FDIR_FLX;
17095 memset(&inset, 0, sizeof(inset));
17097 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17098 &inset, inset_type);
17100 printf("Failed to clear input set.\n");
17106 if (ret == -ENOTSUP)
17107 printf("Function not supported\n");
17110 cmdline_parse_token_string_t cmd_clear_input_set_port =
17111 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17113 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17114 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17116 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17117 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17119 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17120 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17122 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17123 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17125 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17126 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17128 "hash_inset#fdir_inset#fdir_flx_inset");
17129 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17130 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17132 cmdline_parse_token_string_t cmd_clear_input_set_all =
17133 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17136 cmdline_parse_inst_t cmd_clear_input_set = {
17137 .f = cmd_clear_input_set_parsed,
17139 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17140 "fdir_inset|fdir_flx_inset clear all",
17142 (void *)&cmd_clear_input_set_port,
17143 (void *)&cmd_clear_input_set_cfg,
17144 (void *)&cmd_clear_input_set_port_id,
17145 (void *)&cmd_clear_input_set_pctype,
17146 (void *)&cmd_clear_input_set_pctype_id,
17147 (void *)&cmd_clear_input_set_inset_type,
17148 (void *)&cmd_clear_input_set_clear,
17149 (void *)&cmd_clear_input_set_all,
17154 /* show vf stats */
17156 /* Common result structure for show vf stats */
17157 struct cmd_show_vf_stats_result {
17158 cmdline_fixed_string_t show;
17159 cmdline_fixed_string_t vf;
17160 cmdline_fixed_string_t stats;
17165 /* Common CLI fields show vf stats*/
17166 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17167 TOKEN_STRING_INITIALIZER
17168 (struct cmd_show_vf_stats_result,
17170 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17171 TOKEN_STRING_INITIALIZER
17172 (struct cmd_show_vf_stats_result,
17174 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17175 TOKEN_STRING_INITIALIZER
17176 (struct cmd_show_vf_stats_result,
17178 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17179 TOKEN_NUM_INITIALIZER
17180 (struct cmd_show_vf_stats_result,
17182 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17183 TOKEN_NUM_INITIALIZER
17184 (struct cmd_show_vf_stats_result,
17188 cmd_show_vf_stats_parsed(
17189 void *parsed_result,
17190 __rte_unused struct cmdline *cl,
17191 __rte_unused void *data)
17193 struct cmd_show_vf_stats_result *res = parsed_result;
17194 struct rte_eth_stats stats;
17195 int ret = -ENOTSUP;
17196 static const char *nic_stats_border = "########################";
17198 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17201 memset(&stats, 0, sizeof(stats));
17203 #ifdef RTE_LIBRTE_I40E_PMD
17204 if (ret == -ENOTSUP)
17205 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17209 #ifdef RTE_LIBRTE_BNXT_PMD
17210 if (ret == -ENOTSUP)
17211 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17220 printf("invalid vf_id %d\n", res->vf_id);
17223 printf("invalid port_id %d\n", res->port_id);
17226 printf("function not implemented\n");
17229 printf("programming error: (%s)\n", strerror(-ret));
17232 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17233 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17235 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17237 stats.ipackets, stats.imissed, stats.ibytes);
17238 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17239 printf(" RX-nombuf: %-10"PRIu64"\n",
17241 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17243 stats.opackets, stats.oerrors, stats.obytes);
17245 printf(" %s############################%s\n",
17246 nic_stats_border, nic_stats_border);
17249 cmdline_parse_inst_t cmd_show_vf_stats = {
17250 .f = cmd_show_vf_stats_parsed,
17252 .help_str = "show vf stats <port_id> <vf_id>",
17254 (void *)&cmd_show_vf_stats_show,
17255 (void *)&cmd_show_vf_stats_vf,
17256 (void *)&cmd_show_vf_stats_stats,
17257 (void *)&cmd_show_vf_stats_port_id,
17258 (void *)&cmd_show_vf_stats_vf_id,
17263 /* clear vf stats */
17265 /* Common result structure for clear vf stats */
17266 struct cmd_clear_vf_stats_result {
17267 cmdline_fixed_string_t clear;
17268 cmdline_fixed_string_t vf;
17269 cmdline_fixed_string_t stats;
17274 /* Common CLI fields clear vf stats*/
17275 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17276 TOKEN_STRING_INITIALIZER
17277 (struct cmd_clear_vf_stats_result,
17279 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17280 TOKEN_STRING_INITIALIZER
17281 (struct cmd_clear_vf_stats_result,
17283 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17284 TOKEN_STRING_INITIALIZER
17285 (struct cmd_clear_vf_stats_result,
17287 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17288 TOKEN_NUM_INITIALIZER
17289 (struct cmd_clear_vf_stats_result,
17291 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17292 TOKEN_NUM_INITIALIZER
17293 (struct cmd_clear_vf_stats_result,
17297 cmd_clear_vf_stats_parsed(
17298 void *parsed_result,
17299 __rte_unused struct cmdline *cl,
17300 __rte_unused void *data)
17302 struct cmd_clear_vf_stats_result *res = parsed_result;
17303 int ret = -ENOTSUP;
17305 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17308 #ifdef RTE_LIBRTE_I40E_PMD
17309 if (ret == -ENOTSUP)
17310 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17313 #ifdef RTE_LIBRTE_BNXT_PMD
17314 if (ret == -ENOTSUP)
17315 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17323 printf("invalid vf_id %d\n", res->vf_id);
17326 printf("invalid port_id %d\n", res->port_id);
17329 printf("function not implemented\n");
17332 printf("programming error: (%s)\n", strerror(-ret));
17336 cmdline_parse_inst_t cmd_clear_vf_stats = {
17337 .f = cmd_clear_vf_stats_parsed,
17339 .help_str = "clear vf stats <port_id> <vf_id>",
17341 (void *)&cmd_clear_vf_stats_clear,
17342 (void *)&cmd_clear_vf_stats_vf,
17343 (void *)&cmd_clear_vf_stats_stats,
17344 (void *)&cmd_clear_vf_stats_port_id,
17345 (void *)&cmd_clear_vf_stats_vf_id,
17350 /* port config pctype mapping reset */
17352 /* Common result structure for port config pctype mapping reset */
17353 struct cmd_pctype_mapping_reset_result {
17354 cmdline_fixed_string_t port;
17355 cmdline_fixed_string_t config;
17357 cmdline_fixed_string_t pctype;
17358 cmdline_fixed_string_t mapping;
17359 cmdline_fixed_string_t reset;
17362 /* Common CLI fields for port config pctype mapping reset*/
17363 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17364 TOKEN_STRING_INITIALIZER
17365 (struct cmd_pctype_mapping_reset_result,
17367 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17368 TOKEN_STRING_INITIALIZER
17369 (struct cmd_pctype_mapping_reset_result,
17371 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17372 TOKEN_NUM_INITIALIZER
17373 (struct cmd_pctype_mapping_reset_result,
17375 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17376 TOKEN_STRING_INITIALIZER
17377 (struct cmd_pctype_mapping_reset_result,
17379 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17380 TOKEN_STRING_INITIALIZER
17381 (struct cmd_pctype_mapping_reset_result,
17382 mapping, "mapping");
17383 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17384 TOKEN_STRING_INITIALIZER
17385 (struct cmd_pctype_mapping_reset_result,
17389 cmd_pctype_mapping_reset_parsed(
17390 void *parsed_result,
17391 __rte_unused struct cmdline *cl,
17392 __rte_unused void *data)
17394 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17395 int ret = -ENOTSUP;
17397 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17400 #ifdef RTE_LIBRTE_I40E_PMD
17401 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17408 printf("invalid port_id %d\n", res->port_id);
17411 printf("function not implemented\n");
17414 printf("programming error: (%s)\n", strerror(-ret));
17418 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17419 .f = cmd_pctype_mapping_reset_parsed,
17421 .help_str = "port config <port_id> pctype mapping reset",
17423 (void *)&cmd_pctype_mapping_reset_port,
17424 (void *)&cmd_pctype_mapping_reset_config,
17425 (void *)&cmd_pctype_mapping_reset_port_id,
17426 (void *)&cmd_pctype_mapping_reset_pctype,
17427 (void *)&cmd_pctype_mapping_reset_mapping,
17428 (void *)&cmd_pctype_mapping_reset_reset,
17433 /* show port pctype mapping */
17435 /* Common result structure for show port pctype mapping */
17436 struct cmd_pctype_mapping_get_result {
17437 cmdline_fixed_string_t show;
17438 cmdline_fixed_string_t port;
17440 cmdline_fixed_string_t pctype;
17441 cmdline_fixed_string_t mapping;
17444 /* Common CLI fields for pctype mapping get */
17445 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17446 TOKEN_STRING_INITIALIZER
17447 (struct cmd_pctype_mapping_get_result,
17449 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17450 TOKEN_STRING_INITIALIZER
17451 (struct cmd_pctype_mapping_get_result,
17453 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17454 TOKEN_NUM_INITIALIZER
17455 (struct cmd_pctype_mapping_get_result,
17457 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17458 TOKEN_STRING_INITIALIZER
17459 (struct cmd_pctype_mapping_get_result,
17461 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17462 TOKEN_STRING_INITIALIZER
17463 (struct cmd_pctype_mapping_get_result,
17464 mapping, "mapping");
17467 cmd_pctype_mapping_get_parsed(
17468 void *parsed_result,
17469 __rte_unused struct cmdline *cl,
17470 __rte_unused void *data)
17472 struct cmd_pctype_mapping_get_result *res = parsed_result;
17473 int ret = -ENOTSUP;
17474 #ifdef RTE_LIBRTE_I40E_PMD
17475 struct rte_pmd_i40e_flow_type_mapping
17476 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17477 int i, j, first_pctype;
17480 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17483 #ifdef RTE_LIBRTE_I40E_PMD
17484 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17491 printf("invalid port_id %d\n", res->port_id);
17494 printf("function not implemented\n");
17497 printf("programming error: (%s)\n", strerror(-ret));
17501 #ifdef RTE_LIBRTE_I40E_PMD
17502 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17503 if (mapping[i].pctype != 0ULL) {
17506 printf("pctype: ");
17507 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17508 if (mapping[i].pctype & (1ULL << j)) {
17509 printf(first_pctype ?
17510 "%02d" : ",%02d", j);
17514 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17520 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17521 .f = cmd_pctype_mapping_get_parsed,
17523 .help_str = "show port <port_id> pctype mapping",
17525 (void *)&cmd_pctype_mapping_get_show,
17526 (void *)&cmd_pctype_mapping_get_port,
17527 (void *)&cmd_pctype_mapping_get_port_id,
17528 (void *)&cmd_pctype_mapping_get_pctype,
17529 (void *)&cmd_pctype_mapping_get_mapping,
17534 /* port config pctype mapping update */
17536 /* Common result structure for port config pctype mapping update */
17537 struct cmd_pctype_mapping_update_result {
17538 cmdline_fixed_string_t port;
17539 cmdline_fixed_string_t config;
17541 cmdline_fixed_string_t pctype;
17542 cmdline_fixed_string_t mapping;
17543 cmdline_fixed_string_t update;
17544 cmdline_fixed_string_t pctype_list;
17545 uint16_t flow_type;
17548 /* Common CLI fields for pctype mapping update*/
17549 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17550 TOKEN_STRING_INITIALIZER
17551 (struct cmd_pctype_mapping_update_result,
17553 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17554 TOKEN_STRING_INITIALIZER
17555 (struct cmd_pctype_mapping_update_result,
17557 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17558 TOKEN_NUM_INITIALIZER
17559 (struct cmd_pctype_mapping_update_result,
17561 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17562 TOKEN_STRING_INITIALIZER
17563 (struct cmd_pctype_mapping_update_result,
17565 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17566 TOKEN_STRING_INITIALIZER
17567 (struct cmd_pctype_mapping_update_result,
17568 mapping, "mapping");
17569 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17570 TOKEN_STRING_INITIALIZER
17571 (struct cmd_pctype_mapping_update_result,
17573 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17574 TOKEN_STRING_INITIALIZER
17575 (struct cmd_pctype_mapping_update_result,
17576 pctype_list, NULL);
17577 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17578 TOKEN_NUM_INITIALIZER
17579 (struct cmd_pctype_mapping_update_result,
17580 flow_type, UINT16);
17583 cmd_pctype_mapping_update_parsed(
17584 void *parsed_result,
17585 __rte_unused struct cmdline *cl,
17586 __rte_unused void *data)
17588 struct cmd_pctype_mapping_update_result *res = parsed_result;
17589 int ret = -ENOTSUP;
17590 #ifdef RTE_LIBRTE_I40E_PMD
17591 struct rte_pmd_i40e_flow_type_mapping mapping;
17593 unsigned int nb_item;
17594 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17597 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17600 #ifdef RTE_LIBRTE_I40E_PMD
17601 nb_item = parse_item_list(res->pctype_list, "pctypes",
17602 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17603 mapping.flow_type = res->flow_type;
17604 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17605 mapping.pctype |= (1ULL << pctype_list[i]);
17606 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17616 printf("invalid pctype or flow type\n");
17619 printf("invalid port_id %d\n", res->port_id);
17622 printf("function not implemented\n");
17625 printf("programming error: (%s)\n", strerror(-ret));
17629 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17630 .f = cmd_pctype_mapping_update_parsed,
17632 .help_str = "port config <port_id> pctype mapping update"
17633 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17635 (void *)&cmd_pctype_mapping_update_port,
17636 (void *)&cmd_pctype_mapping_update_config,
17637 (void *)&cmd_pctype_mapping_update_port_id,
17638 (void *)&cmd_pctype_mapping_update_pctype,
17639 (void *)&cmd_pctype_mapping_update_mapping,
17640 (void *)&cmd_pctype_mapping_update_update,
17641 (void *)&cmd_pctype_mapping_update_pc_type,
17642 (void *)&cmd_pctype_mapping_update_flow_type,
17647 /* ptype mapping get */
17649 /* Common result structure for ptype mapping get */
17650 struct cmd_ptype_mapping_get_result {
17651 cmdline_fixed_string_t ptype;
17652 cmdline_fixed_string_t mapping;
17653 cmdline_fixed_string_t get;
17655 uint8_t valid_only;
17658 /* Common CLI fields for ptype mapping get */
17659 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17660 TOKEN_STRING_INITIALIZER
17661 (struct cmd_ptype_mapping_get_result,
17663 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17664 TOKEN_STRING_INITIALIZER
17665 (struct cmd_ptype_mapping_get_result,
17666 mapping, "mapping");
17667 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17668 TOKEN_STRING_INITIALIZER
17669 (struct cmd_ptype_mapping_get_result,
17671 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17672 TOKEN_NUM_INITIALIZER
17673 (struct cmd_ptype_mapping_get_result,
17675 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17676 TOKEN_NUM_INITIALIZER
17677 (struct cmd_ptype_mapping_get_result,
17678 valid_only, UINT8);
17681 cmd_ptype_mapping_get_parsed(
17682 void *parsed_result,
17683 __rte_unused struct cmdline *cl,
17684 __rte_unused void *data)
17686 struct cmd_ptype_mapping_get_result *res = parsed_result;
17687 int ret = -ENOTSUP;
17688 #ifdef RTE_LIBRTE_I40E_PMD
17689 int max_ptype_num = 256;
17690 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17695 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17698 #ifdef RTE_LIBRTE_I40E_PMD
17699 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17710 printf("invalid port_id %d\n", res->port_id);
17713 printf("function not implemented\n");
17716 printf("programming error: (%s)\n", strerror(-ret));
17719 #ifdef RTE_LIBRTE_I40E_PMD
17721 for (i = 0; i < count; i++)
17722 printf("%3d\t0x%08x\n",
17723 mapping[i].hw_ptype, mapping[i].sw_ptype);
17728 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17729 .f = cmd_ptype_mapping_get_parsed,
17731 .help_str = "ptype mapping get <port_id> <valid_only>",
17733 (void *)&cmd_ptype_mapping_get_ptype,
17734 (void *)&cmd_ptype_mapping_get_mapping,
17735 (void *)&cmd_ptype_mapping_get_get,
17736 (void *)&cmd_ptype_mapping_get_port_id,
17737 (void *)&cmd_ptype_mapping_get_valid_only,
17742 /* ptype mapping replace */
17744 /* Common result structure for ptype mapping replace */
17745 struct cmd_ptype_mapping_replace_result {
17746 cmdline_fixed_string_t ptype;
17747 cmdline_fixed_string_t mapping;
17748 cmdline_fixed_string_t replace;
17755 /* Common CLI fields for ptype mapping replace */
17756 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17757 TOKEN_STRING_INITIALIZER
17758 (struct cmd_ptype_mapping_replace_result,
17760 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17761 TOKEN_STRING_INITIALIZER
17762 (struct cmd_ptype_mapping_replace_result,
17763 mapping, "mapping");
17764 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17765 TOKEN_STRING_INITIALIZER
17766 (struct cmd_ptype_mapping_replace_result,
17767 replace, "replace");
17768 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17769 TOKEN_NUM_INITIALIZER
17770 (struct cmd_ptype_mapping_replace_result,
17772 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17773 TOKEN_NUM_INITIALIZER
17774 (struct cmd_ptype_mapping_replace_result,
17776 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17777 TOKEN_NUM_INITIALIZER
17778 (struct cmd_ptype_mapping_replace_result,
17780 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17781 TOKEN_NUM_INITIALIZER
17782 (struct cmd_ptype_mapping_replace_result,
17786 cmd_ptype_mapping_replace_parsed(
17787 void *parsed_result,
17788 __rte_unused struct cmdline *cl,
17789 __rte_unused void *data)
17791 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17792 int ret = -ENOTSUP;
17794 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17797 #ifdef RTE_LIBRTE_I40E_PMD
17798 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17808 printf("invalid ptype 0x%8x or 0x%8x\n",
17809 res->target, res->pkt_type);
17812 printf("invalid port_id %d\n", res->port_id);
17815 printf("function not implemented\n");
17818 printf("programming error: (%s)\n", strerror(-ret));
17822 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17823 .f = cmd_ptype_mapping_replace_parsed,
17826 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17828 (void *)&cmd_ptype_mapping_replace_ptype,
17829 (void *)&cmd_ptype_mapping_replace_mapping,
17830 (void *)&cmd_ptype_mapping_replace_replace,
17831 (void *)&cmd_ptype_mapping_replace_port_id,
17832 (void *)&cmd_ptype_mapping_replace_target,
17833 (void *)&cmd_ptype_mapping_replace_mask,
17834 (void *)&cmd_ptype_mapping_replace_pkt_type,
17839 /* ptype mapping reset */
17841 /* Common result structure for ptype mapping reset */
17842 struct cmd_ptype_mapping_reset_result {
17843 cmdline_fixed_string_t ptype;
17844 cmdline_fixed_string_t mapping;
17845 cmdline_fixed_string_t reset;
17849 /* Common CLI fields for ptype mapping reset*/
17850 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17851 TOKEN_STRING_INITIALIZER
17852 (struct cmd_ptype_mapping_reset_result,
17854 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17855 TOKEN_STRING_INITIALIZER
17856 (struct cmd_ptype_mapping_reset_result,
17857 mapping, "mapping");
17858 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17859 TOKEN_STRING_INITIALIZER
17860 (struct cmd_ptype_mapping_reset_result,
17862 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17863 TOKEN_NUM_INITIALIZER
17864 (struct cmd_ptype_mapping_reset_result,
17868 cmd_ptype_mapping_reset_parsed(
17869 void *parsed_result,
17870 __rte_unused struct cmdline *cl,
17871 __rte_unused void *data)
17873 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17874 int ret = -ENOTSUP;
17876 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17879 #ifdef RTE_LIBRTE_I40E_PMD
17880 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17887 printf("invalid port_id %d\n", res->port_id);
17890 printf("function not implemented\n");
17893 printf("programming error: (%s)\n", strerror(-ret));
17897 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17898 .f = cmd_ptype_mapping_reset_parsed,
17900 .help_str = "ptype mapping reset <port_id>",
17902 (void *)&cmd_ptype_mapping_reset_ptype,
17903 (void *)&cmd_ptype_mapping_reset_mapping,
17904 (void *)&cmd_ptype_mapping_reset_reset,
17905 (void *)&cmd_ptype_mapping_reset_port_id,
17910 /* ptype mapping update */
17912 /* Common result structure for ptype mapping update */
17913 struct cmd_ptype_mapping_update_result {
17914 cmdline_fixed_string_t ptype;
17915 cmdline_fixed_string_t mapping;
17916 cmdline_fixed_string_t reset;
17922 /* Common CLI fields for ptype mapping update*/
17923 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17924 TOKEN_STRING_INITIALIZER
17925 (struct cmd_ptype_mapping_update_result,
17927 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17928 TOKEN_STRING_INITIALIZER
17929 (struct cmd_ptype_mapping_update_result,
17930 mapping, "mapping");
17931 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17932 TOKEN_STRING_INITIALIZER
17933 (struct cmd_ptype_mapping_update_result,
17935 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17936 TOKEN_NUM_INITIALIZER
17937 (struct cmd_ptype_mapping_update_result,
17939 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17940 TOKEN_NUM_INITIALIZER
17941 (struct cmd_ptype_mapping_update_result,
17943 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17944 TOKEN_NUM_INITIALIZER
17945 (struct cmd_ptype_mapping_update_result,
17949 cmd_ptype_mapping_update_parsed(
17950 void *parsed_result,
17951 __rte_unused struct cmdline *cl,
17952 __rte_unused void *data)
17954 struct cmd_ptype_mapping_update_result *res = parsed_result;
17955 int ret = -ENOTSUP;
17956 #ifdef RTE_LIBRTE_I40E_PMD
17957 struct rte_pmd_i40e_ptype_mapping mapping;
17959 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17962 #ifdef RTE_LIBRTE_I40E_PMD
17963 mapping.hw_ptype = res->hw_ptype;
17964 mapping.sw_ptype = res->sw_ptype;
17965 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17975 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17978 printf("invalid port_id %d\n", res->port_id);
17981 printf("function not implemented\n");
17984 printf("programming error: (%s)\n", strerror(-ret));
17988 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17989 .f = cmd_ptype_mapping_update_parsed,
17991 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17993 (void *)&cmd_ptype_mapping_update_ptype,
17994 (void *)&cmd_ptype_mapping_update_mapping,
17995 (void *)&cmd_ptype_mapping_update_update,
17996 (void *)&cmd_ptype_mapping_update_port_id,
17997 (void *)&cmd_ptype_mapping_update_hw_ptype,
17998 (void *)&cmd_ptype_mapping_update_sw_ptype,
18003 /* Common result structure for file commands */
18004 struct cmd_cmdfile_result {
18005 cmdline_fixed_string_t load;
18006 cmdline_fixed_string_t filename;
18009 /* Common CLI fields for file commands */
18010 cmdline_parse_token_string_t cmd_load_cmdfile =
18011 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
18012 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
18013 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
18016 cmd_load_from_file_parsed(
18017 void *parsed_result,
18018 __rte_unused struct cmdline *cl,
18019 __rte_unused void *data)
18021 struct cmd_cmdfile_result *res = parsed_result;
18023 cmdline_read_from_file(res->filename);
18026 cmdline_parse_inst_t cmd_load_from_file = {
18027 .f = cmd_load_from_file_parsed,
18029 .help_str = "load <filename>",
18031 (void *)&cmd_load_cmdfile,
18032 (void *)&cmd_load_cmdfile_filename,
18037 /* Get Rx offloads capabilities */
18038 struct cmd_rx_offload_get_capa_result {
18039 cmdline_fixed_string_t show;
18040 cmdline_fixed_string_t port;
18042 cmdline_fixed_string_t rx_offload;
18043 cmdline_fixed_string_t capabilities;
18046 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
18047 TOKEN_STRING_INITIALIZER
18048 (struct cmd_rx_offload_get_capa_result,
18050 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
18051 TOKEN_STRING_INITIALIZER
18052 (struct cmd_rx_offload_get_capa_result,
18054 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
18055 TOKEN_NUM_INITIALIZER
18056 (struct cmd_rx_offload_get_capa_result,
18058 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
18059 TOKEN_STRING_INITIALIZER
18060 (struct cmd_rx_offload_get_capa_result,
18061 rx_offload, "rx_offload");
18062 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
18063 TOKEN_STRING_INITIALIZER
18064 (struct cmd_rx_offload_get_capa_result,
18065 capabilities, "capabilities");
18068 print_rx_offloads(uint64_t offloads)
18070 uint64_t single_offload;
18078 begin = __builtin_ctzll(offloads);
18079 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18081 single_offload = 1ULL << begin;
18082 for (bit = begin; bit < end; bit++) {
18083 if (offloads & single_offload)
18085 rte_eth_dev_rx_offload_name(single_offload));
18086 single_offload <<= 1;
18091 cmd_rx_offload_get_capa_parsed(
18092 void *parsed_result,
18093 __rte_unused struct cmdline *cl,
18094 __rte_unused void *data)
18096 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18097 struct rte_eth_dev_info dev_info;
18098 portid_t port_id = res->port_id;
18099 uint64_t queue_offloads;
18100 uint64_t port_offloads;
18103 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18107 queue_offloads = dev_info.rx_queue_offload_capa;
18108 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18110 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18111 printf(" Per Queue :");
18112 print_rx_offloads(queue_offloads);
18115 printf(" Per Port :");
18116 print_rx_offloads(port_offloads);
18120 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18121 .f = cmd_rx_offload_get_capa_parsed,
18123 .help_str = "show port <port_id> rx_offload capabilities",
18125 (void *)&cmd_rx_offload_get_capa_show,
18126 (void *)&cmd_rx_offload_get_capa_port,
18127 (void *)&cmd_rx_offload_get_capa_port_id,
18128 (void *)&cmd_rx_offload_get_capa_rx_offload,
18129 (void *)&cmd_rx_offload_get_capa_capabilities,
18134 /* Get Rx offloads configuration */
18135 struct cmd_rx_offload_get_configuration_result {
18136 cmdline_fixed_string_t show;
18137 cmdline_fixed_string_t port;
18139 cmdline_fixed_string_t rx_offload;
18140 cmdline_fixed_string_t configuration;
18143 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18144 TOKEN_STRING_INITIALIZER
18145 (struct cmd_rx_offload_get_configuration_result,
18147 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18148 TOKEN_STRING_INITIALIZER
18149 (struct cmd_rx_offload_get_configuration_result,
18151 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18152 TOKEN_NUM_INITIALIZER
18153 (struct cmd_rx_offload_get_configuration_result,
18155 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18156 TOKEN_STRING_INITIALIZER
18157 (struct cmd_rx_offload_get_configuration_result,
18158 rx_offload, "rx_offload");
18159 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18160 TOKEN_STRING_INITIALIZER
18161 (struct cmd_rx_offload_get_configuration_result,
18162 configuration, "configuration");
18165 cmd_rx_offload_get_configuration_parsed(
18166 void *parsed_result,
18167 __rte_unused struct cmdline *cl,
18168 __rte_unused void *data)
18170 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18171 struct rte_eth_dev_info dev_info;
18172 portid_t port_id = res->port_id;
18173 struct rte_port *port = &ports[port_id];
18174 uint64_t port_offloads;
18175 uint64_t queue_offloads;
18176 uint16_t nb_rx_queues;
18180 printf("Rx Offloading Configuration of port %d :\n", port_id);
18182 port_offloads = port->dev_conf.rxmode.offloads;
18184 print_rx_offloads(port_offloads);
18187 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18191 nb_rx_queues = dev_info.nb_rx_queues;
18192 for (q = 0; q < nb_rx_queues; q++) {
18193 queue_offloads = port->rx_conf[q].offloads;
18194 printf(" Queue[%2d] :", q);
18195 print_rx_offloads(queue_offloads);
18201 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18202 .f = cmd_rx_offload_get_configuration_parsed,
18204 .help_str = "show port <port_id> rx_offload configuration",
18206 (void *)&cmd_rx_offload_get_configuration_show,
18207 (void *)&cmd_rx_offload_get_configuration_port,
18208 (void *)&cmd_rx_offload_get_configuration_port_id,
18209 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18210 (void *)&cmd_rx_offload_get_configuration_configuration,
18215 /* Enable/Disable a per port offloading */
18216 struct cmd_config_per_port_rx_offload_result {
18217 cmdline_fixed_string_t port;
18218 cmdline_fixed_string_t config;
18220 cmdline_fixed_string_t rx_offload;
18221 cmdline_fixed_string_t offload;
18222 cmdline_fixed_string_t on_off;
18225 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18226 TOKEN_STRING_INITIALIZER
18227 (struct cmd_config_per_port_rx_offload_result,
18229 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18230 TOKEN_STRING_INITIALIZER
18231 (struct cmd_config_per_port_rx_offload_result,
18233 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18234 TOKEN_NUM_INITIALIZER
18235 (struct cmd_config_per_port_rx_offload_result,
18237 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18238 TOKEN_STRING_INITIALIZER
18239 (struct cmd_config_per_port_rx_offload_result,
18240 rx_offload, "rx_offload");
18241 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18242 TOKEN_STRING_INITIALIZER
18243 (struct cmd_config_per_port_rx_offload_result,
18244 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18245 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18246 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18247 "scatter#timestamp#security#keep_crc#rss_hash");
18248 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18249 TOKEN_STRING_INITIALIZER
18250 (struct cmd_config_per_port_rx_offload_result,
18254 search_rx_offload(const char *name)
18256 uint64_t single_offload;
18257 const char *single_name;
18261 single_offload = 1;
18262 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18263 single_name = rte_eth_dev_rx_offload_name(single_offload);
18264 if (!strcasecmp(single_name, name)) {
18268 single_offload <<= 1;
18272 return single_offload;
18278 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18279 __rte_unused struct cmdline *cl,
18280 __rte_unused void *data)
18282 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18283 portid_t port_id = res->port_id;
18284 struct rte_eth_dev_info dev_info;
18285 struct rte_port *port = &ports[port_id];
18286 uint64_t single_offload;
18287 uint16_t nb_rx_queues;
18291 if (port->port_status != RTE_PORT_STOPPED) {
18292 printf("Error: Can't config offload when Port %d "
18293 "is not stopped\n", port_id);
18297 single_offload = search_rx_offload(res->offload);
18298 if (single_offload == 0) {
18299 printf("Unknown offload name: %s\n", res->offload);
18303 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18307 nb_rx_queues = dev_info.nb_rx_queues;
18308 if (!strcmp(res->on_off, "on")) {
18309 port->dev_conf.rxmode.offloads |= single_offload;
18310 for (q = 0; q < nb_rx_queues; q++)
18311 port->rx_conf[q].offloads |= single_offload;
18313 port->dev_conf.rxmode.offloads &= ~single_offload;
18314 for (q = 0; q < nb_rx_queues; q++)
18315 port->rx_conf[q].offloads &= ~single_offload;
18318 cmd_reconfig_device_queue(port_id, 1, 1);
18321 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18322 .f = cmd_config_per_port_rx_offload_parsed,
18324 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18325 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18326 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18327 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18330 (void *)&cmd_config_per_port_rx_offload_result_port,
18331 (void *)&cmd_config_per_port_rx_offload_result_config,
18332 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18333 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18334 (void *)&cmd_config_per_port_rx_offload_result_offload,
18335 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18340 /* Enable/Disable a per queue offloading */
18341 struct cmd_config_per_queue_rx_offload_result {
18342 cmdline_fixed_string_t port;
18344 cmdline_fixed_string_t rxq;
18346 cmdline_fixed_string_t rx_offload;
18347 cmdline_fixed_string_t offload;
18348 cmdline_fixed_string_t on_off;
18351 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18352 TOKEN_STRING_INITIALIZER
18353 (struct cmd_config_per_queue_rx_offload_result,
18355 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18356 TOKEN_NUM_INITIALIZER
18357 (struct cmd_config_per_queue_rx_offload_result,
18359 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18360 TOKEN_STRING_INITIALIZER
18361 (struct cmd_config_per_queue_rx_offload_result,
18363 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18364 TOKEN_NUM_INITIALIZER
18365 (struct cmd_config_per_queue_rx_offload_result,
18367 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18368 TOKEN_STRING_INITIALIZER
18369 (struct cmd_config_per_queue_rx_offload_result,
18370 rx_offload, "rx_offload");
18371 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18372 TOKEN_STRING_INITIALIZER
18373 (struct cmd_config_per_queue_rx_offload_result,
18374 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18375 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18376 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18377 "scatter#timestamp#security#keep_crc");
18378 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18379 TOKEN_STRING_INITIALIZER
18380 (struct cmd_config_per_queue_rx_offload_result,
18384 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18385 __rte_unused struct cmdline *cl,
18386 __rte_unused void *data)
18388 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18389 struct rte_eth_dev_info dev_info;
18390 portid_t port_id = res->port_id;
18391 uint16_t queue_id = res->queue_id;
18392 struct rte_port *port = &ports[port_id];
18393 uint64_t single_offload;
18396 if (port->port_status != RTE_PORT_STOPPED) {
18397 printf("Error: Can't config offload when Port %d "
18398 "is not stopped\n", port_id);
18402 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18406 if (queue_id >= dev_info.nb_rx_queues) {
18407 printf("Error: input queue_id should be 0 ... "
18408 "%d\n", dev_info.nb_rx_queues - 1);
18412 single_offload = search_rx_offload(res->offload);
18413 if (single_offload == 0) {
18414 printf("Unknown offload name: %s\n", res->offload);
18418 if (!strcmp(res->on_off, "on"))
18419 port->rx_conf[queue_id].offloads |= single_offload;
18421 port->rx_conf[queue_id].offloads &= ~single_offload;
18423 cmd_reconfig_device_queue(port_id, 1, 1);
18426 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18427 .f = cmd_config_per_queue_rx_offload_parsed,
18429 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18430 "vlan_strip|ipv4_cksum|"
18431 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18432 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18433 "jumbo_frame|scatter|timestamp|security|keep_crc "
18436 (void *)&cmd_config_per_queue_rx_offload_result_port,
18437 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18438 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18439 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18440 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18441 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18442 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18447 /* Get Tx offloads capabilities */
18448 struct cmd_tx_offload_get_capa_result {
18449 cmdline_fixed_string_t show;
18450 cmdline_fixed_string_t port;
18452 cmdline_fixed_string_t tx_offload;
18453 cmdline_fixed_string_t capabilities;
18456 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18457 TOKEN_STRING_INITIALIZER
18458 (struct cmd_tx_offload_get_capa_result,
18460 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18461 TOKEN_STRING_INITIALIZER
18462 (struct cmd_tx_offload_get_capa_result,
18464 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18465 TOKEN_NUM_INITIALIZER
18466 (struct cmd_tx_offload_get_capa_result,
18468 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18469 TOKEN_STRING_INITIALIZER
18470 (struct cmd_tx_offload_get_capa_result,
18471 tx_offload, "tx_offload");
18472 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18473 TOKEN_STRING_INITIALIZER
18474 (struct cmd_tx_offload_get_capa_result,
18475 capabilities, "capabilities");
18478 print_tx_offloads(uint64_t offloads)
18480 uint64_t single_offload;
18488 begin = __builtin_ctzll(offloads);
18489 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18491 single_offload = 1ULL << begin;
18492 for (bit = begin; bit < end; bit++) {
18493 if (offloads & single_offload)
18495 rte_eth_dev_tx_offload_name(single_offload));
18496 single_offload <<= 1;
18501 cmd_tx_offload_get_capa_parsed(
18502 void *parsed_result,
18503 __rte_unused struct cmdline *cl,
18504 __rte_unused void *data)
18506 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18507 struct rte_eth_dev_info dev_info;
18508 portid_t port_id = res->port_id;
18509 uint64_t queue_offloads;
18510 uint64_t port_offloads;
18513 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18517 queue_offloads = dev_info.tx_queue_offload_capa;
18518 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18520 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18521 printf(" Per Queue :");
18522 print_tx_offloads(queue_offloads);
18525 printf(" Per Port :");
18526 print_tx_offloads(port_offloads);
18530 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18531 .f = cmd_tx_offload_get_capa_parsed,
18533 .help_str = "show port <port_id> tx_offload capabilities",
18535 (void *)&cmd_tx_offload_get_capa_show,
18536 (void *)&cmd_tx_offload_get_capa_port,
18537 (void *)&cmd_tx_offload_get_capa_port_id,
18538 (void *)&cmd_tx_offload_get_capa_tx_offload,
18539 (void *)&cmd_tx_offload_get_capa_capabilities,
18544 /* Get Tx offloads configuration */
18545 struct cmd_tx_offload_get_configuration_result {
18546 cmdline_fixed_string_t show;
18547 cmdline_fixed_string_t port;
18549 cmdline_fixed_string_t tx_offload;
18550 cmdline_fixed_string_t configuration;
18553 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18554 TOKEN_STRING_INITIALIZER
18555 (struct cmd_tx_offload_get_configuration_result,
18557 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18558 TOKEN_STRING_INITIALIZER
18559 (struct cmd_tx_offload_get_configuration_result,
18561 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18562 TOKEN_NUM_INITIALIZER
18563 (struct cmd_tx_offload_get_configuration_result,
18565 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18566 TOKEN_STRING_INITIALIZER
18567 (struct cmd_tx_offload_get_configuration_result,
18568 tx_offload, "tx_offload");
18569 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18570 TOKEN_STRING_INITIALIZER
18571 (struct cmd_tx_offload_get_configuration_result,
18572 configuration, "configuration");
18575 cmd_tx_offload_get_configuration_parsed(
18576 void *parsed_result,
18577 __rte_unused struct cmdline *cl,
18578 __rte_unused void *data)
18580 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18581 struct rte_eth_dev_info dev_info;
18582 portid_t port_id = res->port_id;
18583 struct rte_port *port = &ports[port_id];
18584 uint64_t port_offloads;
18585 uint64_t queue_offloads;
18586 uint16_t nb_tx_queues;
18590 printf("Tx Offloading Configuration of port %d :\n", port_id);
18592 port_offloads = port->dev_conf.txmode.offloads;
18594 print_tx_offloads(port_offloads);
18597 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18601 nb_tx_queues = dev_info.nb_tx_queues;
18602 for (q = 0; q < nb_tx_queues; q++) {
18603 queue_offloads = port->tx_conf[q].offloads;
18604 printf(" Queue[%2d] :", q);
18605 print_tx_offloads(queue_offloads);
18611 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18612 .f = cmd_tx_offload_get_configuration_parsed,
18614 .help_str = "show port <port_id> tx_offload configuration",
18616 (void *)&cmd_tx_offload_get_configuration_show,
18617 (void *)&cmd_tx_offload_get_configuration_port,
18618 (void *)&cmd_tx_offload_get_configuration_port_id,
18619 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18620 (void *)&cmd_tx_offload_get_configuration_configuration,
18625 /* Enable/Disable a per port offloading */
18626 struct cmd_config_per_port_tx_offload_result {
18627 cmdline_fixed_string_t port;
18628 cmdline_fixed_string_t config;
18630 cmdline_fixed_string_t tx_offload;
18631 cmdline_fixed_string_t offload;
18632 cmdline_fixed_string_t on_off;
18635 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18636 TOKEN_STRING_INITIALIZER
18637 (struct cmd_config_per_port_tx_offload_result,
18639 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18640 TOKEN_STRING_INITIALIZER
18641 (struct cmd_config_per_port_tx_offload_result,
18643 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18644 TOKEN_NUM_INITIALIZER
18645 (struct cmd_config_per_port_tx_offload_result,
18647 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18648 TOKEN_STRING_INITIALIZER
18649 (struct cmd_config_per_port_tx_offload_result,
18650 tx_offload, "tx_offload");
18651 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18652 TOKEN_STRING_INITIALIZER
18653 (struct cmd_config_per_port_tx_offload_result,
18654 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18655 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18656 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18657 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18658 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18659 "send_on_timestamp");
18660 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18661 TOKEN_STRING_INITIALIZER
18662 (struct cmd_config_per_port_tx_offload_result,
18666 search_tx_offload(const char *name)
18668 uint64_t single_offload;
18669 const char *single_name;
18673 single_offload = 1;
18674 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18675 single_name = rte_eth_dev_tx_offload_name(single_offload);
18676 if (single_name == NULL)
18678 if (!strcasecmp(single_name, name)) {
18681 } else if (!strcasecmp(single_name, "UNKNOWN"))
18683 single_offload <<= 1;
18687 return single_offload;
18693 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18694 __rte_unused struct cmdline *cl,
18695 __rte_unused void *data)
18697 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18698 portid_t port_id = res->port_id;
18699 struct rte_eth_dev_info dev_info;
18700 struct rte_port *port = &ports[port_id];
18701 uint64_t single_offload;
18702 uint16_t nb_tx_queues;
18706 if (port->port_status != RTE_PORT_STOPPED) {
18707 printf("Error: Can't config offload when Port %d "
18708 "is not stopped\n", port_id);
18712 single_offload = search_tx_offload(res->offload);
18713 if (single_offload == 0) {
18714 printf("Unknown offload name: %s\n", res->offload);
18718 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18722 nb_tx_queues = dev_info.nb_tx_queues;
18723 if (!strcmp(res->on_off, "on")) {
18724 port->dev_conf.txmode.offloads |= single_offload;
18725 for (q = 0; q < nb_tx_queues; q++)
18726 port->tx_conf[q].offloads |= single_offload;
18728 port->dev_conf.txmode.offloads &= ~single_offload;
18729 for (q = 0; q < nb_tx_queues; q++)
18730 port->tx_conf[q].offloads &= ~single_offload;
18733 cmd_reconfig_device_queue(port_id, 1, 1);
18736 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18737 .f = cmd_config_per_port_tx_offload_parsed,
18739 .help_str = "port config <port_id> tx_offload "
18740 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18741 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18742 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18743 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18744 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18745 "send_on_timestamp on|off",
18747 (void *)&cmd_config_per_port_tx_offload_result_port,
18748 (void *)&cmd_config_per_port_tx_offload_result_config,
18749 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18750 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18751 (void *)&cmd_config_per_port_tx_offload_result_offload,
18752 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18757 /* Enable/Disable a per queue offloading */
18758 struct cmd_config_per_queue_tx_offload_result {
18759 cmdline_fixed_string_t port;
18761 cmdline_fixed_string_t txq;
18763 cmdline_fixed_string_t tx_offload;
18764 cmdline_fixed_string_t offload;
18765 cmdline_fixed_string_t on_off;
18768 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18769 TOKEN_STRING_INITIALIZER
18770 (struct cmd_config_per_queue_tx_offload_result,
18772 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18773 TOKEN_NUM_INITIALIZER
18774 (struct cmd_config_per_queue_tx_offload_result,
18776 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18777 TOKEN_STRING_INITIALIZER
18778 (struct cmd_config_per_queue_tx_offload_result,
18780 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18781 TOKEN_NUM_INITIALIZER
18782 (struct cmd_config_per_queue_tx_offload_result,
18784 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18785 TOKEN_STRING_INITIALIZER
18786 (struct cmd_config_per_queue_tx_offload_result,
18787 tx_offload, "tx_offload");
18788 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18789 TOKEN_STRING_INITIALIZER
18790 (struct cmd_config_per_queue_tx_offload_result,
18791 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18792 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18793 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18794 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18795 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18796 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18797 TOKEN_STRING_INITIALIZER
18798 (struct cmd_config_per_queue_tx_offload_result,
18802 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18803 __rte_unused struct cmdline *cl,
18804 __rte_unused void *data)
18806 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18807 struct rte_eth_dev_info dev_info;
18808 portid_t port_id = res->port_id;
18809 uint16_t queue_id = res->queue_id;
18810 struct rte_port *port = &ports[port_id];
18811 uint64_t single_offload;
18814 if (port->port_status != RTE_PORT_STOPPED) {
18815 printf("Error: Can't config offload when Port %d "
18816 "is not stopped\n", port_id);
18820 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18824 if (queue_id >= dev_info.nb_tx_queues) {
18825 printf("Error: input queue_id should be 0 ... "
18826 "%d\n", dev_info.nb_tx_queues - 1);
18830 single_offload = search_tx_offload(res->offload);
18831 if (single_offload == 0) {
18832 printf("Unknown offload name: %s\n", res->offload);
18836 if (!strcmp(res->on_off, "on"))
18837 port->tx_conf[queue_id].offloads |= single_offload;
18839 port->tx_conf[queue_id].offloads &= ~single_offload;
18841 cmd_reconfig_device_queue(port_id, 1, 1);
18844 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18845 .f = cmd_config_per_queue_tx_offload_parsed,
18847 .help_str = "port <port_id> txq <queue_id> tx_offload "
18848 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18849 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18850 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18851 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18852 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18855 (void *)&cmd_config_per_queue_tx_offload_result_port,
18856 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18857 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18858 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18859 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18860 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18861 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18866 /* *** configure tx_metadata for specific port *** */
18867 struct cmd_config_tx_metadata_specific_result {
18868 cmdline_fixed_string_t port;
18869 cmdline_fixed_string_t keyword;
18871 cmdline_fixed_string_t item;
18876 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18877 __rte_unused struct cmdline *cl,
18878 __rte_unused void *data)
18880 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18882 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18884 ports[res->port_id].tx_metadata = res->value;
18885 /* Add/remove callback to insert valid metadata in every Tx packet. */
18886 if (ports[res->port_id].tx_metadata)
18887 add_tx_md_callback(res->port_id);
18889 remove_tx_md_callback(res->port_id);
18890 rte_flow_dynf_metadata_register();
18893 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18894 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18896 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18897 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18898 keyword, "config");
18899 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18900 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18902 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18903 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18904 item, "tx_metadata");
18905 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18906 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18909 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18910 .f = cmd_config_tx_metadata_specific_parsed,
18912 .help_str = "port config <port_id> tx_metadata <value>",
18914 (void *)&cmd_config_tx_metadata_specific_port,
18915 (void *)&cmd_config_tx_metadata_specific_keyword,
18916 (void *)&cmd_config_tx_metadata_specific_id,
18917 (void *)&cmd_config_tx_metadata_specific_item,
18918 (void *)&cmd_config_tx_metadata_specific_value,
18923 /* *** set dynf *** */
18924 struct cmd_config_tx_dynf_specific_result {
18925 cmdline_fixed_string_t port;
18926 cmdline_fixed_string_t keyword;
18928 cmdline_fixed_string_t item;
18929 cmdline_fixed_string_t name;
18930 cmdline_fixed_string_t value;
18934 cmd_config_dynf_specific_parsed(void *parsed_result,
18935 __rte_unused struct cmdline *cl,
18936 __rte_unused void *data)
18938 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
18939 struct rte_mbuf_dynflag desc_flag;
18941 uint64_t old_port_flags;
18943 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18945 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
18947 if (strlcpy(desc_flag.name, res->name,
18948 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
18949 printf("Flag name too long\n");
18952 desc_flag.flags = 0;
18953 flag = rte_mbuf_dynflag_register(&desc_flag);
18955 printf("Can't register flag\n");
18958 strcpy(dynf_names[flag], desc_flag.name);
18960 old_port_flags = ports[res->port_id].mbuf_dynf;
18961 if (!strcmp(res->value, "set")) {
18962 ports[res->port_id].mbuf_dynf |= 1UL << flag;
18963 if (old_port_flags == 0)
18964 add_tx_dynf_callback(res->port_id);
18966 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
18967 if (ports[res->port_id].mbuf_dynf == 0)
18968 remove_tx_dynf_callback(res->port_id);
18972 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
18973 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18975 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
18976 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18977 keyword, "config");
18978 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
18979 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18981 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
18982 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18984 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
18985 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18987 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
18988 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18989 value, "set#clear");
18991 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
18992 .f = cmd_config_dynf_specific_parsed,
18994 .help_str = "port config <port id> dynf <name> set|clear",
18996 (void *)&cmd_config_tx_dynf_specific_port,
18997 (void *)&cmd_config_tx_dynf_specific_keyword,
18998 (void *)&cmd_config_tx_dynf_specific_port_id,
18999 (void *)&cmd_config_tx_dynf_specific_item,
19000 (void *)&cmd_config_tx_dynf_specific_name,
19001 (void *)&cmd_config_tx_dynf_specific_value,
19006 /* *** display tx_metadata per port configuration *** */
19007 struct cmd_show_tx_metadata_result {
19008 cmdline_fixed_string_t cmd_show;
19009 cmdline_fixed_string_t cmd_port;
19010 cmdline_fixed_string_t cmd_keyword;
19015 cmd_show_tx_metadata_parsed(void *parsed_result,
19016 __rte_unused struct cmdline *cl,
19017 __rte_unused void *data)
19019 struct cmd_show_tx_metadata_result *res = parsed_result;
19021 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19022 printf("invalid port id %u\n", res->cmd_pid);
19025 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
19026 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
19027 ports[res->cmd_pid].tx_metadata);
19031 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
19032 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19034 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
19035 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19037 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
19038 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
19040 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
19041 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19042 cmd_keyword, "tx_metadata");
19044 cmdline_parse_inst_t cmd_show_tx_metadata = {
19045 .f = cmd_show_tx_metadata_parsed,
19047 .help_str = "show port <port_id> tx_metadata",
19049 (void *)&cmd_show_tx_metadata_show,
19050 (void *)&cmd_show_tx_metadata_port,
19051 (void *)&cmd_show_tx_metadata_pid,
19052 (void *)&cmd_show_tx_metadata_keyword,
19057 /* show port supported ptypes */
19059 /* Common result structure for show port ptypes */
19060 struct cmd_show_port_supported_ptypes_result {
19061 cmdline_fixed_string_t show;
19062 cmdline_fixed_string_t port;
19064 cmdline_fixed_string_t ptypes;
19067 /* Common CLI fields for show port ptypes */
19068 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
19069 TOKEN_STRING_INITIALIZER
19070 (struct cmd_show_port_supported_ptypes_result,
19072 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
19073 TOKEN_STRING_INITIALIZER
19074 (struct cmd_show_port_supported_ptypes_result,
19076 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19077 TOKEN_NUM_INITIALIZER
19078 (struct cmd_show_port_supported_ptypes_result,
19080 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19081 TOKEN_STRING_INITIALIZER
19082 (struct cmd_show_port_supported_ptypes_result,
19086 cmd_show_port_supported_ptypes_parsed(
19087 void *parsed_result,
19088 __rte_unused struct cmdline *cl,
19089 __rte_unused void *data)
19091 #define RSVD_PTYPE_MASK 0xf0000000
19092 #define MAX_PTYPES_PER_LAYER 16
19093 #define LTYPE_NAMESIZE 32
19094 #define PTYPE_NAMESIZE 256
19095 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19096 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19097 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19098 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19099 uint16_t port_id = res->port_id;
19102 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19106 while (ptype_mask != RSVD_PTYPE_MASK) {
19108 switch (ptype_mask) {
19109 case RTE_PTYPE_L2_MASK:
19110 strlcpy(ltype, "L2", sizeof(ltype));
19112 case RTE_PTYPE_L3_MASK:
19113 strlcpy(ltype, "L3", sizeof(ltype));
19115 case RTE_PTYPE_L4_MASK:
19116 strlcpy(ltype, "L4", sizeof(ltype));
19118 case RTE_PTYPE_TUNNEL_MASK:
19119 strlcpy(ltype, "Tunnel", sizeof(ltype));
19121 case RTE_PTYPE_INNER_L2_MASK:
19122 strlcpy(ltype, "Inner L2", sizeof(ltype));
19124 case RTE_PTYPE_INNER_L3_MASK:
19125 strlcpy(ltype, "Inner L3", sizeof(ltype));
19127 case RTE_PTYPE_INNER_L4_MASK:
19128 strlcpy(ltype, "Inner L4", sizeof(ltype));
19134 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19135 ptype_mask, ptypes,
19136 MAX_PTYPES_PER_LAYER);
19139 printf("Supported %s ptypes:\n", ltype);
19141 printf("%s ptypes unsupported\n", ltype);
19143 for (i = 0; i < ret; ++i) {
19144 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19145 printf("%s\n", buf);
19152 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19153 .f = cmd_show_port_supported_ptypes_parsed,
19155 .help_str = "show port <port_id> ptypes",
19157 (void *)&cmd_show_port_supported_ptypes_show,
19158 (void *)&cmd_show_port_supported_ptypes_port,
19159 (void *)&cmd_show_port_supported_ptypes_port_id,
19160 (void *)&cmd_show_port_supported_ptypes_ptypes,
19165 /* *** display rx/tx descriptor status *** */
19166 struct cmd_show_rx_tx_desc_status_result {
19167 cmdline_fixed_string_t cmd_show;
19168 cmdline_fixed_string_t cmd_port;
19169 cmdline_fixed_string_t cmd_keyword;
19170 cmdline_fixed_string_t cmd_desc;
19171 cmdline_fixed_string_t cmd_status;
19178 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19179 __rte_unused struct cmdline *cl,
19180 __rte_unused void *data)
19182 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19185 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19186 printf("invalid port id %u\n", res->cmd_pid);
19190 if (!strcmp(res->cmd_keyword, "rxq")) {
19191 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19194 printf("Invalid queueid = %d\n", res->cmd_qid);
19197 if (rc == RTE_ETH_RX_DESC_AVAIL)
19198 printf("Desc status = AVAILABLE\n");
19199 else if (rc == RTE_ETH_RX_DESC_DONE)
19200 printf("Desc status = DONE\n");
19202 printf("Desc status = UNAVAILABLE\n");
19203 } else if (!strcmp(res->cmd_keyword, "txq")) {
19204 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19207 printf("Invalid queueid = %d\n", res->cmd_qid);
19210 if (rc == RTE_ETH_TX_DESC_FULL)
19211 printf("Desc status = FULL\n");
19212 else if (rc == RTE_ETH_TX_DESC_DONE)
19213 printf("Desc status = DONE\n");
19215 printf("Desc status = UNAVAILABLE\n");
19219 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19220 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19222 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19223 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19225 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19226 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19228 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19229 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19230 cmd_keyword, "rxq#txq");
19231 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19232 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19234 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19235 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19237 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19238 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19240 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19241 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19242 cmd_status, "status");
19243 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19244 .f = cmd_show_rx_tx_desc_status_parsed,
19246 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19249 (void *)&cmd_show_rx_tx_desc_status_show,
19250 (void *)&cmd_show_rx_tx_desc_status_port,
19251 (void *)&cmd_show_rx_tx_desc_status_pid,
19252 (void *)&cmd_show_rx_tx_desc_status_keyword,
19253 (void *)&cmd_show_rx_tx_desc_status_qid,
19254 (void *)&cmd_show_rx_tx_desc_status_desc,
19255 (void *)&cmd_show_rx_tx_desc_status_did,
19256 (void *)&cmd_show_rx_tx_desc_status_status,
19261 /* Common result structure for set port ptypes */
19262 struct cmd_set_port_ptypes_result {
19263 cmdline_fixed_string_t set;
19264 cmdline_fixed_string_t port;
19266 cmdline_fixed_string_t ptype_mask;
19270 /* Common CLI fields for set port ptypes */
19271 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19272 TOKEN_STRING_INITIALIZER
19273 (struct cmd_set_port_ptypes_result,
19275 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19276 TOKEN_STRING_INITIALIZER
19277 (struct cmd_set_port_ptypes_result,
19279 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19280 TOKEN_NUM_INITIALIZER
19281 (struct cmd_set_port_ptypes_result,
19283 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19284 TOKEN_STRING_INITIALIZER
19285 (struct cmd_set_port_ptypes_result,
19286 ptype_mask, "ptype_mask");
19287 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19288 TOKEN_NUM_INITIALIZER
19289 (struct cmd_set_port_ptypes_result,
19293 cmd_set_port_ptypes_parsed(
19294 void *parsed_result,
19295 __rte_unused struct cmdline *cl,
19296 __rte_unused void *data)
19298 struct cmd_set_port_ptypes_result *res = parsed_result;
19299 #define PTYPE_NAMESIZE 256
19300 char ptype_name[PTYPE_NAMESIZE];
19301 uint16_t port_id = res->port_id;
19302 uint32_t ptype_mask = res->mask;
19305 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19308 printf("Port %d doesn't support any ptypes.\n", port_id);
19312 uint32_t ptypes[ret];
19314 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19316 printf("Unable to set requested ptypes for Port %d\n", port_id);
19320 printf("Successfully set following ptypes for Port %d\n", port_id);
19321 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19322 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19323 printf("%s\n", ptype_name);
19326 clear_ptypes = false;
19329 cmdline_parse_inst_t cmd_set_port_ptypes = {
19330 .f = cmd_set_port_ptypes_parsed,
19332 .help_str = "set port <port_id> ptype_mask <mask>",
19334 (void *)&cmd_set_port_ptypes_set,
19335 (void *)&cmd_set_port_ptypes_port,
19336 (void *)&cmd_set_port_ptypes_port_id,
19337 (void *)&cmd_set_port_ptypes_mask_str,
19338 (void *)&cmd_set_port_ptypes_mask_u32,
19343 /* *** display mac addresses added to a port *** */
19344 struct cmd_showport_macs_result {
19345 cmdline_fixed_string_t cmd_show;
19346 cmdline_fixed_string_t cmd_port;
19347 cmdline_fixed_string_t cmd_keyword;
19352 cmd_showport_macs_parsed(void *parsed_result,
19353 __rte_unused struct cmdline *cl,
19354 __rte_unused void *data)
19356 struct cmd_showport_macs_result *res = parsed_result;
19358 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19361 if (!strcmp(res->cmd_keyword, "macs"))
19362 show_macs(res->cmd_pid);
19363 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19364 show_mcast_macs(res->cmd_pid);
19367 cmdline_parse_token_string_t cmd_showport_macs_show =
19368 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19370 cmdline_parse_token_string_t cmd_showport_macs_port =
19371 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19373 cmdline_parse_token_num_t cmd_showport_macs_pid =
19374 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19376 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19377 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19378 cmd_keyword, "macs#mcast_macs");
19380 cmdline_parse_inst_t cmd_showport_macs = {
19381 .f = cmd_showport_macs_parsed,
19383 .help_str = "show port <port_id> macs|mcast_macs",
19385 (void *)&cmd_showport_macs_show,
19386 (void *)&cmd_showport_macs_port,
19387 (void *)&cmd_showport_macs_pid,
19388 (void *)&cmd_showport_macs_keyword,
19393 /* ******************************************************************************** */
19395 /* list of instructions */
19396 cmdline_parse_ctx_t main_ctx[] = {
19397 (cmdline_parse_inst_t *)&cmd_help_brief,
19398 (cmdline_parse_inst_t *)&cmd_help_long,
19399 (cmdline_parse_inst_t *)&cmd_quit,
19400 (cmdline_parse_inst_t *)&cmd_load_from_file,
19401 (cmdline_parse_inst_t *)&cmd_showport,
19402 (cmdline_parse_inst_t *)&cmd_showqueue,
19403 (cmdline_parse_inst_t *)&cmd_showportall,
19404 (cmdline_parse_inst_t *)&cmd_showdevice,
19405 (cmdline_parse_inst_t *)&cmd_showcfg,
19406 (cmdline_parse_inst_t *)&cmd_showfwdall,
19407 (cmdline_parse_inst_t *)&cmd_start,
19408 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19409 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19410 (cmdline_parse_inst_t *)&cmd_set_link_up,
19411 (cmdline_parse_inst_t *)&cmd_set_link_down,
19412 (cmdline_parse_inst_t *)&cmd_reset,
19413 (cmdline_parse_inst_t *)&cmd_set_numbers,
19414 (cmdline_parse_inst_t *)&cmd_set_log,
19415 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19416 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19417 (cmdline_parse_inst_t *)&cmd_set_txtimes,
19418 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19419 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19420 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19421 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19422 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19423 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19424 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19425 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19426 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19427 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19428 (cmdline_parse_inst_t *)&cmd_set_link_check,
19429 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19430 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19431 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19432 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19433 #ifdef RTE_LIBRTE_PMD_BOND
19434 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19435 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19436 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19437 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19438 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19439 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19440 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19441 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19442 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19443 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19444 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19446 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19447 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19448 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19449 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19450 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19451 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19452 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19453 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19454 (cmdline_parse_inst_t *)&cmd_csum_set,
19455 (cmdline_parse_inst_t *)&cmd_csum_show,
19456 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19457 (cmdline_parse_inst_t *)&cmd_tso_set,
19458 (cmdline_parse_inst_t *)&cmd_tso_show,
19459 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19460 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19461 (cmdline_parse_inst_t *)&cmd_gro_enable,
19462 (cmdline_parse_inst_t *)&cmd_gro_flush,
19463 (cmdline_parse_inst_t *)&cmd_gro_show,
19464 (cmdline_parse_inst_t *)&cmd_gso_enable,
19465 (cmdline_parse_inst_t *)&cmd_gso_size,
19466 (cmdline_parse_inst_t *)&cmd_gso_show,
19467 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19468 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19469 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19470 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19471 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19472 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19473 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19474 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19475 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19476 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19477 (cmdline_parse_inst_t *)&cmd_config_dcb,
19478 (cmdline_parse_inst_t *)&cmd_read_reg,
19479 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19480 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19481 (cmdline_parse_inst_t *)&cmd_write_reg,
19482 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19483 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19484 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19485 (cmdline_parse_inst_t *)&cmd_stop,
19486 (cmdline_parse_inst_t *)&cmd_mac_addr,
19487 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19488 (cmdline_parse_inst_t *)&cmd_set_qmap,
19489 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19490 (cmdline_parse_inst_t *)&cmd_operate_port,
19491 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19492 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19493 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19494 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19495 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19496 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19497 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19498 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19499 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19500 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19501 (cmdline_parse_inst_t *)&cmd_config_mtu,
19502 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19503 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19504 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19505 (cmdline_parse_inst_t *)&cmd_config_rss,
19506 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19507 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19508 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19509 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19510 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19511 (cmdline_parse_inst_t *)&cmd_showport_reta,
19512 (cmdline_parse_inst_t *)&cmd_showport_macs,
19513 (cmdline_parse_inst_t *)&cmd_config_burst,
19514 (cmdline_parse_inst_t *)&cmd_config_thresh,
19515 (cmdline_parse_inst_t *)&cmd_config_threshold,
19516 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19517 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19518 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19519 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19520 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19521 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19522 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19523 (cmdline_parse_inst_t *)&cmd_global_config,
19524 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19525 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19526 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19527 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19528 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19529 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19530 (cmdline_parse_inst_t *)&cmd_dump,
19531 (cmdline_parse_inst_t *)&cmd_dump_one,
19532 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19533 (cmdline_parse_inst_t *)&cmd_syn_filter,
19534 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19535 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19536 (cmdline_parse_inst_t *)&cmd_flex_filter,
19537 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19538 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19539 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19540 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19541 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19542 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19543 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19544 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19545 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19546 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19547 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19548 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19549 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19550 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19551 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19552 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19553 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19554 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19555 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19556 (cmdline_parse_inst_t *)&cmd_flow,
19557 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19558 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19559 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19560 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19561 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19562 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19563 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19564 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19565 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19566 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19567 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19568 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19569 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19570 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19571 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19572 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19573 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19574 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19575 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19576 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19577 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19578 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19579 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19580 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19581 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19582 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19583 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19584 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19585 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19586 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19587 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19588 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19589 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19590 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19591 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19592 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19593 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19594 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19595 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19596 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19597 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19598 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19599 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19600 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19601 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19602 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19603 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19604 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19605 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19606 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19607 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19608 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19609 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19610 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19611 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19612 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19613 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19614 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19615 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19616 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19617 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19618 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19619 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19620 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19621 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19622 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19623 (cmdline_parse_inst_t *)&cmd_ddp_add,
19624 (cmdline_parse_inst_t *)&cmd_ddp_del,
19625 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19626 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19627 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19628 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19629 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19630 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19631 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19632 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19633 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19634 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19635 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19636 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19638 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19639 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19640 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19641 (cmdline_parse_inst_t *)&cmd_queue_region,
19642 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19643 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19644 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19645 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19646 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19647 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19648 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19649 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19650 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19651 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19652 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19653 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19654 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19655 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19656 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19657 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19658 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19659 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19660 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19661 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19662 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19663 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19664 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19665 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19666 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19667 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19668 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19669 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19670 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19671 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19672 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19673 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19674 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19675 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19676 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19677 #ifdef RTE_LIBRTE_BPF
19678 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19679 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19681 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19682 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19683 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19684 (cmdline_parse_inst_t *)&cmd_set_raw,
19685 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19686 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19687 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
19691 /* read cmdline commands from file */
19693 cmdline_read_from_file(const char *filename)
19695 struct cmdline *cl;
19697 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19699 printf("Failed to create file based cmdline context: %s\n",
19704 cmdline_interact(cl);
19709 printf("Read CLI commands from %s\n", filename);
19712 /* prompt function, called from main on MASTER lcore */
19716 /* initialize non-constant commands */
19717 cmd_set_fwd_mode_init();
19718 cmd_set_fwd_retry_mode_init();
19720 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19721 if (testpmd_cl == NULL)
19723 cmdline_interact(testpmd_cl);
19724 cmdline_stdin_exit(testpmd_cl);
19730 if (testpmd_cl != NULL)
19731 cmdline_quit(testpmd_cl);
19735 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19737 if (id == (portid_t)RTE_PORT_ALL) {
19740 RTE_ETH_FOREACH_DEV(pid) {
19741 /* check if need_reconfig has been set to 1 */
19742 if (ports[pid].need_reconfig == 0)
19743 ports[pid].need_reconfig = dev;
19744 /* check if need_reconfig_queues has been set to 1 */
19745 if (ports[pid].need_reconfig_queues == 0)
19746 ports[pid].need_reconfig_queues = queue;
19748 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19749 /* check if need_reconfig has been set to 1 */
19750 if (ports[id].need_reconfig == 0)
19751 ports[id].need_reconfig = dev;
19752 /* check if need_reconfig_queues has been set to 1 */
19753 if (ports[id].need_reconfig_queues == 0)
19754 ports[id].need_reconfig_queues = queue;