1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
14 #include <sys/socket.h>
15 #include <netinet/in.h>
17 #include <sys/queue.h>
19 #include <rte_common.h>
20 #include <rte_byteorder.h>
22 #include <rte_debug.h>
23 #include <rte_cycles.h>
24 #include <rte_memory.h>
25 #include <rte_memzone.h>
26 #include <rte_malloc.h>
27 #include <rte_launch.h>
29 #include <rte_per_lcore.h>
30 #include <rte_lcore.h>
31 #include <rte_atomic.h>
32 #include <rte_branch_prediction.h>
34 #include <rte_mempool.h>
35 #include <rte_interrupts.h>
37 #include <rte_ether.h>
38 #include <rte_ethdev.h>
39 #include <rte_string_fns.h>
40 #include <rte_devargs.h>
43 #include <rte_mbuf_dyn.h>
45 #include <cmdline_rdline.h>
46 #include <cmdline_parse.h>
47 #include <cmdline_parse_num.h>
48 #include <cmdline_parse_string.h>
49 #include <cmdline_parse_ipaddr.h>
50 #include <cmdline_parse_etheraddr.h>
51 #include <cmdline_socket.h>
53 #ifdef RTE_LIBRTE_PMD_BOND
54 #include <rte_eth_bond.h>
55 #include <rte_eth_bond_8023ad.h>
57 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
58 #include <rte_pmd_dpaa.h>
60 #ifdef RTE_LIBRTE_IXGBE_PMD
61 #include <rte_pmd_ixgbe.h>
63 #ifdef RTE_LIBRTE_I40E_PMD
64 #include <rte_pmd_i40e.h>
66 #ifdef RTE_LIBRTE_BNXT_PMD
67 #include <rte_pmd_bnxt.h>
70 #include "cmdline_mtr.h"
71 #include "cmdline_tm.h"
74 static struct cmdline *testpmd_cl;
76 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
78 /* *** Help command with introduction. *** */
79 struct cmd_help_brief_result {
80 cmdline_fixed_string_t help;
83 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
85 __rte_unused void *data)
90 "Help is available for the following sections:\n\n"
91 " help control : Start and stop forwarding.\n"
92 " help display : Displaying port, stats and config "
94 " help config : Configuration information.\n"
95 " help ports : Configuring ports.\n"
96 " help registers : Reading and setting port registers.\n"
97 " help filters : Filters configuration help.\n"
98 " help traffic_management : Traffic Management commands.\n"
99 " help devices : Device related cmds.\n"
100 " help all : All of the above sections.\n\n"
105 cmdline_parse_token_string_t cmd_help_brief_help =
106 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
108 cmdline_parse_inst_t cmd_help_brief = {
109 .f = cmd_help_brief_parsed,
111 .help_str = "help: Show help",
113 (void *)&cmd_help_brief_help,
118 /* *** Help command with help sections. *** */
119 struct cmd_help_long_result {
120 cmdline_fixed_string_t help;
121 cmdline_fixed_string_t section;
124 static void cmd_help_long_parsed(void *parsed_result,
126 __rte_unused void *data)
129 struct cmd_help_long_result *res = parsed_result;
131 if (!strcmp(res->section, "all"))
134 if (show_all || !strcmp(res->section, "control")) {
139 "Control forwarding:\n"
140 "-------------------\n\n"
143 " Start packet forwarding with current configuration.\n\n"
146 " Start packet forwarding with current config"
147 " after sending one burst of packets.\n\n"
150 " Stop packet forwarding, and display accumulated"
154 " Quit to prompt.\n\n"
158 if (show_all || !strcmp(res->section, "display")) {
166 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
167 " Display information for port_id, or all.\n\n"
169 "show port X rss reta (size) (mask0,mask1,...)\n"
170 " Display the rss redirection table entry indicated"
171 " by masks on port X. size is used to indicate the"
172 " hardware supported reta size\n\n"
174 "show port (port_id) rss-hash [key]\n"
175 " Display the RSS hash functions and RSS hash key of port\n\n"
177 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
178 " Clear information for port_id, or all.\n\n"
180 "show (rxq|txq) info (port_id) (queue_id)\n"
181 " Display information for configured RX/TX queue.\n\n"
183 "show config (rxtx|cores|fwd|txpkts)\n"
184 " Display the given configuration.\n\n"
186 "read rxd (port_id) (queue_id) (rxd_id)\n"
187 " Display an RX descriptor of a port RX queue.\n\n"
189 "read txd (port_id) (queue_id) (txd_id)\n"
190 " Display a TX descriptor of a port TX queue.\n\n"
192 "ddp get list (port_id)\n"
193 " Get ddp profile info list\n\n"
195 "ddp get info (profile_path)\n"
196 " Get ddp profile information.\n\n"
198 "show vf stats (port_id) (vf_id)\n"
199 " Display a VF's statistics.\n\n"
201 "clear vf stats (port_id) (vf_id)\n"
202 " Reset a VF's statistics.\n\n"
204 "show port (port_id) pctype mapping\n"
205 " Get flow ptype to pctype mapping on a port\n\n"
207 "show port meter stats (port_id) (meter_id) (clear)\n"
208 " Get meter stats on a port\n\n"
210 "show fwd stats all\n"
211 " Display statistics for all fwd engines.\n\n"
213 "clear fwd stats all\n"
214 " Clear statistics for all fwd engines.\n\n"
216 "show port (port_id) rx_offload capabilities\n"
217 " List all per queue and per port Rx offloading"
218 " capabilities of a port\n\n"
220 "show port (port_id) rx_offload configuration\n"
221 " List port level and all queue level"
222 " Rx offloading configuration\n\n"
224 "show port (port_id) tx_offload capabilities\n"
225 " List all per queue and per port"
226 " Tx offloading capabilities of a port\n\n"
228 "show port (port_id) tx_offload configuration\n"
229 " List port level and all queue level"
230 " Tx offloading configuration\n\n"
232 "show port (port_id) tx_metadata\n"
233 " Show Tx metadata value set"
234 " for a specific port\n\n"
236 "show port (port_id) ptypes\n"
237 " Show port supported ptypes"
238 " for a specific port\n\n"
240 "show device info (<identifier>|all)"
241 " Show general information about devices probed.\n\n"
243 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
244 " Show status of rx|tx descriptor.\n\n"
246 "show port (port_id) macs|mcast_macs"
247 " Display list of mac addresses added to port.\n\n"
251 if (show_all || !strcmp(res->section, "config")) {
257 "Configuration changes only become active when"
258 " forwarding is started/restarted.\n\n"
261 " Reset forwarding to the default configuration.\n\n"
263 "set verbose (level)\n"
264 " Set the debug verbosity level X.\n\n"
266 "set log global|(type) (level)\n"
267 " Set the log level.\n\n"
270 " Set number of ports.\n\n"
273 " Set number of cores.\n\n"
275 "set coremask (mask)\n"
276 " Set the forwarding cores hexadecimal mask.\n\n"
278 "set portmask (mask)\n"
279 " Set the forwarding ports hexadecimal mask.\n\n"
282 " Set number of packets per burst.\n\n"
284 "set burst tx delay (microseconds) retry (num)\n"
285 " Set the transmit delay time and number of retries,"
286 " effective when retry is enabled.\n\n"
288 "set txpkts (x[,y]*)\n"
289 " Set the length of each segment of TXONLY"
290 " and optionally CSUM packets.\n\n"
292 "set txsplit (off|on|rand)\n"
293 " Set the split policy for the TX packets."
294 " Right now only applicable for CSUM and TXONLY"
297 "set txtimes (x, y)\n"
298 " Set the scheduling on timestamps"
299 " timings for the TXONLY mode\n\n"
301 "set corelist (x[,y]*)\n"
302 " Set the list of forwarding cores.\n\n"
304 "set portlist (x[,y]*)\n"
305 " Set the list of forwarding ports.\n\n"
307 "set port setup on (iterator|event)\n"
308 " Select how attached port is retrieved for setup.\n\n"
310 "set tx loopback (port_id) (on|off)\n"
311 " Enable or disable tx loopback.\n\n"
313 "set all queues drop (port_id) (on|off)\n"
314 " Set drop enable bit for all queues.\n\n"
316 "set vf split drop (port_id) (vf_id) (on|off)\n"
317 " Set split drop enable bit for a VF from the PF.\n\n"
319 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
320 " Set MAC antispoof for a VF from the PF.\n\n"
322 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
323 " Enable MACsec offload.\n\n"
325 "set macsec offload (port_id) off\n"
326 " Disable MACsec offload.\n\n"
328 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
329 " Configure MACsec secure connection (SC).\n\n"
331 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
332 " Configure MACsec secure association (SA).\n\n"
334 "set vf broadcast (port_id) (vf_id) (on|off)\n"
335 " Set VF broadcast for a VF from the PF.\n\n"
337 "vlan set stripq (on|off) (port_id,queue_id)\n"
338 " Set the VLAN strip for a queue on a port.\n\n"
340 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
341 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
343 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
344 " Set VLAN insert for a VF from the PF.\n\n"
346 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
347 " Set VLAN antispoof for a VF from the PF.\n\n"
349 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
350 " Set VLAN tag for a VF from the PF.\n\n"
352 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
353 " Set a VF's max bandwidth(Mbps).\n\n"
355 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
356 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
358 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
359 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
361 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
362 " Set some TCs' strict link priority mode on a physical port.\n\n"
364 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
365 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
367 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
368 " Set the VLAN strip or filter or qinq strip or extend\n\n"
370 "vlan set (inner|outer) tpid (value) (port_id)\n"
371 " Set the VLAN TPID for Packet Filtering on"
374 "rx_vlan add (vlan_id|all) (port_id)\n"
375 " Add a vlan_id, or all identifiers, to the set"
376 " of VLAN identifiers filtered by port_id.\n\n"
378 "rx_vlan rm (vlan_id|all) (port_id)\n"
379 " Remove a vlan_id, or all identifiers, from the set"
380 " of VLAN identifiers filtered by port_id.\n\n"
382 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
383 " Add a vlan_id, to the set of VLAN identifiers"
384 "filtered for VF(s) from port_id.\n\n"
386 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
387 " Remove a vlan_id, to the set of VLAN identifiers"
388 "filtered for VF(s) from port_id.\n\n"
390 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
391 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
392 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
393 " add a tunnel filter of a port.\n\n"
395 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
396 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
397 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
398 " remove a tunnel filter of a port.\n\n"
400 "rx_vxlan_port add (udp_port) (port_id)\n"
401 " Add an UDP port for VXLAN packet filter on a port\n\n"
403 "rx_vxlan_port rm (udp_port) (port_id)\n"
404 " Remove an UDP port for VXLAN packet filter on a port\n\n"
406 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
407 " Set hardware insertion of VLAN IDs (single or double VLAN "
408 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
410 "tx_vlan set pvid port_id vlan_id (on|off)\n"
411 " Set port based TX VLAN insertion.\n\n"
413 "tx_vlan reset (port_id)\n"
414 " Disable hardware insertion of a VLAN header in"
415 " packets sent on a port.\n\n"
417 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
418 " Select hardware or software calculation of the"
419 " checksum when transmitting a packet using the"
420 " csum forward engine.\n"
421 " ip|udp|tcp|sctp always concern the inner layer.\n"
422 " outer-ip concerns the outer IP layer in"
423 " outer-udp concerns the outer UDP layer in"
424 " case the packet is recognized as a tunnel packet by"
425 " the forward engine (vxlan, gre and ipip are supported)\n"
426 " Please check the NIC datasheet for HW limits.\n\n"
428 "csum parse-tunnel (on|off) (tx_port_id)\n"
429 " If disabled, treat tunnel packets as non-tunneled"
430 " packets (treat inner headers as payload). The port\n"
431 " argument is the port used for TX in csum forward"
434 "csum show (port_id)\n"
435 " Display tx checksum offload configuration\n\n"
437 "tso set (segsize) (portid)\n"
438 " Enable TCP Segmentation Offload in csum forward"
440 " Please check the NIC datasheet for HW limits.\n\n"
443 " Display the status of TCP Segmentation Offload.\n\n"
445 "set port (port_id) gro on|off\n"
446 " Enable or disable Generic Receive Offload in"
447 " csum forwarding engine.\n\n"
449 "show port (port_id) gro\n"
450 " Display GRO configuration.\n\n"
452 "set gro flush (cycles)\n"
453 " Set the cycle to flush GROed packets from"
454 " reassembly tables.\n\n"
456 "set port (port_id) gso (on|off)"
457 " Enable or disable Generic Segmentation Offload in"
458 " csum forwarding engine.\n\n"
460 "set gso segsz (length)\n"
461 " Set max packet length for output GSO segments,"
462 " including packet header and payload.\n\n"
464 "show port (port_id) gso\n"
465 " Show GSO configuration.\n\n"
468 " Set packet forwarding mode.\n\n"
470 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
471 " Add a MAC address on port_id.\n\n"
473 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
474 " Remove a MAC address from port_id.\n\n"
476 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
477 " Set the default MAC address for port_id.\n\n"
479 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
480 " Add a MAC address for a VF on the port.\n\n"
482 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
483 " Set the MAC address for a VF from the PF.\n\n"
485 "set eth-peer (port_id) (peer_addr)\n"
486 " set the peer address for certain port.\n\n"
488 "set port (port_id) uta (mac_address|all) (on|off)\n"
489 " Add/Remove a or all unicast hash filter(s)"
492 "set promisc (port_id|all) (on|off)\n"
493 " Set the promiscuous mode on port_id, or all.\n\n"
495 "set allmulti (port_id|all) (on|off)\n"
496 " Set the allmulti mode on port_id, or all.\n\n"
498 "set vf promisc (port_id) (vf_id) (on|off)\n"
499 " Set unicast promiscuous mode for a VF from the PF.\n\n"
501 "set vf allmulti (port_id) (vf_id) (on|off)\n"
502 " Set multicast promiscuous mode for a VF from the PF.\n\n"
504 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
505 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
506 " (on|off) autoneg (on|off) (port_id)\n"
507 "set flow_ctrl rx (on|off) (portid)\n"
508 "set flow_ctrl tx (on|off) (portid)\n"
509 "set flow_ctrl high_water (high_water) (portid)\n"
510 "set flow_ctrl low_water (low_water) (portid)\n"
511 "set flow_ctrl pause_time (pause_time) (portid)\n"
512 "set flow_ctrl send_xon (send_xon) (portid)\n"
513 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
514 "set flow_ctrl autoneg (on|off) (port_id)\n"
515 " Set the link flow control parameter on a port.\n\n"
517 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
518 " (low_water) (pause_time) (priority) (port_id)\n"
519 " Set the priority flow control parameter on a"
522 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
523 " Set statistics mapping (qmapping 0..15) for RX/TX"
525 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
526 " on port 0 to mapping 5.\n\n"
528 "set xstats-hide-zero on|off\n"
529 " Set the option to hide the zero values"
530 " for xstats display.\n"
532 "set record-core-cycles on|off\n"
533 " Set the option to enable measurement of CPU cycles.\n"
535 "set record-burst-stats on|off\n"
536 " Set the option to enable display of RX and TX bursts.\n"
538 "set port (port_id) vf (vf_id) rx|tx on|off\n"
539 " Enable/Disable a VF receive/tranmit from a port\n\n"
541 "set port (port_id) vf (vf_id) (mac_addr)"
542 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
543 " Add/Remove unicast or multicast MAC addr filter"
546 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
548 " AUPE:accepts untagged VLAN;"
549 "ROPE:accept unicast hash\n\n"
550 " BAM:accepts broadcast packets;"
551 "MPE:accepts all multicast packets\n\n"
552 " Enable/Disable a VF receive mode of a port\n\n"
554 "set port (port_id) queue (queue_id) rate (rate_num)\n"
555 " Set rate limit for a queue of a port\n\n"
557 "set port (port_id) vf (vf_id) rate (rate_num) "
558 "queue_mask (queue_mask_value)\n"
559 " Set rate limit for queues in VF of a port\n\n"
561 "set port (port_id) mirror-rule (rule_id)"
562 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
563 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
564 " Set pool or vlan type mirror rule on a port.\n"
565 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
566 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
569 "set port (port_id) mirror-rule (rule_id)"
570 " (uplink-mirror|downlink-mirror) dst-pool"
571 " (pool_id) (on|off)\n"
572 " Set uplink or downlink type mirror rule on a port.\n"
573 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
574 " 0 on' enable mirror income traffic to pool 0.\n\n"
576 "reset port (port_id) mirror-rule (rule_id)\n"
577 " Reset a mirror rule.\n\n"
579 "set flush_rx (on|off)\n"
580 " Flush (default) or don't flush RX streams before"
581 " forwarding. Mainly used with PCAP drivers.\n\n"
583 "set bypass mode (normal|bypass|isolate) (port_id)\n"
584 " Set the bypass mode for the lowest port on bypass enabled"
587 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
588 "mode (normal|bypass|isolate) (port_id)\n"
589 " Set the event required to initiate specified bypass mode for"
590 " the lowest port on a bypass enabled NIC where:\n"
591 " timeout = enable bypass after watchdog timeout.\n"
592 " os_on = enable bypass when OS/board is powered on.\n"
593 " os_off = enable bypass when OS/board is powered off.\n"
594 " power_on = enable bypass when power supply is turned on.\n"
595 " power_off = enable bypass when power supply is turned off."
598 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
599 " Set the bypass watchdog timeout to 'n' seconds"
600 " where 0 = instant.\n\n"
602 "show bypass config (port_id)\n"
603 " Show the bypass configuration for a bypass enabled NIC"
604 " using the lowest port on the NIC.\n\n"
606 #ifdef RTE_LIBRTE_PMD_BOND
607 "create bonded device (mode) (socket)\n"
608 " Create a new bonded device with specific bonding mode and socket.\n\n"
610 "add bonding slave (slave_id) (port_id)\n"
611 " Add a slave device to a bonded device.\n\n"
613 "remove bonding slave (slave_id) (port_id)\n"
614 " Remove a slave device from a bonded device.\n\n"
616 "set bonding mode (value) (port_id)\n"
617 " Set the bonding mode on a bonded device.\n\n"
619 "set bonding primary (slave_id) (port_id)\n"
620 " Set the primary slave for a bonded device.\n\n"
622 "show bonding config (port_id)\n"
623 " Show the bonding config for port_id.\n\n"
625 "set bonding mac_addr (port_id) (address)\n"
626 " Set the MAC address of a bonded device.\n\n"
628 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
629 " Set Aggregation mode for IEEE802.3AD (mode 4)"
631 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
632 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
634 "set bonding mon_period (port_id) (value)\n"
635 " Set the bonding link status monitoring polling period in ms.\n\n"
637 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
638 " Enable/disable dedicated queues for LACP control traffic.\n\n"
641 "set link-up port (port_id)\n"
642 " Set link up for a port.\n\n"
644 "set link-down port (port_id)\n"
645 " Set link down for a port.\n\n"
647 "E-tag set insertion on port-tag-id (value)"
648 " port (port_id) vf (vf_id)\n"
649 " Enable E-tag insertion for a VF on a port\n\n"
651 "E-tag set insertion off port (port_id) vf (vf_id)\n"
652 " Disable E-tag insertion for a VF on a port\n\n"
654 "E-tag set stripping (on|off) port (port_id)\n"
655 " Enable/disable E-tag stripping on a port\n\n"
657 "E-tag set forwarding (on|off) port (port_id)\n"
658 " Enable/disable E-tag based forwarding"
661 "E-tag set filter add e-tag-id (value) dst-pool"
662 " (pool_id) port (port_id)\n"
663 " Add an E-tag forwarding filter on a port\n\n"
665 "E-tag set filter del e-tag-id (value) port (port_id)\n"
666 " Delete an E-tag forwarding filter on a port\n\n"
668 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
669 " Load a profile package on a port\n\n"
671 "ddp del (port_id) (backup_profile_path)\n"
672 " Delete a profile package from a port\n\n"
674 "ptype mapping get (port_id) (valid_only)\n"
675 " Get ptype mapping on a port\n\n"
677 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
678 " Replace target with the pkt_type in ptype mapping\n\n"
680 "ptype mapping reset (port_id)\n"
681 " Reset ptype mapping on a port\n\n"
683 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
684 " Update a ptype mapping item on a port\n\n"
686 "set port (port_id) ptype_mask (ptype_mask)\n"
687 " set packet types classification for a specific port\n\n"
689 "set port (port_id) queue-region region_id (value) "
690 "queue_start_index (value) queue_num (value)\n"
691 " Set a queue region on a port\n\n"
693 "set port (port_id) queue-region region_id (value) "
695 " Set a flowtype region index on a port\n\n"
697 "set port (port_id) queue-region UP (value) region_id (value)\n"
698 " Set the mapping of User Priority to "
699 "queue region on a port\n\n"
701 "set port (port_id) queue-region flush (on|off)\n"
702 " flush all queue region related configuration\n\n"
704 "show port meter cap (port_id)\n"
705 " Show port meter capability information\n\n"
707 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
708 " meter profile add - srtcm rfc 2697\n\n"
710 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
711 " meter profile add - trtcm rfc 2698\n\n"
713 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
714 " meter profile add - trtcm rfc 4115\n\n"
716 "del port meter profile (port_id) (profile_id)\n"
717 " meter profile delete\n\n"
719 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
720 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
721 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
722 "(dscp_tbl_entry63)]\n"
725 "enable port meter (port_id) (mtr_id)\n"
728 "disable port meter (port_id) (mtr_id)\n"
731 "del port meter (port_id) (mtr_id)\n"
734 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
735 " meter update meter profile\n\n"
737 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
738 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
739 " update meter dscp table entries\n\n"
741 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
742 "(action0) [(action1) (action2)]\n"
743 " meter update policer action\n\n"
745 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
746 " meter update stats\n\n"
748 "show port (port_id) queue-region\n"
749 " show all queue region related configuration info\n\n"
751 , list_pkt_forwarding_modes()
755 if (show_all || !strcmp(res->section, "ports")) {
761 "----------------\n\n"
763 "port start (port_id|all)\n"
764 " Start all ports or port_id.\n\n"
766 "port stop (port_id|all)\n"
767 " Stop all ports or port_id.\n\n"
769 "port close (port_id|all)\n"
770 " Close all ports or port_id.\n\n"
772 "port reset (port_id|all)\n"
773 " Reset all ports or port_id.\n\n"
775 "port attach (ident)\n"
776 " Attach physical or virtual dev by pci address or virtual device name\n\n"
778 "port detach (port_id)\n"
779 " Detach physical or virtual dev by port_id\n\n"
781 "port config (port_id|all)"
782 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
783 " duplex (half|full|auto)\n"
784 " Set speed and duplex for all ports or port_id\n\n"
786 "port config (port_id|all) loopback (mode)\n"
787 " Set loopback mode for all ports or port_id\n\n"
789 "port config all (rxq|txq|rxd|txd) (value)\n"
790 " Set number for rxq/txq/rxd/txd.\n\n"
792 "port config all max-pkt-len (value)\n"
793 " Set the max packet length.\n\n"
795 "port config all max-lro-pkt-size (value)\n"
796 " Set the max LRO aggregated packet size.\n\n"
798 "port config all drop-en (on|off)\n"
799 " Enable or disable packet drop on all RX queues of all ports when no "
800 "receive buffers available.\n\n"
802 "port config all rss (all|default|ip|tcp|udp|sctp|"
803 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
804 " Set the RSS mode.\n\n"
806 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
807 " Set the RSS redirection table.\n\n"
809 "port config (port_id) dcb vt (on|off) (traffic_class)"
811 " Set the DCB mode.\n\n"
813 "port config all burst (value)\n"
814 " Set the number of packets per burst.\n\n"
816 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
818 " Set the ring prefetch/host/writeback threshold"
819 " for tx/rx queue.\n\n"
821 "port config all (txfreet|txrst|rxfreet) (value)\n"
822 " Set free threshold for rx/tx, or set"
823 " tx rs bit threshold.\n\n"
824 "port config mtu X value\n"
825 " Set the MTU of port X to a given value\n\n"
827 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
828 " Set a rx/tx queue's ring size configuration, the new"
829 " value will take effect after command that (re-)start the port"
830 " or command that setup the specific queue\n\n"
832 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
833 " Start/stop a rx/tx queue of port X. Only take effect"
834 " when port X is started\n\n"
836 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
837 " Switch on/off a deferred start of port X rx/tx queue. Only"
838 " take effect when port X is stopped.\n\n"
840 "port (port_id) (rxq|txq) (queue_id) setup\n"
841 " Setup a rx/tx queue of port X.\n\n"
843 "port config (port_id|all) l2-tunnel E-tag ether-type"
845 " Set the value of E-tag ether-type.\n\n"
847 "port config (port_id|all) l2-tunnel E-tag"
848 " (enable|disable)\n"
849 " Enable/disable the E-tag support.\n\n"
851 "port config (port_id) pctype mapping reset\n"
852 " Reset flow type to pctype mapping on a port\n\n"
854 "port config (port_id) pctype mapping update"
855 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
856 " Update a flow type to pctype mapping item on a port\n\n"
858 "port config (port_id) pctype (pctype_id) hash_inset|"
859 "fdir_inset|fdir_flx_inset get|set|clear field\n"
861 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
863 "port config (port_id) pctype (pctype_id) hash_inset|"
864 "fdir_inset|fdir_flx_inset clear all"
865 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
867 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
868 " Add/remove UDP tunnel port for tunneling offload\n\n"
870 "port config <port_id> rx_offload vlan_strip|"
871 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
872 "outer_ipv4_cksum|macsec_strip|header_split|"
873 "vlan_filter|vlan_extend|jumbo_frame|"
874 "scatter|timestamp|security|keep_crc on|off\n"
875 " Enable or disable a per port Rx offloading"
876 " on all Rx queues of a port\n\n"
878 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
879 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
880 "outer_ipv4_cksum|macsec_strip|header_split|"
881 "vlan_filter|vlan_extend|jumbo_frame|"
882 "scatter|timestamp|security|keep_crc on|off\n"
883 " Enable or disable a per queue Rx offloading"
884 " only on a specific Rx queue\n\n"
886 "port config (port_id) tx_offload vlan_insert|"
887 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
888 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
889 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
890 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
892 " Enable or disable a per port Tx offloading"
893 " on all Tx queues of a port\n\n"
895 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
896 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
897 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
898 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
899 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
901 " Enable or disable a per queue Tx offloading"
902 " only on a specific Tx queue\n\n"
904 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
905 " Load an eBPF program as a callback"
906 " for particular RX/TX queue\n\n"
908 "bpf-unload rx|tx (port) (queue)\n"
909 " Unload previously loaded eBPF program"
910 " for particular RX/TX queue\n\n"
912 "port config (port_id) tx_metadata (value)\n"
913 " Set Tx metadata value per port. Testpmd will add this value"
914 " to any Tx packet sent from this port\n\n"
916 "port config (port_id) dynf (name) set|clear\n"
917 " Register a dynf and Set/clear this flag on Tx. "
918 "Testpmd will set this value to any Tx packet "
919 "sent from this port\n\n"
923 if (show_all || !strcmp(res->section, "registers")) {
931 "read reg (port_id) (address)\n"
932 " Display value of a port register.\n\n"
934 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
935 " Display a port register bit field.\n\n"
937 "read regbit (port_id) (address) (bit_x)\n"
938 " Display a single port register bit.\n\n"
940 "write reg (port_id) (address) (value)\n"
941 " Set value of a port register.\n\n"
943 "write regfield (port_id) (address) (bit_x) (bit_y)"
945 " Set bit field of a port register.\n\n"
947 "write regbit (port_id) (address) (bit_x) (value)\n"
948 " Set single bit value of a port register.\n\n"
951 if (show_all || !strcmp(res->section, "filters")) {
959 "ethertype_filter (port_id) (add|del)"
960 " (mac_addr|mac_ignr) (mac_address) ethertype"
961 " (ether_type) (drop|fwd) queue (queue_id)\n"
962 " Add/Del an ethertype filter.\n\n"
964 "2tuple_filter (port_id) (add|del)"
965 " dst_port (dst_port_value) protocol (protocol_value)"
966 " mask (mask_value) tcp_flags (tcp_flags_value)"
967 " priority (prio_value) queue (queue_id)\n"
968 " Add/Del a 2tuple filter.\n\n"
970 "5tuple_filter (port_id) (add|del)"
971 " dst_ip (dst_address) src_ip (src_address)"
972 " dst_port (dst_port_value) src_port (src_port_value)"
973 " protocol (protocol_value)"
974 " mask (mask_value) tcp_flags (tcp_flags_value)"
975 " priority (prio_value) queue (queue_id)\n"
976 " Add/Del a 5tuple filter.\n\n"
978 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
979 " Add/Del syn filter.\n\n"
981 "flex_filter (port_id) (add|del) len (len_value)"
982 " bytes (bytes_value) mask (mask_value)"
983 " priority (prio_value) queue (queue_id)\n"
984 " Add/Del a flex filter.\n\n"
986 "flow_director_filter (port_id) mode IP (add|del|update)"
987 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
988 " src (src_ip_address) dst (dst_ip_address)"
989 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
990 " vlan (vlan_value) flexbytes (flexbytes_value)"
991 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
992 " fd_id (fd_id_value)\n"
993 " Add/Del an IP type flow director filter.\n\n"
995 "flow_director_filter (port_id) mode IP (add|del|update)"
996 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
997 " src (src_ip_address) (src_port)"
998 " dst (dst_ip_address) (dst_port)"
999 " tos (tos_value) ttl (ttl_value)"
1000 " vlan (vlan_value) flexbytes (flexbytes_value)"
1001 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1002 " fd_id (fd_id_value)\n"
1003 " Add/Del an UDP/TCP type flow director filter.\n\n"
1005 "flow_director_filter (port_id) mode IP (add|del|update)"
1006 " flow (ipv4-sctp|ipv6-sctp)"
1007 " src (src_ip_address) (src_port)"
1008 " dst (dst_ip_address) (dst_port)"
1009 " tag (verification_tag) "
1010 " tos (tos_value) ttl (ttl_value)"
1011 " vlan (vlan_value)"
1012 " flexbytes (flexbytes_value) (drop|fwd)"
1013 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1014 " Add/Del a SCTP type flow director filter.\n\n"
1016 "flow_director_filter (port_id) mode IP (add|del|update)"
1017 " flow l2_payload ether (ethertype)"
1018 " flexbytes (flexbytes_value) (drop|fwd)"
1019 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1020 " Add/Del a l2 payload type flow director filter.\n\n"
1022 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1023 " mac (mac_address) vlan (vlan_value)"
1024 " flexbytes (flexbytes_value) (drop|fwd)"
1025 " queue (queue_id) fd_id (fd_id_value)\n"
1026 " Add/Del a MAC-VLAN flow director filter.\n\n"
1028 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1029 " mac (mac_address) vlan (vlan_value)"
1030 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1031 " flexbytes (flexbytes_value) (drop|fwd)"
1032 " queue (queue_id) fd_id (fd_id_value)\n"
1033 " Add/Del a Tunnel flow director filter.\n\n"
1035 "flow_director_filter (port_id) mode raw (add|del|update)"
1036 " flow (flow_id) (drop|fwd) queue (queue_id)"
1037 " fd_id (fd_id_value) packet (packet file name)\n"
1038 " Add/Del a raw type flow director filter.\n\n"
1040 "flush_flow_director (port_id)\n"
1041 " Flush all flow director entries of a device.\n\n"
1043 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1044 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1045 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1046 " Set flow director IP mask.\n\n"
1048 "flow_director_mask (port_id) mode MAC-VLAN"
1049 " vlan (vlan_value)\n"
1050 " Set flow director MAC-VLAN mask.\n\n"
1052 "flow_director_mask (port_id) mode Tunnel"
1053 " vlan (vlan_value) mac (mac_value)"
1054 " tunnel-type (tunnel_type_value)"
1055 " tunnel-id (tunnel_id_value)\n"
1056 " Set flow director Tunnel mask.\n\n"
1058 "flow_director_flex_mask (port_id)"
1059 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1060 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1062 " Configure mask of flex payload.\n\n"
1064 "flow_director_flex_payload (port_id)"
1065 " (raw|l2|l3|l4) (config)\n"
1066 " Configure flex payload selection.\n\n"
1068 "get_sym_hash_ena_per_port (port_id)\n"
1069 " get symmetric hash enable configuration per port.\n\n"
1071 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1072 " set symmetric hash enable configuration per port"
1073 " to enable or disable.\n\n"
1075 "get_hash_global_config (port_id)\n"
1076 " Get the global configurations of hash filters.\n\n"
1078 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1079 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1080 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1081 " (enable|disable)\n"
1082 " Set the global configurations of hash filters.\n\n"
1084 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1085 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1086 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1087 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1088 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1089 "ipv6-next-header|udp-src-port|udp-dst-port|"
1090 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1091 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1092 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1093 "fld-8th|none) (select|add)\n"
1094 " Set the input set for hash.\n\n"
1096 "set_fdir_input_set (port_id) "
1097 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1098 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1099 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1100 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1101 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1102 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1103 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1105 " Set the input set for FDir.\n\n"
1107 "flow validate {port_id}"
1108 " [group {group_id}] [priority {level}]"
1109 " [ingress] [egress]"
1110 " pattern {item} [/ {item} [...]] / end"
1111 " actions {action} [/ {action} [...]] / end\n"
1112 " Check whether a flow rule can be created.\n\n"
1114 "flow create {port_id}"
1115 " [group {group_id}] [priority {level}]"
1116 " [ingress] [egress]"
1117 " pattern {item} [/ {item} [...]] / end"
1118 " actions {action} [/ {action} [...]] / end\n"
1119 " Create a flow rule.\n\n"
1121 "flow destroy {port_id} rule {rule_id} [...]\n"
1122 " Destroy specific flow rules.\n\n"
1124 "flow flush {port_id}\n"
1125 " Destroy all flow rules.\n\n"
1127 "flow query {port_id} {rule_id} {action}\n"
1128 " Query an existing flow rule.\n\n"
1130 "flow list {port_id} [group {group_id}] [...]\n"
1131 " List existing flow rules sorted by priority,"
1132 " filtered by group identifiers.\n\n"
1134 "flow isolate {port_id} {boolean}\n"
1135 " Restrict ingress traffic to the defined"
1138 "flow aged {port_id} [destroy]\n"
1139 " List and destroy aged flows"
1142 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1143 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1144 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1145 " Configure the VXLAN encapsulation for flows.\n\n"
1147 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1148 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1149 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1150 " eth-dst (eth-dst)\n"
1151 " Configure the VXLAN encapsulation for flows.\n\n"
1153 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1154 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1155 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1156 " eth-dst (eth-dst)\n"
1157 " Configure the VXLAN encapsulation for flows.\n\n"
1159 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1160 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1162 " Configure the NVGRE encapsulation for flows.\n\n"
1164 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1165 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1166 " eth-src (eth-src) eth-dst (eth-dst)\n"
1167 " Configure the NVGRE encapsulation for flows.\n\n"
1169 "set raw_encap {flow items}\n"
1170 " Configure the encapsulation with raw data.\n\n"
1172 "set raw_decap {flow items}\n"
1173 " Configure the decapsulation with raw data.\n\n"
1178 if (show_all || !strcmp(res->section, "traffic_management")) {
1182 "Traffic Management:\n"
1184 "show port tm cap (port_id)\n"
1185 " Display the port TM capability.\n\n"
1187 "show port tm level cap (port_id) (level_id)\n"
1188 " Display the port TM hierarchical level capability.\n\n"
1190 "show port tm node cap (port_id) (node_id)\n"
1191 " Display the port TM node capability.\n\n"
1193 "show port tm node type (port_id) (node_id)\n"
1194 " Display the port TM node type.\n\n"
1196 "show port tm node stats (port_id) (node_id) (clear)\n"
1197 " Display the port TM node stats.\n\n"
1199 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1200 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1201 " (packet_length_adjust) (packet_mode)\n"
1202 " Add port tm node private shaper profile.\n\n"
1204 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1205 " Delete port tm node private shaper profile.\n\n"
1207 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1208 " (shaper_profile_id)\n"
1209 " Add/update port tm node shared shaper.\n\n"
1211 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1212 " Delete port tm node shared shaper.\n\n"
1214 "set port tm node shaper profile (port_id) (node_id)"
1215 " (shaper_profile_id)\n"
1216 " Set port tm node shaper profile.\n\n"
1218 "add port tm node wred profile (port_id) (wred_profile_id)"
1219 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1220 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1221 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1222 " Add port tm node wred profile.\n\n"
1224 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1225 " Delete port tm node wred profile.\n\n"
1227 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1228 " (priority) (weight) (level_id) (shaper_profile_id)"
1229 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1230 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1231 " Add port tm nonleaf node.\n\n"
1233 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1234 " (priority) (weight) (level_id) (shaper_profile_id)"
1235 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1236 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1237 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1239 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1240 " (priority) (weight) (level_id) (shaper_profile_id)"
1241 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1242 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1243 " Add port tm leaf node.\n\n"
1245 "del port tm node (port_id) (node_id)\n"
1246 " Delete port tm node.\n\n"
1248 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1249 " (priority) (weight)\n"
1250 " Set port tm node parent.\n\n"
1252 "suspend port tm node (port_id) (node_id)"
1253 " Suspend tm node.\n\n"
1255 "resume port tm node (port_id) (node_id)"
1256 " Resume tm node.\n\n"
1258 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1259 " Commit tm hierarchy.\n\n"
1261 "set port tm mark ip_ecn (port) (green) (yellow)"
1263 " Enables/Disables the traffic management marking"
1264 " for IP ECN (Explicit Congestion Notification)"
1265 " packets on a given port\n\n"
1267 "set port tm mark ip_dscp (port) (green) (yellow)"
1269 " Enables/Disables the traffic management marking"
1270 " on the port for IP dscp packets\n\n"
1272 "set port tm mark vlan_dei (port) (green) (yellow)"
1274 " Enables/Disables the traffic management marking"
1275 " on the port for VLAN packets with DEI enabled\n\n"
1279 if (show_all || !strcmp(res->section, "devices")) {
1283 "Device Operations:\n"
1285 "device detach (identifier)\n"
1286 " Detach device by identifier.\n\n"
1292 cmdline_parse_token_string_t cmd_help_long_help =
1293 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1295 cmdline_parse_token_string_t cmd_help_long_section =
1296 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1297 "all#control#display#config#"
1298 "ports#registers#filters#traffic_management#devices");
1300 cmdline_parse_inst_t cmd_help_long = {
1301 .f = cmd_help_long_parsed,
1303 .help_str = "help all|control|display|config|ports|register|"
1304 "filters|traffic_management|devices: "
1307 (void *)&cmd_help_long_help,
1308 (void *)&cmd_help_long_section,
1314 /* *** start/stop/close all ports *** */
1315 struct cmd_operate_port_result {
1316 cmdline_fixed_string_t keyword;
1317 cmdline_fixed_string_t name;
1318 cmdline_fixed_string_t value;
1321 static void cmd_operate_port_parsed(void *parsed_result,
1322 __rte_unused struct cmdline *cl,
1323 __rte_unused void *data)
1325 struct cmd_operate_port_result *res = parsed_result;
1327 if (!strcmp(res->name, "start"))
1328 start_port(RTE_PORT_ALL);
1329 else if (!strcmp(res->name, "stop"))
1330 stop_port(RTE_PORT_ALL);
1331 else if (!strcmp(res->name, "close"))
1332 close_port(RTE_PORT_ALL);
1333 else if (!strcmp(res->name, "reset"))
1334 reset_port(RTE_PORT_ALL);
1336 printf("Unknown parameter\n");
1339 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1340 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1342 cmdline_parse_token_string_t cmd_operate_port_all_port =
1343 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1344 "start#stop#close#reset");
1345 cmdline_parse_token_string_t cmd_operate_port_all_all =
1346 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1348 cmdline_parse_inst_t cmd_operate_port = {
1349 .f = cmd_operate_port_parsed,
1351 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1353 (void *)&cmd_operate_port_all_cmd,
1354 (void *)&cmd_operate_port_all_port,
1355 (void *)&cmd_operate_port_all_all,
1360 /* *** start/stop/close specific port *** */
1361 struct cmd_operate_specific_port_result {
1362 cmdline_fixed_string_t keyword;
1363 cmdline_fixed_string_t name;
1367 static void cmd_operate_specific_port_parsed(void *parsed_result,
1368 __rte_unused struct cmdline *cl,
1369 __rte_unused void *data)
1371 struct cmd_operate_specific_port_result *res = parsed_result;
1373 if (!strcmp(res->name, "start"))
1374 start_port(res->value);
1375 else if (!strcmp(res->name, "stop"))
1376 stop_port(res->value);
1377 else if (!strcmp(res->name, "close"))
1378 close_port(res->value);
1379 else if (!strcmp(res->name, "reset"))
1380 reset_port(res->value);
1382 printf("Unknown parameter\n");
1385 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1386 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1388 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1389 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1390 name, "start#stop#close#reset");
1391 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1392 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1395 cmdline_parse_inst_t cmd_operate_specific_port = {
1396 .f = cmd_operate_specific_port_parsed,
1398 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1400 (void *)&cmd_operate_specific_port_cmd,
1401 (void *)&cmd_operate_specific_port_port,
1402 (void *)&cmd_operate_specific_port_id,
1407 /* *** enable port setup (after attach) via iterator or event *** */
1408 struct cmd_set_port_setup_on_result {
1409 cmdline_fixed_string_t set;
1410 cmdline_fixed_string_t port;
1411 cmdline_fixed_string_t setup;
1412 cmdline_fixed_string_t on;
1413 cmdline_fixed_string_t mode;
1416 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1417 __rte_unused struct cmdline *cl,
1418 __rte_unused void *data)
1420 struct cmd_set_port_setup_on_result *res = parsed_result;
1422 if (strcmp(res->mode, "event") == 0)
1423 setup_on_probe_event = true;
1424 else if (strcmp(res->mode, "iterator") == 0)
1425 setup_on_probe_event = false;
1427 printf("Unknown mode\n");
1430 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1431 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1433 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1434 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1436 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1437 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1439 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1440 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1442 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1443 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1444 mode, "iterator#event");
1446 cmdline_parse_inst_t cmd_set_port_setup_on = {
1447 .f = cmd_set_port_setup_on_parsed,
1449 .help_str = "set port setup on iterator|event",
1451 (void *)&cmd_set_port_setup_on_set,
1452 (void *)&cmd_set_port_setup_on_port,
1453 (void *)&cmd_set_port_setup_on_setup,
1454 (void *)&cmd_set_port_setup_on_on,
1455 (void *)&cmd_set_port_setup_on_mode,
1460 /* *** attach a specified port *** */
1461 struct cmd_operate_attach_port_result {
1462 cmdline_fixed_string_t port;
1463 cmdline_fixed_string_t keyword;
1464 cmdline_multi_string_t identifier;
1467 static void cmd_operate_attach_port_parsed(void *parsed_result,
1468 __rte_unused struct cmdline *cl,
1469 __rte_unused void *data)
1471 struct cmd_operate_attach_port_result *res = parsed_result;
1473 if (!strcmp(res->keyword, "attach"))
1474 attach_port(res->identifier);
1476 printf("Unknown parameter\n");
1479 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1480 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1482 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1483 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1485 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1486 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1487 identifier, TOKEN_STRING_MULTI);
1489 cmdline_parse_inst_t cmd_operate_attach_port = {
1490 .f = cmd_operate_attach_port_parsed,
1492 .help_str = "port attach <identifier>: "
1493 "(identifier: pci address or virtual dev name)",
1495 (void *)&cmd_operate_attach_port_port,
1496 (void *)&cmd_operate_attach_port_keyword,
1497 (void *)&cmd_operate_attach_port_identifier,
1502 /* *** detach a specified port *** */
1503 struct cmd_operate_detach_port_result {
1504 cmdline_fixed_string_t port;
1505 cmdline_fixed_string_t keyword;
1509 static void cmd_operate_detach_port_parsed(void *parsed_result,
1510 __rte_unused struct cmdline *cl,
1511 __rte_unused void *data)
1513 struct cmd_operate_detach_port_result *res = parsed_result;
1515 if (!strcmp(res->keyword, "detach")) {
1516 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1517 detach_port_device(res->port_id);
1519 printf("Unknown parameter\n");
1523 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1524 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1526 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1527 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1529 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1530 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1533 cmdline_parse_inst_t cmd_operate_detach_port = {
1534 .f = cmd_operate_detach_port_parsed,
1536 .help_str = "port detach <port_id>",
1538 (void *)&cmd_operate_detach_port_port,
1539 (void *)&cmd_operate_detach_port_keyword,
1540 (void *)&cmd_operate_detach_port_port_id,
1545 /* *** detach device by identifier *** */
1546 struct cmd_operate_detach_device_result {
1547 cmdline_fixed_string_t device;
1548 cmdline_fixed_string_t keyword;
1549 cmdline_fixed_string_t identifier;
1552 static void cmd_operate_detach_device_parsed(void *parsed_result,
1553 __rte_unused struct cmdline *cl,
1554 __rte_unused void *data)
1556 struct cmd_operate_detach_device_result *res = parsed_result;
1558 if (!strcmp(res->keyword, "detach"))
1559 detach_devargs(res->identifier);
1561 printf("Unknown parameter\n");
1564 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1565 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1567 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1568 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1570 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1571 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1574 cmdline_parse_inst_t cmd_operate_detach_device = {
1575 .f = cmd_operate_detach_device_parsed,
1577 .help_str = "device detach <identifier>:"
1578 "(identifier: pci address or virtual dev name)",
1580 (void *)&cmd_operate_detach_device_device,
1581 (void *)&cmd_operate_detach_device_keyword,
1582 (void *)&cmd_operate_detach_device_identifier,
1586 /* *** configure speed for all ports *** */
1587 struct cmd_config_speed_all {
1588 cmdline_fixed_string_t port;
1589 cmdline_fixed_string_t keyword;
1590 cmdline_fixed_string_t all;
1591 cmdline_fixed_string_t item1;
1592 cmdline_fixed_string_t item2;
1593 cmdline_fixed_string_t value1;
1594 cmdline_fixed_string_t value2;
1598 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1603 if (!strcmp(duplexstr, "half")) {
1604 duplex = ETH_LINK_HALF_DUPLEX;
1605 } else if (!strcmp(duplexstr, "full")) {
1606 duplex = ETH_LINK_FULL_DUPLEX;
1607 } else if (!strcmp(duplexstr, "auto")) {
1608 duplex = ETH_LINK_FULL_DUPLEX;
1610 printf("Unknown duplex parameter\n");
1614 if (!strcmp(speedstr, "10")) {
1615 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1616 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1617 } else if (!strcmp(speedstr, "100")) {
1618 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1619 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1621 if (duplex != ETH_LINK_FULL_DUPLEX) {
1622 printf("Invalid speed/duplex parameters\n");
1625 if (!strcmp(speedstr, "1000")) {
1626 *speed = ETH_LINK_SPEED_1G;
1627 } else if (!strcmp(speedstr, "10000")) {
1628 *speed = ETH_LINK_SPEED_10G;
1629 } else if (!strcmp(speedstr, "25000")) {
1630 *speed = ETH_LINK_SPEED_25G;
1631 } else if (!strcmp(speedstr, "40000")) {
1632 *speed = ETH_LINK_SPEED_40G;
1633 } else if (!strcmp(speedstr, "50000")) {
1634 *speed = ETH_LINK_SPEED_50G;
1635 } else if (!strcmp(speedstr, "100000")) {
1636 *speed = ETH_LINK_SPEED_100G;
1637 } else if (!strcmp(speedstr, "200000")) {
1638 *speed = ETH_LINK_SPEED_200G;
1639 } else if (!strcmp(speedstr, "auto")) {
1640 *speed = ETH_LINK_SPEED_AUTONEG;
1642 printf("Unknown speed parameter\n");
1651 cmd_config_speed_all_parsed(void *parsed_result,
1652 __rte_unused struct cmdline *cl,
1653 __rte_unused void *data)
1655 struct cmd_config_speed_all *res = parsed_result;
1656 uint32_t link_speed;
1659 if (!all_ports_stopped()) {
1660 printf("Please stop all ports first\n");
1664 if (parse_and_check_speed_duplex(res->value1, res->value2,
1668 RTE_ETH_FOREACH_DEV(pid) {
1669 ports[pid].dev_conf.link_speeds = link_speed;
1672 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1675 cmdline_parse_token_string_t cmd_config_speed_all_port =
1676 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1677 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1678 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1680 cmdline_parse_token_string_t cmd_config_speed_all_all =
1681 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1682 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1683 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1684 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1685 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1686 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1687 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1688 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1689 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1690 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1693 cmdline_parse_inst_t cmd_config_speed_all = {
1694 .f = cmd_config_speed_all_parsed,
1696 .help_str = "port config all speed "
1697 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1700 (void *)&cmd_config_speed_all_port,
1701 (void *)&cmd_config_speed_all_keyword,
1702 (void *)&cmd_config_speed_all_all,
1703 (void *)&cmd_config_speed_all_item1,
1704 (void *)&cmd_config_speed_all_value1,
1705 (void *)&cmd_config_speed_all_item2,
1706 (void *)&cmd_config_speed_all_value2,
1711 /* *** configure speed for specific port *** */
1712 struct cmd_config_speed_specific {
1713 cmdline_fixed_string_t port;
1714 cmdline_fixed_string_t keyword;
1716 cmdline_fixed_string_t item1;
1717 cmdline_fixed_string_t item2;
1718 cmdline_fixed_string_t value1;
1719 cmdline_fixed_string_t value2;
1723 cmd_config_speed_specific_parsed(void *parsed_result,
1724 __rte_unused struct cmdline *cl,
1725 __rte_unused void *data)
1727 struct cmd_config_speed_specific *res = parsed_result;
1728 uint32_t link_speed;
1730 if (!all_ports_stopped()) {
1731 printf("Please stop all ports first\n");
1735 if (port_id_is_invalid(res->id, ENABLED_WARN))
1738 if (parse_and_check_speed_duplex(res->value1, res->value2,
1742 ports[res->id].dev_conf.link_speeds = link_speed;
1744 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1748 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1749 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1751 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1752 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1754 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1755 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1756 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1757 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1759 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1760 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1761 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1762 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1763 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1765 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1766 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1769 cmdline_parse_inst_t cmd_config_speed_specific = {
1770 .f = cmd_config_speed_specific_parsed,
1772 .help_str = "port config <port_id> speed "
1773 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1776 (void *)&cmd_config_speed_specific_port,
1777 (void *)&cmd_config_speed_specific_keyword,
1778 (void *)&cmd_config_speed_specific_id,
1779 (void *)&cmd_config_speed_specific_item1,
1780 (void *)&cmd_config_speed_specific_value1,
1781 (void *)&cmd_config_speed_specific_item2,
1782 (void *)&cmd_config_speed_specific_value2,
1787 /* *** configure loopback for all ports *** */
1788 struct cmd_config_loopback_all {
1789 cmdline_fixed_string_t port;
1790 cmdline_fixed_string_t keyword;
1791 cmdline_fixed_string_t all;
1792 cmdline_fixed_string_t item;
1797 cmd_config_loopback_all_parsed(void *parsed_result,
1798 __rte_unused struct cmdline *cl,
1799 __rte_unused void *data)
1801 struct cmd_config_loopback_all *res = parsed_result;
1804 if (!all_ports_stopped()) {
1805 printf("Please stop all ports first\n");
1809 RTE_ETH_FOREACH_DEV(pid) {
1810 ports[pid].dev_conf.lpbk_mode = res->mode;
1813 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1816 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1817 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1818 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1819 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1821 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1822 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1823 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1824 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1826 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1827 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1829 cmdline_parse_inst_t cmd_config_loopback_all = {
1830 .f = cmd_config_loopback_all_parsed,
1832 .help_str = "port config all loopback <mode>",
1834 (void *)&cmd_config_loopback_all_port,
1835 (void *)&cmd_config_loopback_all_keyword,
1836 (void *)&cmd_config_loopback_all_all,
1837 (void *)&cmd_config_loopback_all_item,
1838 (void *)&cmd_config_loopback_all_mode,
1843 /* *** configure loopback for specific port *** */
1844 struct cmd_config_loopback_specific {
1845 cmdline_fixed_string_t port;
1846 cmdline_fixed_string_t keyword;
1848 cmdline_fixed_string_t item;
1853 cmd_config_loopback_specific_parsed(void *parsed_result,
1854 __rte_unused struct cmdline *cl,
1855 __rte_unused void *data)
1857 struct cmd_config_loopback_specific *res = parsed_result;
1859 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1862 if (!port_is_stopped(res->port_id)) {
1863 printf("Please stop port %u first\n", res->port_id);
1867 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1869 cmd_reconfig_device_queue(res->port_id, 1, 1);
1873 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1874 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1876 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1877 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1879 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1880 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1882 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1883 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1885 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1886 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1889 cmdline_parse_inst_t cmd_config_loopback_specific = {
1890 .f = cmd_config_loopback_specific_parsed,
1892 .help_str = "port config <port_id> loopback <mode>",
1894 (void *)&cmd_config_loopback_specific_port,
1895 (void *)&cmd_config_loopback_specific_keyword,
1896 (void *)&cmd_config_loopback_specific_id,
1897 (void *)&cmd_config_loopback_specific_item,
1898 (void *)&cmd_config_loopback_specific_mode,
1903 /* *** configure txq/rxq, txd/rxd *** */
1904 struct cmd_config_rx_tx {
1905 cmdline_fixed_string_t port;
1906 cmdline_fixed_string_t keyword;
1907 cmdline_fixed_string_t all;
1908 cmdline_fixed_string_t name;
1913 cmd_config_rx_tx_parsed(void *parsed_result,
1914 __rte_unused struct cmdline *cl,
1915 __rte_unused void *data)
1917 struct cmd_config_rx_tx *res = parsed_result;
1919 if (!all_ports_stopped()) {
1920 printf("Please stop all ports first\n");
1923 if (!strcmp(res->name, "rxq")) {
1924 if (!res->value && !nb_txq) {
1925 printf("Warning: Either rx or tx queues should be non zero\n");
1928 if (check_nb_rxq(res->value) != 0)
1930 nb_rxq = res->value;
1932 else if (!strcmp(res->name, "txq")) {
1933 if (!res->value && !nb_rxq) {
1934 printf("Warning: Either rx or tx queues should be non zero\n");
1937 if (check_nb_txq(res->value) != 0)
1939 nb_txq = res->value;
1941 else if (!strcmp(res->name, "rxd")) {
1942 if (check_nb_rxd(res->value) != 0)
1944 nb_rxd = res->value;
1945 } else if (!strcmp(res->name, "txd")) {
1946 if (check_nb_txd(res->value) != 0)
1949 nb_txd = res->value;
1951 printf("Unknown parameter\n");
1959 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1962 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1963 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1964 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1965 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1966 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1967 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1968 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1969 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1971 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1972 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1974 cmdline_parse_inst_t cmd_config_rx_tx = {
1975 .f = cmd_config_rx_tx_parsed,
1977 .help_str = "port config all rxq|txq|rxd|txd <value>",
1979 (void *)&cmd_config_rx_tx_port,
1980 (void *)&cmd_config_rx_tx_keyword,
1981 (void *)&cmd_config_rx_tx_all,
1982 (void *)&cmd_config_rx_tx_name,
1983 (void *)&cmd_config_rx_tx_value,
1988 /* *** config max packet length *** */
1989 struct cmd_config_max_pkt_len_result {
1990 cmdline_fixed_string_t port;
1991 cmdline_fixed_string_t keyword;
1992 cmdline_fixed_string_t all;
1993 cmdline_fixed_string_t name;
1998 cmd_config_max_pkt_len_parsed(void *parsed_result,
1999 __rte_unused struct cmdline *cl,
2000 __rte_unused void *data)
2002 struct cmd_config_max_pkt_len_result *res = parsed_result;
2005 if (!all_ports_stopped()) {
2006 printf("Please stop all ports first\n");
2010 RTE_ETH_FOREACH_DEV(pid) {
2011 struct rte_port *port = &ports[pid];
2012 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
2014 if (!strcmp(res->name, "max-pkt-len")) {
2015 if (res->value < RTE_ETHER_MIN_LEN) {
2016 printf("max-pkt-len can not be less than %d\n",
2020 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2023 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2024 if (res->value > RTE_ETHER_MAX_LEN)
2025 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2027 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2028 port->dev_conf.rxmode.offloads = rx_offloads;
2030 printf("Unknown parameter\n");
2037 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2040 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2041 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2043 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2044 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2046 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2047 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2049 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2050 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2052 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2053 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2056 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2057 .f = cmd_config_max_pkt_len_parsed,
2059 .help_str = "port config all max-pkt-len <value>",
2061 (void *)&cmd_config_max_pkt_len_port,
2062 (void *)&cmd_config_max_pkt_len_keyword,
2063 (void *)&cmd_config_max_pkt_len_all,
2064 (void *)&cmd_config_max_pkt_len_name,
2065 (void *)&cmd_config_max_pkt_len_value,
2070 /* *** config max LRO aggregated packet size *** */
2071 struct cmd_config_max_lro_pkt_size_result {
2072 cmdline_fixed_string_t port;
2073 cmdline_fixed_string_t keyword;
2074 cmdline_fixed_string_t all;
2075 cmdline_fixed_string_t name;
2080 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2081 __rte_unused struct cmdline *cl,
2082 __rte_unused void *data)
2084 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2087 if (!all_ports_stopped()) {
2088 printf("Please stop all ports first\n");
2092 RTE_ETH_FOREACH_DEV(pid) {
2093 struct rte_port *port = &ports[pid];
2095 if (!strcmp(res->name, "max-lro-pkt-size")) {
2097 port->dev_conf.rxmode.max_lro_pkt_size)
2100 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2102 printf("Unknown parameter\n");
2109 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2112 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2113 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2115 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2116 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2118 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2119 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2121 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2122 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2123 name, "max-lro-pkt-size");
2124 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2125 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2128 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2129 .f = cmd_config_max_lro_pkt_size_parsed,
2131 .help_str = "port config all max-lro-pkt-size <value>",
2133 (void *)&cmd_config_max_lro_pkt_size_port,
2134 (void *)&cmd_config_max_lro_pkt_size_keyword,
2135 (void *)&cmd_config_max_lro_pkt_size_all,
2136 (void *)&cmd_config_max_lro_pkt_size_name,
2137 (void *)&cmd_config_max_lro_pkt_size_value,
2142 /* *** configure port MTU *** */
2143 struct cmd_config_mtu_result {
2144 cmdline_fixed_string_t port;
2145 cmdline_fixed_string_t keyword;
2146 cmdline_fixed_string_t mtu;
2152 cmd_config_mtu_parsed(void *parsed_result,
2153 __rte_unused struct cmdline *cl,
2154 __rte_unused void *data)
2156 struct cmd_config_mtu_result *res = parsed_result;
2158 if (res->value < RTE_ETHER_MIN_LEN) {
2159 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2162 port_mtu_set(res->port_id, res->value);
2165 cmdline_parse_token_string_t cmd_config_mtu_port =
2166 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2168 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2169 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2171 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2172 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2174 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2175 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2176 cmdline_parse_token_num_t cmd_config_mtu_value =
2177 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2179 cmdline_parse_inst_t cmd_config_mtu = {
2180 .f = cmd_config_mtu_parsed,
2182 .help_str = "port config mtu <port_id> <value>",
2184 (void *)&cmd_config_mtu_port,
2185 (void *)&cmd_config_mtu_keyword,
2186 (void *)&cmd_config_mtu_mtu,
2187 (void *)&cmd_config_mtu_port_id,
2188 (void *)&cmd_config_mtu_value,
2193 /* *** configure rx mode *** */
2194 struct cmd_config_rx_mode_flag {
2195 cmdline_fixed_string_t port;
2196 cmdline_fixed_string_t keyword;
2197 cmdline_fixed_string_t all;
2198 cmdline_fixed_string_t name;
2199 cmdline_fixed_string_t value;
2203 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2204 __rte_unused struct cmdline *cl,
2205 __rte_unused void *data)
2207 struct cmd_config_rx_mode_flag *res = parsed_result;
2209 if (!all_ports_stopped()) {
2210 printf("Please stop all ports first\n");
2214 if (!strcmp(res->name, "drop-en")) {
2215 if (!strcmp(res->value, "on"))
2217 else if (!strcmp(res->value, "off"))
2220 printf("Unknown parameter\n");
2224 printf("Unknown parameter\n");
2230 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2233 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2234 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2235 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2236 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2238 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2239 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2240 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2241 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2243 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2244 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2247 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2248 .f = cmd_config_rx_mode_flag_parsed,
2250 .help_str = "port config all drop-en on|off",
2252 (void *)&cmd_config_rx_mode_flag_port,
2253 (void *)&cmd_config_rx_mode_flag_keyword,
2254 (void *)&cmd_config_rx_mode_flag_all,
2255 (void *)&cmd_config_rx_mode_flag_name,
2256 (void *)&cmd_config_rx_mode_flag_value,
2261 /* *** configure rss *** */
2262 struct cmd_config_rss {
2263 cmdline_fixed_string_t port;
2264 cmdline_fixed_string_t keyword;
2265 cmdline_fixed_string_t all;
2266 cmdline_fixed_string_t name;
2267 cmdline_fixed_string_t value;
2271 cmd_config_rss_parsed(void *parsed_result,
2272 __rte_unused struct cmdline *cl,
2273 __rte_unused void *data)
2275 struct cmd_config_rss *res = parsed_result;
2276 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2277 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2278 int use_default = 0;
2279 int all_updated = 1;
2284 if (!strcmp(res->value, "all"))
2285 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2286 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2287 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2288 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU;
2289 else if (!strcmp(res->value, "eth"))
2290 rss_conf.rss_hf = ETH_RSS_ETH;
2291 else if (!strcmp(res->value, "vlan"))
2292 rss_conf.rss_hf = ETH_RSS_VLAN;
2293 else if (!strcmp(res->value, "ip"))
2294 rss_conf.rss_hf = ETH_RSS_IP;
2295 else if (!strcmp(res->value, "udp"))
2296 rss_conf.rss_hf = ETH_RSS_UDP;
2297 else if (!strcmp(res->value, "tcp"))
2298 rss_conf.rss_hf = ETH_RSS_TCP;
2299 else if (!strcmp(res->value, "sctp"))
2300 rss_conf.rss_hf = ETH_RSS_SCTP;
2301 else if (!strcmp(res->value, "ether"))
2302 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2303 else if (!strcmp(res->value, "port"))
2304 rss_conf.rss_hf = ETH_RSS_PORT;
2305 else if (!strcmp(res->value, "vxlan"))
2306 rss_conf.rss_hf = ETH_RSS_VXLAN;
2307 else if (!strcmp(res->value, "geneve"))
2308 rss_conf.rss_hf = ETH_RSS_GENEVE;
2309 else if (!strcmp(res->value, "nvgre"))
2310 rss_conf.rss_hf = ETH_RSS_NVGRE;
2311 else if (!strcmp(res->value, "l3-pre32"))
2312 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2313 else if (!strcmp(res->value, "l3-pre40"))
2314 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2315 else if (!strcmp(res->value, "l3-pre48"))
2316 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2317 else if (!strcmp(res->value, "l3-pre56"))
2318 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2319 else if (!strcmp(res->value, "l3-pre64"))
2320 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2321 else if (!strcmp(res->value, "l3-pre96"))
2322 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2323 else if (!strcmp(res->value, "l3-src-only"))
2324 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2325 else if (!strcmp(res->value, "l3-dst-only"))
2326 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2327 else if (!strcmp(res->value, "l4-src-only"))
2328 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2329 else if (!strcmp(res->value, "l4-dst-only"))
2330 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2331 else if (!strcmp(res->value, "l2-src-only"))
2332 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2333 else if (!strcmp(res->value, "l2-dst-only"))
2334 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2335 else if (!strcmp(res->value, "l2tpv3"))
2336 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2337 else if (!strcmp(res->value, "esp"))
2338 rss_conf.rss_hf = ETH_RSS_ESP;
2339 else if (!strcmp(res->value, "ah"))
2340 rss_conf.rss_hf = ETH_RSS_AH;
2341 else if (!strcmp(res->value, "pfcp"))
2342 rss_conf.rss_hf = ETH_RSS_PFCP;
2343 else if (!strcmp(res->value, "pppoe"))
2344 rss_conf.rss_hf = ETH_RSS_PPPOE;
2345 else if (!strcmp(res->value, "gtpu"))
2346 rss_conf.rss_hf = ETH_RSS_GTPU;
2347 else if (!strcmp(res->value, "none"))
2348 rss_conf.rss_hf = 0;
2349 else if (!strcmp(res->value, "default"))
2351 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2352 atoi(res->value) < 64)
2353 rss_conf.rss_hf = 1ULL << atoi(res->value);
2355 printf("Unknown parameter\n");
2358 rss_conf.rss_key = NULL;
2359 /* Update global configuration for RSS types. */
2360 RTE_ETH_FOREACH_DEV(i) {
2361 struct rte_eth_rss_conf local_rss_conf;
2363 ret = eth_dev_info_get_print_err(i, &dev_info);
2368 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2370 local_rss_conf = rss_conf;
2371 local_rss_conf.rss_hf = rss_conf.rss_hf &
2372 dev_info.flow_type_rss_offloads;
2373 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2374 printf("Port %u modified RSS hash function based on hardware support,"
2375 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2376 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2378 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2381 printf("Configuration of RSS hash at ethernet port %d "
2382 "failed with error (%d): %s.\n",
2383 i, -diag, strerror(-diag));
2386 if (all_updated && !use_default) {
2387 rss_hf = rss_conf.rss_hf;
2388 printf("rss_hf %#"PRIx64"\n", rss_hf);
2392 cmdline_parse_token_string_t cmd_config_rss_port =
2393 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2394 cmdline_parse_token_string_t cmd_config_rss_keyword =
2395 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2396 cmdline_parse_token_string_t cmd_config_rss_all =
2397 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2398 cmdline_parse_token_string_t cmd_config_rss_name =
2399 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2400 cmdline_parse_token_string_t cmd_config_rss_value =
2401 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2403 cmdline_parse_inst_t cmd_config_rss = {
2404 .f = cmd_config_rss_parsed,
2406 .help_str = "port config all rss "
2407 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2408 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|<flowtype_id>",
2410 (void *)&cmd_config_rss_port,
2411 (void *)&cmd_config_rss_keyword,
2412 (void *)&cmd_config_rss_all,
2413 (void *)&cmd_config_rss_name,
2414 (void *)&cmd_config_rss_value,
2419 /* *** configure rss hash key *** */
2420 struct cmd_config_rss_hash_key {
2421 cmdline_fixed_string_t port;
2422 cmdline_fixed_string_t config;
2424 cmdline_fixed_string_t rss_hash_key;
2425 cmdline_fixed_string_t rss_type;
2426 cmdline_fixed_string_t key;
2430 hexa_digit_to_value(char hexa_digit)
2432 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2433 return (uint8_t) (hexa_digit - '0');
2434 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2435 return (uint8_t) ((hexa_digit - 'a') + 10);
2436 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2437 return (uint8_t) ((hexa_digit - 'A') + 10);
2438 /* Invalid hexa digit */
2443 parse_and_check_key_hexa_digit(char *key, int idx)
2447 hexa_v = hexa_digit_to_value(key[idx]);
2449 printf("invalid key: character %c at position %d is not a "
2450 "valid hexa digit\n", key[idx], idx);
2455 cmd_config_rss_hash_key_parsed(void *parsed_result,
2456 __rte_unused struct cmdline *cl,
2457 __rte_unused void *data)
2459 struct cmd_config_rss_hash_key *res = parsed_result;
2460 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2464 struct rte_eth_dev_info dev_info;
2465 uint8_t hash_key_size;
2469 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2473 if (dev_info.hash_key_size > 0 &&
2474 dev_info.hash_key_size <= sizeof(hash_key))
2475 hash_key_size = dev_info.hash_key_size;
2477 printf("dev_info did not provide a valid hash key size\n");
2480 /* Check the length of the RSS hash key */
2481 key_len = strlen(res->key);
2482 if (key_len != (hash_key_size * 2)) {
2483 printf("key length: %d invalid - key must be a string of %d"
2484 " hexa-decimal numbers\n",
2485 (int) key_len, hash_key_size * 2);
2488 /* Translate RSS hash key into binary representation */
2489 for (i = 0; i < hash_key_size; i++) {
2490 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2493 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2496 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2498 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2502 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2503 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2504 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2505 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2507 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2508 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2509 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2510 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2511 rss_hash_key, "rss-hash-key");
2512 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2513 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2514 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2515 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2516 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2517 "ipv6-tcp-ex#ipv6-udp-ex#"
2518 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2519 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2520 "l2tpv3#esp#ah#pfcp#pppoe#gtpu");
2521 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2522 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2524 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2525 .f = cmd_config_rss_hash_key_parsed,
2527 .help_str = "port config <port_id> rss-hash-key "
2528 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2529 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2530 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2531 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2532 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2533 "l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2534 "<string of hex digits (variable length, NIC dependent)>",
2536 (void *)&cmd_config_rss_hash_key_port,
2537 (void *)&cmd_config_rss_hash_key_config,
2538 (void *)&cmd_config_rss_hash_key_port_id,
2539 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2540 (void *)&cmd_config_rss_hash_key_rss_type,
2541 (void *)&cmd_config_rss_hash_key_value,
2546 /* *** configure port rxq/txq ring size *** */
2547 struct cmd_config_rxtx_ring_size {
2548 cmdline_fixed_string_t port;
2549 cmdline_fixed_string_t config;
2551 cmdline_fixed_string_t rxtxq;
2553 cmdline_fixed_string_t rsize;
2558 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2559 __rte_unused struct cmdline *cl,
2560 __rte_unused void *data)
2562 struct cmd_config_rxtx_ring_size *res = parsed_result;
2563 struct rte_port *port;
2566 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2569 if (res->portid == (portid_t)RTE_PORT_ALL) {
2570 printf("Invalid port id\n");
2574 port = &ports[res->portid];
2576 if (!strcmp(res->rxtxq, "rxq"))
2578 else if (!strcmp(res->rxtxq, "txq"))
2581 printf("Unknown parameter\n");
2585 if (isrx && rx_queue_id_is_invalid(res->qid))
2587 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2590 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2591 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2597 port->nb_rx_desc[res->qid] = res->size;
2599 port->nb_tx_desc[res->qid] = res->size;
2601 cmd_reconfig_device_queue(res->portid, 0, 1);
2604 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2605 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2607 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2608 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2610 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2611 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2613 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2614 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2616 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2617 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2619 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2620 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2621 rsize, "ring_size");
2622 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2623 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2626 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2627 .f = cmd_config_rxtx_ring_size_parsed,
2629 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2631 (void *)&cmd_config_rxtx_ring_size_port,
2632 (void *)&cmd_config_rxtx_ring_size_config,
2633 (void *)&cmd_config_rxtx_ring_size_portid,
2634 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2635 (void *)&cmd_config_rxtx_ring_size_qid,
2636 (void *)&cmd_config_rxtx_ring_size_rsize,
2637 (void *)&cmd_config_rxtx_ring_size_size,
2642 /* *** configure port rxq/txq start/stop *** */
2643 struct cmd_config_rxtx_queue {
2644 cmdline_fixed_string_t port;
2646 cmdline_fixed_string_t rxtxq;
2648 cmdline_fixed_string_t opname;
2652 cmd_config_rxtx_queue_parsed(void *parsed_result,
2653 __rte_unused struct cmdline *cl,
2654 __rte_unused void *data)
2656 struct cmd_config_rxtx_queue *res = parsed_result;
2661 if (test_done == 0) {
2662 printf("Please stop forwarding first\n");
2666 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2669 if (port_is_started(res->portid) != 1) {
2670 printf("Please start port %u first\n", res->portid);
2674 if (!strcmp(res->rxtxq, "rxq"))
2676 else if (!strcmp(res->rxtxq, "txq"))
2679 printf("Unknown parameter\n");
2683 if (isrx && rx_queue_id_is_invalid(res->qid))
2685 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2688 if (!strcmp(res->opname, "start"))
2690 else if (!strcmp(res->opname, "stop"))
2693 printf("Unknown parameter\n");
2697 if (isstart && isrx)
2698 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2699 else if (!isstart && isrx)
2700 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2701 else if (isstart && !isrx)
2702 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2704 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2706 if (ret == -ENOTSUP)
2707 printf("Function not supported in PMD driver\n");
2710 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2711 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2712 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2713 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2714 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2715 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2716 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2717 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2718 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2719 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2722 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2723 .f = cmd_config_rxtx_queue_parsed,
2725 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2727 (void *)&cmd_config_rxtx_queue_port,
2728 (void *)&cmd_config_rxtx_queue_portid,
2729 (void *)&cmd_config_rxtx_queue_rxtxq,
2730 (void *)&cmd_config_rxtx_queue_qid,
2731 (void *)&cmd_config_rxtx_queue_opname,
2736 /* *** configure port rxq/txq deferred start on/off *** */
2737 struct cmd_config_deferred_start_rxtx_queue {
2738 cmdline_fixed_string_t port;
2740 cmdline_fixed_string_t rxtxq;
2742 cmdline_fixed_string_t opname;
2743 cmdline_fixed_string_t state;
2747 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2748 __rte_unused struct cmdline *cl,
2749 __rte_unused void *data)
2751 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2752 struct rte_port *port;
2755 uint8_t needreconfig = 0;
2757 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2760 if (port_is_started(res->port_id) != 0) {
2761 printf("Please stop port %u first\n", res->port_id);
2765 port = &ports[res->port_id];
2767 isrx = !strcmp(res->rxtxq, "rxq");
2769 if (isrx && rx_queue_id_is_invalid(res->qid))
2771 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2774 ison = !strcmp(res->state, "on");
2776 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2777 port->rx_conf[res->qid].rx_deferred_start = ison;
2779 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2780 port->tx_conf[res->qid].tx_deferred_start = ison;
2785 cmd_reconfig_device_queue(res->port_id, 0, 1);
2788 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2789 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2791 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2792 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2794 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2795 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2797 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2798 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2800 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2801 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2802 opname, "deferred_start");
2803 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2804 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2807 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2808 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2810 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2812 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2813 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2814 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2815 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2816 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2817 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2822 /* *** configure port rxq/txq setup *** */
2823 struct cmd_setup_rxtx_queue {
2824 cmdline_fixed_string_t port;
2826 cmdline_fixed_string_t rxtxq;
2828 cmdline_fixed_string_t setup;
2831 /* Common CLI fields for queue setup */
2832 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2833 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2834 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2835 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2836 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2837 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2838 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2839 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2840 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2841 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2844 cmd_setup_rxtx_queue_parsed(
2845 void *parsed_result,
2846 __rte_unused struct cmdline *cl,
2847 __rte_unused void *data)
2849 struct cmd_setup_rxtx_queue *res = parsed_result;
2850 struct rte_port *port;
2851 struct rte_mempool *mp;
2852 unsigned int socket_id;
2856 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2859 if (res->portid == (portid_t)RTE_PORT_ALL) {
2860 printf("Invalid port id\n");
2864 if (!strcmp(res->rxtxq, "rxq"))
2866 else if (!strcmp(res->rxtxq, "txq"))
2869 printf("Unknown parameter\n");
2873 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2874 printf("Invalid rx queue\n");
2876 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2877 printf("Invalid tx queue\n");
2881 port = &ports[res->portid];
2883 socket_id = rxring_numa[res->portid];
2884 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2885 socket_id = port->socket_id;
2887 mp = mbuf_pool_find(socket_id);
2889 printf("Failed to setup RX queue: "
2890 "No mempool allocation"
2891 " on the socket %d\n",
2892 rxring_numa[res->portid]);
2895 ret = rte_eth_rx_queue_setup(res->portid,
2897 port->nb_rx_desc[res->qid],
2899 &port->rx_conf[res->qid],
2902 printf("Failed to setup RX queue\n");
2904 socket_id = txring_numa[res->portid];
2905 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2906 socket_id = port->socket_id;
2908 ret = rte_eth_tx_queue_setup(res->portid,
2910 port->nb_tx_desc[res->qid],
2912 &port->tx_conf[res->qid]);
2914 printf("Failed to setup TX queue\n");
2918 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2919 .f = cmd_setup_rxtx_queue_parsed,
2921 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2923 (void *)&cmd_setup_rxtx_queue_port,
2924 (void *)&cmd_setup_rxtx_queue_portid,
2925 (void *)&cmd_setup_rxtx_queue_rxtxq,
2926 (void *)&cmd_setup_rxtx_queue_qid,
2927 (void *)&cmd_setup_rxtx_queue_setup,
2933 /* *** Configure RSS RETA *** */
2934 struct cmd_config_rss_reta {
2935 cmdline_fixed_string_t port;
2936 cmdline_fixed_string_t keyword;
2938 cmdline_fixed_string_t name;
2939 cmdline_fixed_string_t list_name;
2940 cmdline_fixed_string_t list_of_items;
2944 parse_reta_config(const char *str,
2945 struct rte_eth_rss_reta_entry64 *reta_conf,
2946 uint16_t nb_entries)
2950 uint16_t hash_index, idx, shift;
2953 const char *p, *p0 = str;
2960 unsigned long int_fld[_NUM_FLD];
2961 char *str_fld[_NUM_FLD];
2963 while ((p = strchr(p0,'(')) != NULL) {
2965 if((p0 = strchr(p,')')) == NULL)
2969 if(size >= sizeof(s))
2972 snprintf(s, sizeof(s), "%.*s", size, p);
2973 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2975 for (i = 0; i < _NUM_FLD; i++) {
2977 int_fld[i] = strtoul(str_fld[i], &end, 0);
2978 if (errno != 0 || end == str_fld[i] ||
2983 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2984 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2986 if (hash_index >= nb_entries) {
2987 printf("Invalid RETA hash index=%d\n", hash_index);
2991 idx = hash_index / RTE_RETA_GROUP_SIZE;
2992 shift = hash_index % RTE_RETA_GROUP_SIZE;
2993 reta_conf[idx].mask |= (1ULL << shift);
2994 reta_conf[idx].reta[shift] = nb_queue;
3001 cmd_set_rss_reta_parsed(void *parsed_result,
3002 __rte_unused struct cmdline *cl,
3003 __rte_unused void *data)
3006 struct rte_eth_dev_info dev_info;
3007 struct rte_eth_rss_reta_entry64 reta_conf[8];
3008 struct cmd_config_rss_reta *res = parsed_result;
3010 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3014 if (dev_info.reta_size == 0) {
3015 printf("Redirection table size is 0 which is "
3016 "invalid for RSS\n");
3019 printf("The reta size of port %d is %u\n",
3020 res->port_id, dev_info.reta_size);
3021 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3022 printf("Currently do not support more than %u entries of "
3023 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3027 memset(reta_conf, 0, sizeof(reta_conf));
3028 if (!strcmp(res->list_name, "reta")) {
3029 if (parse_reta_config(res->list_of_items, reta_conf,
3030 dev_info.reta_size)) {
3031 printf("Invalid RSS Redirection Table "
3032 "config entered\n");
3035 ret = rte_eth_dev_rss_reta_update(res->port_id,
3036 reta_conf, dev_info.reta_size);
3038 printf("Bad redirection table parameter, "
3039 "return code = %d \n", ret);
3043 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3044 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3045 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3046 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3047 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3048 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3049 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3050 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3051 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3052 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3053 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3054 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3056 cmdline_parse_inst_t cmd_config_rss_reta = {
3057 .f = cmd_set_rss_reta_parsed,
3059 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3061 (void *)&cmd_config_rss_reta_port,
3062 (void *)&cmd_config_rss_reta_keyword,
3063 (void *)&cmd_config_rss_reta_port_id,
3064 (void *)&cmd_config_rss_reta_name,
3065 (void *)&cmd_config_rss_reta_list_name,
3066 (void *)&cmd_config_rss_reta_list_of_items,
3071 /* *** SHOW PORT RETA INFO *** */
3072 struct cmd_showport_reta {
3073 cmdline_fixed_string_t show;
3074 cmdline_fixed_string_t port;
3076 cmdline_fixed_string_t rss;
3077 cmdline_fixed_string_t reta;
3079 cmdline_fixed_string_t list_of_items;
3083 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3084 uint16_t nb_entries,
3088 const char *p, *p0 = str;
3093 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3094 RTE_RETA_GROUP_SIZE;
3097 p = strchr(p0, '(');
3101 p0 = strchr(p, ')');
3105 if (size >= sizeof(s)) {
3106 printf("The string size exceeds the internal buffer size\n");
3109 snprintf(s, sizeof(s), "%.*s", size, p);
3110 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3111 if (ret <= 0 || ret != num) {
3112 printf("The bits of masks do not match the number of "
3113 "reta entries: %u\n", num);
3116 for (i = 0; i < ret; i++)
3117 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3123 cmd_showport_reta_parsed(void *parsed_result,
3124 __rte_unused struct cmdline *cl,
3125 __rte_unused void *data)
3127 struct cmd_showport_reta *res = parsed_result;
3128 struct rte_eth_rss_reta_entry64 reta_conf[8];
3129 struct rte_eth_dev_info dev_info;
3130 uint16_t max_reta_size;
3133 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3137 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3138 if (res->size == 0 || res->size > max_reta_size) {
3139 printf("Invalid redirection table size: %u (1-%u)\n",
3140 res->size, max_reta_size);
3144 memset(reta_conf, 0, sizeof(reta_conf));
3145 if (showport_parse_reta_config(reta_conf, res->size,
3146 res->list_of_items) < 0) {
3147 printf("Invalid string: %s for reta masks\n",
3148 res->list_of_items);
3151 port_rss_reta_info(res->port_id, reta_conf, res->size);
3154 cmdline_parse_token_string_t cmd_showport_reta_show =
3155 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3156 cmdline_parse_token_string_t cmd_showport_reta_port =
3157 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3158 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3159 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3160 cmdline_parse_token_string_t cmd_showport_reta_rss =
3161 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3162 cmdline_parse_token_string_t cmd_showport_reta_reta =
3163 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3164 cmdline_parse_token_num_t cmd_showport_reta_size =
3165 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3166 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3167 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3168 list_of_items, NULL);
3170 cmdline_parse_inst_t cmd_showport_reta = {
3171 .f = cmd_showport_reta_parsed,
3173 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3175 (void *)&cmd_showport_reta_show,
3176 (void *)&cmd_showport_reta_port,
3177 (void *)&cmd_showport_reta_port_id,
3178 (void *)&cmd_showport_reta_rss,
3179 (void *)&cmd_showport_reta_reta,
3180 (void *)&cmd_showport_reta_size,
3181 (void *)&cmd_showport_reta_list_of_items,
3186 /* *** Show RSS hash configuration *** */
3187 struct cmd_showport_rss_hash {
3188 cmdline_fixed_string_t show;
3189 cmdline_fixed_string_t port;
3191 cmdline_fixed_string_t rss_hash;
3192 cmdline_fixed_string_t rss_type;
3193 cmdline_fixed_string_t key; /* optional argument */
3196 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3197 __rte_unused struct cmdline *cl,
3200 struct cmd_showport_rss_hash *res = parsed_result;
3202 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3205 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3206 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3207 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3208 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3209 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3210 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3211 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3212 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3214 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3215 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3217 cmdline_parse_inst_t cmd_showport_rss_hash = {
3218 .f = cmd_showport_rss_hash_parsed,
3220 .help_str = "show port <port_id> rss-hash",
3222 (void *)&cmd_showport_rss_hash_show,
3223 (void *)&cmd_showport_rss_hash_port,
3224 (void *)&cmd_showport_rss_hash_port_id,
3225 (void *)&cmd_showport_rss_hash_rss_hash,
3230 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3231 .f = cmd_showport_rss_hash_parsed,
3233 .help_str = "show port <port_id> rss-hash key",
3235 (void *)&cmd_showport_rss_hash_show,
3236 (void *)&cmd_showport_rss_hash_port,
3237 (void *)&cmd_showport_rss_hash_port_id,
3238 (void *)&cmd_showport_rss_hash_rss_hash,
3239 (void *)&cmd_showport_rss_hash_rss_key,
3244 /* *** Configure DCB *** */
3245 struct cmd_config_dcb {
3246 cmdline_fixed_string_t port;
3247 cmdline_fixed_string_t config;
3249 cmdline_fixed_string_t dcb;
3250 cmdline_fixed_string_t vt;
3251 cmdline_fixed_string_t vt_en;
3253 cmdline_fixed_string_t pfc;
3254 cmdline_fixed_string_t pfc_en;
3258 cmd_config_dcb_parsed(void *parsed_result,
3259 __rte_unused struct cmdline *cl,
3260 __rte_unused void *data)
3262 struct cmd_config_dcb *res = parsed_result;
3263 portid_t port_id = res->port_id;
3264 struct rte_port *port;
3268 port = &ports[port_id];
3269 /** Check if the port is not started **/
3270 if (port->port_status != RTE_PORT_STOPPED) {
3271 printf("Please stop port %d first\n", port_id);
3275 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3276 printf("The invalid number of traffic class,"
3277 " only 4 or 8 allowed.\n");
3281 if (nb_fwd_lcores < res->num_tcs) {
3282 printf("nb_cores shouldn't be less than number of TCs.\n");
3285 if (!strncmp(res->pfc_en, "on", 2))
3290 /* DCB in VT mode */
3291 if (!strncmp(res->vt_en, "on", 2))
3292 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3293 (enum rte_eth_nb_tcs)res->num_tcs,
3296 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3297 (enum rte_eth_nb_tcs)res->num_tcs,
3302 printf("Cannot initialize network ports.\n");
3306 cmd_reconfig_device_queue(port_id, 1, 1);
3309 cmdline_parse_token_string_t cmd_config_dcb_port =
3310 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3311 cmdline_parse_token_string_t cmd_config_dcb_config =
3312 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3313 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3314 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3315 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3316 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3317 cmdline_parse_token_string_t cmd_config_dcb_vt =
3318 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3319 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3320 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3321 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3322 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3323 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3324 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3325 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3326 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3328 cmdline_parse_inst_t cmd_config_dcb = {
3329 .f = cmd_config_dcb_parsed,
3331 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3333 (void *)&cmd_config_dcb_port,
3334 (void *)&cmd_config_dcb_config,
3335 (void *)&cmd_config_dcb_port_id,
3336 (void *)&cmd_config_dcb_dcb,
3337 (void *)&cmd_config_dcb_vt,
3338 (void *)&cmd_config_dcb_vt_en,
3339 (void *)&cmd_config_dcb_num_tcs,
3340 (void *)&cmd_config_dcb_pfc,
3341 (void *)&cmd_config_dcb_pfc_en,
3346 /* *** configure number of packets per burst *** */
3347 struct cmd_config_burst {
3348 cmdline_fixed_string_t port;
3349 cmdline_fixed_string_t keyword;
3350 cmdline_fixed_string_t all;
3351 cmdline_fixed_string_t name;
3356 cmd_config_burst_parsed(void *parsed_result,
3357 __rte_unused struct cmdline *cl,
3358 __rte_unused void *data)
3360 struct cmd_config_burst *res = parsed_result;
3361 struct rte_eth_dev_info dev_info;
3362 uint16_t rec_nb_pkts;
3365 if (!all_ports_stopped()) {
3366 printf("Please stop all ports first\n");
3370 if (!strcmp(res->name, "burst")) {
3371 if (res->value == 0) {
3372 /* If user gives a value of zero, query the PMD for
3373 * its recommended Rx burst size. Testpmd uses a single
3374 * size for all ports, so assume all ports are the same
3375 * NIC model and use the values from Port 0.
3377 ret = eth_dev_info_get_print_err(0, &dev_info);
3381 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3383 if (rec_nb_pkts == 0) {
3384 printf("PMD does not recommend a burst size.\n"
3385 "User provided value must be between"
3386 " 1 and %d\n", MAX_PKT_BURST);
3388 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3389 printf("PMD recommended burst size of %d"
3390 " exceeds maximum value of %d\n",
3391 rec_nb_pkts, MAX_PKT_BURST);
3394 printf("Using PMD-provided burst value of %d\n",
3396 nb_pkt_per_burst = rec_nb_pkts;
3397 } else if (res->value > MAX_PKT_BURST) {
3398 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3401 nb_pkt_per_burst = res->value;
3403 printf("Unknown parameter\n");
3409 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3412 cmdline_parse_token_string_t cmd_config_burst_port =
3413 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3414 cmdline_parse_token_string_t cmd_config_burst_keyword =
3415 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3416 cmdline_parse_token_string_t cmd_config_burst_all =
3417 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3418 cmdline_parse_token_string_t cmd_config_burst_name =
3419 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3420 cmdline_parse_token_num_t cmd_config_burst_value =
3421 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3423 cmdline_parse_inst_t cmd_config_burst = {
3424 .f = cmd_config_burst_parsed,
3426 .help_str = "port config all burst <value>",
3428 (void *)&cmd_config_burst_port,
3429 (void *)&cmd_config_burst_keyword,
3430 (void *)&cmd_config_burst_all,
3431 (void *)&cmd_config_burst_name,
3432 (void *)&cmd_config_burst_value,
3437 /* *** configure rx/tx queues *** */
3438 struct cmd_config_thresh {
3439 cmdline_fixed_string_t port;
3440 cmdline_fixed_string_t keyword;
3441 cmdline_fixed_string_t all;
3442 cmdline_fixed_string_t name;
3447 cmd_config_thresh_parsed(void *parsed_result,
3448 __rte_unused struct cmdline *cl,
3449 __rte_unused void *data)
3451 struct cmd_config_thresh *res = parsed_result;
3453 if (!all_ports_stopped()) {
3454 printf("Please stop all ports first\n");
3458 if (!strcmp(res->name, "txpt"))
3459 tx_pthresh = res->value;
3460 else if(!strcmp(res->name, "txht"))
3461 tx_hthresh = res->value;
3462 else if(!strcmp(res->name, "txwt"))
3463 tx_wthresh = res->value;
3464 else if(!strcmp(res->name, "rxpt"))
3465 rx_pthresh = res->value;
3466 else if(!strcmp(res->name, "rxht"))
3467 rx_hthresh = res->value;
3468 else if(!strcmp(res->name, "rxwt"))
3469 rx_wthresh = res->value;
3471 printf("Unknown parameter\n");
3477 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3480 cmdline_parse_token_string_t cmd_config_thresh_port =
3481 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3482 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3483 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3484 cmdline_parse_token_string_t cmd_config_thresh_all =
3485 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3486 cmdline_parse_token_string_t cmd_config_thresh_name =
3487 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3488 "txpt#txht#txwt#rxpt#rxht#rxwt");
3489 cmdline_parse_token_num_t cmd_config_thresh_value =
3490 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3492 cmdline_parse_inst_t cmd_config_thresh = {
3493 .f = cmd_config_thresh_parsed,
3495 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3497 (void *)&cmd_config_thresh_port,
3498 (void *)&cmd_config_thresh_keyword,
3499 (void *)&cmd_config_thresh_all,
3500 (void *)&cmd_config_thresh_name,
3501 (void *)&cmd_config_thresh_value,
3506 /* *** configure free/rs threshold *** */
3507 struct cmd_config_threshold {
3508 cmdline_fixed_string_t port;
3509 cmdline_fixed_string_t keyword;
3510 cmdline_fixed_string_t all;
3511 cmdline_fixed_string_t name;
3516 cmd_config_threshold_parsed(void *parsed_result,
3517 __rte_unused struct cmdline *cl,
3518 __rte_unused void *data)
3520 struct cmd_config_threshold *res = parsed_result;
3522 if (!all_ports_stopped()) {
3523 printf("Please stop all ports first\n");
3527 if (!strcmp(res->name, "txfreet"))
3528 tx_free_thresh = res->value;
3529 else if (!strcmp(res->name, "txrst"))
3530 tx_rs_thresh = res->value;
3531 else if (!strcmp(res->name, "rxfreet"))
3532 rx_free_thresh = res->value;
3534 printf("Unknown parameter\n");
3540 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3543 cmdline_parse_token_string_t cmd_config_threshold_port =
3544 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3545 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3546 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3548 cmdline_parse_token_string_t cmd_config_threshold_all =
3549 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3550 cmdline_parse_token_string_t cmd_config_threshold_name =
3551 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3552 "txfreet#txrst#rxfreet");
3553 cmdline_parse_token_num_t cmd_config_threshold_value =
3554 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3556 cmdline_parse_inst_t cmd_config_threshold = {
3557 .f = cmd_config_threshold_parsed,
3559 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3561 (void *)&cmd_config_threshold_port,
3562 (void *)&cmd_config_threshold_keyword,
3563 (void *)&cmd_config_threshold_all,
3564 (void *)&cmd_config_threshold_name,
3565 (void *)&cmd_config_threshold_value,
3571 struct cmd_stop_result {
3572 cmdline_fixed_string_t stop;
3575 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3576 __rte_unused struct cmdline *cl,
3577 __rte_unused void *data)
3579 stop_packet_forwarding();
3582 cmdline_parse_token_string_t cmd_stop_stop =
3583 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3585 cmdline_parse_inst_t cmd_stop = {
3586 .f = cmd_stop_parsed,
3588 .help_str = "stop: Stop packet forwarding",
3590 (void *)&cmd_stop_stop,
3595 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3598 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3599 unsigned int *parsed_items, int check_unique_values)
3601 unsigned int nb_item;
3609 * First parse all items in the list and store their value.
3614 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3616 if ((c >= '0') && (c <= '9')) {
3617 value = (unsigned int) (value * 10 + (c - '0'));
3622 printf("character %c is not a decimal digit\n", c);
3626 printf("No valid value before comma\n");
3629 if (nb_item < max_items) {
3630 parsed_items[nb_item] = value;
3636 if (nb_item >= max_items) {
3637 printf("Number of %s = %u > %u (maximum items)\n",
3638 item_name, nb_item + 1, max_items);
3641 parsed_items[nb_item++] = value;
3642 if (! check_unique_values)
3646 * Then, check that all values in the list are differents.
3647 * No optimization here...
3649 for (i = 0; i < nb_item; i++) {
3650 for (j = i + 1; j < nb_item; j++) {
3651 if (parsed_items[j] == parsed_items[i]) {
3652 printf("duplicated %s %u at index %u and %u\n",
3653 item_name, parsed_items[i], i, j);
3661 struct cmd_set_list_result {
3662 cmdline_fixed_string_t cmd_keyword;
3663 cmdline_fixed_string_t list_name;
3664 cmdline_fixed_string_t list_of_items;
3667 static void cmd_set_list_parsed(void *parsed_result,
3668 __rte_unused struct cmdline *cl,
3669 __rte_unused void *data)
3671 struct cmd_set_list_result *res;
3673 unsigned int lcorelist[RTE_MAX_LCORE];
3674 unsigned int portlist[RTE_MAX_ETHPORTS];
3676 unsigned int nb_item;
3678 if (test_done == 0) {
3679 printf("Please stop forwarding first\n");
3683 res = parsed_result;
3684 if (!strcmp(res->list_name, "corelist")) {
3685 nb_item = parse_item_list(res->list_of_items, "core",
3687 parsed_items.lcorelist, 1);
3689 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3694 if (!strcmp(res->list_name, "portlist")) {
3695 nb_item = parse_item_list(res->list_of_items, "port",
3697 parsed_items.portlist, 1);
3699 set_fwd_ports_list(parsed_items.portlist, nb_item);
3705 cmdline_parse_token_string_t cmd_set_list_keyword =
3706 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3708 cmdline_parse_token_string_t cmd_set_list_name =
3709 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3710 "corelist#portlist");
3711 cmdline_parse_token_string_t cmd_set_list_of_items =
3712 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3715 cmdline_parse_inst_t cmd_set_fwd_list = {
3716 .f = cmd_set_list_parsed,
3718 .help_str = "set corelist|portlist <list0[,list1]*>",
3720 (void *)&cmd_set_list_keyword,
3721 (void *)&cmd_set_list_name,
3722 (void *)&cmd_set_list_of_items,
3727 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3729 struct cmd_setmask_result {
3730 cmdline_fixed_string_t set;
3731 cmdline_fixed_string_t mask;
3735 static void cmd_set_mask_parsed(void *parsed_result,
3736 __rte_unused struct cmdline *cl,
3737 __rte_unused void *data)
3739 struct cmd_setmask_result *res = parsed_result;
3741 if (test_done == 0) {
3742 printf("Please stop forwarding first\n");
3745 if (!strcmp(res->mask, "coremask")) {
3746 set_fwd_lcores_mask(res->hexavalue);
3748 } else if (!strcmp(res->mask, "portmask")) {
3749 set_fwd_ports_mask(res->hexavalue);
3754 cmdline_parse_token_string_t cmd_setmask_set =
3755 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3756 cmdline_parse_token_string_t cmd_setmask_mask =
3757 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3758 "coremask#portmask");
3759 cmdline_parse_token_num_t cmd_setmask_value =
3760 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3762 cmdline_parse_inst_t cmd_set_fwd_mask = {
3763 .f = cmd_set_mask_parsed,
3765 .help_str = "set coremask|portmask <hexadecimal value>",
3767 (void *)&cmd_setmask_set,
3768 (void *)&cmd_setmask_mask,
3769 (void *)&cmd_setmask_value,
3775 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3777 struct cmd_set_result {
3778 cmdline_fixed_string_t set;
3779 cmdline_fixed_string_t what;
3783 static void cmd_set_parsed(void *parsed_result,
3784 __rte_unused struct cmdline *cl,
3785 __rte_unused void *data)
3787 struct cmd_set_result *res = parsed_result;
3788 if (!strcmp(res->what, "nbport")) {
3789 set_fwd_ports_number(res->value);
3791 } else if (!strcmp(res->what, "nbcore")) {
3792 set_fwd_lcores_number(res->value);
3794 } else if (!strcmp(res->what, "burst"))
3795 set_nb_pkt_per_burst(res->value);
3796 else if (!strcmp(res->what, "verbose"))
3797 set_verbose_level(res->value);
3800 cmdline_parse_token_string_t cmd_set_set =
3801 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3802 cmdline_parse_token_string_t cmd_set_what =
3803 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3804 "nbport#nbcore#burst#verbose");
3805 cmdline_parse_token_num_t cmd_set_value =
3806 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3808 cmdline_parse_inst_t cmd_set_numbers = {
3809 .f = cmd_set_parsed,
3811 .help_str = "set nbport|nbcore|burst|verbose <value>",
3813 (void *)&cmd_set_set,
3814 (void *)&cmd_set_what,
3815 (void *)&cmd_set_value,
3820 /* *** SET LOG LEVEL CONFIGURATION *** */
3822 struct cmd_set_log_result {
3823 cmdline_fixed_string_t set;
3824 cmdline_fixed_string_t log;
3825 cmdline_fixed_string_t type;
3830 cmd_set_log_parsed(void *parsed_result,
3831 __rte_unused struct cmdline *cl,
3832 __rte_unused void *data)
3834 struct cmd_set_log_result *res;
3837 res = parsed_result;
3838 if (!strcmp(res->type, "global"))
3839 rte_log_set_global_level(res->level);
3841 ret = rte_log_set_level_regexp(res->type, res->level);
3843 printf("Unable to set log level\n");
3847 cmdline_parse_token_string_t cmd_set_log_set =
3848 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3849 cmdline_parse_token_string_t cmd_set_log_log =
3850 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3851 cmdline_parse_token_string_t cmd_set_log_type =
3852 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3853 cmdline_parse_token_num_t cmd_set_log_level =
3854 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3856 cmdline_parse_inst_t cmd_set_log = {
3857 .f = cmd_set_log_parsed,
3859 .help_str = "set log global|<type> <level>",
3861 (void *)&cmd_set_log_set,
3862 (void *)&cmd_set_log_log,
3863 (void *)&cmd_set_log_type,
3864 (void *)&cmd_set_log_level,
3869 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3871 struct cmd_set_txpkts_result {
3872 cmdline_fixed_string_t cmd_keyword;
3873 cmdline_fixed_string_t txpkts;
3874 cmdline_fixed_string_t seg_lengths;
3878 cmd_set_txpkts_parsed(void *parsed_result,
3879 __rte_unused struct cmdline *cl,
3880 __rte_unused void *data)
3882 struct cmd_set_txpkts_result *res;
3883 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3884 unsigned int nb_segs;
3886 res = parsed_result;
3887 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3888 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3890 set_tx_pkt_segments(seg_lengths, nb_segs);
3893 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3894 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3895 cmd_keyword, "set");
3896 cmdline_parse_token_string_t cmd_set_txpkts_name =
3897 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3899 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3900 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3903 cmdline_parse_inst_t cmd_set_txpkts = {
3904 .f = cmd_set_txpkts_parsed,
3906 .help_str = "set txpkts <len0[,len1]*>",
3908 (void *)&cmd_set_txpkts_keyword,
3909 (void *)&cmd_set_txpkts_name,
3910 (void *)&cmd_set_txpkts_lengths,
3915 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3917 struct cmd_set_txsplit_result {
3918 cmdline_fixed_string_t cmd_keyword;
3919 cmdline_fixed_string_t txsplit;
3920 cmdline_fixed_string_t mode;
3924 cmd_set_txsplit_parsed(void *parsed_result,
3925 __rte_unused struct cmdline *cl,
3926 __rte_unused void *data)
3928 struct cmd_set_txsplit_result *res;
3930 res = parsed_result;
3931 set_tx_pkt_split(res->mode);
3934 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3935 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3936 cmd_keyword, "set");
3937 cmdline_parse_token_string_t cmd_set_txsplit_name =
3938 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3939 txsplit, "txsplit");
3940 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3941 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3944 cmdline_parse_inst_t cmd_set_txsplit = {
3945 .f = cmd_set_txsplit_parsed,
3947 .help_str = "set txsplit on|off|rand",
3949 (void *)&cmd_set_txsplit_keyword,
3950 (void *)&cmd_set_txsplit_name,
3951 (void *)&cmd_set_txsplit_mode,
3956 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
3958 struct cmd_set_txtimes_result {
3959 cmdline_fixed_string_t cmd_keyword;
3960 cmdline_fixed_string_t txtimes;
3961 cmdline_fixed_string_t tx_times;
3965 cmd_set_txtimes_parsed(void *parsed_result,
3966 __rte_unused struct cmdline *cl,
3967 __rte_unused void *data)
3969 struct cmd_set_txtimes_result *res;
3970 unsigned int tx_times[2] = {0, 0};
3971 unsigned int n_times;
3973 res = parsed_result;
3974 n_times = parse_item_list(res->tx_times, "tx times",
3977 set_tx_pkt_times(tx_times);
3980 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
3981 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3982 cmd_keyword, "set");
3983 cmdline_parse_token_string_t cmd_set_txtimes_name =
3984 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3985 txtimes, "txtimes");
3986 cmdline_parse_token_string_t cmd_set_txtimes_value =
3987 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3990 cmdline_parse_inst_t cmd_set_txtimes = {
3991 .f = cmd_set_txtimes_parsed,
3993 .help_str = "set txtimes <inter_burst>,<intra_burst>",
3995 (void *)&cmd_set_txtimes_keyword,
3996 (void *)&cmd_set_txtimes_name,
3997 (void *)&cmd_set_txtimes_value,
4002 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4003 struct cmd_rx_vlan_filter_all_result {
4004 cmdline_fixed_string_t rx_vlan;
4005 cmdline_fixed_string_t what;
4006 cmdline_fixed_string_t all;
4011 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4012 __rte_unused struct cmdline *cl,
4013 __rte_unused void *data)
4015 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4017 if (!strcmp(res->what, "add"))
4018 rx_vlan_all_filter_set(res->port_id, 1);
4020 rx_vlan_all_filter_set(res->port_id, 0);
4023 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4024 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4025 rx_vlan, "rx_vlan");
4026 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4027 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4029 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4030 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4032 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4033 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4036 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4037 .f = cmd_rx_vlan_filter_all_parsed,
4039 .help_str = "rx_vlan add|rm all <port_id>: "
4040 "Add/Remove all identifiers to/from the set of VLAN "
4041 "identifiers filtered by a port",
4043 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4044 (void *)&cmd_rx_vlan_filter_all_what,
4045 (void *)&cmd_rx_vlan_filter_all_all,
4046 (void *)&cmd_rx_vlan_filter_all_portid,
4051 /* *** VLAN OFFLOAD SET ON A PORT *** */
4052 struct cmd_vlan_offload_result {
4053 cmdline_fixed_string_t vlan;
4054 cmdline_fixed_string_t set;
4055 cmdline_fixed_string_t vlan_type;
4056 cmdline_fixed_string_t what;
4057 cmdline_fixed_string_t on;
4058 cmdline_fixed_string_t port_id;
4062 cmd_vlan_offload_parsed(void *parsed_result,
4063 __rte_unused struct cmdline *cl,
4064 __rte_unused void *data)
4067 struct cmd_vlan_offload_result *res = parsed_result;
4070 portid_t port_id = 0;
4074 len = strnlen(str, STR_TOKEN_SIZE);
4076 /* Get port_id first */
4084 tmp = strtoul(str, NULL, 0);
4085 /* If port_id greater that what portid_t can represent, return */
4086 if(tmp >= RTE_MAX_ETHPORTS)
4088 port_id = (portid_t)tmp;
4090 if (!strcmp(res->on, "on"))
4095 if (!strcmp(res->what, "strip"))
4096 rx_vlan_strip_set(port_id, on);
4097 else if(!strcmp(res->what, "stripq")){
4098 uint16_t queue_id = 0;
4100 /* No queue_id, return */
4102 printf("must specify (port,queue_id)\n");
4105 tmp = strtoul(str + i + 1, NULL, 0);
4106 /* If queue_id greater that what 16-bits can represent, return */
4110 queue_id = (uint16_t)tmp;
4111 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4113 else if (!strcmp(res->what, "filter"))
4114 rx_vlan_filter_set(port_id, on);
4115 else if (!strcmp(res->what, "qinq_strip"))
4116 rx_vlan_qinq_strip_set(port_id, on);
4118 vlan_extend_set(port_id, on);
4123 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4124 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4126 cmdline_parse_token_string_t cmd_vlan_offload_set =
4127 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4129 cmdline_parse_token_string_t cmd_vlan_offload_what =
4130 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4131 what, "strip#filter#qinq_strip#extend#stripq");
4132 cmdline_parse_token_string_t cmd_vlan_offload_on =
4133 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4135 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4136 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4139 cmdline_parse_inst_t cmd_vlan_offload = {
4140 .f = cmd_vlan_offload_parsed,
4142 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4143 "<port_id[,queue_id]>: "
4144 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4146 (void *)&cmd_vlan_offload_vlan,
4147 (void *)&cmd_vlan_offload_set,
4148 (void *)&cmd_vlan_offload_what,
4149 (void *)&cmd_vlan_offload_on,
4150 (void *)&cmd_vlan_offload_portid,
4155 /* *** VLAN TPID SET ON A PORT *** */
4156 struct cmd_vlan_tpid_result {
4157 cmdline_fixed_string_t vlan;
4158 cmdline_fixed_string_t set;
4159 cmdline_fixed_string_t vlan_type;
4160 cmdline_fixed_string_t what;
4166 cmd_vlan_tpid_parsed(void *parsed_result,
4167 __rte_unused struct cmdline *cl,
4168 __rte_unused void *data)
4170 struct cmd_vlan_tpid_result *res = parsed_result;
4171 enum rte_vlan_type vlan_type;
4173 if (!strcmp(res->vlan_type, "inner"))
4174 vlan_type = ETH_VLAN_TYPE_INNER;
4175 else if (!strcmp(res->vlan_type, "outer"))
4176 vlan_type = ETH_VLAN_TYPE_OUTER;
4178 printf("Unknown vlan type\n");
4181 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4184 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4185 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4187 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4188 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4190 cmdline_parse_token_string_t cmd_vlan_type =
4191 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4192 vlan_type, "inner#outer");
4193 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4194 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4196 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4197 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4199 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4200 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4203 cmdline_parse_inst_t cmd_vlan_tpid = {
4204 .f = cmd_vlan_tpid_parsed,
4206 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4207 "Set the VLAN Ether type",
4209 (void *)&cmd_vlan_tpid_vlan,
4210 (void *)&cmd_vlan_tpid_set,
4211 (void *)&cmd_vlan_type,
4212 (void *)&cmd_vlan_tpid_what,
4213 (void *)&cmd_vlan_tpid_tpid,
4214 (void *)&cmd_vlan_tpid_portid,
4219 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4220 struct cmd_rx_vlan_filter_result {
4221 cmdline_fixed_string_t rx_vlan;
4222 cmdline_fixed_string_t what;
4228 cmd_rx_vlan_filter_parsed(void *parsed_result,
4229 __rte_unused struct cmdline *cl,
4230 __rte_unused void *data)
4232 struct cmd_rx_vlan_filter_result *res = parsed_result;
4234 if (!strcmp(res->what, "add"))
4235 rx_vft_set(res->port_id, res->vlan_id, 1);
4237 rx_vft_set(res->port_id, res->vlan_id, 0);
4240 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4241 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4242 rx_vlan, "rx_vlan");
4243 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4244 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4246 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4247 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4249 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4250 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4253 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4254 .f = cmd_rx_vlan_filter_parsed,
4256 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4257 "Add/Remove a VLAN identifier to/from the set of VLAN "
4258 "identifiers filtered by a port",
4260 (void *)&cmd_rx_vlan_filter_rx_vlan,
4261 (void *)&cmd_rx_vlan_filter_what,
4262 (void *)&cmd_rx_vlan_filter_vlanid,
4263 (void *)&cmd_rx_vlan_filter_portid,
4268 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4269 struct cmd_tx_vlan_set_result {
4270 cmdline_fixed_string_t tx_vlan;
4271 cmdline_fixed_string_t set;
4277 cmd_tx_vlan_set_parsed(void *parsed_result,
4278 __rte_unused struct cmdline *cl,
4279 __rte_unused void *data)
4281 struct cmd_tx_vlan_set_result *res = parsed_result;
4283 if (!port_is_stopped(res->port_id)) {
4284 printf("Please stop port %d first\n", res->port_id);
4288 tx_vlan_set(res->port_id, res->vlan_id);
4290 cmd_reconfig_device_queue(res->port_id, 1, 1);
4293 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4294 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4295 tx_vlan, "tx_vlan");
4296 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4297 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4299 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4300 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4302 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4303 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4306 cmdline_parse_inst_t cmd_tx_vlan_set = {
4307 .f = cmd_tx_vlan_set_parsed,
4309 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4310 "Enable hardware insertion of a single VLAN header "
4311 "with a given TAG Identifier in packets sent on a port",
4313 (void *)&cmd_tx_vlan_set_tx_vlan,
4314 (void *)&cmd_tx_vlan_set_set,
4315 (void *)&cmd_tx_vlan_set_portid,
4316 (void *)&cmd_tx_vlan_set_vlanid,
4321 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4322 struct cmd_tx_vlan_set_qinq_result {
4323 cmdline_fixed_string_t tx_vlan;
4324 cmdline_fixed_string_t set;
4327 uint16_t vlan_id_outer;
4331 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4332 __rte_unused struct cmdline *cl,
4333 __rte_unused void *data)
4335 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4337 if (!port_is_stopped(res->port_id)) {
4338 printf("Please stop port %d first\n", res->port_id);
4342 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4344 cmd_reconfig_device_queue(res->port_id, 1, 1);
4347 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4348 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4349 tx_vlan, "tx_vlan");
4350 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4351 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4353 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4354 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4356 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4357 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4359 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4360 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4361 vlan_id_outer, UINT16);
4363 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4364 .f = cmd_tx_vlan_set_qinq_parsed,
4366 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4367 "Enable hardware insertion of double VLAN header "
4368 "with given TAG Identifiers in packets sent on a port",
4370 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4371 (void *)&cmd_tx_vlan_set_qinq_set,
4372 (void *)&cmd_tx_vlan_set_qinq_portid,
4373 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4374 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4379 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4380 struct cmd_tx_vlan_set_pvid_result {
4381 cmdline_fixed_string_t tx_vlan;
4382 cmdline_fixed_string_t set;
4383 cmdline_fixed_string_t pvid;
4386 cmdline_fixed_string_t mode;
4390 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4391 __rte_unused struct cmdline *cl,
4392 __rte_unused void *data)
4394 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4396 if (strcmp(res->mode, "on") == 0)
4397 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4399 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4402 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4403 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4404 tx_vlan, "tx_vlan");
4405 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4406 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4408 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4409 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4411 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4412 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4414 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4415 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4417 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4418 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4421 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4422 .f = cmd_tx_vlan_set_pvid_parsed,
4424 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4426 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4427 (void *)&cmd_tx_vlan_set_pvid_set,
4428 (void *)&cmd_tx_vlan_set_pvid_pvid,
4429 (void *)&cmd_tx_vlan_set_pvid_port_id,
4430 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4431 (void *)&cmd_tx_vlan_set_pvid_mode,
4436 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4437 struct cmd_tx_vlan_reset_result {
4438 cmdline_fixed_string_t tx_vlan;
4439 cmdline_fixed_string_t reset;
4444 cmd_tx_vlan_reset_parsed(void *parsed_result,
4445 __rte_unused struct cmdline *cl,
4446 __rte_unused void *data)
4448 struct cmd_tx_vlan_reset_result *res = parsed_result;
4450 if (!port_is_stopped(res->port_id)) {
4451 printf("Please stop port %d first\n", res->port_id);
4455 tx_vlan_reset(res->port_id);
4457 cmd_reconfig_device_queue(res->port_id, 1, 1);
4460 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4461 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4462 tx_vlan, "tx_vlan");
4463 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4464 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4466 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4467 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4470 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4471 .f = cmd_tx_vlan_reset_parsed,
4473 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4474 "VLAN header in packets sent on a port",
4476 (void *)&cmd_tx_vlan_reset_tx_vlan,
4477 (void *)&cmd_tx_vlan_reset_reset,
4478 (void *)&cmd_tx_vlan_reset_portid,
4484 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4485 struct cmd_csum_result {
4486 cmdline_fixed_string_t csum;
4487 cmdline_fixed_string_t mode;
4488 cmdline_fixed_string_t proto;
4489 cmdline_fixed_string_t hwsw;
4494 csum_show(int port_id)
4496 struct rte_eth_dev_info dev_info;
4497 uint64_t tx_offloads;
4500 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4501 printf("Parse tunnel is %s\n",
4502 (ports[port_id].parse_tunnel) ? "on" : "off");
4503 printf("IP checksum offload is %s\n",
4504 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4505 printf("UDP checksum offload is %s\n",
4506 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4507 printf("TCP checksum offload is %s\n",
4508 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4509 printf("SCTP checksum offload is %s\n",
4510 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4511 printf("Outer-Ip checksum offload is %s\n",
4512 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4513 printf("Outer-Udp checksum offload is %s\n",
4514 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4516 /* display warnings if configuration is not supported by the NIC */
4517 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4521 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4522 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4523 printf("Warning: hardware IP checksum enabled but not "
4524 "supported by port %d\n", port_id);
4526 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4527 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4528 printf("Warning: hardware UDP checksum enabled but not "
4529 "supported by port %d\n", port_id);
4531 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4532 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4533 printf("Warning: hardware TCP checksum enabled but not "
4534 "supported by port %d\n", port_id);
4536 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4537 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4538 printf("Warning: hardware SCTP checksum enabled but not "
4539 "supported by port %d\n", port_id);
4541 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4542 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4543 printf("Warning: hardware outer IP checksum enabled but not "
4544 "supported by port %d\n", port_id);
4546 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4547 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4549 printf("Warning: hardware outer UDP checksum enabled but not "
4550 "supported by port %d\n", port_id);
4555 cmd_config_queue_tx_offloads(struct rte_port *port)
4559 /* Apply queue tx offloads configuration */
4560 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4561 port->tx_conf[k].offloads =
4562 port->dev_conf.txmode.offloads;
4566 cmd_csum_parsed(void *parsed_result,
4567 __rte_unused struct cmdline *cl,
4568 __rte_unused void *data)
4570 struct cmd_csum_result *res = parsed_result;
4572 uint64_t csum_offloads = 0;
4573 struct rte_eth_dev_info dev_info;
4576 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4577 printf("invalid port %d\n", res->port_id);
4580 if (!port_is_stopped(res->port_id)) {
4581 printf("Please stop port %d first\n", res->port_id);
4585 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4589 if (!strcmp(res->mode, "set")) {
4591 if (!strcmp(res->hwsw, "hw"))
4594 if (!strcmp(res->proto, "ip")) {
4595 if (hw == 0 || (dev_info.tx_offload_capa &
4596 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4597 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4599 printf("IP checksum offload is not supported "
4600 "by port %u\n", res->port_id);
4602 } else if (!strcmp(res->proto, "udp")) {
4603 if (hw == 0 || (dev_info.tx_offload_capa &
4604 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4605 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4607 printf("UDP checksum offload is not supported "
4608 "by port %u\n", res->port_id);
4610 } else if (!strcmp(res->proto, "tcp")) {
4611 if (hw == 0 || (dev_info.tx_offload_capa &
4612 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4613 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4615 printf("TCP checksum offload is not supported "
4616 "by port %u\n", res->port_id);
4618 } else if (!strcmp(res->proto, "sctp")) {
4619 if (hw == 0 || (dev_info.tx_offload_capa &
4620 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4621 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4623 printf("SCTP checksum offload is not supported "
4624 "by port %u\n", res->port_id);
4626 } else if (!strcmp(res->proto, "outer-ip")) {
4627 if (hw == 0 || (dev_info.tx_offload_capa &
4628 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4630 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4632 printf("Outer IP checksum offload is not "
4633 "supported by port %u\n", res->port_id);
4635 } else if (!strcmp(res->proto, "outer-udp")) {
4636 if (hw == 0 || (dev_info.tx_offload_capa &
4637 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4639 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4641 printf("Outer UDP checksum offload is not "
4642 "supported by port %u\n", res->port_id);
4647 ports[res->port_id].dev_conf.txmode.offloads |=
4650 ports[res->port_id].dev_conf.txmode.offloads &=
4653 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4655 csum_show(res->port_id);
4657 cmd_reconfig_device_queue(res->port_id, 1, 1);
4660 cmdline_parse_token_string_t cmd_csum_csum =
4661 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4663 cmdline_parse_token_string_t cmd_csum_mode =
4664 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4666 cmdline_parse_token_string_t cmd_csum_proto =
4667 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4668 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4669 cmdline_parse_token_string_t cmd_csum_hwsw =
4670 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4672 cmdline_parse_token_num_t cmd_csum_portid =
4673 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4676 cmdline_parse_inst_t cmd_csum_set = {
4677 .f = cmd_csum_parsed,
4679 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4680 "Enable/Disable hardware calculation of L3/L4 checksum when "
4681 "using csum forward engine",
4683 (void *)&cmd_csum_csum,
4684 (void *)&cmd_csum_mode,
4685 (void *)&cmd_csum_proto,
4686 (void *)&cmd_csum_hwsw,
4687 (void *)&cmd_csum_portid,
4692 cmdline_parse_token_string_t cmd_csum_mode_show =
4693 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4696 cmdline_parse_inst_t cmd_csum_show = {
4697 .f = cmd_csum_parsed,
4699 .help_str = "csum show <port_id>: Show checksum offload configuration",
4701 (void *)&cmd_csum_csum,
4702 (void *)&cmd_csum_mode_show,
4703 (void *)&cmd_csum_portid,
4708 /* Enable/disable tunnel parsing */
4709 struct cmd_csum_tunnel_result {
4710 cmdline_fixed_string_t csum;
4711 cmdline_fixed_string_t parse;
4712 cmdline_fixed_string_t onoff;
4717 cmd_csum_tunnel_parsed(void *parsed_result,
4718 __rte_unused struct cmdline *cl,
4719 __rte_unused void *data)
4721 struct cmd_csum_tunnel_result *res = parsed_result;
4723 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4726 if (!strcmp(res->onoff, "on"))
4727 ports[res->port_id].parse_tunnel = 1;
4729 ports[res->port_id].parse_tunnel = 0;
4731 csum_show(res->port_id);
4734 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4735 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4737 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4738 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4739 parse, "parse-tunnel");
4740 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4741 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4743 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4744 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4747 cmdline_parse_inst_t cmd_csum_tunnel = {
4748 .f = cmd_csum_tunnel_parsed,
4750 .help_str = "csum parse-tunnel on|off <port_id>: "
4751 "Enable/Disable parsing of tunnels for csum engine",
4753 (void *)&cmd_csum_tunnel_csum,
4754 (void *)&cmd_csum_tunnel_parse,
4755 (void *)&cmd_csum_tunnel_onoff,
4756 (void *)&cmd_csum_tunnel_portid,
4761 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4762 struct cmd_tso_set_result {
4763 cmdline_fixed_string_t tso;
4764 cmdline_fixed_string_t mode;
4770 cmd_tso_set_parsed(void *parsed_result,
4771 __rte_unused struct cmdline *cl,
4772 __rte_unused void *data)
4774 struct cmd_tso_set_result *res = parsed_result;
4775 struct rte_eth_dev_info dev_info;
4778 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4780 if (!port_is_stopped(res->port_id)) {
4781 printf("Please stop port %d first\n", res->port_id);
4785 if (!strcmp(res->mode, "set"))
4786 ports[res->port_id].tso_segsz = res->tso_segsz;
4788 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4792 if ((ports[res->port_id].tso_segsz != 0) &&
4793 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4794 printf("Error: TSO is not supported by port %d\n",
4799 if (ports[res->port_id].tso_segsz == 0) {
4800 ports[res->port_id].dev_conf.txmode.offloads &=
4801 ~DEV_TX_OFFLOAD_TCP_TSO;
4802 printf("TSO for non-tunneled packets is disabled\n");
4804 ports[res->port_id].dev_conf.txmode.offloads |=
4805 DEV_TX_OFFLOAD_TCP_TSO;
4806 printf("TSO segment size for non-tunneled packets is %d\n",
4807 ports[res->port_id].tso_segsz);
4809 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4811 /* display warnings if configuration is not supported by the NIC */
4812 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4816 if ((ports[res->port_id].tso_segsz != 0) &&
4817 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4818 printf("Warning: TSO enabled but not "
4819 "supported by port %d\n", res->port_id);
4822 cmd_reconfig_device_queue(res->port_id, 1, 1);
4825 cmdline_parse_token_string_t cmd_tso_set_tso =
4826 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4828 cmdline_parse_token_string_t cmd_tso_set_mode =
4829 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4831 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4832 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4834 cmdline_parse_token_num_t cmd_tso_set_portid =
4835 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4838 cmdline_parse_inst_t cmd_tso_set = {
4839 .f = cmd_tso_set_parsed,
4841 .help_str = "tso set <tso_segsz> <port_id>: "
4842 "Set TSO segment size of non-tunneled packets for csum engine "
4845 (void *)&cmd_tso_set_tso,
4846 (void *)&cmd_tso_set_mode,
4847 (void *)&cmd_tso_set_tso_segsz,
4848 (void *)&cmd_tso_set_portid,
4853 cmdline_parse_token_string_t cmd_tso_show_mode =
4854 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4858 cmdline_parse_inst_t cmd_tso_show = {
4859 .f = cmd_tso_set_parsed,
4861 .help_str = "tso show <port_id>: "
4862 "Show TSO segment size of non-tunneled packets for csum engine",
4864 (void *)&cmd_tso_set_tso,
4865 (void *)&cmd_tso_show_mode,
4866 (void *)&cmd_tso_set_portid,
4871 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4872 struct cmd_tunnel_tso_set_result {
4873 cmdline_fixed_string_t tso;
4874 cmdline_fixed_string_t mode;
4879 static struct rte_eth_dev_info
4880 check_tunnel_tso_nic_support(portid_t port_id)
4882 struct rte_eth_dev_info dev_info;
4884 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4887 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4888 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4889 "not enabled for port %d\n", port_id);
4890 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4891 printf("Warning: GRE TUNNEL TSO not supported therefore "
4892 "not enabled for port %d\n", port_id);
4893 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4894 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4895 "not enabled for port %d\n", port_id);
4896 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4897 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4898 "not enabled for port %d\n", port_id);
4899 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4900 printf("Warning: IP TUNNEL TSO not supported therefore "
4901 "not enabled for port %d\n", port_id);
4902 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4903 printf("Warning: UDP TUNNEL TSO not supported therefore "
4904 "not enabled for port %d\n", port_id);
4909 cmd_tunnel_tso_set_parsed(void *parsed_result,
4910 __rte_unused struct cmdline *cl,
4911 __rte_unused void *data)
4913 struct cmd_tunnel_tso_set_result *res = parsed_result;
4914 struct rte_eth_dev_info dev_info;
4916 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4918 if (!port_is_stopped(res->port_id)) {
4919 printf("Please stop port %d first\n", res->port_id);
4923 if (!strcmp(res->mode, "set"))
4924 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4926 dev_info = check_tunnel_tso_nic_support(res->port_id);
4927 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4928 ports[res->port_id].dev_conf.txmode.offloads &=
4929 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4930 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4931 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4932 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4933 DEV_TX_OFFLOAD_IP_TNL_TSO |
4934 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4935 printf("TSO for tunneled packets is disabled\n");
4937 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4938 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4939 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4940 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4941 DEV_TX_OFFLOAD_IP_TNL_TSO |
4942 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4944 ports[res->port_id].dev_conf.txmode.offloads |=
4945 (tso_offloads & dev_info.tx_offload_capa);
4946 printf("TSO segment size for tunneled packets is %d\n",
4947 ports[res->port_id].tunnel_tso_segsz);
4949 /* Below conditions are needed to make it work:
4950 * (1) tunnel TSO is supported by the NIC;
4951 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4953 * (3) for tunneled pkts with outer L3 of IPv4,
4954 * "csum set outer-ip" must be set to hw, because after tso,
4955 * total_len of outer IP header is changed, and the checksum
4956 * of outer IP header calculated by sw should be wrong; that
4957 * is not necessary for IPv6 tunneled pkts because there's no
4958 * checksum in IP header anymore.
4961 if (!ports[res->port_id].parse_tunnel)
4962 printf("Warning: csum parse_tunnel must be set "
4963 "so that tunneled packets are recognized\n");
4964 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4965 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4966 printf("Warning: csum set outer-ip must be set to hw "
4967 "if outer L3 is IPv4; not necessary for IPv6\n");
4970 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4971 cmd_reconfig_device_queue(res->port_id, 1, 1);
4974 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4975 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4977 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4978 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4980 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4981 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4983 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4984 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4987 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4988 .f = cmd_tunnel_tso_set_parsed,
4990 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4991 "Set TSO segment size of tunneled packets for csum engine "
4994 (void *)&cmd_tunnel_tso_set_tso,
4995 (void *)&cmd_tunnel_tso_set_mode,
4996 (void *)&cmd_tunnel_tso_set_tso_segsz,
4997 (void *)&cmd_tunnel_tso_set_portid,
5002 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5003 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5007 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5008 .f = cmd_tunnel_tso_set_parsed,
5010 .help_str = "tunnel_tso show <port_id> "
5011 "Show TSO segment size of tunneled packets for csum engine",
5013 (void *)&cmd_tunnel_tso_set_tso,
5014 (void *)&cmd_tunnel_tso_show_mode,
5015 (void *)&cmd_tunnel_tso_set_portid,
5020 /* *** SET GRO FOR A PORT *** */
5021 struct cmd_gro_enable_result {
5022 cmdline_fixed_string_t cmd_set;
5023 cmdline_fixed_string_t cmd_port;
5024 cmdline_fixed_string_t cmd_keyword;
5025 cmdline_fixed_string_t cmd_onoff;
5030 cmd_gro_enable_parsed(void *parsed_result,
5031 __rte_unused struct cmdline *cl,
5032 __rte_unused void *data)
5034 struct cmd_gro_enable_result *res;
5036 res = parsed_result;
5037 if (!strcmp(res->cmd_keyword, "gro"))
5038 setup_gro(res->cmd_onoff, res->cmd_pid);
5041 cmdline_parse_token_string_t cmd_gro_enable_set =
5042 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5044 cmdline_parse_token_string_t cmd_gro_enable_port =
5045 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5046 cmd_keyword, "port");
5047 cmdline_parse_token_num_t cmd_gro_enable_pid =
5048 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5050 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5051 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5052 cmd_keyword, "gro");
5053 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5054 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5055 cmd_onoff, "on#off");
5057 cmdline_parse_inst_t cmd_gro_enable = {
5058 .f = cmd_gro_enable_parsed,
5060 .help_str = "set port <port_id> gro on|off",
5062 (void *)&cmd_gro_enable_set,
5063 (void *)&cmd_gro_enable_port,
5064 (void *)&cmd_gro_enable_pid,
5065 (void *)&cmd_gro_enable_keyword,
5066 (void *)&cmd_gro_enable_onoff,
5071 /* *** DISPLAY GRO CONFIGURATION *** */
5072 struct cmd_gro_show_result {
5073 cmdline_fixed_string_t cmd_show;
5074 cmdline_fixed_string_t cmd_port;
5075 cmdline_fixed_string_t cmd_keyword;
5080 cmd_gro_show_parsed(void *parsed_result,
5081 __rte_unused struct cmdline *cl,
5082 __rte_unused void *data)
5084 struct cmd_gro_show_result *res;
5086 res = parsed_result;
5087 if (!strcmp(res->cmd_keyword, "gro"))
5088 show_gro(res->cmd_pid);
5091 cmdline_parse_token_string_t cmd_gro_show_show =
5092 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5094 cmdline_parse_token_string_t cmd_gro_show_port =
5095 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5097 cmdline_parse_token_num_t cmd_gro_show_pid =
5098 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5100 cmdline_parse_token_string_t cmd_gro_show_keyword =
5101 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5102 cmd_keyword, "gro");
5104 cmdline_parse_inst_t cmd_gro_show = {
5105 .f = cmd_gro_show_parsed,
5107 .help_str = "show port <port_id> gro",
5109 (void *)&cmd_gro_show_show,
5110 (void *)&cmd_gro_show_port,
5111 (void *)&cmd_gro_show_pid,
5112 (void *)&cmd_gro_show_keyword,
5117 /* *** SET FLUSH CYCLES FOR GRO *** */
5118 struct cmd_gro_flush_result {
5119 cmdline_fixed_string_t cmd_set;
5120 cmdline_fixed_string_t cmd_keyword;
5121 cmdline_fixed_string_t cmd_flush;
5126 cmd_gro_flush_parsed(void *parsed_result,
5127 __rte_unused struct cmdline *cl,
5128 __rte_unused void *data)
5130 struct cmd_gro_flush_result *res;
5132 res = parsed_result;
5133 if ((!strcmp(res->cmd_keyword, "gro")) &&
5134 (!strcmp(res->cmd_flush, "flush")))
5135 setup_gro_flush_cycles(res->cmd_cycles);
5138 cmdline_parse_token_string_t cmd_gro_flush_set =
5139 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5141 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5142 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5143 cmd_keyword, "gro");
5144 cmdline_parse_token_string_t cmd_gro_flush_flush =
5145 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5146 cmd_flush, "flush");
5147 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5148 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5151 cmdline_parse_inst_t cmd_gro_flush = {
5152 .f = cmd_gro_flush_parsed,
5154 .help_str = "set gro flush <cycles>",
5156 (void *)&cmd_gro_flush_set,
5157 (void *)&cmd_gro_flush_keyword,
5158 (void *)&cmd_gro_flush_flush,
5159 (void *)&cmd_gro_flush_cycles,
5164 /* *** ENABLE/DISABLE GSO *** */
5165 struct cmd_gso_enable_result {
5166 cmdline_fixed_string_t cmd_set;
5167 cmdline_fixed_string_t cmd_port;
5168 cmdline_fixed_string_t cmd_keyword;
5169 cmdline_fixed_string_t cmd_mode;
5174 cmd_gso_enable_parsed(void *parsed_result,
5175 __rte_unused struct cmdline *cl,
5176 __rte_unused void *data)
5178 struct cmd_gso_enable_result *res;
5180 res = parsed_result;
5181 if (!strcmp(res->cmd_keyword, "gso"))
5182 setup_gso(res->cmd_mode, res->cmd_pid);
5185 cmdline_parse_token_string_t cmd_gso_enable_set =
5186 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5188 cmdline_parse_token_string_t cmd_gso_enable_port =
5189 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5191 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5192 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5193 cmd_keyword, "gso");
5194 cmdline_parse_token_string_t cmd_gso_enable_mode =
5195 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5196 cmd_mode, "on#off");
5197 cmdline_parse_token_num_t cmd_gso_enable_pid =
5198 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5201 cmdline_parse_inst_t cmd_gso_enable = {
5202 .f = cmd_gso_enable_parsed,
5204 .help_str = "set port <port_id> gso on|off",
5206 (void *)&cmd_gso_enable_set,
5207 (void *)&cmd_gso_enable_port,
5208 (void *)&cmd_gso_enable_pid,
5209 (void *)&cmd_gso_enable_keyword,
5210 (void *)&cmd_gso_enable_mode,
5215 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5216 struct cmd_gso_size_result {
5217 cmdline_fixed_string_t cmd_set;
5218 cmdline_fixed_string_t cmd_keyword;
5219 cmdline_fixed_string_t cmd_segsz;
5224 cmd_gso_size_parsed(void *parsed_result,
5225 __rte_unused struct cmdline *cl,
5226 __rte_unused void *data)
5228 struct cmd_gso_size_result *res = parsed_result;
5230 if (test_done == 0) {
5231 printf("Before setting GSO segsz, please first"
5232 " stop forwarding\n");
5236 if (!strcmp(res->cmd_keyword, "gso") &&
5237 !strcmp(res->cmd_segsz, "segsz")) {
5238 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5239 printf("gso_size should be larger than %zu."
5240 " Please input a legal value\n",
5241 RTE_GSO_SEG_SIZE_MIN);
5243 gso_max_segment_size = res->cmd_size;
5247 cmdline_parse_token_string_t cmd_gso_size_set =
5248 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5250 cmdline_parse_token_string_t cmd_gso_size_keyword =
5251 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5252 cmd_keyword, "gso");
5253 cmdline_parse_token_string_t cmd_gso_size_segsz =
5254 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5255 cmd_segsz, "segsz");
5256 cmdline_parse_token_num_t cmd_gso_size_size =
5257 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5260 cmdline_parse_inst_t cmd_gso_size = {
5261 .f = cmd_gso_size_parsed,
5263 .help_str = "set gso segsz <length>",
5265 (void *)&cmd_gso_size_set,
5266 (void *)&cmd_gso_size_keyword,
5267 (void *)&cmd_gso_size_segsz,
5268 (void *)&cmd_gso_size_size,
5273 /* *** SHOW GSO CONFIGURATION *** */
5274 struct cmd_gso_show_result {
5275 cmdline_fixed_string_t cmd_show;
5276 cmdline_fixed_string_t cmd_port;
5277 cmdline_fixed_string_t cmd_keyword;
5282 cmd_gso_show_parsed(void *parsed_result,
5283 __rte_unused struct cmdline *cl,
5284 __rte_unused void *data)
5286 struct cmd_gso_show_result *res = parsed_result;
5288 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5289 printf("invalid port id %u\n", res->cmd_pid);
5292 if (!strcmp(res->cmd_keyword, "gso")) {
5293 if (gso_ports[res->cmd_pid].enable) {
5294 printf("Max GSO'd packet size: %uB\n"
5295 "Supported GSO types: TCP/IPv4, "
5296 "UDP/IPv4, VxLAN with inner "
5297 "TCP/IPv4 packet, GRE with inner "
5298 "TCP/IPv4 packet\n",
5299 gso_max_segment_size);
5301 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5305 cmdline_parse_token_string_t cmd_gso_show_show =
5306 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5308 cmdline_parse_token_string_t cmd_gso_show_port =
5309 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5311 cmdline_parse_token_string_t cmd_gso_show_keyword =
5312 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5313 cmd_keyword, "gso");
5314 cmdline_parse_token_num_t cmd_gso_show_pid =
5315 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5318 cmdline_parse_inst_t cmd_gso_show = {
5319 .f = cmd_gso_show_parsed,
5321 .help_str = "show port <port_id> gso",
5323 (void *)&cmd_gso_show_show,
5324 (void *)&cmd_gso_show_port,
5325 (void *)&cmd_gso_show_pid,
5326 (void *)&cmd_gso_show_keyword,
5331 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5332 struct cmd_set_flush_rx {
5333 cmdline_fixed_string_t set;
5334 cmdline_fixed_string_t flush_rx;
5335 cmdline_fixed_string_t mode;
5339 cmd_set_flush_rx_parsed(void *parsed_result,
5340 __rte_unused struct cmdline *cl,
5341 __rte_unused void *data)
5343 struct cmd_set_flush_rx *res = parsed_result;
5344 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5347 cmdline_parse_token_string_t cmd_setflushrx_set =
5348 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5350 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5351 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5352 flush_rx, "flush_rx");
5353 cmdline_parse_token_string_t cmd_setflushrx_mode =
5354 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5358 cmdline_parse_inst_t cmd_set_flush_rx = {
5359 .f = cmd_set_flush_rx_parsed,
5360 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5363 (void *)&cmd_setflushrx_set,
5364 (void *)&cmd_setflushrx_flush_rx,
5365 (void *)&cmd_setflushrx_mode,
5370 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5371 struct cmd_set_link_check {
5372 cmdline_fixed_string_t set;
5373 cmdline_fixed_string_t link_check;
5374 cmdline_fixed_string_t mode;
5378 cmd_set_link_check_parsed(void *parsed_result,
5379 __rte_unused struct cmdline *cl,
5380 __rte_unused void *data)
5382 struct cmd_set_link_check *res = parsed_result;
5383 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5386 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5387 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5389 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5390 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5391 link_check, "link_check");
5392 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5393 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5397 cmdline_parse_inst_t cmd_set_link_check = {
5398 .f = cmd_set_link_check_parsed,
5399 .help_str = "set link_check on|off: Enable/Disable link status check "
5400 "when starting/stopping a port",
5403 (void *)&cmd_setlinkcheck_set,
5404 (void *)&cmd_setlinkcheck_link_check,
5405 (void *)&cmd_setlinkcheck_mode,
5410 /* *** SET NIC BYPASS MODE *** */
5411 struct cmd_set_bypass_mode_result {
5412 cmdline_fixed_string_t set;
5413 cmdline_fixed_string_t bypass;
5414 cmdline_fixed_string_t mode;
5415 cmdline_fixed_string_t value;
5420 cmd_set_bypass_mode_parsed(void *parsed_result,
5421 __rte_unused struct cmdline *cl,
5422 __rte_unused void *data)
5424 struct cmd_set_bypass_mode_result *res = parsed_result;
5425 portid_t port_id = res->port_id;
5426 int32_t rc = -EINVAL;
5428 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5429 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5431 if (!strcmp(res->value, "bypass"))
5432 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5433 else if (!strcmp(res->value, "isolate"))
5434 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5436 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5438 /* Set the bypass mode for the relevant port. */
5439 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5442 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5445 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5446 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5448 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5449 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5451 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5452 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5454 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5455 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5456 value, "normal#bypass#isolate");
5457 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5458 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5461 cmdline_parse_inst_t cmd_set_bypass_mode = {
5462 .f = cmd_set_bypass_mode_parsed,
5463 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5464 "Set the NIC bypass mode for port_id",
5467 (void *)&cmd_setbypass_mode_set,
5468 (void *)&cmd_setbypass_mode_bypass,
5469 (void *)&cmd_setbypass_mode_mode,
5470 (void *)&cmd_setbypass_mode_value,
5471 (void *)&cmd_setbypass_mode_port,
5476 /* *** SET NIC BYPASS EVENT *** */
5477 struct cmd_set_bypass_event_result {
5478 cmdline_fixed_string_t set;
5479 cmdline_fixed_string_t bypass;
5480 cmdline_fixed_string_t event;
5481 cmdline_fixed_string_t event_value;
5482 cmdline_fixed_string_t mode;
5483 cmdline_fixed_string_t mode_value;
5488 cmd_set_bypass_event_parsed(void *parsed_result,
5489 __rte_unused struct cmdline *cl,
5490 __rte_unused void *data)
5492 int32_t rc = -EINVAL;
5493 struct cmd_set_bypass_event_result *res = parsed_result;
5494 portid_t port_id = res->port_id;
5496 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5497 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5498 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5500 if (!strcmp(res->event_value, "timeout"))
5501 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5502 else if (!strcmp(res->event_value, "os_on"))
5503 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5504 else if (!strcmp(res->event_value, "os_off"))
5505 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5506 else if (!strcmp(res->event_value, "power_on"))
5507 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5508 else if (!strcmp(res->event_value, "power_off"))
5509 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5511 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5513 if (!strcmp(res->mode_value, "bypass"))
5514 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5515 else if (!strcmp(res->mode_value, "isolate"))
5516 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5518 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5520 /* Set the watchdog timeout. */
5521 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5524 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5525 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5529 printf("Failed to set timeout value %u "
5530 "for port %d, errto code: %d.\n",
5531 bypass_timeout, port_id, rc);
5535 /* Set the bypass event to transition to bypass mode. */
5536 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5541 printf("\t Failed to set bypass event for port = %d.\n",
5545 cmdline_parse_token_string_t cmd_setbypass_event_set =
5546 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5548 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5549 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5551 cmdline_parse_token_string_t cmd_setbypass_event_event =
5552 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5554 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5555 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5556 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5557 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5558 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5560 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5561 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5562 mode_value, "normal#bypass#isolate");
5563 cmdline_parse_token_num_t cmd_setbypass_event_port =
5564 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5567 cmdline_parse_inst_t cmd_set_bypass_event = {
5568 .f = cmd_set_bypass_event_parsed,
5569 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5570 "power_off mode normal|bypass|isolate <port_id>: "
5571 "Set the NIC bypass event mode for port_id",
5574 (void *)&cmd_setbypass_event_set,
5575 (void *)&cmd_setbypass_event_bypass,
5576 (void *)&cmd_setbypass_event_event,
5577 (void *)&cmd_setbypass_event_event_value,
5578 (void *)&cmd_setbypass_event_mode,
5579 (void *)&cmd_setbypass_event_mode_value,
5580 (void *)&cmd_setbypass_event_port,
5586 /* *** SET NIC BYPASS TIMEOUT *** */
5587 struct cmd_set_bypass_timeout_result {
5588 cmdline_fixed_string_t set;
5589 cmdline_fixed_string_t bypass;
5590 cmdline_fixed_string_t timeout;
5591 cmdline_fixed_string_t value;
5595 cmd_set_bypass_timeout_parsed(void *parsed_result,
5596 __rte_unused struct cmdline *cl,
5597 __rte_unused void *data)
5599 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5601 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5602 if (!strcmp(res->value, "1.5"))
5603 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5604 else if (!strcmp(res->value, "2"))
5605 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5606 else if (!strcmp(res->value, "3"))
5607 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5608 else if (!strcmp(res->value, "4"))
5609 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5610 else if (!strcmp(res->value, "8"))
5611 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5612 else if (!strcmp(res->value, "16"))
5613 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5614 else if (!strcmp(res->value, "32"))
5615 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5617 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5621 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5622 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5624 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5625 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5627 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5628 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5629 timeout, "timeout");
5630 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5631 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5632 value, "0#1.5#2#3#4#8#16#32");
5634 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5635 .f = cmd_set_bypass_timeout_parsed,
5636 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5637 "Set the NIC bypass watchdog timeout in seconds",
5640 (void *)&cmd_setbypass_timeout_set,
5641 (void *)&cmd_setbypass_timeout_bypass,
5642 (void *)&cmd_setbypass_timeout_timeout,
5643 (void *)&cmd_setbypass_timeout_value,
5648 /* *** SHOW NIC BYPASS MODE *** */
5649 struct cmd_show_bypass_config_result {
5650 cmdline_fixed_string_t show;
5651 cmdline_fixed_string_t bypass;
5652 cmdline_fixed_string_t config;
5657 cmd_show_bypass_config_parsed(void *parsed_result,
5658 __rte_unused struct cmdline *cl,
5659 __rte_unused void *data)
5661 struct cmd_show_bypass_config_result *res = parsed_result;
5662 portid_t port_id = res->port_id;
5664 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5665 uint32_t event_mode;
5666 uint32_t bypass_mode;
5667 uint32_t timeout = bypass_timeout;
5670 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5671 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5672 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5673 {"UNKNOWN", "normal", "bypass", "isolate"};
5674 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5682 /* Display the bypass mode.*/
5683 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5684 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5688 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5689 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5691 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5694 /* Display the bypass timeout.*/
5695 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5696 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5698 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5700 /* Display the bypass events and associated modes. */
5701 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5703 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5704 printf("\tFailed to get bypass mode for event = %s\n",
5707 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5708 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5710 printf("\tbypass event: %-16s = %s\n", events[i],
5716 printf("\tFailed to get bypass configuration for port = %d\n",
5720 cmdline_parse_token_string_t cmd_showbypass_config_show =
5721 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5723 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5724 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5726 cmdline_parse_token_string_t cmd_showbypass_config_config =
5727 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5729 cmdline_parse_token_num_t cmd_showbypass_config_port =
5730 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5733 cmdline_parse_inst_t cmd_show_bypass_config = {
5734 .f = cmd_show_bypass_config_parsed,
5735 .help_str = "show bypass config <port_id>: "
5736 "Show the NIC bypass config for port_id",
5739 (void *)&cmd_showbypass_config_show,
5740 (void *)&cmd_showbypass_config_bypass,
5741 (void *)&cmd_showbypass_config_config,
5742 (void *)&cmd_showbypass_config_port,
5747 #ifdef RTE_LIBRTE_PMD_BOND
5748 /* *** SET BONDING MODE *** */
5749 struct cmd_set_bonding_mode_result {
5750 cmdline_fixed_string_t set;
5751 cmdline_fixed_string_t bonding;
5752 cmdline_fixed_string_t mode;
5757 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5758 __rte_unused struct cmdline *cl,
5759 __rte_unused void *data)
5761 struct cmd_set_bonding_mode_result *res = parsed_result;
5762 portid_t port_id = res->port_id;
5764 /* Set the bonding mode for the relevant port. */
5765 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5766 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5769 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5770 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5772 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5773 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5774 bonding, "bonding");
5775 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5776 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5778 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5779 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5781 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5782 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5785 cmdline_parse_inst_t cmd_set_bonding_mode = {
5786 .f = cmd_set_bonding_mode_parsed,
5787 .help_str = "set bonding mode <mode_value> <port_id>: "
5788 "Set the bonding mode for port_id",
5791 (void *) &cmd_setbonding_mode_set,
5792 (void *) &cmd_setbonding_mode_bonding,
5793 (void *) &cmd_setbonding_mode_mode,
5794 (void *) &cmd_setbonding_mode_value,
5795 (void *) &cmd_setbonding_mode_port,
5800 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5801 struct cmd_set_bonding_lacp_dedicated_queues_result {
5802 cmdline_fixed_string_t set;
5803 cmdline_fixed_string_t bonding;
5804 cmdline_fixed_string_t lacp;
5805 cmdline_fixed_string_t dedicated_queues;
5807 cmdline_fixed_string_t mode;
5810 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5811 __rte_unused struct cmdline *cl,
5812 __rte_unused void *data)
5814 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5815 portid_t port_id = res->port_id;
5816 struct rte_port *port;
5818 port = &ports[port_id];
5820 /** Check if the port is not started **/
5821 if (port->port_status != RTE_PORT_STOPPED) {
5822 printf("Please stop port %d first\n", port_id);
5826 if (!strcmp(res->mode, "enable")) {
5827 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5828 printf("Dedicate queues for LACP control packets"
5831 printf("Enabling dedicate queues for LACP control "
5832 "packets on port %d failed\n", port_id);
5833 } else if (!strcmp(res->mode, "disable")) {
5834 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5835 printf("Dedicated queues for LACP control packets "
5838 printf("Disabling dedicated queues for LACP control "
5839 "traffic on port %d failed\n", port_id);
5843 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5844 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5846 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5847 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5848 bonding, "bonding");
5849 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5850 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5852 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5853 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5854 dedicated_queues, "dedicated_queues");
5855 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5856 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5858 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5859 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5860 mode, "enable#disable");
5862 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5863 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5864 .help_str = "set bonding lacp dedicated_queues <port_id> "
5866 "Enable/disable dedicated queues for LACP control traffic for port_id",
5869 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5870 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5871 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5872 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5873 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5874 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5879 /* *** SET BALANCE XMIT POLICY *** */
5880 struct cmd_set_bonding_balance_xmit_policy_result {
5881 cmdline_fixed_string_t set;
5882 cmdline_fixed_string_t bonding;
5883 cmdline_fixed_string_t balance_xmit_policy;
5885 cmdline_fixed_string_t policy;
5888 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5889 __rte_unused struct cmdline *cl,
5890 __rte_unused void *data)
5892 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5893 portid_t port_id = res->port_id;
5896 if (!strcmp(res->policy, "l2")) {
5897 policy = BALANCE_XMIT_POLICY_LAYER2;
5898 } else if (!strcmp(res->policy, "l23")) {
5899 policy = BALANCE_XMIT_POLICY_LAYER23;
5900 } else if (!strcmp(res->policy, "l34")) {
5901 policy = BALANCE_XMIT_POLICY_LAYER34;
5903 printf("\t Invalid xmit policy selection");
5907 /* Set the bonding mode for the relevant port. */
5908 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5909 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5914 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5915 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5917 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5918 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5919 bonding, "bonding");
5920 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5921 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5922 balance_xmit_policy, "balance_xmit_policy");
5923 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5924 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5926 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5927 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5928 policy, "l2#l23#l34");
5930 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5931 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5932 .help_str = "set bonding balance_xmit_policy <port_id> "
5934 "Set the bonding balance_xmit_policy for port_id",
5937 (void *)&cmd_setbonding_balance_xmit_policy_set,
5938 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5939 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5940 (void *)&cmd_setbonding_balance_xmit_policy_port,
5941 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5946 /* *** SHOW NIC BONDING CONFIGURATION *** */
5947 struct cmd_show_bonding_config_result {
5948 cmdline_fixed_string_t show;
5949 cmdline_fixed_string_t bonding;
5950 cmdline_fixed_string_t config;
5954 static void cmd_show_bonding_config_parsed(void *parsed_result,
5955 __rte_unused struct cmdline *cl,
5956 __rte_unused void *data)
5958 struct cmd_show_bonding_config_result *res = parsed_result;
5959 int bonding_mode, agg_mode;
5960 portid_t slaves[RTE_MAX_ETHPORTS];
5961 int num_slaves, num_active_slaves;
5964 portid_t port_id = res->port_id;
5966 /* Display the bonding mode.*/
5967 bonding_mode = rte_eth_bond_mode_get(port_id);
5968 if (bonding_mode < 0) {
5969 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5972 printf("\tBonding mode: %d\n", bonding_mode);
5974 if (bonding_mode == BONDING_MODE_BALANCE) {
5975 int balance_xmit_policy;
5977 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5978 if (balance_xmit_policy < 0) {
5979 printf("\tFailed to get balance xmit policy for port = %d\n",
5983 printf("\tBalance Xmit Policy: ");
5985 switch (balance_xmit_policy) {
5986 case BALANCE_XMIT_POLICY_LAYER2:
5987 printf("BALANCE_XMIT_POLICY_LAYER2");
5989 case BALANCE_XMIT_POLICY_LAYER23:
5990 printf("BALANCE_XMIT_POLICY_LAYER23");
5992 case BALANCE_XMIT_POLICY_LAYER34:
5993 printf("BALANCE_XMIT_POLICY_LAYER34");
6000 if (bonding_mode == BONDING_MODE_8023AD) {
6001 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6002 printf("\tIEEE802.3AD Aggregator Mode: ");
6005 printf("bandwidth");
6017 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6019 if (num_slaves < 0) {
6020 printf("\tFailed to get slave list for port = %d\n", port_id);
6023 if (num_slaves > 0) {
6024 printf("\tSlaves (%d): [", num_slaves);
6025 for (i = 0; i < num_slaves - 1; i++)
6026 printf("%d ", slaves[i]);
6028 printf("%d]\n", slaves[num_slaves - 1]);
6030 printf("\tSlaves: []\n");
6034 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6037 if (num_active_slaves < 0) {
6038 printf("\tFailed to get active slave list for port = %d\n", port_id);
6041 if (num_active_slaves > 0) {
6042 printf("\tActive Slaves (%d): [", num_active_slaves);
6043 for (i = 0; i < num_active_slaves - 1; i++)
6044 printf("%d ", slaves[i]);
6046 printf("%d]\n", slaves[num_active_slaves - 1]);
6049 printf("\tActive Slaves: []\n");
6053 primary_id = rte_eth_bond_primary_get(port_id);
6054 if (primary_id < 0) {
6055 printf("\tFailed to get primary slave for port = %d\n", port_id);
6058 printf("\tPrimary: [%d]\n", primary_id);
6062 cmdline_parse_token_string_t cmd_showbonding_config_show =
6063 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6065 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6066 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6067 bonding, "bonding");
6068 cmdline_parse_token_string_t cmd_showbonding_config_config =
6069 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6071 cmdline_parse_token_num_t cmd_showbonding_config_port =
6072 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6075 cmdline_parse_inst_t cmd_show_bonding_config = {
6076 .f = cmd_show_bonding_config_parsed,
6077 .help_str = "show bonding config <port_id>: "
6078 "Show the bonding config for port_id",
6081 (void *)&cmd_showbonding_config_show,
6082 (void *)&cmd_showbonding_config_bonding,
6083 (void *)&cmd_showbonding_config_config,
6084 (void *)&cmd_showbonding_config_port,
6089 /* *** SET BONDING PRIMARY *** */
6090 struct cmd_set_bonding_primary_result {
6091 cmdline_fixed_string_t set;
6092 cmdline_fixed_string_t bonding;
6093 cmdline_fixed_string_t primary;
6098 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6099 __rte_unused struct cmdline *cl,
6100 __rte_unused void *data)
6102 struct cmd_set_bonding_primary_result *res = parsed_result;
6103 portid_t master_port_id = res->port_id;
6104 portid_t slave_port_id = res->slave_id;
6106 /* Set the primary slave for a bonded device. */
6107 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6108 printf("\t Failed to set primary slave for port = %d.\n",
6115 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6116 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6118 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6119 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6120 bonding, "bonding");
6121 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6122 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6123 primary, "primary");
6124 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6125 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6127 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6128 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6131 cmdline_parse_inst_t cmd_set_bonding_primary = {
6132 .f = cmd_set_bonding_primary_parsed,
6133 .help_str = "set bonding primary <slave_id> <port_id>: "
6134 "Set the primary slave for port_id",
6137 (void *)&cmd_setbonding_primary_set,
6138 (void *)&cmd_setbonding_primary_bonding,
6139 (void *)&cmd_setbonding_primary_primary,
6140 (void *)&cmd_setbonding_primary_slave,
6141 (void *)&cmd_setbonding_primary_port,
6146 /* *** ADD SLAVE *** */
6147 struct cmd_add_bonding_slave_result {
6148 cmdline_fixed_string_t add;
6149 cmdline_fixed_string_t bonding;
6150 cmdline_fixed_string_t slave;
6155 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6156 __rte_unused struct cmdline *cl,
6157 __rte_unused void *data)
6159 struct cmd_add_bonding_slave_result *res = parsed_result;
6160 portid_t master_port_id = res->port_id;
6161 portid_t slave_port_id = res->slave_id;
6163 /* add the slave for a bonded device. */
6164 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6165 printf("\t Failed to add slave %d to master port = %d.\n",
6166 slave_port_id, master_port_id);
6170 set_port_slave_flag(slave_port_id);
6173 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6174 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6176 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6177 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6178 bonding, "bonding");
6179 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6180 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6182 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6183 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6185 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6186 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6189 cmdline_parse_inst_t cmd_add_bonding_slave = {
6190 .f = cmd_add_bonding_slave_parsed,
6191 .help_str = "add bonding slave <slave_id> <port_id>: "
6192 "Add a slave device to a bonded device",
6195 (void *)&cmd_addbonding_slave_add,
6196 (void *)&cmd_addbonding_slave_bonding,
6197 (void *)&cmd_addbonding_slave_slave,
6198 (void *)&cmd_addbonding_slave_slaveid,
6199 (void *)&cmd_addbonding_slave_port,
6204 /* *** REMOVE SLAVE *** */
6205 struct cmd_remove_bonding_slave_result {
6206 cmdline_fixed_string_t remove;
6207 cmdline_fixed_string_t bonding;
6208 cmdline_fixed_string_t slave;
6213 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6214 __rte_unused struct cmdline *cl,
6215 __rte_unused void *data)
6217 struct cmd_remove_bonding_slave_result *res = parsed_result;
6218 portid_t master_port_id = res->port_id;
6219 portid_t slave_port_id = res->slave_id;
6221 /* remove the slave from a bonded device. */
6222 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6223 printf("\t Failed to remove slave %d from master port = %d.\n",
6224 slave_port_id, master_port_id);
6228 clear_port_slave_flag(slave_port_id);
6231 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6232 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6234 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6235 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6236 bonding, "bonding");
6237 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6238 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6240 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6241 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6243 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6244 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6247 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6248 .f = cmd_remove_bonding_slave_parsed,
6249 .help_str = "remove bonding slave <slave_id> <port_id>: "
6250 "Remove a slave device from a bonded device",
6253 (void *)&cmd_removebonding_slave_remove,
6254 (void *)&cmd_removebonding_slave_bonding,
6255 (void *)&cmd_removebonding_slave_slave,
6256 (void *)&cmd_removebonding_slave_slaveid,
6257 (void *)&cmd_removebonding_slave_port,
6262 /* *** CREATE BONDED DEVICE *** */
6263 struct cmd_create_bonded_device_result {
6264 cmdline_fixed_string_t create;
6265 cmdline_fixed_string_t bonded;
6266 cmdline_fixed_string_t device;
6271 static int bond_dev_num = 0;
6273 static void cmd_create_bonded_device_parsed(void *parsed_result,
6274 __rte_unused struct cmdline *cl,
6275 __rte_unused void *data)
6277 struct cmd_create_bonded_device_result *res = parsed_result;
6278 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6282 if (test_done == 0) {
6283 printf("Please stop forwarding first\n");
6287 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6290 /* Create a new bonded device. */
6291 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6293 printf("\t Failed to create bonded device.\n");
6296 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6299 /* Update number of ports */
6300 nb_ports = rte_eth_dev_count_avail();
6301 reconfig(port_id, res->socket);
6302 ret = rte_eth_promiscuous_enable(port_id);
6304 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6305 port_id, rte_strerror(-ret));
6307 ports[port_id].need_setup = 0;
6308 ports[port_id].port_status = RTE_PORT_STOPPED;
6313 cmdline_parse_token_string_t cmd_createbonded_device_create =
6314 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6316 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6317 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6319 cmdline_parse_token_string_t cmd_createbonded_device_device =
6320 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6322 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6323 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6325 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6326 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6329 cmdline_parse_inst_t cmd_create_bonded_device = {
6330 .f = cmd_create_bonded_device_parsed,
6331 .help_str = "create bonded device <mode> <socket>: "
6332 "Create a new bonded device with specific bonding mode and socket",
6335 (void *)&cmd_createbonded_device_create,
6336 (void *)&cmd_createbonded_device_bonded,
6337 (void *)&cmd_createbonded_device_device,
6338 (void *)&cmd_createbonded_device_mode,
6339 (void *)&cmd_createbonded_device_socket,
6344 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6345 struct cmd_set_bond_mac_addr_result {
6346 cmdline_fixed_string_t set;
6347 cmdline_fixed_string_t bonding;
6348 cmdline_fixed_string_t mac_addr;
6350 struct rte_ether_addr address;
6353 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6354 __rte_unused struct cmdline *cl,
6355 __rte_unused void *data)
6357 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6360 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6363 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6365 /* check the return value and print it if is < 0 */
6367 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6370 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6371 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6372 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6373 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6375 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6376 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6378 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6379 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6381 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6382 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6384 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6385 .f = cmd_set_bond_mac_addr_parsed,
6387 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6389 (void *)&cmd_set_bond_mac_addr_set,
6390 (void *)&cmd_set_bond_mac_addr_bonding,
6391 (void *)&cmd_set_bond_mac_addr_mac,
6392 (void *)&cmd_set_bond_mac_addr_portnum,
6393 (void *)&cmd_set_bond_mac_addr_addr,
6399 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6400 struct cmd_set_bond_mon_period_result {
6401 cmdline_fixed_string_t set;
6402 cmdline_fixed_string_t bonding;
6403 cmdline_fixed_string_t mon_period;
6408 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6409 __rte_unused struct cmdline *cl,
6410 __rte_unused void *data)
6412 struct cmd_set_bond_mon_period_result *res = parsed_result;
6415 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6417 /* check the return value and print it if is < 0 */
6419 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6422 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6423 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6425 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6426 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6427 bonding, "bonding");
6428 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6429 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6430 mon_period, "mon_period");
6431 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6432 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6434 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6435 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6438 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6439 .f = cmd_set_bond_mon_period_parsed,
6441 .help_str = "set bonding mon_period <port_id> <period_ms>",
6443 (void *)&cmd_set_bond_mon_period_set,
6444 (void *)&cmd_set_bond_mon_period_bonding,
6445 (void *)&cmd_set_bond_mon_period_mon_period,
6446 (void *)&cmd_set_bond_mon_period_portnum,
6447 (void *)&cmd_set_bond_mon_period_period_ms,
6454 struct cmd_set_bonding_agg_mode_policy_result {
6455 cmdline_fixed_string_t set;
6456 cmdline_fixed_string_t bonding;
6457 cmdline_fixed_string_t agg_mode;
6459 cmdline_fixed_string_t policy;
6464 cmd_set_bonding_agg_mode(void *parsed_result,
6465 __rte_unused struct cmdline *cl,
6466 __rte_unused void *data)
6468 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6469 uint8_t policy = AGG_BANDWIDTH;
6471 if (!strcmp(res->policy, "bandwidth"))
6472 policy = AGG_BANDWIDTH;
6473 else if (!strcmp(res->policy, "stable"))
6474 policy = AGG_STABLE;
6475 else if (!strcmp(res->policy, "count"))
6478 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6482 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6483 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6485 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6486 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6487 bonding, "bonding");
6489 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6490 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6491 agg_mode, "agg_mode");
6493 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6494 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6497 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6498 TOKEN_STRING_INITIALIZER(
6499 struct cmd_set_bonding_balance_xmit_policy_result,
6500 policy, "stable#bandwidth#count");
6502 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6503 .f = cmd_set_bonding_agg_mode,
6505 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6507 (void *)&cmd_set_bonding_agg_mode_set,
6508 (void *)&cmd_set_bonding_agg_mode_bonding,
6509 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6510 (void *)&cmd_set_bonding_agg_mode_portnum,
6511 (void *)&cmd_set_bonding_agg_mode_policy_string,
6517 #endif /* RTE_LIBRTE_PMD_BOND */
6519 /* *** SET FORWARDING MODE *** */
6520 struct cmd_set_fwd_mode_result {
6521 cmdline_fixed_string_t set;
6522 cmdline_fixed_string_t fwd;
6523 cmdline_fixed_string_t mode;
6526 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6527 __rte_unused struct cmdline *cl,
6528 __rte_unused void *data)
6530 struct cmd_set_fwd_mode_result *res = parsed_result;
6533 set_pkt_forwarding_mode(res->mode);
6536 cmdline_parse_token_string_t cmd_setfwd_set =
6537 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6538 cmdline_parse_token_string_t cmd_setfwd_fwd =
6539 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6540 cmdline_parse_token_string_t cmd_setfwd_mode =
6541 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6542 "" /* defined at init */);
6544 cmdline_parse_inst_t cmd_set_fwd_mode = {
6545 .f = cmd_set_fwd_mode_parsed,
6547 .help_str = NULL, /* defined at init */
6549 (void *)&cmd_setfwd_set,
6550 (void *)&cmd_setfwd_fwd,
6551 (void *)&cmd_setfwd_mode,
6556 static void cmd_set_fwd_mode_init(void)
6559 static char token[128];
6560 static char help[256];
6561 cmdline_parse_token_string_t *token_struct;
6563 modes = list_pkt_forwarding_modes();
6564 snprintf(help, sizeof(help), "set fwd %s: "
6565 "Set packet forwarding mode", modes);
6566 cmd_set_fwd_mode.help_str = help;
6568 /* string token separator is # */
6569 for (c = token; *modes != '\0'; modes++)
6574 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6575 token_struct->string_data.str = token;
6578 /* *** SET RETRY FORWARDING MODE *** */
6579 struct cmd_set_fwd_retry_mode_result {
6580 cmdline_fixed_string_t set;
6581 cmdline_fixed_string_t fwd;
6582 cmdline_fixed_string_t mode;
6583 cmdline_fixed_string_t retry;
6586 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6587 __rte_unused struct cmdline *cl,
6588 __rte_unused void *data)
6590 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6593 set_pkt_forwarding_mode(res->mode);
6596 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6597 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6599 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6600 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6602 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6603 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6605 "" /* defined at init */);
6606 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6607 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6610 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6611 .f = cmd_set_fwd_retry_mode_parsed,
6613 .help_str = NULL, /* defined at init */
6615 (void *)&cmd_setfwd_retry_set,
6616 (void *)&cmd_setfwd_retry_fwd,
6617 (void *)&cmd_setfwd_retry_mode,
6618 (void *)&cmd_setfwd_retry_retry,
6623 static void cmd_set_fwd_retry_mode_init(void)
6626 static char token[128];
6627 static char help[256];
6628 cmdline_parse_token_string_t *token_struct;
6630 modes = list_pkt_forwarding_retry_modes();
6631 snprintf(help, sizeof(help), "set fwd %s retry: "
6632 "Set packet forwarding mode with retry", modes);
6633 cmd_set_fwd_retry_mode.help_str = help;
6635 /* string token separator is # */
6636 for (c = token; *modes != '\0'; modes++)
6641 token_struct = (cmdline_parse_token_string_t *)
6642 cmd_set_fwd_retry_mode.tokens[2];
6643 token_struct->string_data.str = token;
6646 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6647 struct cmd_set_burst_tx_retry_result {
6648 cmdline_fixed_string_t set;
6649 cmdline_fixed_string_t burst;
6650 cmdline_fixed_string_t tx;
6651 cmdline_fixed_string_t delay;
6653 cmdline_fixed_string_t retry;
6657 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6658 __rte_unused struct cmdline *cl,
6659 __rte_unused void *data)
6661 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6663 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6664 && !strcmp(res->tx, "tx")) {
6665 if (!strcmp(res->delay, "delay"))
6666 burst_tx_delay_time = res->time;
6667 if (!strcmp(res->retry, "retry"))
6668 burst_tx_retry_num = res->retry_num;
6673 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6674 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6675 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6676 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6678 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6679 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6680 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6681 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6682 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6683 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6684 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6685 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6686 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6687 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6689 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6690 .f = cmd_set_burst_tx_retry_parsed,
6691 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6693 (void *)&cmd_set_burst_tx_retry_set,
6694 (void *)&cmd_set_burst_tx_retry_burst,
6695 (void *)&cmd_set_burst_tx_retry_tx,
6696 (void *)&cmd_set_burst_tx_retry_delay,
6697 (void *)&cmd_set_burst_tx_retry_time,
6698 (void *)&cmd_set_burst_tx_retry_retry,
6699 (void *)&cmd_set_burst_tx_retry_retry_num,
6704 /* *** SET PROMISC MODE *** */
6705 struct cmd_set_promisc_mode_result {
6706 cmdline_fixed_string_t set;
6707 cmdline_fixed_string_t promisc;
6708 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6709 uint16_t port_num; /* valid if "allports" argument == 0 */
6710 cmdline_fixed_string_t mode;
6713 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6714 __rte_unused struct cmdline *cl,
6717 struct cmd_set_promisc_mode_result *res = parsed_result;
6721 if (!strcmp(res->mode, "on"))
6728 RTE_ETH_FOREACH_DEV(i)
6729 eth_set_promisc_mode(i, enable);
6731 eth_set_promisc_mode(res->port_num, enable);
6735 cmdline_parse_token_string_t cmd_setpromisc_set =
6736 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6737 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6738 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6740 cmdline_parse_token_string_t cmd_setpromisc_portall =
6741 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6743 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6744 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6746 cmdline_parse_token_string_t cmd_setpromisc_mode =
6747 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6750 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6751 .f = cmd_set_promisc_mode_parsed,
6753 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6755 (void *)&cmd_setpromisc_set,
6756 (void *)&cmd_setpromisc_promisc,
6757 (void *)&cmd_setpromisc_portall,
6758 (void *)&cmd_setpromisc_mode,
6763 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6764 .f = cmd_set_promisc_mode_parsed,
6766 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6768 (void *)&cmd_setpromisc_set,
6769 (void *)&cmd_setpromisc_promisc,
6770 (void *)&cmd_setpromisc_portnum,
6771 (void *)&cmd_setpromisc_mode,
6776 /* *** SET ALLMULTI MODE *** */
6777 struct cmd_set_allmulti_mode_result {
6778 cmdline_fixed_string_t set;
6779 cmdline_fixed_string_t allmulti;
6780 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6781 uint16_t port_num; /* valid if "allports" argument == 0 */
6782 cmdline_fixed_string_t mode;
6785 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6786 __rte_unused struct cmdline *cl,
6789 struct cmd_set_allmulti_mode_result *res = parsed_result;
6793 if (!strcmp(res->mode, "on"))
6800 RTE_ETH_FOREACH_DEV(i) {
6801 eth_set_allmulticast_mode(i, enable);
6805 eth_set_allmulticast_mode(res->port_num, enable);
6809 cmdline_parse_token_string_t cmd_setallmulti_set =
6810 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6811 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6812 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6814 cmdline_parse_token_string_t cmd_setallmulti_portall =
6815 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6817 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6818 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6820 cmdline_parse_token_string_t cmd_setallmulti_mode =
6821 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6824 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6825 .f = cmd_set_allmulti_mode_parsed,
6827 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6829 (void *)&cmd_setallmulti_set,
6830 (void *)&cmd_setallmulti_allmulti,
6831 (void *)&cmd_setallmulti_portall,
6832 (void *)&cmd_setallmulti_mode,
6837 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6838 .f = cmd_set_allmulti_mode_parsed,
6840 .help_str = "set allmulti <port_id> on|off: "
6841 "Set allmulti mode on port_id",
6843 (void *)&cmd_setallmulti_set,
6844 (void *)&cmd_setallmulti_allmulti,
6845 (void *)&cmd_setallmulti_portnum,
6846 (void *)&cmd_setallmulti_mode,
6851 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6852 struct cmd_link_flow_ctrl_set_result {
6853 cmdline_fixed_string_t set;
6854 cmdline_fixed_string_t flow_ctrl;
6855 cmdline_fixed_string_t rx;
6856 cmdline_fixed_string_t rx_lfc_mode;
6857 cmdline_fixed_string_t tx;
6858 cmdline_fixed_string_t tx_lfc_mode;
6859 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6860 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6861 cmdline_fixed_string_t autoneg_str;
6862 cmdline_fixed_string_t autoneg;
6863 cmdline_fixed_string_t hw_str;
6864 uint32_t high_water;
6865 cmdline_fixed_string_t lw_str;
6867 cmdline_fixed_string_t pt_str;
6868 uint16_t pause_time;
6869 cmdline_fixed_string_t xon_str;
6874 cmdline_parse_token_string_t cmd_lfc_set_set =
6875 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6877 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6878 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6879 flow_ctrl, "flow_ctrl");
6880 cmdline_parse_token_string_t cmd_lfc_set_rx =
6881 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6883 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6884 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6885 rx_lfc_mode, "on#off");
6886 cmdline_parse_token_string_t cmd_lfc_set_tx =
6887 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6889 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6890 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6891 tx_lfc_mode, "on#off");
6892 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6893 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6894 hw_str, "high_water");
6895 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6896 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6897 high_water, UINT32);
6898 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6899 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6900 lw_str, "low_water");
6901 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6902 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6904 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6905 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6906 pt_str, "pause_time");
6907 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6908 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6909 pause_time, UINT16);
6910 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6911 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6912 xon_str, "send_xon");
6913 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6914 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6916 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6917 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6918 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6919 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6920 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6921 mac_ctrl_frame_fwd_mode, "on#off");
6922 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6923 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6924 autoneg_str, "autoneg");
6925 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6926 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6928 cmdline_parse_token_num_t cmd_lfc_set_portid =
6929 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6932 /* forward declaration */
6934 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6937 cmdline_parse_inst_t cmd_link_flow_control_set = {
6938 .f = cmd_link_flow_ctrl_set_parsed,
6940 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6941 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6942 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6944 (void *)&cmd_lfc_set_set,
6945 (void *)&cmd_lfc_set_flow_ctrl,
6946 (void *)&cmd_lfc_set_rx,
6947 (void *)&cmd_lfc_set_rx_mode,
6948 (void *)&cmd_lfc_set_tx,
6949 (void *)&cmd_lfc_set_tx_mode,
6950 (void *)&cmd_lfc_set_high_water,
6951 (void *)&cmd_lfc_set_low_water,
6952 (void *)&cmd_lfc_set_pause_time,
6953 (void *)&cmd_lfc_set_send_xon,
6954 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6955 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6956 (void *)&cmd_lfc_set_autoneg_str,
6957 (void *)&cmd_lfc_set_autoneg,
6958 (void *)&cmd_lfc_set_portid,
6963 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6964 .f = cmd_link_flow_ctrl_set_parsed,
6965 .data = (void *)&cmd_link_flow_control_set_rx,
6966 .help_str = "set flow_ctrl rx on|off <port_id>: "
6967 "Change rx flow control parameter",
6969 (void *)&cmd_lfc_set_set,
6970 (void *)&cmd_lfc_set_flow_ctrl,
6971 (void *)&cmd_lfc_set_rx,
6972 (void *)&cmd_lfc_set_rx_mode,
6973 (void *)&cmd_lfc_set_portid,
6978 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6979 .f = cmd_link_flow_ctrl_set_parsed,
6980 .data = (void *)&cmd_link_flow_control_set_tx,
6981 .help_str = "set flow_ctrl tx on|off <port_id>: "
6982 "Change tx flow control parameter",
6984 (void *)&cmd_lfc_set_set,
6985 (void *)&cmd_lfc_set_flow_ctrl,
6986 (void *)&cmd_lfc_set_tx,
6987 (void *)&cmd_lfc_set_tx_mode,
6988 (void *)&cmd_lfc_set_portid,
6993 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6994 .f = cmd_link_flow_ctrl_set_parsed,
6995 .data = (void *)&cmd_link_flow_control_set_hw,
6996 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6997 "Change high water flow control parameter",
6999 (void *)&cmd_lfc_set_set,
7000 (void *)&cmd_lfc_set_flow_ctrl,
7001 (void *)&cmd_lfc_set_high_water_str,
7002 (void *)&cmd_lfc_set_high_water,
7003 (void *)&cmd_lfc_set_portid,
7008 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7009 .f = cmd_link_flow_ctrl_set_parsed,
7010 .data = (void *)&cmd_link_flow_control_set_lw,
7011 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7012 "Change low water flow control parameter",
7014 (void *)&cmd_lfc_set_set,
7015 (void *)&cmd_lfc_set_flow_ctrl,
7016 (void *)&cmd_lfc_set_low_water_str,
7017 (void *)&cmd_lfc_set_low_water,
7018 (void *)&cmd_lfc_set_portid,
7023 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7024 .f = cmd_link_flow_ctrl_set_parsed,
7025 .data = (void *)&cmd_link_flow_control_set_pt,
7026 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7027 "Change pause time flow control parameter",
7029 (void *)&cmd_lfc_set_set,
7030 (void *)&cmd_lfc_set_flow_ctrl,
7031 (void *)&cmd_lfc_set_pause_time_str,
7032 (void *)&cmd_lfc_set_pause_time,
7033 (void *)&cmd_lfc_set_portid,
7038 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7039 .f = cmd_link_flow_ctrl_set_parsed,
7040 .data = (void *)&cmd_link_flow_control_set_xon,
7041 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7042 "Change send_xon flow control parameter",
7044 (void *)&cmd_lfc_set_set,
7045 (void *)&cmd_lfc_set_flow_ctrl,
7046 (void *)&cmd_lfc_set_send_xon_str,
7047 (void *)&cmd_lfc_set_send_xon,
7048 (void *)&cmd_lfc_set_portid,
7053 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7054 .f = cmd_link_flow_ctrl_set_parsed,
7055 .data = (void *)&cmd_link_flow_control_set_macfwd,
7056 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7057 "Change mac ctrl fwd flow control parameter",
7059 (void *)&cmd_lfc_set_set,
7060 (void *)&cmd_lfc_set_flow_ctrl,
7061 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7062 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7063 (void *)&cmd_lfc_set_portid,
7068 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7069 .f = cmd_link_flow_ctrl_set_parsed,
7070 .data = (void *)&cmd_link_flow_control_set_autoneg,
7071 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7072 "Change autoneg flow control parameter",
7074 (void *)&cmd_lfc_set_set,
7075 (void *)&cmd_lfc_set_flow_ctrl,
7076 (void *)&cmd_lfc_set_autoneg_str,
7077 (void *)&cmd_lfc_set_autoneg,
7078 (void *)&cmd_lfc_set_portid,
7084 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7085 __rte_unused struct cmdline *cl,
7088 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7089 cmdline_parse_inst_t *cmd = data;
7090 struct rte_eth_fc_conf fc_conf;
7096 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7097 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7098 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7099 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7101 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7102 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7105 /* Partial command line, retrieve current configuration */
7107 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7109 printf("cannot get current flow ctrl parameters, return"
7110 "code = %d\n", ret);
7114 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7115 (fc_conf.mode == RTE_FC_FULL))
7117 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7118 (fc_conf.mode == RTE_FC_FULL))
7122 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7123 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7125 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7126 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7128 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7130 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7131 fc_conf.high_water = res->high_water;
7133 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7134 fc_conf.low_water = res->low_water;
7136 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7137 fc_conf.pause_time = res->pause_time;
7139 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7140 fc_conf.send_xon = res->send_xon;
7142 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7143 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7144 fc_conf.mac_ctrl_frame_fwd = 1;
7146 fc_conf.mac_ctrl_frame_fwd = 0;
7149 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7150 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7152 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7154 printf("bad flow contrl parameter, return code = %d \n", ret);
7157 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7158 struct cmd_priority_flow_ctrl_set_result {
7159 cmdline_fixed_string_t set;
7160 cmdline_fixed_string_t pfc_ctrl;
7161 cmdline_fixed_string_t rx;
7162 cmdline_fixed_string_t rx_pfc_mode;
7163 cmdline_fixed_string_t tx;
7164 cmdline_fixed_string_t tx_pfc_mode;
7165 uint32_t high_water;
7167 uint16_t pause_time;
7173 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7174 __rte_unused struct cmdline *cl,
7175 __rte_unused void *data)
7177 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7178 struct rte_eth_pfc_conf pfc_conf;
7179 int rx_fc_enable, tx_fc_enable;
7183 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7184 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7185 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7186 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7188 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7189 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7192 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7193 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7194 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7195 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7196 pfc_conf.fc.high_water = res->high_water;
7197 pfc_conf.fc.low_water = res->low_water;
7198 pfc_conf.fc.pause_time = res->pause_time;
7199 pfc_conf.priority = res->priority;
7201 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7203 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7206 cmdline_parse_token_string_t cmd_pfc_set_set =
7207 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7209 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7210 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7211 pfc_ctrl, "pfc_ctrl");
7212 cmdline_parse_token_string_t cmd_pfc_set_rx =
7213 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7215 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7216 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7217 rx_pfc_mode, "on#off");
7218 cmdline_parse_token_string_t cmd_pfc_set_tx =
7219 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7221 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7222 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7223 tx_pfc_mode, "on#off");
7224 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7225 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7226 high_water, UINT32);
7227 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7228 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7230 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7231 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7232 pause_time, UINT16);
7233 cmdline_parse_token_num_t cmd_pfc_set_priority =
7234 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7236 cmdline_parse_token_num_t cmd_pfc_set_portid =
7237 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7240 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7241 .f = cmd_priority_flow_ctrl_set_parsed,
7243 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7244 "<pause_time> <priority> <port_id>: "
7245 "Configure the Ethernet priority flow control",
7247 (void *)&cmd_pfc_set_set,
7248 (void *)&cmd_pfc_set_flow_ctrl,
7249 (void *)&cmd_pfc_set_rx,
7250 (void *)&cmd_pfc_set_rx_mode,
7251 (void *)&cmd_pfc_set_tx,
7252 (void *)&cmd_pfc_set_tx_mode,
7253 (void *)&cmd_pfc_set_high_water,
7254 (void *)&cmd_pfc_set_low_water,
7255 (void *)&cmd_pfc_set_pause_time,
7256 (void *)&cmd_pfc_set_priority,
7257 (void *)&cmd_pfc_set_portid,
7262 /* *** RESET CONFIGURATION *** */
7263 struct cmd_reset_result {
7264 cmdline_fixed_string_t reset;
7265 cmdline_fixed_string_t def;
7268 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7270 __rte_unused void *data)
7272 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7273 set_def_fwd_config();
7276 cmdline_parse_token_string_t cmd_reset_set =
7277 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7278 cmdline_parse_token_string_t cmd_reset_def =
7279 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7282 cmdline_parse_inst_t cmd_reset = {
7283 .f = cmd_reset_parsed,
7285 .help_str = "set default: Reset default forwarding configuration",
7287 (void *)&cmd_reset_set,
7288 (void *)&cmd_reset_def,
7293 /* *** START FORWARDING *** */
7294 struct cmd_start_result {
7295 cmdline_fixed_string_t start;
7298 cmdline_parse_token_string_t cmd_start_start =
7299 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7301 static void cmd_start_parsed(__rte_unused void *parsed_result,
7302 __rte_unused struct cmdline *cl,
7303 __rte_unused void *data)
7305 start_packet_forwarding(0);
7308 cmdline_parse_inst_t cmd_start = {
7309 .f = cmd_start_parsed,
7311 .help_str = "start: Start packet forwarding",
7313 (void *)&cmd_start_start,
7318 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7319 struct cmd_start_tx_first_result {
7320 cmdline_fixed_string_t start;
7321 cmdline_fixed_string_t tx_first;
7325 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7326 __rte_unused struct cmdline *cl,
7327 __rte_unused void *data)
7329 start_packet_forwarding(1);
7332 cmdline_parse_token_string_t cmd_start_tx_first_start =
7333 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7335 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7336 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7337 tx_first, "tx_first");
7339 cmdline_parse_inst_t cmd_start_tx_first = {
7340 .f = cmd_start_tx_first_parsed,
7342 .help_str = "start tx_first: Start packet forwarding, "
7343 "after sending 1 burst of packets",
7345 (void *)&cmd_start_tx_first_start,
7346 (void *)&cmd_start_tx_first_tx_first,
7351 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7352 struct cmd_start_tx_first_n_result {
7353 cmdline_fixed_string_t start;
7354 cmdline_fixed_string_t tx_first;
7359 cmd_start_tx_first_n_parsed(void *parsed_result,
7360 __rte_unused struct cmdline *cl,
7361 __rte_unused void *data)
7363 struct cmd_start_tx_first_n_result *res = parsed_result;
7365 start_packet_forwarding(res->tx_num);
7368 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7369 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7371 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7372 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7373 tx_first, "tx_first");
7374 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7375 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7378 cmdline_parse_inst_t cmd_start_tx_first_n = {
7379 .f = cmd_start_tx_first_n_parsed,
7381 .help_str = "start tx_first <num>: "
7382 "packet forwarding, after sending <num> bursts of packets",
7384 (void *)&cmd_start_tx_first_n_start,
7385 (void *)&cmd_start_tx_first_n_tx_first,
7386 (void *)&cmd_start_tx_first_n_tx_num,
7391 /* *** SET LINK UP *** */
7392 struct cmd_set_link_up_result {
7393 cmdline_fixed_string_t set;
7394 cmdline_fixed_string_t link_up;
7395 cmdline_fixed_string_t port;
7399 cmdline_parse_token_string_t cmd_set_link_up_set =
7400 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7401 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7402 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7404 cmdline_parse_token_string_t cmd_set_link_up_port =
7405 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7406 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7407 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7409 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7410 __rte_unused struct cmdline *cl,
7411 __rte_unused void *data)
7413 struct cmd_set_link_up_result *res = parsed_result;
7414 dev_set_link_up(res->port_id);
7417 cmdline_parse_inst_t cmd_set_link_up = {
7418 .f = cmd_set_link_up_parsed,
7420 .help_str = "set link-up port <port id>",
7422 (void *)&cmd_set_link_up_set,
7423 (void *)&cmd_set_link_up_link_up,
7424 (void *)&cmd_set_link_up_port,
7425 (void *)&cmd_set_link_up_port_id,
7430 /* *** SET LINK DOWN *** */
7431 struct cmd_set_link_down_result {
7432 cmdline_fixed_string_t set;
7433 cmdline_fixed_string_t link_down;
7434 cmdline_fixed_string_t port;
7438 cmdline_parse_token_string_t cmd_set_link_down_set =
7439 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7440 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7441 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7443 cmdline_parse_token_string_t cmd_set_link_down_port =
7444 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7445 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7446 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7448 static void cmd_set_link_down_parsed(
7449 __rte_unused void *parsed_result,
7450 __rte_unused struct cmdline *cl,
7451 __rte_unused void *data)
7453 struct cmd_set_link_down_result *res = parsed_result;
7454 dev_set_link_down(res->port_id);
7457 cmdline_parse_inst_t cmd_set_link_down = {
7458 .f = cmd_set_link_down_parsed,
7460 .help_str = "set link-down port <port id>",
7462 (void *)&cmd_set_link_down_set,
7463 (void *)&cmd_set_link_down_link_down,
7464 (void *)&cmd_set_link_down_port,
7465 (void *)&cmd_set_link_down_port_id,
7470 /* *** SHOW CFG *** */
7471 struct cmd_showcfg_result {
7472 cmdline_fixed_string_t show;
7473 cmdline_fixed_string_t cfg;
7474 cmdline_fixed_string_t what;
7477 static void cmd_showcfg_parsed(void *parsed_result,
7478 __rte_unused struct cmdline *cl,
7479 __rte_unused void *data)
7481 struct cmd_showcfg_result *res = parsed_result;
7482 if (!strcmp(res->what, "rxtx"))
7483 rxtx_config_display();
7484 else if (!strcmp(res->what, "cores"))
7485 fwd_lcores_config_display();
7486 else if (!strcmp(res->what, "fwd"))
7487 pkt_fwd_config_display(&cur_fwd_config);
7488 else if (!strcmp(res->what, "txpkts"))
7489 show_tx_pkt_segments();
7490 else if (!strcmp(res->what, "txtimes"))
7491 show_tx_pkt_times();
7494 cmdline_parse_token_string_t cmd_showcfg_show =
7495 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7496 cmdline_parse_token_string_t cmd_showcfg_port =
7497 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7498 cmdline_parse_token_string_t cmd_showcfg_what =
7499 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7500 "rxtx#cores#fwd#txpkts#txtimes");
7502 cmdline_parse_inst_t cmd_showcfg = {
7503 .f = cmd_showcfg_parsed,
7505 .help_str = "show config rxtx|cores|fwd|txpkts|txtimes",
7507 (void *)&cmd_showcfg_show,
7508 (void *)&cmd_showcfg_port,
7509 (void *)&cmd_showcfg_what,
7514 /* *** SHOW ALL PORT INFO *** */
7515 struct cmd_showportall_result {
7516 cmdline_fixed_string_t show;
7517 cmdline_fixed_string_t port;
7518 cmdline_fixed_string_t what;
7519 cmdline_fixed_string_t all;
7522 static void cmd_showportall_parsed(void *parsed_result,
7523 __rte_unused struct cmdline *cl,
7524 __rte_unused void *data)
7528 struct cmd_showportall_result *res = parsed_result;
7529 if (!strcmp(res->show, "clear")) {
7530 if (!strcmp(res->what, "stats"))
7531 RTE_ETH_FOREACH_DEV(i)
7533 else if (!strcmp(res->what, "xstats"))
7534 RTE_ETH_FOREACH_DEV(i)
7535 nic_xstats_clear(i);
7536 } else if (!strcmp(res->what, "info"))
7537 RTE_ETH_FOREACH_DEV(i)
7538 port_infos_display(i);
7539 else if (!strcmp(res->what, "summary")) {
7540 port_summary_header_display();
7541 RTE_ETH_FOREACH_DEV(i)
7542 port_summary_display(i);
7544 else if (!strcmp(res->what, "stats"))
7545 RTE_ETH_FOREACH_DEV(i)
7546 nic_stats_display(i);
7547 else if (!strcmp(res->what, "xstats"))
7548 RTE_ETH_FOREACH_DEV(i)
7549 nic_xstats_display(i);
7550 else if (!strcmp(res->what, "fdir"))
7551 RTE_ETH_FOREACH_DEV(i)
7553 else if (!strcmp(res->what, "stat_qmap"))
7554 RTE_ETH_FOREACH_DEV(i)
7555 nic_stats_mapping_display(i);
7556 else if (!strcmp(res->what, "dcb_tc"))
7557 RTE_ETH_FOREACH_DEV(i)
7558 port_dcb_info_display(i);
7559 else if (!strcmp(res->what, "cap"))
7560 RTE_ETH_FOREACH_DEV(i)
7561 port_offload_cap_display(i);
7564 cmdline_parse_token_string_t cmd_showportall_show =
7565 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7567 cmdline_parse_token_string_t cmd_showportall_port =
7568 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7569 cmdline_parse_token_string_t cmd_showportall_what =
7570 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7571 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7572 cmdline_parse_token_string_t cmd_showportall_all =
7573 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7574 cmdline_parse_inst_t cmd_showportall = {
7575 .f = cmd_showportall_parsed,
7577 .help_str = "show|clear port "
7578 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7580 (void *)&cmd_showportall_show,
7581 (void *)&cmd_showportall_port,
7582 (void *)&cmd_showportall_what,
7583 (void *)&cmd_showportall_all,
7588 /* *** SHOW PORT INFO *** */
7589 struct cmd_showport_result {
7590 cmdline_fixed_string_t show;
7591 cmdline_fixed_string_t port;
7592 cmdline_fixed_string_t what;
7596 static void cmd_showport_parsed(void *parsed_result,
7597 __rte_unused struct cmdline *cl,
7598 __rte_unused void *data)
7600 struct cmd_showport_result *res = parsed_result;
7601 if (!strcmp(res->show, "clear")) {
7602 if (!strcmp(res->what, "stats"))
7603 nic_stats_clear(res->portnum);
7604 else if (!strcmp(res->what, "xstats"))
7605 nic_xstats_clear(res->portnum);
7606 } else if (!strcmp(res->what, "info"))
7607 port_infos_display(res->portnum);
7608 else if (!strcmp(res->what, "summary")) {
7609 port_summary_header_display();
7610 port_summary_display(res->portnum);
7612 else if (!strcmp(res->what, "stats"))
7613 nic_stats_display(res->portnum);
7614 else if (!strcmp(res->what, "xstats"))
7615 nic_xstats_display(res->portnum);
7616 else if (!strcmp(res->what, "fdir"))
7617 fdir_get_infos(res->portnum);
7618 else if (!strcmp(res->what, "stat_qmap"))
7619 nic_stats_mapping_display(res->portnum);
7620 else if (!strcmp(res->what, "dcb_tc"))
7621 port_dcb_info_display(res->portnum);
7622 else if (!strcmp(res->what, "cap"))
7623 port_offload_cap_display(res->portnum);
7626 cmdline_parse_token_string_t cmd_showport_show =
7627 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7629 cmdline_parse_token_string_t cmd_showport_port =
7630 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7631 cmdline_parse_token_string_t cmd_showport_what =
7632 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7633 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7634 cmdline_parse_token_num_t cmd_showport_portnum =
7635 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7637 cmdline_parse_inst_t cmd_showport = {
7638 .f = cmd_showport_parsed,
7640 .help_str = "show|clear port "
7641 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7644 (void *)&cmd_showport_show,
7645 (void *)&cmd_showport_port,
7646 (void *)&cmd_showport_what,
7647 (void *)&cmd_showport_portnum,
7652 /* *** SHOW DEVICE INFO *** */
7653 struct cmd_showdevice_result {
7654 cmdline_fixed_string_t show;
7655 cmdline_fixed_string_t device;
7656 cmdline_fixed_string_t what;
7657 cmdline_fixed_string_t identifier;
7660 static void cmd_showdevice_parsed(void *parsed_result,
7661 __rte_unused struct cmdline *cl,
7662 __rte_unused void *data)
7664 struct cmd_showdevice_result *res = parsed_result;
7665 if (!strcmp(res->what, "info")) {
7666 if (!strcmp(res->identifier, "all"))
7667 device_infos_display(NULL);
7669 device_infos_display(res->identifier);
7673 cmdline_parse_token_string_t cmd_showdevice_show =
7674 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7676 cmdline_parse_token_string_t cmd_showdevice_device =
7677 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7678 cmdline_parse_token_string_t cmd_showdevice_what =
7679 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7681 cmdline_parse_token_string_t cmd_showdevice_identifier =
7682 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7685 cmdline_parse_inst_t cmd_showdevice = {
7686 .f = cmd_showdevice_parsed,
7688 .help_str = "show device info <identifier>|all",
7690 (void *)&cmd_showdevice_show,
7691 (void *)&cmd_showdevice_device,
7692 (void *)&cmd_showdevice_what,
7693 (void *)&cmd_showdevice_identifier,
7697 /* *** SHOW QUEUE INFO *** */
7698 struct cmd_showqueue_result {
7699 cmdline_fixed_string_t show;
7700 cmdline_fixed_string_t type;
7701 cmdline_fixed_string_t what;
7707 cmd_showqueue_parsed(void *parsed_result,
7708 __rte_unused struct cmdline *cl,
7709 __rte_unused void *data)
7711 struct cmd_showqueue_result *res = parsed_result;
7713 if (!strcmp(res->type, "rxq"))
7714 rx_queue_infos_display(res->portnum, res->queuenum);
7715 else if (!strcmp(res->type, "txq"))
7716 tx_queue_infos_display(res->portnum, res->queuenum);
7719 cmdline_parse_token_string_t cmd_showqueue_show =
7720 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7721 cmdline_parse_token_string_t cmd_showqueue_type =
7722 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7723 cmdline_parse_token_string_t cmd_showqueue_what =
7724 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7725 cmdline_parse_token_num_t cmd_showqueue_portnum =
7726 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7727 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7728 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7730 cmdline_parse_inst_t cmd_showqueue = {
7731 .f = cmd_showqueue_parsed,
7733 .help_str = "show rxq|txq info <port_id> <queue_id>",
7735 (void *)&cmd_showqueue_show,
7736 (void *)&cmd_showqueue_type,
7737 (void *)&cmd_showqueue_what,
7738 (void *)&cmd_showqueue_portnum,
7739 (void *)&cmd_showqueue_queuenum,
7744 /* show/clear fwd engine statistics */
7746 cmdline_fixed_string_t action;
7747 cmdline_fixed_string_t fwd;
7748 cmdline_fixed_string_t stats;
7749 cmdline_fixed_string_t all;
7752 cmdline_parse_token_string_t cmd_fwd_action =
7753 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7754 cmdline_parse_token_string_t cmd_fwd_fwd =
7755 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7756 cmdline_parse_token_string_t cmd_fwd_stats =
7757 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7758 cmdline_parse_token_string_t cmd_fwd_all =
7759 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7762 cmd_showfwdall_parsed(void *parsed_result,
7763 __rte_unused struct cmdline *cl,
7764 __rte_unused void *data)
7766 struct fwd_result *res = parsed_result;
7768 if (!strcmp(res->action, "show"))
7769 fwd_stats_display();
7774 static cmdline_parse_inst_t cmd_showfwdall = {
7775 .f = cmd_showfwdall_parsed,
7777 .help_str = "show|clear fwd stats all",
7779 (void *)&cmd_fwd_action,
7780 (void *)&cmd_fwd_fwd,
7781 (void *)&cmd_fwd_stats,
7782 (void *)&cmd_fwd_all,
7787 /* *** READ PORT REGISTER *** */
7788 struct cmd_read_reg_result {
7789 cmdline_fixed_string_t read;
7790 cmdline_fixed_string_t reg;
7796 cmd_read_reg_parsed(void *parsed_result,
7797 __rte_unused struct cmdline *cl,
7798 __rte_unused void *data)
7800 struct cmd_read_reg_result *res = parsed_result;
7801 port_reg_display(res->port_id, res->reg_off);
7804 cmdline_parse_token_string_t cmd_read_reg_read =
7805 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7806 cmdline_parse_token_string_t cmd_read_reg_reg =
7807 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7808 cmdline_parse_token_num_t cmd_read_reg_port_id =
7809 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7810 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7811 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7813 cmdline_parse_inst_t cmd_read_reg = {
7814 .f = cmd_read_reg_parsed,
7816 .help_str = "read reg <port_id> <reg_off>",
7818 (void *)&cmd_read_reg_read,
7819 (void *)&cmd_read_reg_reg,
7820 (void *)&cmd_read_reg_port_id,
7821 (void *)&cmd_read_reg_reg_off,
7826 /* *** READ PORT REGISTER BIT FIELD *** */
7827 struct cmd_read_reg_bit_field_result {
7828 cmdline_fixed_string_t read;
7829 cmdline_fixed_string_t regfield;
7837 cmd_read_reg_bit_field_parsed(void *parsed_result,
7838 __rte_unused struct cmdline *cl,
7839 __rte_unused void *data)
7841 struct cmd_read_reg_bit_field_result *res = parsed_result;
7842 port_reg_bit_field_display(res->port_id, res->reg_off,
7843 res->bit1_pos, res->bit2_pos);
7846 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7847 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7849 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7850 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7851 regfield, "regfield");
7852 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7853 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7855 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7856 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7858 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7859 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7861 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7862 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7865 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7866 .f = cmd_read_reg_bit_field_parsed,
7868 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7869 "Read register bit field between bit_x and bit_y included",
7871 (void *)&cmd_read_reg_bit_field_read,
7872 (void *)&cmd_read_reg_bit_field_regfield,
7873 (void *)&cmd_read_reg_bit_field_port_id,
7874 (void *)&cmd_read_reg_bit_field_reg_off,
7875 (void *)&cmd_read_reg_bit_field_bit1_pos,
7876 (void *)&cmd_read_reg_bit_field_bit2_pos,
7881 /* *** READ PORT REGISTER BIT *** */
7882 struct cmd_read_reg_bit_result {
7883 cmdline_fixed_string_t read;
7884 cmdline_fixed_string_t regbit;
7891 cmd_read_reg_bit_parsed(void *parsed_result,
7892 __rte_unused struct cmdline *cl,
7893 __rte_unused void *data)
7895 struct cmd_read_reg_bit_result *res = parsed_result;
7896 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7899 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7900 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7901 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7902 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7904 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7905 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7906 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7907 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7908 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7909 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7911 cmdline_parse_inst_t cmd_read_reg_bit = {
7912 .f = cmd_read_reg_bit_parsed,
7914 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7916 (void *)&cmd_read_reg_bit_read,
7917 (void *)&cmd_read_reg_bit_regbit,
7918 (void *)&cmd_read_reg_bit_port_id,
7919 (void *)&cmd_read_reg_bit_reg_off,
7920 (void *)&cmd_read_reg_bit_bit_pos,
7925 /* *** WRITE PORT REGISTER *** */
7926 struct cmd_write_reg_result {
7927 cmdline_fixed_string_t write;
7928 cmdline_fixed_string_t reg;
7935 cmd_write_reg_parsed(void *parsed_result,
7936 __rte_unused struct cmdline *cl,
7937 __rte_unused void *data)
7939 struct cmd_write_reg_result *res = parsed_result;
7940 port_reg_set(res->port_id, res->reg_off, res->value);
7943 cmdline_parse_token_string_t cmd_write_reg_write =
7944 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7945 cmdline_parse_token_string_t cmd_write_reg_reg =
7946 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7947 cmdline_parse_token_num_t cmd_write_reg_port_id =
7948 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7949 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7950 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7951 cmdline_parse_token_num_t cmd_write_reg_value =
7952 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7954 cmdline_parse_inst_t cmd_write_reg = {
7955 .f = cmd_write_reg_parsed,
7957 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7959 (void *)&cmd_write_reg_write,
7960 (void *)&cmd_write_reg_reg,
7961 (void *)&cmd_write_reg_port_id,
7962 (void *)&cmd_write_reg_reg_off,
7963 (void *)&cmd_write_reg_value,
7968 /* *** WRITE PORT REGISTER BIT FIELD *** */
7969 struct cmd_write_reg_bit_field_result {
7970 cmdline_fixed_string_t write;
7971 cmdline_fixed_string_t regfield;
7980 cmd_write_reg_bit_field_parsed(void *parsed_result,
7981 __rte_unused struct cmdline *cl,
7982 __rte_unused void *data)
7984 struct cmd_write_reg_bit_field_result *res = parsed_result;
7985 port_reg_bit_field_set(res->port_id, res->reg_off,
7986 res->bit1_pos, res->bit2_pos, res->value);
7989 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7990 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7992 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7993 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7994 regfield, "regfield");
7995 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7996 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7998 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7999 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8001 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8002 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8004 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8005 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8007 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8008 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8011 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8012 .f = cmd_write_reg_bit_field_parsed,
8014 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8016 "Set register bit field between bit_x and bit_y included",
8018 (void *)&cmd_write_reg_bit_field_write,
8019 (void *)&cmd_write_reg_bit_field_regfield,
8020 (void *)&cmd_write_reg_bit_field_port_id,
8021 (void *)&cmd_write_reg_bit_field_reg_off,
8022 (void *)&cmd_write_reg_bit_field_bit1_pos,
8023 (void *)&cmd_write_reg_bit_field_bit2_pos,
8024 (void *)&cmd_write_reg_bit_field_value,
8029 /* *** WRITE PORT REGISTER BIT *** */
8030 struct cmd_write_reg_bit_result {
8031 cmdline_fixed_string_t write;
8032 cmdline_fixed_string_t regbit;
8040 cmd_write_reg_bit_parsed(void *parsed_result,
8041 __rte_unused struct cmdline *cl,
8042 __rte_unused void *data)
8044 struct cmd_write_reg_bit_result *res = parsed_result;
8045 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8048 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8049 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8051 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8052 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8054 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8055 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
8056 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8057 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
8058 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8059 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
8060 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8061 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
8063 cmdline_parse_inst_t cmd_write_reg_bit = {
8064 .f = cmd_write_reg_bit_parsed,
8066 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8069 (void *)&cmd_write_reg_bit_write,
8070 (void *)&cmd_write_reg_bit_regbit,
8071 (void *)&cmd_write_reg_bit_port_id,
8072 (void *)&cmd_write_reg_bit_reg_off,
8073 (void *)&cmd_write_reg_bit_bit_pos,
8074 (void *)&cmd_write_reg_bit_value,
8079 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8080 struct cmd_read_rxd_txd_result {
8081 cmdline_fixed_string_t read;
8082 cmdline_fixed_string_t rxd_txd;
8089 cmd_read_rxd_txd_parsed(void *parsed_result,
8090 __rte_unused struct cmdline *cl,
8091 __rte_unused void *data)
8093 struct cmd_read_rxd_txd_result *res = parsed_result;
8095 if (!strcmp(res->rxd_txd, "rxd"))
8096 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8097 else if (!strcmp(res->rxd_txd, "txd"))
8098 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8101 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8102 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8103 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8104 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8106 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8107 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8108 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8109 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8110 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8111 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8113 cmdline_parse_inst_t cmd_read_rxd_txd = {
8114 .f = cmd_read_rxd_txd_parsed,
8116 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8118 (void *)&cmd_read_rxd_txd_read,
8119 (void *)&cmd_read_rxd_txd_rxd_txd,
8120 (void *)&cmd_read_rxd_txd_port_id,
8121 (void *)&cmd_read_rxd_txd_queue_id,
8122 (void *)&cmd_read_rxd_txd_desc_id,
8128 struct cmd_quit_result {
8129 cmdline_fixed_string_t quit;
8132 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8134 __rte_unused void *data)
8139 cmdline_parse_token_string_t cmd_quit_quit =
8140 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8142 cmdline_parse_inst_t cmd_quit = {
8143 .f = cmd_quit_parsed,
8145 .help_str = "quit: Exit application",
8147 (void *)&cmd_quit_quit,
8152 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8153 struct cmd_mac_addr_result {
8154 cmdline_fixed_string_t mac_addr_cmd;
8155 cmdline_fixed_string_t what;
8157 struct rte_ether_addr address;
8160 static void cmd_mac_addr_parsed(void *parsed_result,
8161 __rte_unused struct cmdline *cl,
8162 __rte_unused void *data)
8164 struct cmd_mac_addr_result *res = parsed_result;
8167 if (strcmp(res->what, "add") == 0)
8168 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8169 else if (strcmp(res->what, "set") == 0)
8170 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8173 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8175 /* check the return value and print it if is < 0 */
8177 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8181 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8182 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8184 cmdline_parse_token_string_t cmd_mac_addr_what =
8185 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8187 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8188 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8190 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8191 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8193 cmdline_parse_inst_t cmd_mac_addr = {
8194 .f = cmd_mac_addr_parsed,
8196 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8197 "Add/Remove/Set MAC address on port_id",
8199 (void *)&cmd_mac_addr_cmd,
8200 (void *)&cmd_mac_addr_what,
8201 (void *)&cmd_mac_addr_portnum,
8202 (void *)&cmd_mac_addr_addr,
8207 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8208 struct cmd_eth_peer_result {
8209 cmdline_fixed_string_t set;
8210 cmdline_fixed_string_t eth_peer;
8212 cmdline_fixed_string_t peer_addr;
8215 static void cmd_set_eth_peer_parsed(void *parsed_result,
8216 __rte_unused struct cmdline *cl,
8217 __rte_unused void *data)
8219 struct cmd_eth_peer_result *res = parsed_result;
8221 if (test_done == 0) {
8222 printf("Please stop forwarding first\n");
8225 if (!strcmp(res->eth_peer, "eth-peer")) {
8226 set_fwd_eth_peer(res->port_id, res->peer_addr);
8230 cmdline_parse_token_string_t cmd_eth_peer_set =
8231 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8232 cmdline_parse_token_string_t cmd_eth_peer =
8233 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8234 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8235 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8236 cmdline_parse_token_string_t cmd_eth_peer_addr =
8237 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8239 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8240 .f = cmd_set_eth_peer_parsed,
8242 .help_str = "set eth-peer <port_id> <peer_mac>",
8244 (void *)&cmd_eth_peer_set,
8245 (void *)&cmd_eth_peer,
8246 (void *)&cmd_eth_peer_port_id,
8247 (void *)&cmd_eth_peer_addr,
8252 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8253 struct cmd_set_qmap_result {
8254 cmdline_fixed_string_t set;
8255 cmdline_fixed_string_t qmap;
8256 cmdline_fixed_string_t what;
8263 cmd_set_qmap_parsed(void *parsed_result,
8264 __rte_unused struct cmdline *cl,
8265 __rte_unused void *data)
8267 struct cmd_set_qmap_result *res = parsed_result;
8268 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8270 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8273 cmdline_parse_token_string_t cmd_setqmap_set =
8274 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8276 cmdline_parse_token_string_t cmd_setqmap_qmap =
8277 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8279 cmdline_parse_token_string_t cmd_setqmap_what =
8280 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8282 cmdline_parse_token_num_t cmd_setqmap_portid =
8283 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8285 cmdline_parse_token_num_t cmd_setqmap_queueid =
8286 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8288 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8289 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8292 cmdline_parse_inst_t cmd_set_qmap = {
8293 .f = cmd_set_qmap_parsed,
8295 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8296 "Set statistics mapping value on tx|rx queue_id of port_id",
8298 (void *)&cmd_setqmap_set,
8299 (void *)&cmd_setqmap_qmap,
8300 (void *)&cmd_setqmap_what,
8301 (void *)&cmd_setqmap_portid,
8302 (void *)&cmd_setqmap_queueid,
8303 (void *)&cmd_setqmap_mapvalue,
8308 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8309 struct cmd_set_xstats_hide_zero_result {
8310 cmdline_fixed_string_t keyword;
8311 cmdline_fixed_string_t name;
8312 cmdline_fixed_string_t on_off;
8316 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8317 __rte_unused struct cmdline *cl,
8318 __rte_unused void *data)
8320 struct cmd_set_xstats_hide_zero_result *res;
8321 uint16_t on_off = 0;
8323 res = parsed_result;
8324 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8325 set_xstats_hide_zero(on_off);
8328 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8329 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8331 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8332 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8333 name, "xstats-hide-zero");
8334 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8335 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8338 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8339 .f = cmd_set_xstats_hide_zero_parsed,
8341 .help_str = "set xstats-hide-zero on|off",
8343 (void *)&cmd_set_xstats_hide_zero_keyword,
8344 (void *)&cmd_set_xstats_hide_zero_name,
8345 (void *)&cmd_set_xstats_hide_zero_on_off,
8350 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8351 struct cmd_set_record_core_cycles_result {
8352 cmdline_fixed_string_t keyword;
8353 cmdline_fixed_string_t name;
8354 cmdline_fixed_string_t on_off;
8358 cmd_set_record_core_cycles_parsed(void *parsed_result,
8359 __rte_unused struct cmdline *cl,
8360 __rte_unused void *data)
8362 struct cmd_set_record_core_cycles_result *res;
8363 uint16_t on_off = 0;
8365 res = parsed_result;
8366 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8367 set_record_core_cycles(on_off);
8370 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8371 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8373 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8374 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8375 name, "record-core-cycles");
8376 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8377 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8380 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8381 .f = cmd_set_record_core_cycles_parsed,
8383 .help_str = "set record-core-cycles on|off",
8385 (void *)&cmd_set_record_core_cycles_keyword,
8386 (void *)&cmd_set_record_core_cycles_name,
8387 (void *)&cmd_set_record_core_cycles_on_off,
8392 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8393 struct cmd_set_record_burst_stats_result {
8394 cmdline_fixed_string_t keyword;
8395 cmdline_fixed_string_t name;
8396 cmdline_fixed_string_t on_off;
8400 cmd_set_record_burst_stats_parsed(void *parsed_result,
8401 __rte_unused struct cmdline *cl,
8402 __rte_unused void *data)
8404 struct cmd_set_record_burst_stats_result *res;
8405 uint16_t on_off = 0;
8407 res = parsed_result;
8408 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8409 set_record_burst_stats(on_off);
8412 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8413 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8415 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8416 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8417 name, "record-burst-stats");
8418 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8419 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8422 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8423 .f = cmd_set_record_burst_stats_parsed,
8425 .help_str = "set record-burst-stats on|off",
8427 (void *)&cmd_set_record_burst_stats_keyword,
8428 (void *)&cmd_set_record_burst_stats_name,
8429 (void *)&cmd_set_record_burst_stats_on_off,
8434 /* *** CONFIGURE UNICAST HASH TABLE *** */
8435 struct cmd_set_uc_hash_table {
8436 cmdline_fixed_string_t set;
8437 cmdline_fixed_string_t port;
8439 cmdline_fixed_string_t what;
8440 struct rte_ether_addr address;
8441 cmdline_fixed_string_t mode;
8445 cmd_set_uc_hash_parsed(void *parsed_result,
8446 __rte_unused struct cmdline *cl,
8447 __rte_unused void *data)
8450 struct cmd_set_uc_hash_table *res = parsed_result;
8452 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8454 if (strcmp(res->what, "uta") == 0)
8455 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8456 &res->address,(uint8_t)is_on);
8458 printf("bad unicast hash table parameter, return code = %d \n", ret);
8462 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8463 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8465 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8466 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8468 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8469 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8471 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8472 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8474 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8475 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8477 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8478 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8481 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8482 .f = cmd_set_uc_hash_parsed,
8484 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8486 (void *)&cmd_set_uc_hash_set,
8487 (void *)&cmd_set_uc_hash_port,
8488 (void *)&cmd_set_uc_hash_portid,
8489 (void *)&cmd_set_uc_hash_what,
8490 (void *)&cmd_set_uc_hash_mac,
8491 (void *)&cmd_set_uc_hash_mode,
8496 struct cmd_set_uc_all_hash_table {
8497 cmdline_fixed_string_t set;
8498 cmdline_fixed_string_t port;
8500 cmdline_fixed_string_t what;
8501 cmdline_fixed_string_t value;
8502 cmdline_fixed_string_t mode;
8506 cmd_set_uc_all_hash_parsed(void *parsed_result,
8507 __rte_unused struct cmdline *cl,
8508 __rte_unused void *data)
8511 struct cmd_set_uc_all_hash_table *res = parsed_result;
8513 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8515 if ((strcmp(res->what, "uta") == 0) &&
8516 (strcmp(res->value, "all") == 0))
8517 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8519 printf("bad unicast hash table parameter,"
8520 "return code = %d \n", ret);
8523 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8524 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8526 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8527 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8529 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8530 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8532 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8533 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8535 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8536 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8538 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8539 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8542 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8543 .f = cmd_set_uc_all_hash_parsed,
8545 .help_str = "set port <port_id> uta all on|off",
8547 (void *)&cmd_set_uc_all_hash_set,
8548 (void *)&cmd_set_uc_all_hash_port,
8549 (void *)&cmd_set_uc_all_hash_portid,
8550 (void *)&cmd_set_uc_all_hash_what,
8551 (void *)&cmd_set_uc_all_hash_value,
8552 (void *)&cmd_set_uc_all_hash_mode,
8557 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8558 struct cmd_set_vf_macvlan_filter {
8559 cmdline_fixed_string_t set;
8560 cmdline_fixed_string_t port;
8562 cmdline_fixed_string_t vf;
8564 struct rte_ether_addr address;
8565 cmdline_fixed_string_t filter_type;
8566 cmdline_fixed_string_t mode;
8570 cmd_set_vf_macvlan_parsed(void *parsed_result,
8571 __rte_unused struct cmdline *cl,
8572 __rte_unused void *data)
8575 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8576 struct rte_eth_mac_filter filter;
8578 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8580 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8582 /* set VF MAC filter */
8586 filter.dst_id = res->vf_id;
8588 if (!strcmp(res->filter_type, "exact-mac"))
8589 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8590 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8591 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8592 else if (!strcmp(res->filter_type, "hashmac"))
8593 filter.filter_type = RTE_MAC_HASH_MATCH;
8594 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8595 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8597 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8600 ret = rte_eth_dev_filter_ctrl(res->port_id,
8601 RTE_ETH_FILTER_MACVLAN,
8605 ret = rte_eth_dev_filter_ctrl(res->port_id,
8606 RTE_ETH_FILTER_MACVLAN,
8607 RTE_ETH_FILTER_DELETE,
8611 printf("bad set MAC hash parameter, return code = %d\n", ret);
8615 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8616 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8618 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8619 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8621 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8622 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8624 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8625 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8627 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8628 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8630 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8631 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8633 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8634 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8635 filter_type, "exact-mac#exact-mac-vlan"
8636 "#hashmac#hashmac-vlan");
8637 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8638 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8641 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8642 .f = cmd_set_vf_macvlan_parsed,
8644 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8645 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8646 "Exact match rule: exact match of MAC or MAC and VLAN; "
8647 "hash match rule: hash match of MAC and exact match of VLAN",
8649 (void *)&cmd_set_vf_macvlan_set,
8650 (void *)&cmd_set_vf_macvlan_port,
8651 (void *)&cmd_set_vf_macvlan_portid,
8652 (void *)&cmd_set_vf_macvlan_vf,
8653 (void *)&cmd_set_vf_macvlan_vf_id,
8654 (void *)&cmd_set_vf_macvlan_mac,
8655 (void *)&cmd_set_vf_macvlan_filter_type,
8656 (void *)&cmd_set_vf_macvlan_mode,
8661 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8662 struct cmd_set_vf_traffic {
8663 cmdline_fixed_string_t set;
8664 cmdline_fixed_string_t port;
8666 cmdline_fixed_string_t vf;
8668 cmdline_fixed_string_t what;
8669 cmdline_fixed_string_t mode;
8673 cmd_set_vf_traffic_parsed(void *parsed_result,
8674 __rte_unused struct cmdline *cl,
8675 __rte_unused void *data)
8677 struct cmd_set_vf_traffic *res = parsed_result;
8678 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8679 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8681 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8684 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8685 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8687 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8688 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8690 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8691 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8693 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8694 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8696 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8697 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8699 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8700 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8702 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8703 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8706 cmdline_parse_inst_t cmd_set_vf_traffic = {
8707 .f = cmd_set_vf_traffic_parsed,
8709 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8711 (void *)&cmd_setvf_traffic_set,
8712 (void *)&cmd_setvf_traffic_port,
8713 (void *)&cmd_setvf_traffic_portid,
8714 (void *)&cmd_setvf_traffic_vf,
8715 (void *)&cmd_setvf_traffic_vfid,
8716 (void *)&cmd_setvf_traffic_what,
8717 (void *)&cmd_setvf_traffic_mode,
8722 /* *** CONFIGURE VF RECEIVE MODE *** */
8723 struct cmd_set_vf_rxmode {
8724 cmdline_fixed_string_t set;
8725 cmdline_fixed_string_t port;
8727 cmdline_fixed_string_t vf;
8729 cmdline_fixed_string_t what;
8730 cmdline_fixed_string_t mode;
8731 cmdline_fixed_string_t on;
8735 cmd_set_vf_rxmode_parsed(void *parsed_result,
8736 __rte_unused struct cmdline *cl,
8737 __rte_unused void *data)
8740 uint16_t vf_rxmode = 0;
8741 struct cmd_set_vf_rxmode *res = parsed_result;
8743 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8744 if (!strcmp(res->what,"rxmode")) {
8745 if (!strcmp(res->mode, "AUPE"))
8746 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8747 else if (!strcmp(res->mode, "ROPE"))
8748 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8749 else if (!strcmp(res->mode, "BAM"))
8750 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8751 else if (!strncmp(res->mode, "MPE",3))
8752 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8755 RTE_SET_USED(is_on);
8757 #ifdef RTE_LIBRTE_IXGBE_PMD
8758 if (ret == -ENOTSUP)
8759 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8760 vf_rxmode, (uint8_t)is_on);
8762 #ifdef RTE_LIBRTE_BNXT_PMD
8763 if (ret == -ENOTSUP)
8764 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8765 vf_rxmode, (uint8_t)is_on);
8768 printf("bad VF receive mode parameter, return code = %d \n",
8772 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8773 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8775 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8776 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8778 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8779 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8781 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8782 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8784 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8785 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8787 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8788 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8790 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8791 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8792 mode, "AUPE#ROPE#BAM#MPE");
8793 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8794 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8797 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8798 .f = cmd_set_vf_rxmode_parsed,
8800 .help_str = "set port <port_id> vf <vf_id> rxmode "
8801 "AUPE|ROPE|BAM|MPE on|off",
8803 (void *)&cmd_set_vf_rxmode_set,
8804 (void *)&cmd_set_vf_rxmode_port,
8805 (void *)&cmd_set_vf_rxmode_portid,
8806 (void *)&cmd_set_vf_rxmode_vf,
8807 (void *)&cmd_set_vf_rxmode_vfid,
8808 (void *)&cmd_set_vf_rxmode_what,
8809 (void *)&cmd_set_vf_rxmode_mode,
8810 (void *)&cmd_set_vf_rxmode_on,
8815 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8816 struct cmd_vf_mac_addr_result {
8817 cmdline_fixed_string_t mac_addr_cmd;
8818 cmdline_fixed_string_t what;
8819 cmdline_fixed_string_t port;
8821 cmdline_fixed_string_t vf;
8823 struct rte_ether_addr address;
8826 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8827 __rte_unused struct cmdline *cl,
8828 __rte_unused void *data)
8830 struct cmd_vf_mac_addr_result *res = parsed_result;
8833 if (strcmp(res->what, "add") != 0)
8836 #ifdef RTE_LIBRTE_I40E_PMD
8837 if (ret == -ENOTSUP)
8838 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8841 #ifdef RTE_LIBRTE_BNXT_PMD
8842 if (ret == -ENOTSUP)
8843 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8848 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8852 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8853 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8854 mac_addr_cmd,"mac_addr");
8855 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8856 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8858 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8859 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8861 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8862 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8864 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8865 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8867 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8868 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8870 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8871 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8874 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8875 .f = cmd_vf_mac_addr_parsed,
8877 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8878 "Add MAC address filtering for a VF on port_id",
8880 (void *)&cmd_vf_mac_addr_cmd,
8881 (void *)&cmd_vf_mac_addr_what,
8882 (void *)&cmd_vf_mac_addr_port,
8883 (void *)&cmd_vf_mac_addr_portnum,
8884 (void *)&cmd_vf_mac_addr_vf,
8885 (void *)&cmd_vf_mac_addr_vfnum,
8886 (void *)&cmd_vf_mac_addr_addr,
8891 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8892 struct cmd_vf_rx_vlan_filter {
8893 cmdline_fixed_string_t rx_vlan;
8894 cmdline_fixed_string_t what;
8896 cmdline_fixed_string_t port;
8898 cmdline_fixed_string_t vf;
8903 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8904 __rte_unused struct cmdline *cl,
8905 __rte_unused void *data)
8907 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8910 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8912 #ifdef RTE_LIBRTE_IXGBE_PMD
8913 if (ret == -ENOTSUP)
8914 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8915 res->vlan_id, res->vf_mask, is_add);
8917 #ifdef RTE_LIBRTE_I40E_PMD
8918 if (ret == -ENOTSUP)
8919 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8920 res->vlan_id, res->vf_mask, is_add);
8922 #ifdef RTE_LIBRTE_BNXT_PMD
8923 if (ret == -ENOTSUP)
8924 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8925 res->vlan_id, res->vf_mask, is_add);
8932 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8933 res->vlan_id, res->vf_mask);
8936 printf("invalid port_id %d\n", res->port_id);
8939 printf("function not implemented or supported\n");
8942 printf("programming error: (%s)\n", strerror(-ret));
8946 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8947 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8948 rx_vlan, "rx_vlan");
8949 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8950 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8952 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8953 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8955 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8956 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8958 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8959 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8961 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8962 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8964 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8965 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8968 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8969 .f = cmd_vf_rx_vlan_filter_parsed,
8971 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8972 "(vf_mask = hexadecimal VF mask)",
8974 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8975 (void *)&cmd_vf_rx_vlan_filter_what,
8976 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8977 (void *)&cmd_vf_rx_vlan_filter_port,
8978 (void *)&cmd_vf_rx_vlan_filter_portid,
8979 (void *)&cmd_vf_rx_vlan_filter_vf,
8980 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8985 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8986 struct cmd_queue_rate_limit_result {
8987 cmdline_fixed_string_t set;
8988 cmdline_fixed_string_t port;
8990 cmdline_fixed_string_t queue;
8992 cmdline_fixed_string_t rate;
8996 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8997 __rte_unused struct cmdline *cl,
8998 __rte_unused void *data)
9000 struct cmd_queue_rate_limit_result *res = parsed_result;
9003 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9004 && (strcmp(res->queue, "queue") == 0)
9005 && (strcmp(res->rate, "rate") == 0))
9006 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9009 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
9013 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9014 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9016 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9017 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9019 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9020 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9022 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9023 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9025 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9026 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9028 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9029 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9031 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9032 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9035 cmdline_parse_inst_t cmd_queue_rate_limit = {
9036 .f = cmd_queue_rate_limit_parsed,
9038 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9039 "Set rate limit for a queue on port_id",
9041 (void *)&cmd_queue_rate_limit_set,
9042 (void *)&cmd_queue_rate_limit_port,
9043 (void *)&cmd_queue_rate_limit_portnum,
9044 (void *)&cmd_queue_rate_limit_queue,
9045 (void *)&cmd_queue_rate_limit_queuenum,
9046 (void *)&cmd_queue_rate_limit_rate,
9047 (void *)&cmd_queue_rate_limit_ratenum,
9052 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9053 struct cmd_vf_rate_limit_result {
9054 cmdline_fixed_string_t set;
9055 cmdline_fixed_string_t port;
9057 cmdline_fixed_string_t vf;
9059 cmdline_fixed_string_t rate;
9061 cmdline_fixed_string_t q_msk;
9065 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9066 __rte_unused struct cmdline *cl,
9067 __rte_unused void *data)
9069 struct cmd_vf_rate_limit_result *res = parsed_result;
9072 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9073 && (strcmp(res->vf, "vf") == 0)
9074 && (strcmp(res->rate, "rate") == 0)
9075 && (strcmp(res->q_msk, "queue_mask") == 0))
9076 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9077 res->rate_num, res->q_msk_val);
9079 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9083 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9084 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9086 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9087 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9089 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9090 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9092 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9093 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9095 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9096 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9098 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9099 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9101 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9102 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9104 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9105 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9106 q_msk, "queue_mask");
9107 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9108 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9111 cmdline_parse_inst_t cmd_vf_rate_limit = {
9112 .f = cmd_vf_rate_limit_parsed,
9114 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9115 "queue_mask <queue_mask_value>: "
9116 "Set rate limit for queues of VF on port_id",
9118 (void *)&cmd_vf_rate_limit_set,
9119 (void *)&cmd_vf_rate_limit_port,
9120 (void *)&cmd_vf_rate_limit_portnum,
9121 (void *)&cmd_vf_rate_limit_vf,
9122 (void *)&cmd_vf_rate_limit_vfnum,
9123 (void *)&cmd_vf_rate_limit_rate,
9124 (void *)&cmd_vf_rate_limit_ratenum,
9125 (void *)&cmd_vf_rate_limit_q_msk,
9126 (void *)&cmd_vf_rate_limit_q_msk_val,
9131 /* *** ADD TUNNEL FILTER OF A PORT *** */
9132 struct cmd_tunnel_filter_result {
9133 cmdline_fixed_string_t cmd;
9134 cmdline_fixed_string_t what;
9136 struct rte_ether_addr outer_mac;
9137 struct rte_ether_addr inner_mac;
9138 cmdline_ipaddr_t ip_value;
9139 uint16_t inner_vlan;
9140 cmdline_fixed_string_t tunnel_type;
9141 cmdline_fixed_string_t filter_type;
9147 cmd_tunnel_filter_parsed(void *parsed_result,
9148 __rte_unused struct cmdline *cl,
9149 __rte_unused void *data)
9151 struct cmd_tunnel_filter_result *res = parsed_result;
9152 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
9155 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
9157 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
9158 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
9159 tunnel_filter_conf.inner_vlan = res->inner_vlan;
9161 if (res->ip_value.family == AF_INET) {
9162 tunnel_filter_conf.ip_addr.ipv4_addr =
9163 res->ip_value.addr.ipv4.s_addr;
9164 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
9166 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
9167 &(res->ip_value.addr.ipv6),
9168 sizeof(struct in6_addr));
9169 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
9172 if (!strcmp(res->filter_type, "imac-ivlan"))
9173 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
9174 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
9175 tunnel_filter_conf.filter_type =
9176 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
9177 else if (!strcmp(res->filter_type, "imac-tenid"))
9178 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
9179 else if (!strcmp(res->filter_type, "imac"))
9180 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
9181 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
9182 tunnel_filter_conf.filter_type =
9183 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
9184 else if (!strcmp(res->filter_type, "oip"))
9185 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9186 else if (!strcmp(res->filter_type, "iip"))
9187 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9189 printf("The filter type is not supported");
9193 if (!strcmp(res->tunnel_type, "vxlan"))
9194 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9195 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9196 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9197 else if (!strcmp(res->tunnel_type, "nvgre"))
9198 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9199 else if (!strcmp(res->tunnel_type, "ipingre"))
9200 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9202 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9206 tunnel_filter_conf.tenant_id = res->tenant_id;
9207 tunnel_filter_conf.queue_id = res->queue_num;
9208 if (!strcmp(res->what, "add"))
9209 ret = rte_eth_dev_filter_ctrl(res->port_id,
9210 RTE_ETH_FILTER_TUNNEL,
9212 &tunnel_filter_conf);
9214 ret = rte_eth_dev_filter_ctrl(res->port_id,
9215 RTE_ETH_FILTER_TUNNEL,
9216 RTE_ETH_FILTER_DELETE,
9217 &tunnel_filter_conf);
9219 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9223 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9224 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9225 cmd, "tunnel_filter");
9226 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9227 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9229 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9230 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9232 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9233 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9235 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9236 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9238 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9239 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9240 inner_vlan, UINT16);
9241 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9242 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9244 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9245 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9246 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9248 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9249 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9250 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9251 "imac#omac-imac-tenid");
9252 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9253 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9255 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9256 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9259 cmdline_parse_inst_t cmd_tunnel_filter = {
9260 .f = cmd_tunnel_filter_parsed,
9262 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9263 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9264 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9265 "<queue_id>: Add/Rm tunnel filter of a port",
9267 (void *)&cmd_tunnel_filter_cmd,
9268 (void *)&cmd_tunnel_filter_what,
9269 (void *)&cmd_tunnel_filter_port_id,
9270 (void *)&cmd_tunnel_filter_outer_mac,
9271 (void *)&cmd_tunnel_filter_inner_mac,
9272 (void *)&cmd_tunnel_filter_ip_value,
9273 (void *)&cmd_tunnel_filter_innner_vlan,
9274 (void *)&cmd_tunnel_filter_tunnel_type,
9275 (void *)&cmd_tunnel_filter_filter_type,
9276 (void *)&cmd_tunnel_filter_tenant_id,
9277 (void *)&cmd_tunnel_filter_queue_num,
9282 /* *** CONFIGURE TUNNEL UDP PORT *** */
9283 struct cmd_tunnel_udp_config {
9284 cmdline_fixed_string_t cmd;
9285 cmdline_fixed_string_t what;
9291 cmd_tunnel_udp_config_parsed(void *parsed_result,
9292 __rte_unused struct cmdline *cl,
9293 __rte_unused void *data)
9295 struct cmd_tunnel_udp_config *res = parsed_result;
9296 struct rte_eth_udp_tunnel tunnel_udp;
9299 tunnel_udp.udp_port = res->udp_port;
9301 if (!strcmp(res->cmd, "rx_vxlan_port"))
9302 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9304 if (!strcmp(res->what, "add"))
9305 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9308 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9312 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9315 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9316 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9317 cmd, "rx_vxlan_port");
9318 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9319 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9321 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9322 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9324 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9325 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9328 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9329 .f = cmd_tunnel_udp_config_parsed,
9331 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9332 "Add/Remove a tunneling UDP port filter",
9334 (void *)&cmd_tunnel_udp_config_cmd,
9335 (void *)&cmd_tunnel_udp_config_what,
9336 (void *)&cmd_tunnel_udp_config_udp_port,
9337 (void *)&cmd_tunnel_udp_config_port_id,
9342 struct cmd_config_tunnel_udp_port {
9343 cmdline_fixed_string_t port;
9344 cmdline_fixed_string_t config;
9346 cmdline_fixed_string_t udp_tunnel_port;
9347 cmdline_fixed_string_t action;
9348 cmdline_fixed_string_t tunnel_type;
9353 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9354 __rte_unused struct cmdline *cl,
9355 __rte_unused void *data)
9357 struct cmd_config_tunnel_udp_port *res = parsed_result;
9358 struct rte_eth_udp_tunnel tunnel_udp;
9361 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9364 tunnel_udp.udp_port = res->udp_port;
9366 if (!strcmp(res->tunnel_type, "vxlan")) {
9367 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9368 } else if (!strcmp(res->tunnel_type, "geneve")) {
9369 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9370 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9371 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9373 printf("Invalid tunnel type\n");
9377 if (!strcmp(res->action, "add"))
9378 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9381 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9385 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9388 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9389 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9391 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9392 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9394 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9395 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9397 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9398 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9401 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9402 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9404 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9405 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9406 "vxlan#geneve#vxlan-gpe");
9407 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9408 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9411 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9412 .f = cmd_cfg_tunnel_udp_port_parsed,
9414 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9416 (void *)&cmd_config_tunnel_udp_port_port,
9417 (void *)&cmd_config_tunnel_udp_port_config,
9418 (void *)&cmd_config_tunnel_udp_port_port_id,
9419 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9420 (void *)&cmd_config_tunnel_udp_port_action,
9421 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9422 (void *)&cmd_config_tunnel_udp_port_value,
9427 /* *** GLOBAL CONFIG *** */
9428 struct cmd_global_config_result {
9429 cmdline_fixed_string_t cmd;
9431 cmdline_fixed_string_t cfg_type;
9436 cmd_global_config_parsed(void *parsed_result,
9437 __rte_unused struct cmdline *cl,
9438 __rte_unused void *data)
9440 struct cmd_global_config_result *res = parsed_result;
9441 struct rte_eth_global_cfg conf;
9444 memset(&conf, 0, sizeof(conf));
9445 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9446 conf.cfg.gre_key_len = res->len;
9447 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9448 RTE_ETH_FILTER_SET, &conf);
9449 #ifdef RTE_LIBRTE_I40E_PMD
9450 if (ret == -ENOTSUP)
9451 ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len);
9454 printf("Global config error\n");
9457 cmdline_parse_token_string_t cmd_global_config_cmd =
9458 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9460 cmdline_parse_token_num_t cmd_global_config_port_id =
9461 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9463 cmdline_parse_token_string_t cmd_global_config_type =
9464 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9465 cfg_type, "gre-key-len");
9466 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9467 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9470 cmdline_parse_inst_t cmd_global_config = {
9471 .f = cmd_global_config_parsed,
9472 .data = (void *)NULL,
9473 .help_str = "global_config <port_id> gre-key-len <key_len>",
9475 (void *)&cmd_global_config_cmd,
9476 (void *)&cmd_global_config_port_id,
9477 (void *)&cmd_global_config_type,
9478 (void *)&cmd_global_config_gre_key_len,
9483 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9484 struct cmd_set_mirror_mask_result {
9485 cmdline_fixed_string_t set;
9486 cmdline_fixed_string_t port;
9488 cmdline_fixed_string_t mirror;
9490 cmdline_fixed_string_t what;
9491 cmdline_fixed_string_t value;
9492 cmdline_fixed_string_t dstpool;
9494 cmdline_fixed_string_t on;
9497 cmdline_parse_token_string_t cmd_mirror_mask_set =
9498 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9500 cmdline_parse_token_string_t cmd_mirror_mask_port =
9501 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9503 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9504 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9506 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9507 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9508 mirror, "mirror-rule");
9509 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9510 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9512 cmdline_parse_token_string_t cmd_mirror_mask_what =
9513 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9514 what, "pool-mirror-up#pool-mirror-down"
9516 cmdline_parse_token_string_t cmd_mirror_mask_value =
9517 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9519 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9520 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9521 dstpool, "dst-pool");
9522 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9523 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9525 cmdline_parse_token_string_t cmd_mirror_mask_on =
9526 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9530 cmd_set_mirror_mask_parsed(void *parsed_result,
9531 __rte_unused struct cmdline *cl,
9532 __rte_unused void *data)
9535 struct cmd_set_mirror_mask_result *res = parsed_result;
9536 struct rte_eth_mirror_conf mr_conf;
9538 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9540 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9542 mr_conf.dst_pool = res->dstpool_id;
9544 if (!strcmp(res->what, "pool-mirror-up")) {
9545 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9546 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9547 } else if (!strcmp(res->what, "pool-mirror-down")) {
9548 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9549 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9550 } else if (!strcmp(res->what, "vlan-mirror")) {
9551 mr_conf.rule_type = ETH_MIRROR_VLAN;
9552 nb_item = parse_item_list(res->value, "vlan",
9553 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9557 for (i = 0; i < nb_item; i++) {
9558 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9559 printf("Invalid vlan_id: must be < 4096\n");
9563 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9564 mr_conf.vlan.vlan_mask |= 1ULL << i;
9568 if (!strcmp(res->on, "on"))
9569 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9572 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9575 printf("mirror rule add error: (%s)\n", strerror(-ret));
9578 cmdline_parse_inst_t cmd_set_mirror_mask = {
9579 .f = cmd_set_mirror_mask_parsed,
9581 .help_str = "set port <port_id> mirror-rule <rule_id> "
9582 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9583 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9585 (void *)&cmd_mirror_mask_set,
9586 (void *)&cmd_mirror_mask_port,
9587 (void *)&cmd_mirror_mask_portid,
9588 (void *)&cmd_mirror_mask_mirror,
9589 (void *)&cmd_mirror_mask_ruleid,
9590 (void *)&cmd_mirror_mask_what,
9591 (void *)&cmd_mirror_mask_value,
9592 (void *)&cmd_mirror_mask_dstpool,
9593 (void *)&cmd_mirror_mask_poolid,
9594 (void *)&cmd_mirror_mask_on,
9599 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9600 struct cmd_set_mirror_link_result {
9601 cmdline_fixed_string_t set;
9602 cmdline_fixed_string_t port;
9604 cmdline_fixed_string_t mirror;
9606 cmdline_fixed_string_t what;
9607 cmdline_fixed_string_t dstpool;
9609 cmdline_fixed_string_t on;
9612 cmdline_parse_token_string_t cmd_mirror_link_set =
9613 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9615 cmdline_parse_token_string_t cmd_mirror_link_port =
9616 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9618 cmdline_parse_token_num_t cmd_mirror_link_portid =
9619 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9621 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9622 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9623 mirror, "mirror-rule");
9624 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9625 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9627 cmdline_parse_token_string_t cmd_mirror_link_what =
9628 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9629 what, "uplink-mirror#downlink-mirror");
9630 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9631 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9632 dstpool, "dst-pool");
9633 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9634 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9636 cmdline_parse_token_string_t cmd_mirror_link_on =
9637 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9641 cmd_set_mirror_link_parsed(void *parsed_result,
9642 __rte_unused struct cmdline *cl,
9643 __rte_unused void *data)
9646 struct cmd_set_mirror_link_result *res = parsed_result;
9647 struct rte_eth_mirror_conf mr_conf;
9649 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9650 if (!strcmp(res->what, "uplink-mirror"))
9651 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9653 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9655 mr_conf.dst_pool = res->dstpool_id;
9657 if (!strcmp(res->on, "on"))
9658 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9661 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9664 /* check the return value and print it if is < 0 */
9666 printf("mirror rule add error: (%s)\n", strerror(-ret));
9670 cmdline_parse_inst_t cmd_set_mirror_link = {
9671 .f = cmd_set_mirror_link_parsed,
9673 .help_str = "set port <port_id> mirror-rule <rule_id> "
9674 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9676 (void *)&cmd_mirror_link_set,
9677 (void *)&cmd_mirror_link_port,
9678 (void *)&cmd_mirror_link_portid,
9679 (void *)&cmd_mirror_link_mirror,
9680 (void *)&cmd_mirror_link_ruleid,
9681 (void *)&cmd_mirror_link_what,
9682 (void *)&cmd_mirror_link_dstpool,
9683 (void *)&cmd_mirror_link_poolid,
9684 (void *)&cmd_mirror_link_on,
9689 /* *** RESET VM MIRROR RULE *** */
9690 struct cmd_rm_mirror_rule_result {
9691 cmdline_fixed_string_t reset;
9692 cmdline_fixed_string_t port;
9694 cmdline_fixed_string_t mirror;
9698 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9699 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9701 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9702 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9704 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9705 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9707 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9708 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9709 mirror, "mirror-rule");
9710 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9711 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9715 cmd_reset_mirror_rule_parsed(void *parsed_result,
9716 __rte_unused struct cmdline *cl,
9717 __rte_unused void *data)
9720 struct cmd_set_mirror_link_result *res = parsed_result;
9722 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9724 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9727 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9728 .f = cmd_reset_mirror_rule_parsed,
9730 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9732 (void *)&cmd_rm_mirror_rule_reset,
9733 (void *)&cmd_rm_mirror_rule_port,
9734 (void *)&cmd_rm_mirror_rule_portid,
9735 (void *)&cmd_rm_mirror_rule_mirror,
9736 (void *)&cmd_rm_mirror_rule_ruleid,
9741 /* ******************************************************************************** */
9743 struct cmd_dump_result {
9744 cmdline_fixed_string_t dump;
9748 dump_struct_sizes(void)
9750 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9751 DUMP_SIZE(struct rte_mbuf);
9752 DUMP_SIZE(struct rte_mempool);
9753 DUMP_SIZE(struct rte_ring);
9758 /* Dump the socket memory statistics on console */
9760 dump_socket_mem(FILE *f)
9762 struct rte_malloc_socket_stats socket_stats;
9767 unsigned int n_alloc = 0;
9768 unsigned int n_free = 0;
9769 static size_t last_allocs;
9770 static size_t last_total;
9773 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9774 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9775 !socket_stats.heap_totalsz_bytes)
9777 total += socket_stats.heap_totalsz_bytes;
9778 alloc += socket_stats.heap_allocsz_bytes;
9779 free += socket_stats.heap_freesz_bytes;
9780 n_alloc += socket_stats.alloc_count;
9781 n_free += socket_stats.free_count;
9783 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9785 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9786 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9787 (double)socket_stats.heap_allocsz_bytes * 100 /
9788 (double)socket_stats.heap_totalsz_bytes,
9789 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9790 socket_stats.alloc_count,
9791 socket_stats.free_count);
9794 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9795 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9796 (double)alloc * 100 / (double)total,
9797 (double)free / (1024 * 1024),
9800 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9801 ((double)total - (double)last_total) / (1024 * 1024),
9802 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9803 last_allocs = alloc;
9807 static void cmd_dump_parsed(void *parsed_result,
9808 __rte_unused struct cmdline *cl,
9809 __rte_unused void *data)
9811 struct cmd_dump_result *res = parsed_result;
9813 if (!strcmp(res->dump, "dump_physmem"))
9814 rte_dump_physmem_layout(stdout);
9815 else if (!strcmp(res->dump, "dump_socket_mem"))
9816 dump_socket_mem(stdout);
9817 else if (!strcmp(res->dump, "dump_memzone"))
9818 rte_memzone_dump(stdout);
9819 else if (!strcmp(res->dump, "dump_struct_sizes"))
9820 dump_struct_sizes();
9821 else if (!strcmp(res->dump, "dump_ring"))
9822 rte_ring_list_dump(stdout);
9823 else if (!strcmp(res->dump, "dump_mempool"))
9824 rte_mempool_list_dump(stdout);
9825 else if (!strcmp(res->dump, "dump_devargs"))
9826 rte_devargs_dump(stdout);
9827 else if (!strcmp(res->dump, "dump_log_types"))
9828 rte_log_dump(stdout);
9831 cmdline_parse_token_string_t cmd_dump_dump =
9832 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9836 "dump_struct_sizes#"
9842 cmdline_parse_inst_t cmd_dump = {
9843 .f = cmd_dump_parsed, /* function to call */
9844 .data = NULL, /* 2nd arg of func */
9845 .help_str = "Dump status",
9846 .tokens = { /* token list, NULL terminated */
9847 (void *)&cmd_dump_dump,
9852 /* ******************************************************************************** */
9854 struct cmd_dump_one_result {
9855 cmdline_fixed_string_t dump;
9856 cmdline_fixed_string_t name;
9859 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9860 __rte_unused void *data)
9862 struct cmd_dump_one_result *res = parsed_result;
9864 if (!strcmp(res->dump, "dump_ring")) {
9866 r = rte_ring_lookup(res->name);
9868 cmdline_printf(cl, "Cannot find ring\n");
9871 rte_ring_dump(stdout, r);
9872 } else if (!strcmp(res->dump, "dump_mempool")) {
9873 struct rte_mempool *mp;
9874 mp = rte_mempool_lookup(res->name);
9876 cmdline_printf(cl, "Cannot find mempool\n");
9879 rte_mempool_dump(stdout, mp);
9883 cmdline_parse_token_string_t cmd_dump_one_dump =
9884 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9885 "dump_ring#dump_mempool");
9887 cmdline_parse_token_string_t cmd_dump_one_name =
9888 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9890 cmdline_parse_inst_t cmd_dump_one = {
9891 .f = cmd_dump_one_parsed, /* function to call */
9892 .data = NULL, /* 2nd arg of func */
9893 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9894 .tokens = { /* token list, NULL terminated */
9895 (void *)&cmd_dump_one_dump,
9896 (void *)&cmd_dump_one_name,
9901 /* *** Add/Del syn filter *** */
9902 struct cmd_syn_filter_result {
9903 cmdline_fixed_string_t filter;
9905 cmdline_fixed_string_t ops;
9906 cmdline_fixed_string_t priority;
9907 cmdline_fixed_string_t high;
9908 cmdline_fixed_string_t queue;
9913 cmd_syn_filter_parsed(void *parsed_result,
9914 __rte_unused struct cmdline *cl,
9915 __rte_unused void *data)
9917 struct cmd_syn_filter_result *res = parsed_result;
9918 struct rte_eth_syn_filter syn_filter;
9921 ret = rte_eth_dev_filter_supported(res->port_id,
9922 RTE_ETH_FILTER_SYN);
9924 printf("syn filter is not supported on port %u.\n",
9929 memset(&syn_filter, 0, sizeof(syn_filter));
9931 if (!strcmp(res->ops, "add")) {
9932 if (!strcmp(res->high, "high"))
9933 syn_filter.hig_pri = 1;
9935 syn_filter.hig_pri = 0;
9937 syn_filter.queue = res->queue_id;
9938 ret = rte_eth_dev_filter_ctrl(res->port_id,
9943 ret = rte_eth_dev_filter_ctrl(res->port_id,
9945 RTE_ETH_FILTER_DELETE,
9949 printf("syn filter programming error: (%s)\n",
9953 cmdline_parse_token_string_t cmd_syn_filter_filter =
9954 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9955 filter, "syn_filter");
9956 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9957 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9959 cmdline_parse_token_string_t cmd_syn_filter_ops =
9960 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9962 cmdline_parse_token_string_t cmd_syn_filter_priority =
9963 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9964 priority, "priority");
9965 cmdline_parse_token_string_t cmd_syn_filter_high =
9966 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9968 cmdline_parse_token_string_t cmd_syn_filter_queue =
9969 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9971 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9972 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9975 cmdline_parse_inst_t cmd_syn_filter = {
9976 .f = cmd_syn_filter_parsed,
9978 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9979 "<queue_id>: Add/Delete syn filter",
9981 (void *)&cmd_syn_filter_filter,
9982 (void *)&cmd_syn_filter_port_id,
9983 (void *)&cmd_syn_filter_ops,
9984 (void *)&cmd_syn_filter_priority,
9985 (void *)&cmd_syn_filter_high,
9986 (void *)&cmd_syn_filter_queue,
9987 (void *)&cmd_syn_filter_queue_id,
9992 /* *** queue region set *** */
9993 struct cmd_queue_region_result {
9994 cmdline_fixed_string_t set;
9995 cmdline_fixed_string_t port;
9997 cmdline_fixed_string_t cmd;
9998 cmdline_fixed_string_t region;
10000 cmdline_fixed_string_t queue_start_index;
10002 cmdline_fixed_string_t queue_num;
10003 uint8_t queue_num_value;
10007 cmd_queue_region_parsed(void *parsed_result,
10008 __rte_unused struct cmdline *cl,
10009 __rte_unused void *data)
10011 struct cmd_queue_region_result *res = parsed_result;
10012 int ret = -ENOTSUP;
10013 #ifdef RTE_LIBRTE_I40E_PMD
10014 struct rte_pmd_i40e_queue_region_conf region_conf;
10015 enum rte_pmd_i40e_queue_region_op op_type;
10018 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10021 #ifdef RTE_LIBRTE_I40E_PMD
10022 memset(®ion_conf, 0, sizeof(region_conf));
10023 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
10024 region_conf.region_id = res->region_id;
10025 region_conf.queue_num = res->queue_num_value;
10026 region_conf.queue_start_index = res->queue_id;
10028 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10029 op_type, ®ion_conf);
10036 printf("function not implemented or supported\n");
10039 printf("queue region config error: (%s)\n", strerror(-ret));
10043 cmdline_parse_token_string_t cmd_queue_region_set =
10044 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10046 cmdline_parse_token_string_t cmd_queue_region_port =
10047 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10048 cmdline_parse_token_num_t cmd_queue_region_port_id =
10049 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10051 cmdline_parse_token_string_t cmd_queue_region_cmd =
10052 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10053 cmd, "queue-region");
10054 cmdline_parse_token_string_t cmd_queue_region_id =
10055 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10056 region, "region_id");
10057 cmdline_parse_token_num_t cmd_queue_region_index =
10058 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10060 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10061 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10062 queue_start_index, "queue_start_index");
10063 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10064 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10066 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10067 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10068 queue_num, "queue_num");
10069 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10070 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10071 queue_num_value, UINT8);
10073 cmdline_parse_inst_t cmd_queue_region = {
10074 .f = cmd_queue_region_parsed,
10076 .help_str = "set port <port_id> queue-region region_id <value> "
10077 "queue_start_index <value> queue_num <value>: Set a queue region",
10079 (void *)&cmd_queue_region_set,
10080 (void *)&cmd_queue_region_port,
10081 (void *)&cmd_queue_region_port_id,
10082 (void *)&cmd_queue_region_cmd,
10083 (void *)&cmd_queue_region_id,
10084 (void *)&cmd_queue_region_index,
10085 (void *)&cmd_queue_region_queue_start_index,
10086 (void *)&cmd_queue_region_queue_id,
10087 (void *)&cmd_queue_region_queue_num,
10088 (void *)&cmd_queue_region_queue_num_value,
10093 /* *** queue region and flowtype set *** */
10094 struct cmd_region_flowtype_result {
10095 cmdline_fixed_string_t set;
10096 cmdline_fixed_string_t port;
10098 cmdline_fixed_string_t cmd;
10099 cmdline_fixed_string_t region;
10101 cmdline_fixed_string_t flowtype;
10102 uint8_t flowtype_id;
10106 cmd_region_flowtype_parsed(void *parsed_result,
10107 __rte_unused struct cmdline *cl,
10108 __rte_unused void *data)
10110 struct cmd_region_flowtype_result *res = parsed_result;
10111 int ret = -ENOTSUP;
10112 #ifdef RTE_LIBRTE_I40E_PMD
10113 struct rte_pmd_i40e_queue_region_conf region_conf;
10114 enum rte_pmd_i40e_queue_region_op op_type;
10117 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10120 #ifdef RTE_LIBRTE_I40E_PMD
10121 memset(®ion_conf, 0, sizeof(region_conf));
10123 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10124 region_conf.region_id = res->region_id;
10125 region_conf.hw_flowtype = res->flowtype_id;
10127 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10128 op_type, ®ion_conf);
10135 printf("function not implemented or supported\n");
10138 printf("region flowtype config error: (%s)\n", strerror(-ret));
10142 cmdline_parse_token_string_t cmd_region_flowtype_set =
10143 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10145 cmdline_parse_token_string_t cmd_region_flowtype_port =
10146 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10148 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10149 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10151 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10152 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10153 cmd, "queue-region");
10154 cmdline_parse_token_string_t cmd_region_flowtype_index =
10155 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10156 region, "region_id");
10157 cmdline_parse_token_num_t cmd_region_flowtype_id =
10158 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10160 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10161 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10162 flowtype, "flowtype");
10163 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10164 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10165 flowtype_id, UINT8);
10166 cmdline_parse_inst_t cmd_region_flowtype = {
10167 .f = cmd_region_flowtype_parsed,
10169 .help_str = "set port <port_id> queue-region region_id <value> "
10170 "flowtype <value>: Set a flowtype region index",
10172 (void *)&cmd_region_flowtype_set,
10173 (void *)&cmd_region_flowtype_port,
10174 (void *)&cmd_region_flowtype_port_index,
10175 (void *)&cmd_region_flowtype_cmd,
10176 (void *)&cmd_region_flowtype_index,
10177 (void *)&cmd_region_flowtype_id,
10178 (void *)&cmd_region_flowtype_flow_index,
10179 (void *)&cmd_region_flowtype_flow_id,
10184 /* *** User Priority (UP) to queue region (region_id) set *** */
10185 struct cmd_user_priority_region_result {
10186 cmdline_fixed_string_t set;
10187 cmdline_fixed_string_t port;
10189 cmdline_fixed_string_t cmd;
10190 cmdline_fixed_string_t user_priority;
10191 uint8_t user_priority_id;
10192 cmdline_fixed_string_t region;
10197 cmd_user_priority_region_parsed(void *parsed_result,
10198 __rte_unused struct cmdline *cl,
10199 __rte_unused void *data)
10201 struct cmd_user_priority_region_result *res = parsed_result;
10202 int ret = -ENOTSUP;
10203 #ifdef RTE_LIBRTE_I40E_PMD
10204 struct rte_pmd_i40e_queue_region_conf region_conf;
10205 enum rte_pmd_i40e_queue_region_op op_type;
10208 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10211 #ifdef RTE_LIBRTE_I40E_PMD
10212 memset(®ion_conf, 0, sizeof(region_conf));
10213 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10214 region_conf.user_priority = res->user_priority_id;
10215 region_conf.region_id = res->region_id;
10217 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10218 op_type, ®ion_conf);
10225 printf("function not implemented or supported\n");
10228 printf("user_priority region config error: (%s)\n",
10233 cmdline_parse_token_string_t cmd_user_priority_region_set =
10234 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10236 cmdline_parse_token_string_t cmd_user_priority_region_port =
10237 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10239 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10240 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10242 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10243 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10244 cmd, "queue-region");
10245 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10246 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10247 user_priority, "UP");
10248 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10249 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10250 user_priority_id, UINT8);
10251 cmdline_parse_token_string_t cmd_user_priority_region_region =
10252 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10253 region, "region_id");
10254 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10255 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10258 cmdline_parse_inst_t cmd_user_priority_region = {
10259 .f = cmd_user_priority_region_parsed,
10261 .help_str = "set port <port_id> queue-region UP <value> "
10262 "region_id <value>: Set the mapping of User Priority (UP) "
10263 "to queue region (region_id) ",
10265 (void *)&cmd_user_priority_region_set,
10266 (void *)&cmd_user_priority_region_port,
10267 (void *)&cmd_user_priority_region_port_index,
10268 (void *)&cmd_user_priority_region_cmd,
10269 (void *)&cmd_user_priority_region_UP,
10270 (void *)&cmd_user_priority_region_UP_id,
10271 (void *)&cmd_user_priority_region_region,
10272 (void *)&cmd_user_priority_region_region_id,
10277 /* *** flush all queue region related configuration *** */
10278 struct cmd_flush_queue_region_result {
10279 cmdline_fixed_string_t set;
10280 cmdline_fixed_string_t port;
10282 cmdline_fixed_string_t cmd;
10283 cmdline_fixed_string_t flush;
10284 cmdline_fixed_string_t what;
10288 cmd_flush_queue_region_parsed(void *parsed_result,
10289 __rte_unused struct cmdline *cl,
10290 __rte_unused void *data)
10292 struct cmd_flush_queue_region_result *res = parsed_result;
10293 int ret = -ENOTSUP;
10294 #ifdef RTE_LIBRTE_I40E_PMD
10295 struct rte_pmd_i40e_queue_region_conf region_conf;
10296 enum rte_pmd_i40e_queue_region_op op_type;
10299 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10302 #ifdef RTE_LIBRTE_I40E_PMD
10303 memset(®ion_conf, 0, sizeof(region_conf));
10305 if (strcmp(res->what, "on") == 0)
10306 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10308 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10310 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10311 op_type, ®ion_conf);
10318 printf("function not implemented or supported\n");
10321 printf("queue region config flush error: (%s)\n",
10326 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10327 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10329 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10330 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10332 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10333 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10335 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10336 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10337 cmd, "queue-region");
10338 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10339 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10341 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10342 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10345 cmdline_parse_inst_t cmd_flush_queue_region = {
10346 .f = cmd_flush_queue_region_parsed,
10348 .help_str = "set port <port_id> queue-region flush on|off"
10349 ": flush all queue region related configuration",
10351 (void *)&cmd_flush_queue_region_set,
10352 (void *)&cmd_flush_queue_region_port,
10353 (void *)&cmd_flush_queue_region_port_index,
10354 (void *)&cmd_flush_queue_region_cmd,
10355 (void *)&cmd_flush_queue_region_flush,
10356 (void *)&cmd_flush_queue_region_what,
10361 /* *** get all queue region related configuration info *** */
10362 struct cmd_show_queue_region_info {
10363 cmdline_fixed_string_t show;
10364 cmdline_fixed_string_t port;
10366 cmdline_fixed_string_t cmd;
10370 cmd_show_queue_region_info_parsed(void *parsed_result,
10371 __rte_unused struct cmdline *cl,
10372 __rte_unused void *data)
10374 struct cmd_show_queue_region_info *res = parsed_result;
10375 int ret = -ENOTSUP;
10376 #ifdef RTE_LIBRTE_I40E_PMD
10377 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10378 enum rte_pmd_i40e_queue_region_op op_type;
10381 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10384 #ifdef RTE_LIBRTE_I40E_PMD
10385 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10387 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10389 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10390 op_type, &rte_pmd_regions);
10392 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10399 printf("function not implemented or supported\n");
10402 printf("queue region config info show error: (%s)\n",
10407 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10408 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10410 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10411 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10413 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10414 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10416 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10417 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10418 cmd, "queue-region");
10420 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10421 .f = cmd_show_queue_region_info_parsed,
10423 .help_str = "show port <port_id> queue-region"
10424 ": show all queue region related configuration info",
10426 (void *)&cmd_show_queue_region_info_get,
10427 (void *)&cmd_show_queue_region_info_port,
10428 (void *)&cmd_show_queue_region_info_port_index,
10429 (void *)&cmd_show_queue_region_info_cmd,
10434 /* *** ADD/REMOVE A 2tuple FILTER *** */
10435 struct cmd_2tuple_filter_result {
10436 cmdline_fixed_string_t filter;
10438 cmdline_fixed_string_t ops;
10439 cmdline_fixed_string_t dst_port;
10440 uint16_t dst_port_value;
10441 cmdline_fixed_string_t protocol;
10442 uint8_t protocol_value;
10443 cmdline_fixed_string_t mask;
10444 uint8_t mask_value;
10445 cmdline_fixed_string_t tcp_flags;
10446 uint8_t tcp_flags_value;
10447 cmdline_fixed_string_t priority;
10448 uint8_t priority_value;
10449 cmdline_fixed_string_t queue;
10454 cmd_2tuple_filter_parsed(void *parsed_result,
10455 __rte_unused struct cmdline *cl,
10456 __rte_unused void *data)
10458 struct rte_eth_ntuple_filter filter;
10459 struct cmd_2tuple_filter_result *res = parsed_result;
10462 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10464 printf("ntuple filter is not supported on port %u.\n",
10469 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10471 filter.flags = RTE_2TUPLE_FLAGS;
10472 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10473 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10474 filter.proto = res->protocol_value;
10475 filter.priority = res->priority_value;
10476 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10477 printf("nonzero tcp_flags is only meaningful"
10478 " when protocol is TCP.\n");
10481 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10482 printf("invalid TCP flags.\n");
10486 if (res->tcp_flags_value != 0) {
10487 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10488 filter.tcp_flags = res->tcp_flags_value;
10491 /* need convert to big endian. */
10492 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10493 filter.queue = res->queue_id;
10495 if (!strcmp(res->ops, "add"))
10496 ret = rte_eth_dev_filter_ctrl(res->port_id,
10497 RTE_ETH_FILTER_NTUPLE,
10498 RTE_ETH_FILTER_ADD,
10501 ret = rte_eth_dev_filter_ctrl(res->port_id,
10502 RTE_ETH_FILTER_NTUPLE,
10503 RTE_ETH_FILTER_DELETE,
10506 printf("2tuple filter programming error: (%s)\n",
10511 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10512 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10513 filter, "2tuple_filter");
10514 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10515 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10517 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10518 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10520 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10521 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10522 dst_port, "dst_port");
10523 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10524 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10525 dst_port_value, UINT16);
10526 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10527 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10528 protocol, "protocol");
10529 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10530 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10531 protocol_value, UINT8);
10532 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10533 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10535 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10536 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10538 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10539 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10540 tcp_flags, "tcp_flags");
10541 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10542 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10543 tcp_flags_value, UINT8);
10544 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10545 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10546 priority, "priority");
10547 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10548 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10549 priority_value, UINT8);
10550 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10551 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10553 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10554 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10557 cmdline_parse_inst_t cmd_2tuple_filter = {
10558 .f = cmd_2tuple_filter_parsed,
10560 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10561 "<value> mask <value> tcp_flags <value> priority <value> queue "
10562 "<queue_id>: Add a 2tuple filter",
10564 (void *)&cmd_2tuple_filter_filter,
10565 (void *)&cmd_2tuple_filter_port_id,
10566 (void *)&cmd_2tuple_filter_ops,
10567 (void *)&cmd_2tuple_filter_dst_port,
10568 (void *)&cmd_2tuple_filter_dst_port_value,
10569 (void *)&cmd_2tuple_filter_protocol,
10570 (void *)&cmd_2tuple_filter_protocol_value,
10571 (void *)&cmd_2tuple_filter_mask,
10572 (void *)&cmd_2tuple_filter_mask_value,
10573 (void *)&cmd_2tuple_filter_tcp_flags,
10574 (void *)&cmd_2tuple_filter_tcp_flags_value,
10575 (void *)&cmd_2tuple_filter_priority,
10576 (void *)&cmd_2tuple_filter_priority_value,
10577 (void *)&cmd_2tuple_filter_queue,
10578 (void *)&cmd_2tuple_filter_queue_id,
10583 /* *** ADD/REMOVE A 5tuple FILTER *** */
10584 struct cmd_5tuple_filter_result {
10585 cmdline_fixed_string_t filter;
10587 cmdline_fixed_string_t ops;
10588 cmdline_fixed_string_t dst_ip;
10589 cmdline_ipaddr_t dst_ip_value;
10590 cmdline_fixed_string_t src_ip;
10591 cmdline_ipaddr_t src_ip_value;
10592 cmdline_fixed_string_t dst_port;
10593 uint16_t dst_port_value;
10594 cmdline_fixed_string_t src_port;
10595 uint16_t src_port_value;
10596 cmdline_fixed_string_t protocol;
10597 uint8_t protocol_value;
10598 cmdline_fixed_string_t mask;
10599 uint8_t mask_value;
10600 cmdline_fixed_string_t tcp_flags;
10601 uint8_t tcp_flags_value;
10602 cmdline_fixed_string_t priority;
10603 uint8_t priority_value;
10604 cmdline_fixed_string_t queue;
10609 cmd_5tuple_filter_parsed(void *parsed_result,
10610 __rte_unused struct cmdline *cl,
10611 __rte_unused void *data)
10613 struct rte_eth_ntuple_filter filter;
10614 struct cmd_5tuple_filter_result *res = parsed_result;
10617 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10619 printf("ntuple filter is not supported on port %u.\n",
10624 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10626 filter.flags = RTE_5TUPLE_FLAGS;
10627 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10628 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10629 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10630 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10631 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10632 filter.proto = res->protocol_value;
10633 filter.priority = res->priority_value;
10634 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10635 printf("nonzero tcp_flags is only meaningful"
10636 " when protocol is TCP.\n");
10639 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10640 printf("invalid TCP flags.\n");
10644 if (res->tcp_flags_value != 0) {
10645 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10646 filter.tcp_flags = res->tcp_flags_value;
10649 if (res->dst_ip_value.family == AF_INET)
10650 /* no need to convert, already big endian. */
10651 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10653 if (filter.dst_ip_mask == 0) {
10654 printf("can not support ipv6 involved compare.\n");
10660 if (res->src_ip_value.family == AF_INET)
10661 /* no need to convert, already big endian. */
10662 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10664 if (filter.src_ip_mask == 0) {
10665 printf("can not support ipv6 involved compare.\n");
10670 /* need convert to big endian. */
10671 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10672 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10673 filter.queue = res->queue_id;
10675 if (!strcmp(res->ops, "add"))
10676 ret = rte_eth_dev_filter_ctrl(res->port_id,
10677 RTE_ETH_FILTER_NTUPLE,
10678 RTE_ETH_FILTER_ADD,
10681 ret = rte_eth_dev_filter_ctrl(res->port_id,
10682 RTE_ETH_FILTER_NTUPLE,
10683 RTE_ETH_FILTER_DELETE,
10686 printf("5tuple filter programming error: (%s)\n",
10690 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10691 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10692 filter, "5tuple_filter");
10693 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10694 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10696 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10697 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10699 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10700 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10702 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10703 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10705 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10706 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10708 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10709 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10711 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10712 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10713 dst_port, "dst_port");
10714 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10715 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10716 dst_port_value, UINT16);
10717 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10718 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10719 src_port, "src_port");
10720 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10721 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10722 src_port_value, UINT16);
10723 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10724 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10725 protocol, "protocol");
10726 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10727 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10728 protocol_value, UINT8);
10729 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10730 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10732 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10733 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10735 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10736 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10737 tcp_flags, "tcp_flags");
10738 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10739 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10740 tcp_flags_value, UINT8);
10741 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10742 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10743 priority, "priority");
10744 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10745 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10746 priority_value, UINT8);
10747 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10748 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10750 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10751 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10754 cmdline_parse_inst_t cmd_5tuple_filter = {
10755 .f = cmd_5tuple_filter_parsed,
10757 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10758 "src_ip <value> dst_port <value> src_port <value> "
10759 "protocol <value> mask <value> tcp_flags <value> "
10760 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10762 (void *)&cmd_5tuple_filter_filter,
10763 (void *)&cmd_5tuple_filter_port_id,
10764 (void *)&cmd_5tuple_filter_ops,
10765 (void *)&cmd_5tuple_filter_dst_ip,
10766 (void *)&cmd_5tuple_filter_dst_ip_value,
10767 (void *)&cmd_5tuple_filter_src_ip,
10768 (void *)&cmd_5tuple_filter_src_ip_value,
10769 (void *)&cmd_5tuple_filter_dst_port,
10770 (void *)&cmd_5tuple_filter_dst_port_value,
10771 (void *)&cmd_5tuple_filter_src_port,
10772 (void *)&cmd_5tuple_filter_src_port_value,
10773 (void *)&cmd_5tuple_filter_protocol,
10774 (void *)&cmd_5tuple_filter_protocol_value,
10775 (void *)&cmd_5tuple_filter_mask,
10776 (void *)&cmd_5tuple_filter_mask_value,
10777 (void *)&cmd_5tuple_filter_tcp_flags,
10778 (void *)&cmd_5tuple_filter_tcp_flags_value,
10779 (void *)&cmd_5tuple_filter_priority,
10780 (void *)&cmd_5tuple_filter_priority_value,
10781 (void *)&cmd_5tuple_filter_queue,
10782 (void *)&cmd_5tuple_filter_queue_id,
10787 /* *** ADD/REMOVE A flex FILTER *** */
10788 struct cmd_flex_filter_result {
10789 cmdline_fixed_string_t filter;
10790 cmdline_fixed_string_t ops;
10792 cmdline_fixed_string_t len;
10794 cmdline_fixed_string_t bytes;
10795 cmdline_fixed_string_t bytes_value;
10796 cmdline_fixed_string_t mask;
10797 cmdline_fixed_string_t mask_value;
10798 cmdline_fixed_string_t priority;
10799 uint8_t priority_value;
10800 cmdline_fixed_string_t queue;
10804 static int xdigit2val(unsigned char c)
10809 else if (isupper(c))
10810 val = c - 'A' + 10;
10812 val = c - 'a' + 10;
10817 cmd_flex_filter_parsed(void *parsed_result,
10818 __rte_unused struct cmdline *cl,
10819 __rte_unused void *data)
10822 struct rte_eth_flex_filter filter;
10823 struct cmd_flex_filter_result *res = parsed_result;
10824 char *bytes_ptr, *mask_ptr;
10825 uint16_t len, i, j = 0;
10830 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10831 printf("the len exceed the max length 128\n");
10834 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10835 filter.len = res->len_value;
10836 filter.priority = res->priority_value;
10837 filter.queue = res->queue_id;
10838 bytes_ptr = res->bytes_value;
10839 mask_ptr = res->mask_value;
10841 /* translate bytes string to array. */
10842 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10843 (bytes_ptr[1] == 'X')))
10845 len = strnlen(bytes_ptr, res->len_value * 2);
10846 if (len == 0 || (len % 8 != 0)) {
10847 printf("please check len and bytes input\n");
10850 for (i = 0; i < len; i++) {
10852 if (isxdigit(c) == 0) {
10853 /* invalid characters. */
10854 printf("invalid input\n");
10857 val = xdigit2val(c);
10860 filter.bytes[j] = byte;
10861 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10868 /* translate mask string to uint8_t array. */
10869 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10870 (mask_ptr[1] == 'X')))
10872 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10874 printf("invalid input\n");
10879 for (i = 0; i < len; i++) {
10881 if (isxdigit(c) == 0) {
10882 /* invalid characters. */
10883 printf("invalid input\n");
10886 val = xdigit2val(c);
10889 filter.mask[j] = byte;
10890 printf("mask[%d]:%02x ", j, filter.mask[j]);
10898 if (!strcmp(res->ops, "add"))
10899 ret = rte_eth_dev_filter_ctrl(res->port_id,
10900 RTE_ETH_FILTER_FLEXIBLE,
10901 RTE_ETH_FILTER_ADD,
10904 ret = rte_eth_dev_filter_ctrl(res->port_id,
10905 RTE_ETH_FILTER_FLEXIBLE,
10906 RTE_ETH_FILTER_DELETE,
10910 printf("flex filter setting error: (%s)\n", strerror(-ret));
10913 cmdline_parse_token_string_t cmd_flex_filter_filter =
10914 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10915 filter, "flex_filter");
10916 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10917 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10919 cmdline_parse_token_string_t cmd_flex_filter_ops =
10920 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10922 cmdline_parse_token_string_t cmd_flex_filter_len =
10923 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10925 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10926 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10928 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10929 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10931 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10932 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10933 bytes_value, NULL);
10934 cmdline_parse_token_string_t cmd_flex_filter_mask =
10935 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10937 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10938 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10940 cmdline_parse_token_string_t cmd_flex_filter_priority =
10941 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10942 priority, "priority");
10943 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10944 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10945 priority_value, UINT8);
10946 cmdline_parse_token_string_t cmd_flex_filter_queue =
10947 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10949 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10950 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10952 cmdline_parse_inst_t cmd_flex_filter = {
10953 .f = cmd_flex_filter_parsed,
10955 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10956 "<value> mask <value> priority <value> queue <queue_id>: "
10957 "Add/Del a flex filter",
10959 (void *)&cmd_flex_filter_filter,
10960 (void *)&cmd_flex_filter_port_id,
10961 (void *)&cmd_flex_filter_ops,
10962 (void *)&cmd_flex_filter_len,
10963 (void *)&cmd_flex_filter_len_value,
10964 (void *)&cmd_flex_filter_bytes,
10965 (void *)&cmd_flex_filter_bytes_value,
10966 (void *)&cmd_flex_filter_mask,
10967 (void *)&cmd_flex_filter_mask_value,
10968 (void *)&cmd_flex_filter_priority,
10969 (void *)&cmd_flex_filter_priority_value,
10970 (void *)&cmd_flex_filter_queue,
10971 (void *)&cmd_flex_filter_queue_id,
10976 /* *** Filters Control *** */
10978 /* *** deal with ethertype filter *** */
10979 struct cmd_ethertype_filter_result {
10980 cmdline_fixed_string_t filter;
10982 cmdline_fixed_string_t ops;
10983 cmdline_fixed_string_t mac;
10984 struct rte_ether_addr mac_addr;
10985 cmdline_fixed_string_t ethertype;
10986 uint16_t ethertype_value;
10987 cmdline_fixed_string_t drop;
10988 cmdline_fixed_string_t queue;
10992 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10993 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10994 filter, "ethertype_filter");
10995 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10996 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10998 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10999 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11001 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
11002 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11003 mac, "mac_addr#mac_ignr");
11004 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
11005 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
11007 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
11008 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11009 ethertype, "ethertype");
11010 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
11011 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
11012 ethertype_value, UINT16);
11013 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
11014 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11016 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
11017 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11019 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
11020 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
11024 cmd_ethertype_filter_parsed(void *parsed_result,
11025 __rte_unused struct cmdline *cl,
11026 __rte_unused void *data)
11028 struct cmd_ethertype_filter_result *res = parsed_result;
11029 struct rte_eth_ethertype_filter filter;
11032 ret = rte_eth_dev_filter_supported(res->port_id,
11033 RTE_ETH_FILTER_ETHERTYPE);
11035 printf("ethertype filter is not supported on port %u.\n",
11040 memset(&filter, 0, sizeof(filter));
11041 if (!strcmp(res->mac, "mac_addr")) {
11042 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
11043 rte_memcpy(&filter.mac_addr, &res->mac_addr,
11044 sizeof(struct rte_ether_addr));
11046 if (!strcmp(res->drop, "drop"))
11047 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
11048 filter.ether_type = res->ethertype_value;
11049 filter.queue = res->queue_id;
11051 if (!strcmp(res->ops, "add"))
11052 ret = rte_eth_dev_filter_ctrl(res->port_id,
11053 RTE_ETH_FILTER_ETHERTYPE,
11054 RTE_ETH_FILTER_ADD,
11057 ret = rte_eth_dev_filter_ctrl(res->port_id,
11058 RTE_ETH_FILTER_ETHERTYPE,
11059 RTE_ETH_FILTER_DELETE,
11062 printf("ethertype filter programming error: (%s)\n",
11066 cmdline_parse_inst_t cmd_ethertype_filter = {
11067 .f = cmd_ethertype_filter_parsed,
11069 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
11070 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
11071 "Add or delete an ethertype filter entry",
11073 (void *)&cmd_ethertype_filter_filter,
11074 (void *)&cmd_ethertype_filter_port_id,
11075 (void *)&cmd_ethertype_filter_ops,
11076 (void *)&cmd_ethertype_filter_mac,
11077 (void *)&cmd_ethertype_filter_mac_addr,
11078 (void *)&cmd_ethertype_filter_ethertype,
11079 (void *)&cmd_ethertype_filter_ethertype_value,
11080 (void *)&cmd_ethertype_filter_drop,
11081 (void *)&cmd_ethertype_filter_queue,
11082 (void *)&cmd_ethertype_filter_queue_id,
11087 /* *** deal with flow director filter *** */
11088 struct cmd_flow_director_result {
11089 cmdline_fixed_string_t flow_director_filter;
11091 cmdline_fixed_string_t mode;
11092 cmdline_fixed_string_t mode_value;
11093 cmdline_fixed_string_t ops;
11094 cmdline_fixed_string_t flow;
11095 cmdline_fixed_string_t flow_type;
11096 cmdline_fixed_string_t ether;
11097 uint16_t ether_type;
11098 cmdline_fixed_string_t src;
11099 cmdline_ipaddr_t ip_src;
11101 cmdline_fixed_string_t dst;
11102 cmdline_ipaddr_t ip_dst;
11104 cmdline_fixed_string_t verify_tag;
11105 uint32_t verify_tag_value;
11106 cmdline_fixed_string_t tos;
11108 cmdline_fixed_string_t proto;
11109 uint8_t proto_value;
11110 cmdline_fixed_string_t ttl;
11112 cmdline_fixed_string_t vlan;
11113 uint16_t vlan_value;
11114 cmdline_fixed_string_t flexbytes;
11115 cmdline_fixed_string_t flexbytes_value;
11116 cmdline_fixed_string_t pf_vf;
11117 cmdline_fixed_string_t drop;
11118 cmdline_fixed_string_t queue;
11120 cmdline_fixed_string_t fd_id;
11121 uint32_t fd_id_value;
11122 cmdline_fixed_string_t mac;
11123 struct rte_ether_addr mac_addr;
11124 cmdline_fixed_string_t tunnel;
11125 cmdline_fixed_string_t tunnel_type;
11126 cmdline_fixed_string_t tunnel_id;
11127 uint32_t tunnel_id_value;
11128 cmdline_fixed_string_t packet;
11133 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
11136 const char *p, *p0 = q_arg;
11138 unsigned long int_fld;
11139 char *str_fld[max_num];
11144 p = strchr(p0, '(');
11148 p0 = strchr(p, ')');
11153 if (size >= sizeof(s))
11156 snprintf(s, sizeof(s), "%.*s", size, p);
11157 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11158 if (ret < 0 || ret > max_num)
11160 for (i = 0; i < ret; i++) {
11162 int_fld = strtoul(str_fld[i], &end, 0);
11163 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
11165 flexbytes[i] = (uint8_t)int_fld;
11171 str2flowtype(char *string)
11174 static const struct {
11177 } flowtype_str[] = {
11178 {"raw", RTE_ETH_FLOW_RAW},
11179 {"ipv4", RTE_ETH_FLOW_IPV4},
11180 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11181 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11182 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11183 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11184 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11185 {"ipv6", RTE_ETH_FLOW_IPV6},
11186 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11187 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11188 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11189 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11190 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11191 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11194 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
11195 if (!strcmp(flowtype_str[i].str, string))
11196 return flowtype_str[i].type;
11199 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
11200 return (uint16_t)atoi(string);
11202 return RTE_ETH_FLOW_UNKNOWN;
11205 static enum rte_eth_fdir_tunnel_type
11206 str2fdir_tunneltype(char *string)
11210 static const struct {
11212 enum rte_eth_fdir_tunnel_type type;
11213 } tunneltype_str[] = {
11214 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
11215 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
11218 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
11219 if (!strcmp(tunneltype_str[i].str, string))
11220 return tunneltype_str[i].type;
11222 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
11225 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
11227 if ((ip_addr).family == AF_INET) \
11228 (ip) = (ip_addr).addr.ipv4.s_addr; \
11230 printf("invalid parameter.\n"); \
11235 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
11237 if ((ip_addr).family == AF_INET6) \
11238 rte_memcpy(&(ip), \
11239 &((ip_addr).addr.ipv6), \
11240 sizeof(struct in6_addr)); \
11242 printf("invalid parameter.\n"); \
11248 cmd_flow_director_filter_parsed(void *parsed_result,
11249 __rte_unused struct cmdline *cl,
11250 __rte_unused void *data)
11252 struct cmd_flow_director_result *res = parsed_result;
11253 struct rte_eth_fdir_filter entry;
11254 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11256 unsigned long vf_id;
11259 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11261 printf("flow director is not supported on port %u.\n",
11265 memset(flexbytes, 0, sizeof(flexbytes));
11266 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11268 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11269 if (strcmp(res->mode_value, "MAC-VLAN")) {
11270 printf("Please set mode to MAC-VLAN.\n");
11273 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11274 if (strcmp(res->mode_value, "Tunnel")) {
11275 printf("Please set mode to Tunnel.\n");
11279 if (!strcmp(res->mode_value, "raw")) {
11280 #ifdef RTE_LIBRTE_I40E_PMD
11281 struct rte_pmd_i40e_flow_type_mapping
11282 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11283 struct rte_pmd_i40e_pkt_template_conf conf;
11284 uint16_t flow_type = str2flowtype(res->flow_type);
11285 uint16_t i, port = res->port_id;
11288 memset(&conf, 0, sizeof(conf));
11290 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11291 printf("Invalid flow type specified.\n");
11294 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11298 if (mapping[flow_type].pctype == 0ULL) {
11299 printf("Invalid flow type specified.\n");
11302 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11303 if (mapping[flow_type].pctype & (1ULL << i)) {
11304 conf.input.pctype = i;
11309 conf.input.packet = open_file(res->filepath,
11310 &conf.input.length);
11311 if (!conf.input.packet)
11313 if (!strcmp(res->drop, "drop"))
11314 conf.action.behavior =
11315 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11317 conf.action.behavior =
11318 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11319 conf.action.report_status =
11320 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11321 conf.action.rx_queue = res->queue_id;
11322 conf.soft_id = res->fd_id_value;
11323 add = strcmp(res->ops, "del") ? 1 : 0;
11324 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11328 printf("flow director config error: (%s)\n",
11330 close_file(conf.input.packet);
11333 } else if (strcmp(res->mode_value, "IP")) {
11334 printf("Please set mode to IP or raw.\n");
11337 entry.input.flow_type = str2flowtype(res->flow_type);
11340 ret = parse_flexbytes(res->flexbytes_value,
11342 RTE_ETH_FDIR_MAX_FLEXLEN);
11344 printf("error: Cannot parse flexbytes input.\n");
11348 switch (entry.input.flow_type) {
11349 case RTE_ETH_FLOW_FRAG_IPV4:
11350 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11351 entry.input.flow.ip4_flow.proto = res->proto_value;
11353 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11354 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11355 IPV4_ADDR_TO_UINT(res->ip_dst,
11356 entry.input.flow.ip4_flow.dst_ip);
11357 IPV4_ADDR_TO_UINT(res->ip_src,
11358 entry.input.flow.ip4_flow.src_ip);
11359 entry.input.flow.ip4_flow.tos = res->tos_value;
11360 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11361 /* need convert to big endian. */
11362 entry.input.flow.udp4_flow.dst_port =
11363 rte_cpu_to_be_16(res->port_dst);
11364 entry.input.flow.udp4_flow.src_port =
11365 rte_cpu_to_be_16(res->port_src);
11367 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11368 IPV4_ADDR_TO_UINT(res->ip_dst,
11369 entry.input.flow.sctp4_flow.ip.dst_ip);
11370 IPV4_ADDR_TO_UINT(res->ip_src,
11371 entry.input.flow.sctp4_flow.ip.src_ip);
11372 entry.input.flow.ip4_flow.tos = res->tos_value;
11373 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11374 /* need convert to big endian. */
11375 entry.input.flow.sctp4_flow.dst_port =
11376 rte_cpu_to_be_16(res->port_dst);
11377 entry.input.flow.sctp4_flow.src_port =
11378 rte_cpu_to_be_16(res->port_src);
11379 entry.input.flow.sctp4_flow.verify_tag =
11380 rte_cpu_to_be_32(res->verify_tag_value);
11382 case RTE_ETH_FLOW_FRAG_IPV6:
11383 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11384 entry.input.flow.ipv6_flow.proto = res->proto_value;
11386 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11387 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11388 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11389 entry.input.flow.ipv6_flow.dst_ip);
11390 IPV6_ADDR_TO_ARRAY(res->ip_src,
11391 entry.input.flow.ipv6_flow.src_ip);
11392 entry.input.flow.ipv6_flow.tc = res->tos_value;
11393 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11394 /* need convert to big endian. */
11395 entry.input.flow.udp6_flow.dst_port =
11396 rte_cpu_to_be_16(res->port_dst);
11397 entry.input.flow.udp6_flow.src_port =
11398 rte_cpu_to_be_16(res->port_src);
11400 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11401 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11402 entry.input.flow.sctp6_flow.ip.dst_ip);
11403 IPV6_ADDR_TO_ARRAY(res->ip_src,
11404 entry.input.flow.sctp6_flow.ip.src_ip);
11405 entry.input.flow.ipv6_flow.tc = res->tos_value;
11406 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11407 /* need convert to big endian. */
11408 entry.input.flow.sctp6_flow.dst_port =
11409 rte_cpu_to_be_16(res->port_dst);
11410 entry.input.flow.sctp6_flow.src_port =
11411 rte_cpu_to_be_16(res->port_src);
11412 entry.input.flow.sctp6_flow.verify_tag =
11413 rte_cpu_to_be_32(res->verify_tag_value);
11415 case RTE_ETH_FLOW_L2_PAYLOAD:
11416 entry.input.flow.l2_flow.ether_type =
11417 rte_cpu_to_be_16(res->ether_type);
11423 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11424 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11426 sizeof(struct rte_ether_addr));
11428 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11429 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11431 sizeof(struct rte_ether_addr));
11432 entry.input.flow.tunnel_flow.tunnel_type =
11433 str2fdir_tunneltype(res->tunnel_type);
11434 entry.input.flow.tunnel_flow.tunnel_id =
11435 rte_cpu_to_be_32(res->tunnel_id_value);
11438 rte_memcpy(entry.input.flow_ext.flexbytes,
11440 RTE_ETH_FDIR_MAX_FLEXLEN);
11442 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11444 entry.action.flex_off = 0; /*use 0 by default */
11445 if (!strcmp(res->drop, "drop"))
11446 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11448 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11450 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11451 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11452 if (!strcmp(res->pf_vf, "pf"))
11453 entry.input.flow_ext.is_vf = 0;
11454 else if (!strncmp(res->pf_vf, "vf", 2)) {
11455 struct rte_eth_dev_info dev_info;
11457 ret = eth_dev_info_get_print_err(res->port_id,
11463 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11464 if (errno != 0 || *end != '\0' ||
11465 vf_id >= dev_info.max_vfs) {
11466 printf("invalid parameter %s.\n", res->pf_vf);
11469 entry.input.flow_ext.is_vf = 1;
11470 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11472 printf("invalid parameter %s.\n", res->pf_vf);
11477 /* set to report FD ID by default */
11478 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11479 entry.action.rx_queue = res->queue_id;
11480 entry.soft_id = res->fd_id_value;
11481 if (!strcmp(res->ops, "add"))
11482 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11483 RTE_ETH_FILTER_ADD, &entry);
11484 else if (!strcmp(res->ops, "del"))
11485 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11486 RTE_ETH_FILTER_DELETE, &entry);
11488 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11489 RTE_ETH_FILTER_UPDATE, &entry);
11491 printf("flow director programming error: (%s)\n",
11495 cmdline_parse_token_string_t cmd_flow_director_filter =
11496 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11497 flow_director_filter, "flow_director_filter");
11498 cmdline_parse_token_num_t cmd_flow_director_port_id =
11499 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11501 cmdline_parse_token_string_t cmd_flow_director_ops =
11502 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11503 ops, "add#del#update");
11504 cmdline_parse_token_string_t cmd_flow_director_flow =
11505 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11507 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11508 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11510 cmdline_parse_token_string_t cmd_flow_director_ether =
11511 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11513 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11514 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11515 ether_type, UINT16);
11516 cmdline_parse_token_string_t cmd_flow_director_src =
11517 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11519 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11520 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11522 cmdline_parse_token_num_t cmd_flow_director_port_src =
11523 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11525 cmdline_parse_token_string_t cmd_flow_director_dst =
11526 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11528 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11529 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11531 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11532 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11534 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11535 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11536 verify_tag, "verify_tag");
11537 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11538 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11539 verify_tag_value, UINT32);
11540 cmdline_parse_token_string_t cmd_flow_director_tos =
11541 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11543 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11544 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11546 cmdline_parse_token_string_t cmd_flow_director_proto =
11547 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11549 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11550 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11551 proto_value, UINT8);
11552 cmdline_parse_token_string_t cmd_flow_director_ttl =
11553 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11555 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11556 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11558 cmdline_parse_token_string_t cmd_flow_director_vlan =
11559 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11561 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11562 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11563 vlan_value, UINT16);
11564 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11565 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11566 flexbytes, "flexbytes");
11567 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11568 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11569 flexbytes_value, NULL);
11570 cmdline_parse_token_string_t cmd_flow_director_drop =
11571 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11573 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11574 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11576 cmdline_parse_token_string_t cmd_flow_director_queue =
11577 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11579 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11580 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11582 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11583 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11585 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11586 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11587 fd_id_value, UINT32);
11589 cmdline_parse_token_string_t cmd_flow_director_mode =
11590 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11592 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11593 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11595 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11596 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11597 mode_value, "MAC-VLAN");
11598 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11599 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11600 mode_value, "Tunnel");
11601 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11602 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11603 mode_value, "raw");
11604 cmdline_parse_token_string_t cmd_flow_director_mac =
11605 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11607 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11608 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11610 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11611 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11613 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11614 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11615 tunnel_type, "NVGRE#VxLAN");
11616 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11617 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11618 tunnel_id, "tunnel-id");
11619 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11620 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11621 tunnel_id_value, UINT32);
11622 cmdline_parse_token_string_t cmd_flow_director_packet =
11623 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11625 cmdline_parse_token_string_t cmd_flow_director_filepath =
11626 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11629 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11630 .f = cmd_flow_director_filter_parsed,
11632 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11633 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11634 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11635 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11636 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11637 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11638 "fd_id <fd_id_value>: "
11639 "Add or delete an ip flow director entry on NIC",
11641 (void *)&cmd_flow_director_filter,
11642 (void *)&cmd_flow_director_port_id,
11643 (void *)&cmd_flow_director_mode,
11644 (void *)&cmd_flow_director_mode_ip,
11645 (void *)&cmd_flow_director_ops,
11646 (void *)&cmd_flow_director_flow,
11647 (void *)&cmd_flow_director_flow_type,
11648 (void *)&cmd_flow_director_src,
11649 (void *)&cmd_flow_director_ip_src,
11650 (void *)&cmd_flow_director_dst,
11651 (void *)&cmd_flow_director_ip_dst,
11652 (void *)&cmd_flow_director_tos,
11653 (void *)&cmd_flow_director_tos_value,
11654 (void *)&cmd_flow_director_proto,
11655 (void *)&cmd_flow_director_proto_value,
11656 (void *)&cmd_flow_director_ttl,
11657 (void *)&cmd_flow_director_ttl_value,
11658 (void *)&cmd_flow_director_vlan,
11659 (void *)&cmd_flow_director_vlan_value,
11660 (void *)&cmd_flow_director_flexbytes,
11661 (void *)&cmd_flow_director_flexbytes_value,
11662 (void *)&cmd_flow_director_drop,
11663 (void *)&cmd_flow_director_pf_vf,
11664 (void *)&cmd_flow_director_queue,
11665 (void *)&cmd_flow_director_queue_id,
11666 (void *)&cmd_flow_director_fd_id,
11667 (void *)&cmd_flow_director_fd_id_value,
11672 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11673 .f = cmd_flow_director_filter_parsed,
11675 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11676 "director entry on NIC",
11678 (void *)&cmd_flow_director_filter,
11679 (void *)&cmd_flow_director_port_id,
11680 (void *)&cmd_flow_director_mode,
11681 (void *)&cmd_flow_director_mode_ip,
11682 (void *)&cmd_flow_director_ops,
11683 (void *)&cmd_flow_director_flow,
11684 (void *)&cmd_flow_director_flow_type,
11685 (void *)&cmd_flow_director_src,
11686 (void *)&cmd_flow_director_ip_src,
11687 (void *)&cmd_flow_director_port_src,
11688 (void *)&cmd_flow_director_dst,
11689 (void *)&cmd_flow_director_ip_dst,
11690 (void *)&cmd_flow_director_port_dst,
11691 (void *)&cmd_flow_director_tos,
11692 (void *)&cmd_flow_director_tos_value,
11693 (void *)&cmd_flow_director_ttl,
11694 (void *)&cmd_flow_director_ttl_value,
11695 (void *)&cmd_flow_director_vlan,
11696 (void *)&cmd_flow_director_vlan_value,
11697 (void *)&cmd_flow_director_flexbytes,
11698 (void *)&cmd_flow_director_flexbytes_value,
11699 (void *)&cmd_flow_director_drop,
11700 (void *)&cmd_flow_director_pf_vf,
11701 (void *)&cmd_flow_director_queue,
11702 (void *)&cmd_flow_director_queue_id,
11703 (void *)&cmd_flow_director_fd_id,
11704 (void *)&cmd_flow_director_fd_id_value,
11709 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11710 .f = cmd_flow_director_filter_parsed,
11712 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11713 "director entry on NIC",
11715 (void *)&cmd_flow_director_filter,
11716 (void *)&cmd_flow_director_port_id,
11717 (void *)&cmd_flow_director_mode,
11718 (void *)&cmd_flow_director_mode_ip,
11719 (void *)&cmd_flow_director_ops,
11720 (void *)&cmd_flow_director_flow,
11721 (void *)&cmd_flow_director_flow_type,
11722 (void *)&cmd_flow_director_src,
11723 (void *)&cmd_flow_director_ip_src,
11724 (void *)&cmd_flow_director_port_src,
11725 (void *)&cmd_flow_director_dst,
11726 (void *)&cmd_flow_director_ip_dst,
11727 (void *)&cmd_flow_director_port_dst,
11728 (void *)&cmd_flow_director_verify_tag,
11729 (void *)&cmd_flow_director_verify_tag_value,
11730 (void *)&cmd_flow_director_tos,
11731 (void *)&cmd_flow_director_tos_value,
11732 (void *)&cmd_flow_director_ttl,
11733 (void *)&cmd_flow_director_ttl_value,
11734 (void *)&cmd_flow_director_vlan,
11735 (void *)&cmd_flow_director_vlan_value,
11736 (void *)&cmd_flow_director_flexbytes,
11737 (void *)&cmd_flow_director_flexbytes_value,
11738 (void *)&cmd_flow_director_drop,
11739 (void *)&cmd_flow_director_pf_vf,
11740 (void *)&cmd_flow_director_queue,
11741 (void *)&cmd_flow_director_queue_id,
11742 (void *)&cmd_flow_director_fd_id,
11743 (void *)&cmd_flow_director_fd_id_value,
11748 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11749 .f = cmd_flow_director_filter_parsed,
11751 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11752 "director entry on NIC",
11754 (void *)&cmd_flow_director_filter,
11755 (void *)&cmd_flow_director_port_id,
11756 (void *)&cmd_flow_director_mode,
11757 (void *)&cmd_flow_director_mode_ip,
11758 (void *)&cmd_flow_director_ops,
11759 (void *)&cmd_flow_director_flow,
11760 (void *)&cmd_flow_director_flow_type,
11761 (void *)&cmd_flow_director_ether,
11762 (void *)&cmd_flow_director_ether_type,
11763 (void *)&cmd_flow_director_flexbytes,
11764 (void *)&cmd_flow_director_flexbytes_value,
11765 (void *)&cmd_flow_director_drop,
11766 (void *)&cmd_flow_director_pf_vf,
11767 (void *)&cmd_flow_director_queue,
11768 (void *)&cmd_flow_director_queue_id,
11769 (void *)&cmd_flow_director_fd_id,
11770 (void *)&cmd_flow_director_fd_id_value,
11775 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11776 .f = cmd_flow_director_filter_parsed,
11778 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11779 "director entry on NIC",
11781 (void *)&cmd_flow_director_filter,
11782 (void *)&cmd_flow_director_port_id,
11783 (void *)&cmd_flow_director_mode,
11784 (void *)&cmd_flow_director_mode_mac_vlan,
11785 (void *)&cmd_flow_director_ops,
11786 (void *)&cmd_flow_director_mac,
11787 (void *)&cmd_flow_director_mac_addr,
11788 (void *)&cmd_flow_director_vlan,
11789 (void *)&cmd_flow_director_vlan_value,
11790 (void *)&cmd_flow_director_flexbytes,
11791 (void *)&cmd_flow_director_flexbytes_value,
11792 (void *)&cmd_flow_director_drop,
11793 (void *)&cmd_flow_director_queue,
11794 (void *)&cmd_flow_director_queue_id,
11795 (void *)&cmd_flow_director_fd_id,
11796 (void *)&cmd_flow_director_fd_id_value,
11801 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11802 .f = cmd_flow_director_filter_parsed,
11804 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11805 "director entry on NIC",
11807 (void *)&cmd_flow_director_filter,
11808 (void *)&cmd_flow_director_port_id,
11809 (void *)&cmd_flow_director_mode,
11810 (void *)&cmd_flow_director_mode_tunnel,
11811 (void *)&cmd_flow_director_ops,
11812 (void *)&cmd_flow_director_mac,
11813 (void *)&cmd_flow_director_mac_addr,
11814 (void *)&cmd_flow_director_vlan,
11815 (void *)&cmd_flow_director_vlan_value,
11816 (void *)&cmd_flow_director_tunnel,
11817 (void *)&cmd_flow_director_tunnel_type,
11818 (void *)&cmd_flow_director_tunnel_id,
11819 (void *)&cmd_flow_director_tunnel_id_value,
11820 (void *)&cmd_flow_director_flexbytes,
11821 (void *)&cmd_flow_director_flexbytes_value,
11822 (void *)&cmd_flow_director_drop,
11823 (void *)&cmd_flow_director_queue,
11824 (void *)&cmd_flow_director_queue_id,
11825 (void *)&cmd_flow_director_fd_id,
11826 (void *)&cmd_flow_director_fd_id_value,
11831 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11832 .f = cmd_flow_director_filter_parsed,
11834 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11835 "director entry on NIC",
11837 (void *)&cmd_flow_director_filter,
11838 (void *)&cmd_flow_director_port_id,
11839 (void *)&cmd_flow_director_mode,
11840 (void *)&cmd_flow_director_mode_raw,
11841 (void *)&cmd_flow_director_ops,
11842 (void *)&cmd_flow_director_flow,
11843 (void *)&cmd_flow_director_flow_type,
11844 (void *)&cmd_flow_director_drop,
11845 (void *)&cmd_flow_director_queue,
11846 (void *)&cmd_flow_director_queue_id,
11847 (void *)&cmd_flow_director_fd_id,
11848 (void *)&cmd_flow_director_fd_id_value,
11849 (void *)&cmd_flow_director_packet,
11850 (void *)&cmd_flow_director_filepath,
11855 struct cmd_flush_flow_director_result {
11856 cmdline_fixed_string_t flush_flow_director;
11860 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11861 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11862 flush_flow_director, "flush_flow_director");
11863 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11864 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11868 cmd_flush_flow_director_parsed(void *parsed_result,
11869 __rte_unused struct cmdline *cl,
11870 __rte_unused void *data)
11872 struct cmd_flow_director_result *res = parsed_result;
11875 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11877 printf("flow director is not supported on port %u.\n",
11882 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11883 RTE_ETH_FILTER_FLUSH, NULL);
11885 printf("flow director table flushing error: (%s)\n",
11889 cmdline_parse_inst_t cmd_flush_flow_director = {
11890 .f = cmd_flush_flow_director_parsed,
11892 .help_str = "flush_flow_director <port_id>: "
11893 "Flush all flow director entries of a device on NIC",
11895 (void *)&cmd_flush_flow_director_flush,
11896 (void *)&cmd_flush_flow_director_port_id,
11901 /* *** deal with flow director mask *** */
11902 struct cmd_flow_director_mask_result {
11903 cmdline_fixed_string_t flow_director_mask;
11905 cmdline_fixed_string_t mode;
11906 cmdline_fixed_string_t mode_value;
11907 cmdline_fixed_string_t vlan;
11908 uint16_t vlan_mask;
11909 cmdline_fixed_string_t src_mask;
11910 cmdline_ipaddr_t ipv4_src;
11911 cmdline_ipaddr_t ipv6_src;
11913 cmdline_fixed_string_t dst_mask;
11914 cmdline_ipaddr_t ipv4_dst;
11915 cmdline_ipaddr_t ipv6_dst;
11917 cmdline_fixed_string_t mac;
11918 uint8_t mac_addr_byte_mask;
11919 cmdline_fixed_string_t tunnel_id;
11920 uint32_t tunnel_id_mask;
11921 cmdline_fixed_string_t tunnel_type;
11922 uint8_t tunnel_type_mask;
11926 cmd_flow_director_mask_parsed(void *parsed_result,
11927 __rte_unused struct cmdline *cl,
11928 __rte_unused void *data)
11930 struct cmd_flow_director_mask_result *res = parsed_result;
11931 struct rte_eth_fdir_masks *mask;
11932 struct rte_port *port;
11934 port = &ports[res->port_id];
11935 /** Check if the port is not started **/
11936 if (port->port_status != RTE_PORT_STOPPED) {
11937 printf("Please stop port %d first\n", res->port_id);
11941 mask = &port->dev_conf.fdir_conf.mask;
11943 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11944 if (strcmp(res->mode_value, "MAC-VLAN")) {
11945 printf("Please set mode to MAC-VLAN.\n");
11949 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11950 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11951 if (strcmp(res->mode_value, "Tunnel")) {
11952 printf("Please set mode to Tunnel.\n");
11956 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11957 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11958 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11959 mask->tunnel_type_mask = res->tunnel_type_mask;
11961 if (strcmp(res->mode_value, "IP")) {
11962 printf("Please set mode to IP.\n");
11966 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11967 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11968 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11969 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11970 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11971 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11972 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11975 cmd_reconfig_device_queue(res->port_id, 1, 1);
11978 cmdline_parse_token_string_t cmd_flow_director_mask =
11979 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11980 flow_director_mask, "flow_director_mask");
11981 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11982 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11984 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11985 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11987 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11988 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11989 vlan_mask, UINT16);
11990 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11991 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11992 src_mask, "src_mask");
11993 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11994 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11996 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11997 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11999 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
12000 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12002 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
12003 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12004 dst_mask, "dst_mask");
12005 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
12006 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12008 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
12009 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12011 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
12012 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12015 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
12016 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12018 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
12019 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12021 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
12022 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12023 mode_value, "MAC-VLAN");
12024 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
12025 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12026 mode_value, "Tunnel");
12027 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
12028 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12030 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
12031 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12032 mac_addr_byte_mask, UINT8);
12033 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
12034 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12035 tunnel_type, "tunnel-type");
12036 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
12037 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12038 tunnel_type_mask, UINT8);
12039 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
12040 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12041 tunnel_id, "tunnel-id");
12042 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
12043 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12044 tunnel_id_mask, UINT32);
12046 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
12047 .f = cmd_flow_director_mask_parsed,
12049 .help_str = "flow_director_mask ... : "
12050 "Set IP mode flow director's mask on NIC",
12052 (void *)&cmd_flow_director_mask,
12053 (void *)&cmd_flow_director_mask_port_id,
12054 (void *)&cmd_flow_director_mask_mode,
12055 (void *)&cmd_flow_director_mask_mode_ip,
12056 (void *)&cmd_flow_director_mask_vlan,
12057 (void *)&cmd_flow_director_mask_vlan_value,
12058 (void *)&cmd_flow_director_mask_src,
12059 (void *)&cmd_flow_director_mask_ipv4_src,
12060 (void *)&cmd_flow_director_mask_ipv6_src,
12061 (void *)&cmd_flow_director_mask_port_src,
12062 (void *)&cmd_flow_director_mask_dst,
12063 (void *)&cmd_flow_director_mask_ipv4_dst,
12064 (void *)&cmd_flow_director_mask_ipv6_dst,
12065 (void *)&cmd_flow_director_mask_port_dst,
12070 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
12071 .f = cmd_flow_director_mask_parsed,
12073 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
12074 "flow director's mask on NIC",
12076 (void *)&cmd_flow_director_mask,
12077 (void *)&cmd_flow_director_mask_port_id,
12078 (void *)&cmd_flow_director_mask_mode,
12079 (void *)&cmd_flow_director_mask_mode_mac_vlan,
12080 (void *)&cmd_flow_director_mask_vlan,
12081 (void *)&cmd_flow_director_mask_vlan_value,
12086 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
12087 .f = cmd_flow_director_mask_parsed,
12089 .help_str = "flow_director_mask ... : Set tunnel mode "
12090 "flow director's mask on NIC",
12092 (void *)&cmd_flow_director_mask,
12093 (void *)&cmd_flow_director_mask_port_id,
12094 (void *)&cmd_flow_director_mask_mode,
12095 (void *)&cmd_flow_director_mask_mode_tunnel,
12096 (void *)&cmd_flow_director_mask_vlan,
12097 (void *)&cmd_flow_director_mask_vlan_value,
12098 (void *)&cmd_flow_director_mask_mac,
12099 (void *)&cmd_flow_director_mask_mac_value,
12100 (void *)&cmd_flow_director_mask_tunnel_type,
12101 (void *)&cmd_flow_director_mask_tunnel_type_value,
12102 (void *)&cmd_flow_director_mask_tunnel_id,
12103 (void *)&cmd_flow_director_mask_tunnel_id_value,
12108 /* *** deal with flow director mask on flexible payload *** */
12109 struct cmd_flow_director_flex_mask_result {
12110 cmdline_fixed_string_t flow_director_flexmask;
12112 cmdline_fixed_string_t flow;
12113 cmdline_fixed_string_t flow_type;
12114 cmdline_fixed_string_t mask;
12118 cmd_flow_director_flex_mask_parsed(void *parsed_result,
12119 __rte_unused struct cmdline *cl,
12120 __rte_unused void *data)
12122 struct cmd_flow_director_flex_mask_result *res = parsed_result;
12123 struct rte_eth_fdir_info fdir_info;
12124 struct rte_eth_fdir_flex_mask flex_mask;
12125 struct rte_port *port;
12126 uint64_t flow_type_mask;
12130 port = &ports[res->port_id];
12131 /** Check if the port is not started **/
12132 if (port->port_status != RTE_PORT_STOPPED) {
12133 printf("Please stop port %d first\n", res->port_id);
12137 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
12138 ret = parse_flexbytes(res->mask,
12140 RTE_ETH_FDIR_MAX_FLEXLEN);
12142 printf("error: Cannot parse mask input.\n");
12146 memset(&fdir_info, 0, sizeof(fdir_info));
12147 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12148 RTE_ETH_FILTER_INFO, &fdir_info);
12150 printf("Cannot get FDir filter info\n");
12154 if (!strcmp(res->flow_type, "none")) {
12155 /* means don't specify the flow type */
12156 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
12157 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
12158 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
12159 0, sizeof(struct rte_eth_fdir_flex_mask));
12160 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
12161 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
12163 sizeof(struct rte_eth_fdir_flex_mask));
12164 cmd_reconfig_device_queue(res->port_id, 1, 1);
12167 flow_type_mask = fdir_info.flow_types_mask[0];
12168 if (!strcmp(res->flow_type, "all")) {
12169 if (!flow_type_mask) {
12170 printf("No flow type supported\n");
12173 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
12174 if (flow_type_mask & (1ULL << i)) {
12175 flex_mask.flow_type = i;
12176 fdir_set_flex_mask(res->port_id, &flex_mask);
12179 cmd_reconfig_device_queue(res->port_id, 1, 1);
12182 flex_mask.flow_type = str2flowtype(res->flow_type);
12183 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
12184 printf("Flow type %s not supported on port %d\n",
12185 res->flow_type, res->port_id);
12188 fdir_set_flex_mask(res->port_id, &flex_mask);
12189 cmd_reconfig_device_queue(res->port_id, 1, 1);
12192 cmdline_parse_token_string_t cmd_flow_director_flexmask =
12193 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12194 flow_director_flexmask,
12195 "flow_director_flex_mask");
12196 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
12197 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12199 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
12200 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12202 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
12203 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12204 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
12205 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
12206 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
12207 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12210 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
12211 .f = cmd_flow_director_flex_mask_parsed,
12213 .help_str = "flow_director_flex_mask ... : "
12214 "Set flow director's flex mask on NIC",
12216 (void *)&cmd_flow_director_flexmask,
12217 (void *)&cmd_flow_director_flexmask_port_id,
12218 (void *)&cmd_flow_director_flexmask_flow,
12219 (void *)&cmd_flow_director_flexmask_flow_type,
12220 (void *)&cmd_flow_director_flexmask_mask,
12225 /* *** deal with flow director flexible payload configuration *** */
12226 struct cmd_flow_director_flexpayload_result {
12227 cmdline_fixed_string_t flow_director_flexpayload;
12229 cmdline_fixed_string_t payload_layer;
12230 cmdline_fixed_string_t payload_cfg;
12234 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
12237 const char *p, *p0 = q_arg;
12239 unsigned long int_fld;
12240 char *str_fld[max_num];
12245 p = strchr(p0, '(');
12249 p0 = strchr(p, ')');
12254 if (size >= sizeof(s))
12257 snprintf(s, sizeof(s), "%.*s", size, p);
12258 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12259 if (ret < 0 || ret > max_num)
12261 for (i = 0; i < ret; i++) {
12263 int_fld = strtoul(str_fld[i], &end, 0);
12264 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12266 offsets[i] = (uint16_t)int_fld;
12272 cmd_flow_director_flxpld_parsed(void *parsed_result,
12273 __rte_unused struct cmdline *cl,
12274 __rte_unused void *data)
12276 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12277 struct rte_eth_flex_payload_cfg flex_cfg;
12278 struct rte_port *port;
12281 port = &ports[res->port_id];
12282 /** Check if the port is not started **/
12283 if (port->port_status != RTE_PORT_STOPPED) {
12284 printf("Please stop port %d first\n", res->port_id);
12288 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12290 if (!strcmp(res->payload_layer, "raw"))
12291 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12292 else if (!strcmp(res->payload_layer, "l2"))
12293 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12294 else if (!strcmp(res->payload_layer, "l3"))
12295 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12296 else if (!strcmp(res->payload_layer, "l4"))
12297 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12299 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12300 RTE_ETH_FDIR_MAX_FLEXLEN);
12302 printf("error: Cannot parse flex payload input.\n");
12306 fdir_set_flex_payload(res->port_id, &flex_cfg);
12307 cmd_reconfig_device_queue(res->port_id, 1, 1);
12310 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12311 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12312 flow_director_flexpayload,
12313 "flow_director_flex_payload");
12314 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12315 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12317 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12318 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12319 payload_layer, "raw#l2#l3#l4");
12320 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12321 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12322 payload_cfg, NULL);
12324 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12325 .f = cmd_flow_director_flxpld_parsed,
12327 .help_str = "flow_director_flexpayload ... : "
12328 "Set flow director's flex payload on NIC",
12330 (void *)&cmd_flow_director_flexpayload,
12331 (void *)&cmd_flow_director_flexpayload_port_id,
12332 (void *)&cmd_flow_director_flexpayload_payload_layer,
12333 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12338 /* Generic flow interface command. */
12339 extern cmdline_parse_inst_t cmd_flow;
12341 /* *** Classification Filters Control *** */
12342 /* *** Get symmetric hash enable per port *** */
12343 struct cmd_get_sym_hash_ena_per_port_result {
12344 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12349 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12350 __rte_unused struct cmdline *cl,
12351 __rte_unused void *data)
12353 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12354 struct rte_eth_hash_filter_info info;
12357 if (rte_eth_dev_filter_supported(res->port_id,
12358 RTE_ETH_FILTER_HASH) < 0) {
12359 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12364 memset(&info, 0, sizeof(info));
12365 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12366 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12367 RTE_ETH_FILTER_GET, &info);
12370 printf("Cannot get symmetric hash enable per port "
12371 "on port %u\n", res->port_id);
12375 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12376 "enabled" : "disabled", res->port_id);
12379 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12380 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12381 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12382 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12383 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12386 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12387 .f = cmd_get_sym_hash_per_port_parsed,
12389 .help_str = "get_sym_hash_ena_per_port <port_id>",
12391 (void *)&cmd_get_sym_hash_ena_per_port_all,
12392 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12397 /* *** Set symmetric hash enable per port *** */
12398 struct cmd_set_sym_hash_ena_per_port_result {
12399 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12400 cmdline_fixed_string_t enable;
12405 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12406 __rte_unused struct cmdline *cl,
12407 __rte_unused void *data)
12409 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12410 struct rte_eth_hash_filter_info info;
12413 if (rte_eth_dev_filter_supported(res->port_id,
12414 RTE_ETH_FILTER_HASH) < 0) {
12415 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12420 memset(&info, 0, sizeof(info));
12421 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12422 if (!strcmp(res->enable, "enable"))
12423 info.info.enable = 1;
12424 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12425 RTE_ETH_FILTER_SET, &info);
12427 printf("Cannot set symmetric hash enable per port on "
12428 "port %u\n", res->port_id);
12431 printf("Symmetric hash has been set to %s on port %u\n",
12432 res->enable, res->port_id);
12435 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12436 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12437 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12438 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12439 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12441 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12442 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12443 enable, "enable#disable");
12445 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12446 .f = cmd_set_sym_hash_per_port_parsed,
12448 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12450 (void *)&cmd_set_sym_hash_ena_per_port_all,
12451 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12452 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12457 /* Get global config of hash function */
12458 struct cmd_get_hash_global_config_result {
12459 cmdline_fixed_string_t get_hash_global_config;
12464 flowtype_to_str(uint16_t ftype)
12470 } ftype_table[] = {
12471 {"ipv4", RTE_ETH_FLOW_IPV4},
12472 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12473 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12474 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12475 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12476 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12477 {"ipv6", RTE_ETH_FLOW_IPV6},
12478 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12479 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12480 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12481 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12482 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12483 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12484 {"port", RTE_ETH_FLOW_PORT},
12485 {"vxlan", RTE_ETH_FLOW_VXLAN},
12486 {"geneve", RTE_ETH_FLOW_GENEVE},
12487 {"nvgre", RTE_ETH_FLOW_NVGRE},
12488 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12491 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12492 if (ftype_table[i].ftype == ftype)
12493 return ftype_table[i].str;
12500 cmd_get_hash_global_config_parsed(void *parsed_result,
12501 __rte_unused struct cmdline *cl,
12502 __rte_unused void *data)
12504 struct cmd_get_hash_global_config_result *res = parsed_result;
12505 struct rte_eth_hash_filter_info info;
12506 uint32_t idx, offset;
12511 if (rte_eth_dev_filter_supported(res->port_id,
12512 RTE_ETH_FILTER_HASH) < 0) {
12513 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12518 memset(&info, 0, sizeof(info));
12519 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12520 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12521 RTE_ETH_FILTER_GET, &info);
12523 printf("Cannot get hash global configurations by port %d\n",
12528 switch (info.info.global_conf.hash_func) {
12529 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12530 printf("Hash function is Toeplitz\n");
12532 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12533 printf("Hash function is Simple XOR\n");
12535 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12536 printf("Hash function is Symmetric Toeplitz\n");
12539 printf("Unknown hash function\n");
12543 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12544 idx = i / UINT64_BIT;
12545 offset = i % UINT64_BIT;
12546 if (!(info.info.global_conf.valid_bit_mask[idx] &
12549 str = flowtype_to_str(i);
12552 printf("Symmetric hash is %s globally for flow type %s "
12554 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12555 (1ULL << offset)) ? "enabled" : "disabled"), str,
12560 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12561 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12562 get_hash_global_config, "get_hash_global_config");
12563 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12564 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12567 cmdline_parse_inst_t cmd_get_hash_global_config = {
12568 .f = cmd_get_hash_global_config_parsed,
12570 .help_str = "get_hash_global_config <port_id>",
12572 (void *)&cmd_get_hash_global_config_all,
12573 (void *)&cmd_get_hash_global_config_port_id,
12578 /* Set global config of hash function */
12579 struct cmd_set_hash_global_config_result {
12580 cmdline_fixed_string_t set_hash_global_config;
12582 cmdline_fixed_string_t hash_func;
12583 cmdline_fixed_string_t flow_type;
12584 cmdline_fixed_string_t enable;
12588 cmd_set_hash_global_config_parsed(void *parsed_result,
12589 __rte_unused struct cmdline *cl,
12590 __rte_unused void *data)
12592 struct cmd_set_hash_global_config_result *res = parsed_result;
12593 struct rte_eth_hash_filter_info info;
12594 uint32_t ftype, idx, offset;
12597 if (rte_eth_dev_filter_supported(res->port_id,
12598 RTE_ETH_FILTER_HASH) < 0) {
12599 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12603 memset(&info, 0, sizeof(info));
12604 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12605 if (!strcmp(res->hash_func, "toeplitz"))
12606 info.info.global_conf.hash_func =
12607 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12608 else if (!strcmp(res->hash_func, "simple_xor"))
12609 info.info.global_conf.hash_func =
12610 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12611 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12612 info.info.global_conf.hash_func =
12613 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12614 else if (!strcmp(res->hash_func, "default"))
12615 info.info.global_conf.hash_func =
12616 RTE_ETH_HASH_FUNCTION_DEFAULT;
12618 ftype = str2flowtype(res->flow_type);
12619 idx = ftype / UINT64_BIT;
12620 offset = ftype % UINT64_BIT;
12621 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12622 if (!strcmp(res->enable, "enable"))
12623 info.info.global_conf.sym_hash_enable_mask[idx] |=
12625 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12626 RTE_ETH_FILTER_SET, &info);
12628 printf("Cannot set global hash configurations by port %d\n",
12631 printf("Global hash configurations have been set "
12632 "successfully by port %d\n", res->port_id);
12635 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12636 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12637 set_hash_global_config, "set_hash_global_config");
12638 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12639 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12641 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12642 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12643 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12644 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12645 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12647 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12648 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12649 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12650 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12651 enable, "enable#disable");
12653 cmdline_parse_inst_t cmd_set_hash_global_config = {
12654 .f = cmd_set_hash_global_config_parsed,
12656 .help_str = "set_hash_global_config <port_id> "
12657 "toeplitz|simple_xor|symmetric_toeplitz|default "
12658 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12659 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12660 "l2_payload enable|disable",
12662 (void *)&cmd_set_hash_global_config_all,
12663 (void *)&cmd_set_hash_global_config_port_id,
12664 (void *)&cmd_set_hash_global_config_hash_func,
12665 (void *)&cmd_set_hash_global_config_flow_type,
12666 (void *)&cmd_set_hash_global_config_enable,
12671 /* Set hash input set */
12672 struct cmd_set_hash_input_set_result {
12673 cmdline_fixed_string_t set_hash_input_set;
12675 cmdline_fixed_string_t flow_type;
12676 cmdline_fixed_string_t inset_field;
12677 cmdline_fixed_string_t select;
12680 static enum rte_eth_input_set_field
12681 str2inset(char *string)
12685 static const struct {
12687 enum rte_eth_input_set_field inset;
12688 } inset_table[] = {
12689 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12690 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12691 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12692 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12693 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12694 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12695 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12696 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12697 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12698 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12699 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12700 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12701 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12702 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12703 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12704 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12705 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12706 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12707 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12708 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12709 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12710 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12711 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12712 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12713 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12714 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12715 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12716 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12717 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12718 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12719 {"none", RTE_ETH_INPUT_SET_NONE},
12722 for (i = 0; i < RTE_DIM(inset_table); i++) {
12723 if (!strcmp(string, inset_table[i].str))
12724 return inset_table[i].inset;
12727 return RTE_ETH_INPUT_SET_UNKNOWN;
12731 cmd_set_hash_input_set_parsed(void *parsed_result,
12732 __rte_unused struct cmdline *cl,
12733 __rte_unused void *data)
12735 struct cmd_set_hash_input_set_result *res = parsed_result;
12736 struct rte_eth_hash_filter_info info;
12738 memset(&info, 0, sizeof(info));
12739 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12740 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12741 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12742 info.info.input_set_conf.inset_size = 1;
12743 if (!strcmp(res->select, "select"))
12744 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12745 else if (!strcmp(res->select, "add"))
12746 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12747 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12748 RTE_ETH_FILTER_SET, &info);
12751 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12752 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12753 set_hash_input_set, "set_hash_input_set");
12754 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12755 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12757 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12758 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12760 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12761 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12763 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12764 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12765 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12766 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12767 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12769 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12770 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12771 select, "select#add");
12773 cmdline_parse_inst_t cmd_set_hash_input_set = {
12774 .f = cmd_set_hash_input_set_parsed,
12776 .help_str = "set_hash_input_set <port_id> "
12777 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12778 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12779 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12780 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12781 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12782 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12783 "fld-7th|fld-8th|none select|add",
12785 (void *)&cmd_set_hash_input_set_cmd,
12786 (void *)&cmd_set_hash_input_set_port_id,
12787 (void *)&cmd_set_hash_input_set_flow_type,
12788 (void *)&cmd_set_hash_input_set_field,
12789 (void *)&cmd_set_hash_input_set_select,
12794 /* Set flow director input set */
12795 struct cmd_set_fdir_input_set_result {
12796 cmdline_fixed_string_t set_fdir_input_set;
12798 cmdline_fixed_string_t flow_type;
12799 cmdline_fixed_string_t inset_field;
12800 cmdline_fixed_string_t select;
12804 cmd_set_fdir_input_set_parsed(void *parsed_result,
12805 __rte_unused struct cmdline *cl,
12806 __rte_unused void *data)
12808 struct cmd_set_fdir_input_set_result *res = parsed_result;
12809 struct rte_eth_fdir_filter_info info;
12811 memset(&info, 0, sizeof(info));
12812 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12813 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12814 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12815 info.info.input_set_conf.inset_size = 1;
12816 if (!strcmp(res->select, "select"))
12817 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12818 else if (!strcmp(res->select, "add"))
12819 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12820 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12821 RTE_ETH_FILTER_SET, &info);
12824 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12825 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12826 set_fdir_input_set, "set_fdir_input_set");
12827 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12828 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12830 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12831 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12833 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12834 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12835 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12836 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12838 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12839 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12840 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12841 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12842 "sctp-veri-tag#none");
12843 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12844 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12845 select, "select#add");
12847 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12848 .f = cmd_set_fdir_input_set_parsed,
12850 .help_str = "set_fdir_input_set <port_id> "
12851 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12852 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12853 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12854 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12855 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12856 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12857 "sctp-veri-tag|none select|add",
12859 (void *)&cmd_set_fdir_input_set_cmd,
12860 (void *)&cmd_set_fdir_input_set_port_id,
12861 (void *)&cmd_set_fdir_input_set_flow_type,
12862 (void *)&cmd_set_fdir_input_set_field,
12863 (void *)&cmd_set_fdir_input_set_select,
12868 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12869 struct cmd_mcast_addr_result {
12870 cmdline_fixed_string_t mcast_addr_cmd;
12871 cmdline_fixed_string_t what;
12873 struct rte_ether_addr mc_addr;
12876 static void cmd_mcast_addr_parsed(void *parsed_result,
12877 __rte_unused struct cmdline *cl,
12878 __rte_unused void *data)
12880 struct cmd_mcast_addr_result *res = parsed_result;
12882 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12883 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12884 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12885 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12886 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12889 if (strcmp(res->what, "add") == 0)
12890 mcast_addr_add(res->port_num, &res->mc_addr);
12892 mcast_addr_remove(res->port_num, &res->mc_addr);
12895 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12896 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12897 mcast_addr_cmd, "mcast_addr");
12898 cmdline_parse_token_string_t cmd_mcast_addr_what =
12899 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12901 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12902 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12903 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12904 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12906 cmdline_parse_inst_t cmd_mcast_addr = {
12907 .f = cmd_mcast_addr_parsed,
12909 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12910 "Add/Remove multicast MAC address on port_id",
12912 (void *)&cmd_mcast_addr_cmd,
12913 (void *)&cmd_mcast_addr_what,
12914 (void *)&cmd_mcast_addr_portnum,
12915 (void *)&cmd_mcast_addr_addr,
12920 /* l2 tunnel config
12921 * only support E-tag now.
12924 /* Ether type config */
12925 struct cmd_config_l2_tunnel_eth_type_result {
12926 cmdline_fixed_string_t port;
12927 cmdline_fixed_string_t config;
12928 cmdline_fixed_string_t all;
12930 cmdline_fixed_string_t l2_tunnel;
12931 cmdline_fixed_string_t l2_tunnel_type;
12932 cmdline_fixed_string_t eth_type;
12933 uint16_t eth_type_val;
12936 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12937 TOKEN_STRING_INITIALIZER
12938 (struct cmd_config_l2_tunnel_eth_type_result,
12940 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12941 TOKEN_STRING_INITIALIZER
12942 (struct cmd_config_l2_tunnel_eth_type_result,
12944 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12945 TOKEN_STRING_INITIALIZER
12946 (struct cmd_config_l2_tunnel_eth_type_result,
12948 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12949 TOKEN_NUM_INITIALIZER
12950 (struct cmd_config_l2_tunnel_eth_type_result,
12952 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12953 TOKEN_STRING_INITIALIZER
12954 (struct cmd_config_l2_tunnel_eth_type_result,
12955 l2_tunnel, "l2-tunnel");
12956 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12957 TOKEN_STRING_INITIALIZER
12958 (struct cmd_config_l2_tunnel_eth_type_result,
12959 l2_tunnel_type, "E-tag");
12960 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12961 TOKEN_STRING_INITIALIZER
12962 (struct cmd_config_l2_tunnel_eth_type_result,
12963 eth_type, "ether-type");
12964 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12965 TOKEN_NUM_INITIALIZER
12966 (struct cmd_config_l2_tunnel_eth_type_result,
12967 eth_type_val, UINT16);
12969 static enum rte_eth_tunnel_type
12970 str2fdir_l2_tunnel_type(char *string)
12974 static const struct {
12976 enum rte_eth_tunnel_type type;
12977 } l2_tunnel_type_str[] = {
12978 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12981 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12982 if (!strcmp(l2_tunnel_type_str[i].str, string))
12983 return l2_tunnel_type_str[i].type;
12985 return RTE_TUNNEL_TYPE_NONE;
12988 /* ether type config for all ports */
12990 cmd_config_l2_tunnel_eth_type_all_parsed
12991 (void *parsed_result,
12992 __rte_unused struct cmdline *cl,
12993 __rte_unused void *data)
12995 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12996 struct rte_eth_l2_tunnel_conf entry;
12999 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13000 entry.ether_type = res->eth_type_val;
13002 RTE_ETH_FOREACH_DEV(pid) {
13003 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
13007 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
13008 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
13010 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
13012 (void *)&cmd_config_l2_tunnel_eth_type_port,
13013 (void *)&cmd_config_l2_tunnel_eth_type_config,
13014 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
13015 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
13016 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
13017 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
13018 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
13023 /* ether type config for a specific port */
13025 cmd_config_l2_tunnel_eth_type_specific_parsed(
13026 void *parsed_result,
13027 __rte_unused struct cmdline *cl,
13028 __rte_unused void *data)
13030 struct cmd_config_l2_tunnel_eth_type_result *res =
13032 struct rte_eth_l2_tunnel_conf entry;
13034 if (port_id_is_invalid(res->id, ENABLED_WARN))
13037 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13038 entry.ether_type = res->eth_type_val;
13040 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
13043 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
13044 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
13046 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
13048 (void *)&cmd_config_l2_tunnel_eth_type_port,
13049 (void *)&cmd_config_l2_tunnel_eth_type_config,
13050 (void *)&cmd_config_l2_tunnel_eth_type_id,
13051 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
13052 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
13053 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
13054 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
13059 /* Enable/disable l2 tunnel */
13060 struct cmd_config_l2_tunnel_en_dis_result {
13061 cmdline_fixed_string_t port;
13062 cmdline_fixed_string_t config;
13063 cmdline_fixed_string_t all;
13065 cmdline_fixed_string_t l2_tunnel;
13066 cmdline_fixed_string_t l2_tunnel_type;
13067 cmdline_fixed_string_t en_dis;
13070 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
13071 TOKEN_STRING_INITIALIZER
13072 (struct cmd_config_l2_tunnel_en_dis_result,
13074 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
13075 TOKEN_STRING_INITIALIZER
13076 (struct cmd_config_l2_tunnel_en_dis_result,
13078 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
13079 TOKEN_STRING_INITIALIZER
13080 (struct cmd_config_l2_tunnel_en_dis_result,
13082 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
13083 TOKEN_NUM_INITIALIZER
13084 (struct cmd_config_l2_tunnel_en_dis_result,
13086 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
13087 TOKEN_STRING_INITIALIZER
13088 (struct cmd_config_l2_tunnel_en_dis_result,
13089 l2_tunnel, "l2-tunnel");
13090 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
13091 TOKEN_STRING_INITIALIZER
13092 (struct cmd_config_l2_tunnel_en_dis_result,
13093 l2_tunnel_type, "E-tag");
13094 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
13095 TOKEN_STRING_INITIALIZER
13096 (struct cmd_config_l2_tunnel_en_dis_result,
13097 en_dis, "enable#disable");
13099 /* enable/disable l2 tunnel for all ports */
13101 cmd_config_l2_tunnel_en_dis_all_parsed(
13102 void *parsed_result,
13103 __rte_unused struct cmdline *cl,
13104 __rte_unused void *data)
13106 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
13107 struct rte_eth_l2_tunnel_conf entry;
13111 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13113 if (!strcmp("enable", res->en_dis))
13118 RTE_ETH_FOREACH_DEV(pid) {
13119 rte_eth_dev_l2_tunnel_offload_set(pid,
13121 ETH_L2_TUNNEL_ENABLE_MASK,
13126 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
13127 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
13129 .help_str = "port config all l2-tunnel E-tag enable|disable",
13131 (void *)&cmd_config_l2_tunnel_en_dis_port,
13132 (void *)&cmd_config_l2_tunnel_en_dis_config,
13133 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
13134 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13135 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13136 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13141 /* enable/disable l2 tunnel for a port */
13143 cmd_config_l2_tunnel_en_dis_specific_parsed(
13144 void *parsed_result,
13145 __rte_unused struct cmdline *cl,
13146 __rte_unused void *data)
13148 struct cmd_config_l2_tunnel_en_dis_result *res =
13150 struct rte_eth_l2_tunnel_conf entry;
13152 if (port_id_is_invalid(res->id, ENABLED_WARN))
13155 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13157 if (!strcmp("enable", res->en_dis))
13158 rte_eth_dev_l2_tunnel_offload_set(res->id,
13160 ETH_L2_TUNNEL_ENABLE_MASK,
13163 rte_eth_dev_l2_tunnel_offload_set(res->id,
13165 ETH_L2_TUNNEL_ENABLE_MASK,
13169 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
13170 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
13172 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
13174 (void *)&cmd_config_l2_tunnel_en_dis_port,
13175 (void *)&cmd_config_l2_tunnel_en_dis_config,
13176 (void *)&cmd_config_l2_tunnel_en_dis_id,
13177 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13178 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13179 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13184 /* E-tag configuration */
13186 /* Common result structure for all E-tag configuration */
13187 struct cmd_config_e_tag_result {
13188 cmdline_fixed_string_t e_tag;
13189 cmdline_fixed_string_t set;
13190 cmdline_fixed_string_t insertion;
13191 cmdline_fixed_string_t stripping;
13192 cmdline_fixed_string_t forwarding;
13193 cmdline_fixed_string_t filter;
13194 cmdline_fixed_string_t add;
13195 cmdline_fixed_string_t del;
13196 cmdline_fixed_string_t on;
13197 cmdline_fixed_string_t off;
13198 cmdline_fixed_string_t on_off;
13199 cmdline_fixed_string_t port_tag_id;
13200 uint32_t port_tag_id_val;
13201 cmdline_fixed_string_t e_tag_id;
13202 uint16_t e_tag_id_val;
13203 cmdline_fixed_string_t dst_pool;
13204 uint8_t dst_pool_val;
13205 cmdline_fixed_string_t port;
13207 cmdline_fixed_string_t vf;
13211 /* Common CLI fields for all E-tag configuration */
13212 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
13213 TOKEN_STRING_INITIALIZER
13214 (struct cmd_config_e_tag_result,
13216 cmdline_parse_token_string_t cmd_config_e_tag_set =
13217 TOKEN_STRING_INITIALIZER
13218 (struct cmd_config_e_tag_result,
13220 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
13221 TOKEN_STRING_INITIALIZER
13222 (struct cmd_config_e_tag_result,
13223 insertion, "insertion");
13224 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
13225 TOKEN_STRING_INITIALIZER
13226 (struct cmd_config_e_tag_result,
13227 stripping, "stripping");
13228 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
13229 TOKEN_STRING_INITIALIZER
13230 (struct cmd_config_e_tag_result,
13231 forwarding, "forwarding");
13232 cmdline_parse_token_string_t cmd_config_e_tag_filter =
13233 TOKEN_STRING_INITIALIZER
13234 (struct cmd_config_e_tag_result,
13236 cmdline_parse_token_string_t cmd_config_e_tag_add =
13237 TOKEN_STRING_INITIALIZER
13238 (struct cmd_config_e_tag_result,
13240 cmdline_parse_token_string_t cmd_config_e_tag_del =
13241 TOKEN_STRING_INITIALIZER
13242 (struct cmd_config_e_tag_result,
13244 cmdline_parse_token_string_t cmd_config_e_tag_on =
13245 TOKEN_STRING_INITIALIZER
13246 (struct cmd_config_e_tag_result,
13248 cmdline_parse_token_string_t cmd_config_e_tag_off =
13249 TOKEN_STRING_INITIALIZER
13250 (struct cmd_config_e_tag_result,
13252 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13253 TOKEN_STRING_INITIALIZER
13254 (struct cmd_config_e_tag_result,
13256 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13257 TOKEN_STRING_INITIALIZER
13258 (struct cmd_config_e_tag_result,
13259 port_tag_id, "port-tag-id");
13260 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13261 TOKEN_NUM_INITIALIZER
13262 (struct cmd_config_e_tag_result,
13263 port_tag_id_val, UINT32);
13264 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13265 TOKEN_STRING_INITIALIZER
13266 (struct cmd_config_e_tag_result,
13267 e_tag_id, "e-tag-id");
13268 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13269 TOKEN_NUM_INITIALIZER
13270 (struct cmd_config_e_tag_result,
13271 e_tag_id_val, UINT16);
13272 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13273 TOKEN_STRING_INITIALIZER
13274 (struct cmd_config_e_tag_result,
13275 dst_pool, "dst-pool");
13276 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13277 TOKEN_NUM_INITIALIZER
13278 (struct cmd_config_e_tag_result,
13279 dst_pool_val, UINT8);
13280 cmdline_parse_token_string_t cmd_config_e_tag_port =
13281 TOKEN_STRING_INITIALIZER
13282 (struct cmd_config_e_tag_result,
13284 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13285 TOKEN_NUM_INITIALIZER
13286 (struct cmd_config_e_tag_result,
13288 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13289 TOKEN_STRING_INITIALIZER
13290 (struct cmd_config_e_tag_result,
13292 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13293 TOKEN_NUM_INITIALIZER
13294 (struct cmd_config_e_tag_result,
13297 /* E-tag insertion configuration */
13299 cmd_config_e_tag_insertion_en_parsed(
13300 void *parsed_result,
13301 __rte_unused struct cmdline *cl,
13302 __rte_unused void *data)
13304 struct cmd_config_e_tag_result *res =
13306 struct rte_eth_l2_tunnel_conf entry;
13308 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13311 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13312 entry.tunnel_id = res->port_tag_id_val;
13313 entry.vf_id = res->vf_id;
13314 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13316 ETH_L2_TUNNEL_INSERTION_MASK,
13321 cmd_config_e_tag_insertion_dis_parsed(
13322 void *parsed_result,
13323 __rte_unused struct cmdline *cl,
13324 __rte_unused void *data)
13326 struct cmd_config_e_tag_result *res =
13328 struct rte_eth_l2_tunnel_conf entry;
13330 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13333 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13334 entry.vf_id = res->vf_id;
13336 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13338 ETH_L2_TUNNEL_INSERTION_MASK,
13342 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13343 .f = cmd_config_e_tag_insertion_en_parsed,
13345 .help_str = "E-tag ... : E-tag insertion enable",
13347 (void *)&cmd_config_e_tag_e_tag,
13348 (void *)&cmd_config_e_tag_set,
13349 (void *)&cmd_config_e_tag_insertion,
13350 (void *)&cmd_config_e_tag_on,
13351 (void *)&cmd_config_e_tag_port_tag_id,
13352 (void *)&cmd_config_e_tag_port_tag_id_val,
13353 (void *)&cmd_config_e_tag_port,
13354 (void *)&cmd_config_e_tag_port_id,
13355 (void *)&cmd_config_e_tag_vf,
13356 (void *)&cmd_config_e_tag_vf_id,
13361 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13362 .f = cmd_config_e_tag_insertion_dis_parsed,
13364 .help_str = "E-tag ... : E-tag insertion disable",
13366 (void *)&cmd_config_e_tag_e_tag,
13367 (void *)&cmd_config_e_tag_set,
13368 (void *)&cmd_config_e_tag_insertion,
13369 (void *)&cmd_config_e_tag_off,
13370 (void *)&cmd_config_e_tag_port,
13371 (void *)&cmd_config_e_tag_port_id,
13372 (void *)&cmd_config_e_tag_vf,
13373 (void *)&cmd_config_e_tag_vf_id,
13378 /* E-tag stripping configuration */
13380 cmd_config_e_tag_stripping_parsed(
13381 void *parsed_result,
13382 __rte_unused struct cmdline *cl,
13383 __rte_unused void *data)
13385 struct cmd_config_e_tag_result *res =
13387 struct rte_eth_l2_tunnel_conf entry;
13389 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13392 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13394 if (!strcmp(res->on_off, "on"))
13395 rte_eth_dev_l2_tunnel_offload_set
13398 ETH_L2_TUNNEL_STRIPPING_MASK,
13401 rte_eth_dev_l2_tunnel_offload_set
13404 ETH_L2_TUNNEL_STRIPPING_MASK,
13408 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13409 .f = cmd_config_e_tag_stripping_parsed,
13411 .help_str = "E-tag ... : E-tag stripping enable/disable",
13413 (void *)&cmd_config_e_tag_e_tag,
13414 (void *)&cmd_config_e_tag_set,
13415 (void *)&cmd_config_e_tag_stripping,
13416 (void *)&cmd_config_e_tag_on_off,
13417 (void *)&cmd_config_e_tag_port,
13418 (void *)&cmd_config_e_tag_port_id,
13423 /* E-tag forwarding configuration */
13425 cmd_config_e_tag_forwarding_parsed(
13426 void *parsed_result,
13427 __rte_unused struct cmdline *cl,
13428 __rte_unused void *data)
13430 struct cmd_config_e_tag_result *res = parsed_result;
13431 struct rte_eth_l2_tunnel_conf entry;
13433 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13436 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13438 if (!strcmp(res->on_off, "on"))
13439 rte_eth_dev_l2_tunnel_offload_set
13442 ETH_L2_TUNNEL_FORWARDING_MASK,
13445 rte_eth_dev_l2_tunnel_offload_set
13448 ETH_L2_TUNNEL_FORWARDING_MASK,
13452 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13453 .f = cmd_config_e_tag_forwarding_parsed,
13455 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13457 (void *)&cmd_config_e_tag_e_tag,
13458 (void *)&cmd_config_e_tag_set,
13459 (void *)&cmd_config_e_tag_forwarding,
13460 (void *)&cmd_config_e_tag_on_off,
13461 (void *)&cmd_config_e_tag_port,
13462 (void *)&cmd_config_e_tag_port_id,
13467 /* E-tag filter configuration */
13469 cmd_config_e_tag_filter_add_parsed(
13470 void *parsed_result,
13471 __rte_unused struct cmdline *cl,
13472 __rte_unused void *data)
13474 struct cmd_config_e_tag_result *res = parsed_result;
13475 struct rte_eth_l2_tunnel_conf entry;
13478 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13481 if (res->e_tag_id_val > 0x3fff) {
13482 printf("e-tag-id must be equal or less than 0x3fff.\n");
13486 ret = rte_eth_dev_filter_supported(res->port_id,
13487 RTE_ETH_FILTER_L2_TUNNEL);
13489 printf("E-tag filter is not supported on port %u.\n",
13494 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13495 entry.tunnel_id = res->e_tag_id_val;
13496 entry.pool = res->dst_pool_val;
13498 ret = rte_eth_dev_filter_ctrl(res->port_id,
13499 RTE_ETH_FILTER_L2_TUNNEL,
13500 RTE_ETH_FILTER_ADD,
13503 printf("E-tag filter programming error: (%s)\n",
13507 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13508 .f = cmd_config_e_tag_filter_add_parsed,
13510 .help_str = "E-tag ... : E-tag filter add",
13512 (void *)&cmd_config_e_tag_e_tag,
13513 (void *)&cmd_config_e_tag_set,
13514 (void *)&cmd_config_e_tag_filter,
13515 (void *)&cmd_config_e_tag_add,
13516 (void *)&cmd_config_e_tag_e_tag_id,
13517 (void *)&cmd_config_e_tag_e_tag_id_val,
13518 (void *)&cmd_config_e_tag_dst_pool,
13519 (void *)&cmd_config_e_tag_dst_pool_val,
13520 (void *)&cmd_config_e_tag_port,
13521 (void *)&cmd_config_e_tag_port_id,
13527 cmd_config_e_tag_filter_del_parsed(
13528 void *parsed_result,
13529 __rte_unused struct cmdline *cl,
13530 __rte_unused void *data)
13532 struct cmd_config_e_tag_result *res = parsed_result;
13533 struct rte_eth_l2_tunnel_conf entry;
13536 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13539 if (res->e_tag_id_val > 0x3fff) {
13540 printf("e-tag-id must be less than 0x3fff.\n");
13544 ret = rte_eth_dev_filter_supported(res->port_id,
13545 RTE_ETH_FILTER_L2_TUNNEL);
13547 printf("E-tag filter is not supported on port %u.\n",
13552 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13553 entry.tunnel_id = res->e_tag_id_val;
13555 ret = rte_eth_dev_filter_ctrl(res->port_id,
13556 RTE_ETH_FILTER_L2_TUNNEL,
13557 RTE_ETH_FILTER_DELETE,
13560 printf("E-tag filter programming error: (%s)\n",
13564 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13565 .f = cmd_config_e_tag_filter_del_parsed,
13567 .help_str = "E-tag ... : E-tag filter delete",
13569 (void *)&cmd_config_e_tag_e_tag,
13570 (void *)&cmd_config_e_tag_set,
13571 (void *)&cmd_config_e_tag_filter,
13572 (void *)&cmd_config_e_tag_del,
13573 (void *)&cmd_config_e_tag_e_tag_id,
13574 (void *)&cmd_config_e_tag_e_tag_id_val,
13575 (void *)&cmd_config_e_tag_port,
13576 (void *)&cmd_config_e_tag_port_id,
13581 /* vf vlan anti spoof configuration */
13583 /* Common result structure for vf vlan anti spoof */
13584 struct cmd_vf_vlan_anti_spoof_result {
13585 cmdline_fixed_string_t set;
13586 cmdline_fixed_string_t vf;
13587 cmdline_fixed_string_t vlan;
13588 cmdline_fixed_string_t antispoof;
13591 cmdline_fixed_string_t on_off;
13594 /* Common CLI fields for vf vlan anti spoof enable disable */
13595 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13596 TOKEN_STRING_INITIALIZER
13597 (struct cmd_vf_vlan_anti_spoof_result,
13599 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13600 TOKEN_STRING_INITIALIZER
13601 (struct cmd_vf_vlan_anti_spoof_result,
13603 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13604 TOKEN_STRING_INITIALIZER
13605 (struct cmd_vf_vlan_anti_spoof_result,
13607 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13608 TOKEN_STRING_INITIALIZER
13609 (struct cmd_vf_vlan_anti_spoof_result,
13610 antispoof, "antispoof");
13611 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13612 TOKEN_NUM_INITIALIZER
13613 (struct cmd_vf_vlan_anti_spoof_result,
13615 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13616 TOKEN_NUM_INITIALIZER
13617 (struct cmd_vf_vlan_anti_spoof_result,
13619 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13620 TOKEN_STRING_INITIALIZER
13621 (struct cmd_vf_vlan_anti_spoof_result,
13625 cmd_set_vf_vlan_anti_spoof_parsed(
13626 void *parsed_result,
13627 __rte_unused struct cmdline *cl,
13628 __rte_unused void *data)
13630 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13631 int ret = -ENOTSUP;
13633 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13635 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13638 #ifdef RTE_LIBRTE_IXGBE_PMD
13639 if (ret == -ENOTSUP)
13640 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13641 res->vf_id, is_on);
13643 #ifdef RTE_LIBRTE_I40E_PMD
13644 if (ret == -ENOTSUP)
13645 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13646 res->vf_id, is_on);
13648 #ifdef RTE_LIBRTE_BNXT_PMD
13649 if (ret == -ENOTSUP)
13650 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13651 res->vf_id, is_on);
13658 printf("invalid vf_id %d\n", res->vf_id);
13661 printf("invalid port_id %d\n", res->port_id);
13664 printf("function not implemented\n");
13667 printf("programming error: (%s)\n", strerror(-ret));
13671 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13672 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13674 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13676 (void *)&cmd_vf_vlan_anti_spoof_set,
13677 (void *)&cmd_vf_vlan_anti_spoof_vf,
13678 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13679 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13680 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13681 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13682 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13687 /* vf mac anti spoof configuration */
13689 /* Common result structure for vf mac anti spoof */
13690 struct cmd_vf_mac_anti_spoof_result {
13691 cmdline_fixed_string_t set;
13692 cmdline_fixed_string_t vf;
13693 cmdline_fixed_string_t mac;
13694 cmdline_fixed_string_t antispoof;
13697 cmdline_fixed_string_t on_off;
13700 /* Common CLI fields for vf mac anti spoof enable disable */
13701 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13702 TOKEN_STRING_INITIALIZER
13703 (struct cmd_vf_mac_anti_spoof_result,
13705 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13706 TOKEN_STRING_INITIALIZER
13707 (struct cmd_vf_mac_anti_spoof_result,
13709 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13710 TOKEN_STRING_INITIALIZER
13711 (struct cmd_vf_mac_anti_spoof_result,
13713 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13714 TOKEN_STRING_INITIALIZER
13715 (struct cmd_vf_mac_anti_spoof_result,
13716 antispoof, "antispoof");
13717 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13718 TOKEN_NUM_INITIALIZER
13719 (struct cmd_vf_mac_anti_spoof_result,
13721 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13722 TOKEN_NUM_INITIALIZER
13723 (struct cmd_vf_mac_anti_spoof_result,
13725 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13726 TOKEN_STRING_INITIALIZER
13727 (struct cmd_vf_mac_anti_spoof_result,
13731 cmd_set_vf_mac_anti_spoof_parsed(
13732 void *parsed_result,
13733 __rte_unused struct cmdline *cl,
13734 __rte_unused void *data)
13736 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13737 int ret = -ENOTSUP;
13739 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13741 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13744 #ifdef RTE_LIBRTE_IXGBE_PMD
13745 if (ret == -ENOTSUP)
13746 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13747 res->vf_id, is_on);
13749 #ifdef RTE_LIBRTE_I40E_PMD
13750 if (ret == -ENOTSUP)
13751 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13752 res->vf_id, is_on);
13754 #ifdef RTE_LIBRTE_BNXT_PMD
13755 if (ret == -ENOTSUP)
13756 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13757 res->vf_id, is_on);
13764 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13767 printf("invalid port_id %d\n", res->port_id);
13770 printf("function not implemented\n");
13773 printf("programming error: (%s)\n", strerror(-ret));
13777 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13778 .f = cmd_set_vf_mac_anti_spoof_parsed,
13780 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13782 (void *)&cmd_vf_mac_anti_spoof_set,
13783 (void *)&cmd_vf_mac_anti_spoof_vf,
13784 (void *)&cmd_vf_mac_anti_spoof_mac,
13785 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13786 (void *)&cmd_vf_mac_anti_spoof_port_id,
13787 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13788 (void *)&cmd_vf_mac_anti_spoof_on_off,
13793 /* vf vlan strip queue configuration */
13795 /* Common result structure for vf mac anti spoof */
13796 struct cmd_vf_vlan_stripq_result {
13797 cmdline_fixed_string_t set;
13798 cmdline_fixed_string_t vf;
13799 cmdline_fixed_string_t vlan;
13800 cmdline_fixed_string_t stripq;
13803 cmdline_fixed_string_t on_off;
13806 /* Common CLI fields for vf vlan strip enable disable */
13807 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13808 TOKEN_STRING_INITIALIZER
13809 (struct cmd_vf_vlan_stripq_result,
13811 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13812 TOKEN_STRING_INITIALIZER
13813 (struct cmd_vf_vlan_stripq_result,
13815 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13816 TOKEN_STRING_INITIALIZER
13817 (struct cmd_vf_vlan_stripq_result,
13819 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13820 TOKEN_STRING_INITIALIZER
13821 (struct cmd_vf_vlan_stripq_result,
13823 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13824 TOKEN_NUM_INITIALIZER
13825 (struct cmd_vf_vlan_stripq_result,
13827 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13828 TOKEN_NUM_INITIALIZER
13829 (struct cmd_vf_vlan_stripq_result,
13831 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13832 TOKEN_STRING_INITIALIZER
13833 (struct cmd_vf_vlan_stripq_result,
13837 cmd_set_vf_vlan_stripq_parsed(
13838 void *parsed_result,
13839 __rte_unused struct cmdline *cl,
13840 __rte_unused void *data)
13842 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13843 int ret = -ENOTSUP;
13845 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13847 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13850 #ifdef RTE_LIBRTE_IXGBE_PMD
13851 if (ret == -ENOTSUP)
13852 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13853 res->vf_id, is_on);
13855 #ifdef RTE_LIBRTE_I40E_PMD
13856 if (ret == -ENOTSUP)
13857 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13858 res->vf_id, is_on);
13860 #ifdef RTE_LIBRTE_BNXT_PMD
13861 if (ret == -ENOTSUP)
13862 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13863 res->vf_id, is_on);
13870 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13873 printf("invalid port_id %d\n", res->port_id);
13876 printf("function not implemented\n");
13879 printf("programming error: (%s)\n", strerror(-ret));
13883 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13884 .f = cmd_set_vf_vlan_stripq_parsed,
13886 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13888 (void *)&cmd_vf_vlan_stripq_set,
13889 (void *)&cmd_vf_vlan_stripq_vf,
13890 (void *)&cmd_vf_vlan_stripq_vlan,
13891 (void *)&cmd_vf_vlan_stripq_stripq,
13892 (void *)&cmd_vf_vlan_stripq_port_id,
13893 (void *)&cmd_vf_vlan_stripq_vf_id,
13894 (void *)&cmd_vf_vlan_stripq_on_off,
13899 /* vf vlan insert configuration */
13901 /* Common result structure for vf vlan insert */
13902 struct cmd_vf_vlan_insert_result {
13903 cmdline_fixed_string_t set;
13904 cmdline_fixed_string_t vf;
13905 cmdline_fixed_string_t vlan;
13906 cmdline_fixed_string_t insert;
13912 /* Common CLI fields for vf vlan insert enable disable */
13913 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13914 TOKEN_STRING_INITIALIZER
13915 (struct cmd_vf_vlan_insert_result,
13917 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13918 TOKEN_STRING_INITIALIZER
13919 (struct cmd_vf_vlan_insert_result,
13921 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13922 TOKEN_STRING_INITIALIZER
13923 (struct cmd_vf_vlan_insert_result,
13925 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13926 TOKEN_STRING_INITIALIZER
13927 (struct cmd_vf_vlan_insert_result,
13929 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13930 TOKEN_NUM_INITIALIZER
13931 (struct cmd_vf_vlan_insert_result,
13933 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13934 TOKEN_NUM_INITIALIZER
13935 (struct cmd_vf_vlan_insert_result,
13937 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13938 TOKEN_NUM_INITIALIZER
13939 (struct cmd_vf_vlan_insert_result,
13943 cmd_set_vf_vlan_insert_parsed(
13944 void *parsed_result,
13945 __rte_unused struct cmdline *cl,
13946 __rte_unused void *data)
13948 struct cmd_vf_vlan_insert_result *res = parsed_result;
13949 int ret = -ENOTSUP;
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_vf_vlan_insert(res->port_id, res->vf_id,
13959 #ifdef RTE_LIBRTE_I40E_PMD
13960 if (ret == -ENOTSUP)
13961 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13964 #ifdef RTE_LIBRTE_BNXT_PMD
13965 if (ret == -ENOTSUP)
13966 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13974 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13977 printf("invalid port_id %d\n", res->port_id);
13980 printf("function not implemented\n");
13983 printf("programming error: (%s)\n", strerror(-ret));
13987 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13988 .f = cmd_set_vf_vlan_insert_parsed,
13990 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13992 (void *)&cmd_vf_vlan_insert_set,
13993 (void *)&cmd_vf_vlan_insert_vf,
13994 (void *)&cmd_vf_vlan_insert_vlan,
13995 (void *)&cmd_vf_vlan_insert_insert,
13996 (void *)&cmd_vf_vlan_insert_port_id,
13997 (void *)&cmd_vf_vlan_insert_vf_id,
13998 (void *)&cmd_vf_vlan_insert_vlan_id,
14003 /* tx loopback configuration */
14005 /* Common result structure for tx loopback */
14006 struct cmd_tx_loopback_result {
14007 cmdline_fixed_string_t set;
14008 cmdline_fixed_string_t tx;
14009 cmdline_fixed_string_t loopback;
14011 cmdline_fixed_string_t on_off;
14014 /* Common CLI fields for tx loopback enable disable */
14015 cmdline_parse_token_string_t cmd_tx_loopback_set =
14016 TOKEN_STRING_INITIALIZER
14017 (struct cmd_tx_loopback_result,
14019 cmdline_parse_token_string_t cmd_tx_loopback_tx =
14020 TOKEN_STRING_INITIALIZER
14021 (struct cmd_tx_loopback_result,
14023 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
14024 TOKEN_STRING_INITIALIZER
14025 (struct cmd_tx_loopback_result,
14026 loopback, "loopback");
14027 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
14028 TOKEN_NUM_INITIALIZER
14029 (struct cmd_tx_loopback_result,
14031 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
14032 TOKEN_STRING_INITIALIZER
14033 (struct cmd_tx_loopback_result,
14037 cmd_set_tx_loopback_parsed(
14038 void *parsed_result,
14039 __rte_unused struct cmdline *cl,
14040 __rte_unused void *data)
14042 struct cmd_tx_loopback_result *res = parsed_result;
14043 int ret = -ENOTSUP;
14045 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14047 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14050 #ifdef RTE_LIBRTE_IXGBE_PMD
14051 if (ret == -ENOTSUP)
14052 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
14054 #ifdef RTE_LIBRTE_I40E_PMD
14055 if (ret == -ENOTSUP)
14056 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
14058 #ifdef RTE_LIBRTE_BNXT_PMD
14059 if (ret == -ENOTSUP)
14060 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
14062 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
14063 if (ret == -ENOTSUP)
14064 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
14071 printf("invalid is_on %d\n", is_on);
14074 printf("invalid port_id %d\n", res->port_id);
14077 printf("function not implemented\n");
14080 printf("programming error: (%s)\n", strerror(-ret));
14084 cmdline_parse_inst_t cmd_set_tx_loopback = {
14085 .f = cmd_set_tx_loopback_parsed,
14087 .help_str = "set tx loopback <port_id> on|off",
14089 (void *)&cmd_tx_loopback_set,
14090 (void *)&cmd_tx_loopback_tx,
14091 (void *)&cmd_tx_loopback_loopback,
14092 (void *)&cmd_tx_loopback_port_id,
14093 (void *)&cmd_tx_loopback_on_off,
14098 /* all queues drop enable configuration */
14100 /* Common result structure for all queues drop enable */
14101 struct cmd_all_queues_drop_en_result {
14102 cmdline_fixed_string_t set;
14103 cmdline_fixed_string_t all;
14104 cmdline_fixed_string_t queues;
14105 cmdline_fixed_string_t drop;
14107 cmdline_fixed_string_t on_off;
14110 /* Common CLI fields for tx loopback enable disable */
14111 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
14112 TOKEN_STRING_INITIALIZER
14113 (struct cmd_all_queues_drop_en_result,
14115 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
14116 TOKEN_STRING_INITIALIZER
14117 (struct cmd_all_queues_drop_en_result,
14119 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
14120 TOKEN_STRING_INITIALIZER
14121 (struct cmd_all_queues_drop_en_result,
14123 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
14124 TOKEN_STRING_INITIALIZER
14125 (struct cmd_all_queues_drop_en_result,
14127 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
14128 TOKEN_NUM_INITIALIZER
14129 (struct cmd_all_queues_drop_en_result,
14131 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
14132 TOKEN_STRING_INITIALIZER
14133 (struct cmd_all_queues_drop_en_result,
14137 cmd_set_all_queues_drop_en_parsed(
14138 void *parsed_result,
14139 __rte_unused struct cmdline *cl,
14140 __rte_unused void *data)
14142 struct cmd_all_queues_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 if (ret == -ENOTSUP)
14151 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
14153 #ifdef RTE_LIBRTE_BNXT_PMD
14154 if (ret == -ENOTSUP)
14155 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
14161 printf("invalid is_on %d\n", is_on);
14164 printf("invalid port_id %d\n", res->port_id);
14167 printf("function not implemented\n");
14170 printf("programming error: (%s)\n", strerror(-ret));
14174 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
14175 .f = cmd_set_all_queues_drop_en_parsed,
14177 .help_str = "set all queues drop <port_id> on|off",
14179 (void *)&cmd_all_queues_drop_en_set,
14180 (void *)&cmd_all_queues_drop_en_all,
14181 (void *)&cmd_all_queues_drop_en_queues,
14182 (void *)&cmd_all_queues_drop_en_drop,
14183 (void *)&cmd_all_queues_drop_en_port_id,
14184 (void *)&cmd_all_queues_drop_en_on_off,
14189 /* vf split drop enable configuration */
14191 /* Common result structure for vf split drop enable */
14192 struct cmd_vf_split_drop_en_result {
14193 cmdline_fixed_string_t set;
14194 cmdline_fixed_string_t vf;
14195 cmdline_fixed_string_t split;
14196 cmdline_fixed_string_t drop;
14199 cmdline_fixed_string_t on_off;
14202 /* Common CLI fields for vf split drop enable disable */
14203 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
14204 TOKEN_STRING_INITIALIZER
14205 (struct cmd_vf_split_drop_en_result,
14207 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
14208 TOKEN_STRING_INITIALIZER
14209 (struct cmd_vf_split_drop_en_result,
14211 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
14212 TOKEN_STRING_INITIALIZER
14213 (struct cmd_vf_split_drop_en_result,
14215 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
14216 TOKEN_STRING_INITIALIZER
14217 (struct cmd_vf_split_drop_en_result,
14219 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
14220 TOKEN_NUM_INITIALIZER
14221 (struct cmd_vf_split_drop_en_result,
14223 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
14224 TOKEN_NUM_INITIALIZER
14225 (struct cmd_vf_split_drop_en_result,
14227 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
14228 TOKEN_STRING_INITIALIZER
14229 (struct cmd_vf_split_drop_en_result,
14233 cmd_set_vf_split_drop_en_parsed(
14234 void *parsed_result,
14235 __rte_unused struct cmdline *cl,
14236 __rte_unused void *data)
14238 struct cmd_vf_split_drop_en_result *res = parsed_result;
14239 int ret = -ENOTSUP;
14240 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14242 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14245 #ifdef RTE_LIBRTE_IXGBE_PMD
14246 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14253 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14256 printf("invalid port_id %d\n", res->port_id);
14259 printf("not supported on port %d\n", res->port_id);
14262 printf("programming error: (%s)\n", strerror(-ret));
14266 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14267 .f = cmd_set_vf_split_drop_en_parsed,
14269 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14271 (void *)&cmd_vf_split_drop_en_set,
14272 (void *)&cmd_vf_split_drop_en_vf,
14273 (void *)&cmd_vf_split_drop_en_split,
14274 (void *)&cmd_vf_split_drop_en_drop,
14275 (void *)&cmd_vf_split_drop_en_port_id,
14276 (void *)&cmd_vf_split_drop_en_vf_id,
14277 (void *)&cmd_vf_split_drop_en_on_off,
14282 /* vf mac address configuration */
14284 /* Common result structure for vf mac address */
14285 struct cmd_set_vf_mac_addr_result {
14286 cmdline_fixed_string_t set;
14287 cmdline_fixed_string_t vf;
14288 cmdline_fixed_string_t mac;
14289 cmdline_fixed_string_t addr;
14292 struct rte_ether_addr mac_addr;
14296 /* Common CLI fields for vf split drop enable disable */
14297 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14298 TOKEN_STRING_INITIALIZER
14299 (struct cmd_set_vf_mac_addr_result,
14301 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14302 TOKEN_STRING_INITIALIZER
14303 (struct cmd_set_vf_mac_addr_result,
14305 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14306 TOKEN_STRING_INITIALIZER
14307 (struct cmd_set_vf_mac_addr_result,
14309 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14310 TOKEN_STRING_INITIALIZER
14311 (struct cmd_set_vf_mac_addr_result,
14313 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14314 TOKEN_NUM_INITIALIZER
14315 (struct cmd_set_vf_mac_addr_result,
14317 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14318 TOKEN_NUM_INITIALIZER
14319 (struct cmd_set_vf_mac_addr_result,
14321 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14322 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14326 cmd_set_vf_mac_addr_parsed(
14327 void *parsed_result,
14328 __rte_unused struct cmdline *cl,
14329 __rte_unused void *data)
14331 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14332 int ret = -ENOTSUP;
14334 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14337 #ifdef RTE_LIBRTE_IXGBE_PMD
14338 if (ret == -ENOTSUP)
14339 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14342 #ifdef RTE_LIBRTE_I40E_PMD
14343 if (ret == -ENOTSUP)
14344 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14347 #ifdef RTE_LIBRTE_BNXT_PMD
14348 if (ret == -ENOTSUP)
14349 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14357 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14360 printf("invalid port_id %d\n", res->port_id);
14363 printf("function not implemented\n");
14366 printf("programming error: (%s)\n", strerror(-ret));
14370 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14371 .f = cmd_set_vf_mac_addr_parsed,
14373 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14375 (void *)&cmd_set_vf_mac_addr_set,
14376 (void *)&cmd_set_vf_mac_addr_vf,
14377 (void *)&cmd_set_vf_mac_addr_mac,
14378 (void *)&cmd_set_vf_mac_addr_addr,
14379 (void *)&cmd_set_vf_mac_addr_port_id,
14380 (void *)&cmd_set_vf_mac_addr_vf_id,
14381 (void *)&cmd_set_vf_mac_addr_mac_addr,
14386 /* MACsec configuration */
14388 /* Common result structure for MACsec offload enable */
14389 struct cmd_macsec_offload_on_result {
14390 cmdline_fixed_string_t set;
14391 cmdline_fixed_string_t macsec;
14392 cmdline_fixed_string_t offload;
14394 cmdline_fixed_string_t on;
14395 cmdline_fixed_string_t encrypt;
14396 cmdline_fixed_string_t en_on_off;
14397 cmdline_fixed_string_t replay_protect;
14398 cmdline_fixed_string_t rp_on_off;
14401 /* Common CLI fields for MACsec offload disable */
14402 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14403 TOKEN_STRING_INITIALIZER
14404 (struct cmd_macsec_offload_on_result,
14406 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14407 TOKEN_STRING_INITIALIZER
14408 (struct cmd_macsec_offload_on_result,
14410 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14411 TOKEN_STRING_INITIALIZER
14412 (struct cmd_macsec_offload_on_result,
14413 offload, "offload");
14414 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14415 TOKEN_NUM_INITIALIZER
14416 (struct cmd_macsec_offload_on_result,
14418 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14419 TOKEN_STRING_INITIALIZER
14420 (struct cmd_macsec_offload_on_result,
14422 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14423 TOKEN_STRING_INITIALIZER
14424 (struct cmd_macsec_offload_on_result,
14425 encrypt, "encrypt");
14426 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14427 TOKEN_STRING_INITIALIZER
14428 (struct cmd_macsec_offload_on_result,
14429 en_on_off, "on#off");
14430 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14431 TOKEN_STRING_INITIALIZER
14432 (struct cmd_macsec_offload_on_result,
14433 replay_protect, "replay-protect");
14434 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14435 TOKEN_STRING_INITIALIZER
14436 (struct cmd_macsec_offload_on_result,
14437 rp_on_off, "on#off");
14440 cmd_set_macsec_offload_on_parsed(
14441 void *parsed_result,
14442 __rte_unused struct cmdline *cl,
14443 __rte_unused void *data)
14445 struct cmd_macsec_offload_on_result *res = parsed_result;
14446 int ret = -ENOTSUP;
14447 portid_t port_id = res->port_id;
14448 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14449 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14450 struct rte_eth_dev_info dev_info;
14452 if (port_id_is_invalid(port_id, ENABLED_WARN))
14454 if (!port_is_stopped(port_id)) {
14455 printf("Please stop port %d first\n", port_id);
14459 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14463 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14464 #ifdef RTE_LIBRTE_IXGBE_PMD
14465 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14473 ports[port_id].dev_conf.txmode.offloads |=
14474 DEV_TX_OFFLOAD_MACSEC_INSERT;
14475 cmd_reconfig_device_queue(port_id, 1, 1);
14478 printf("invalid port_id %d\n", port_id);
14481 printf("not supported on port %d\n", port_id);
14484 printf("programming error: (%s)\n", strerror(-ret));
14488 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14489 .f = cmd_set_macsec_offload_on_parsed,
14491 .help_str = "set macsec offload <port_id> on "
14492 "encrypt on|off replay-protect on|off",
14494 (void *)&cmd_macsec_offload_on_set,
14495 (void *)&cmd_macsec_offload_on_macsec,
14496 (void *)&cmd_macsec_offload_on_offload,
14497 (void *)&cmd_macsec_offload_on_port_id,
14498 (void *)&cmd_macsec_offload_on_on,
14499 (void *)&cmd_macsec_offload_on_encrypt,
14500 (void *)&cmd_macsec_offload_on_en_on_off,
14501 (void *)&cmd_macsec_offload_on_replay_protect,
14502 (void *)&cmd_macsec_offload_on_rp_on_off,
14507 /* Common result structure for MACsec offload disable */
14508 struct cmd_macsec_offload_off_result {
14509 cmdline_fixed_string_t set;
14510 cmdline_fixed_string_t macsec;
14511 cmdline_fixed_string_t offload;
14513 cmdline_fixed_string_t off;
14516 /* Common CLI fields for MACsec offload disable */
14517 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14518 TOKEN_STRING_INITIALIZER
14519 (struct cmd_macsec_offload_off_result,
14521 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14522 TOKEN_STRING_INITIALIZER
14523 (struct cmd_macsec_offload_off_result,
14525 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14526 TOKEN_STRING_INITIALIZER
14527 (struct cmd_macsec_offload_off_result,
14528 offload, "offload");
14529 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14530 TOKEN_NUM_INITIALIZER
14531 (struct cmd_macsec_offload_off_result,
14533 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14534 TOKEN_STRING_INITIALIZER
14535 (struct cmd_macsec_offload_off_result,
14539 cmd_set_macsec_offload_off_parsed(
14540 void *parsed_result,
14541 __rte_unused struct cmdline *cl,
14542 __rte_unused void *data)
14544 struct cmd_macsec_offload_off_result *res = parsed_result;
14545 int ret = -ENOTSUP;
14546 struct rte_eth_dev_info dev_info;
14547 portid_t port_id = res->port_id;
14549 if (port_id_is_invalid(port_id, ENABLED_WARN))
14551 if (!port_is_stopped(port_id)) {
14552 printf("Please stop port %d first\n", port_id);
14556 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14560 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14561 #ifdef RTE_LIBRTE_IXGBE_PMD
14562 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14567 ports[port_id].dev_conf.txmode.offloads &=
14568 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14569 cmd_reconfig_device_queue(port_id, 1, 1);
14572 printf("invalid port_id %d\n", port_id);
14575 printf("not supported on port %d\n", port_id);
14578 printf("programming error: (%s)\n", strerror(-ret));
14582 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14583 .f = cmd_set_macsec_offload_off_parsed,
14585 .help_str = "set macsec offload <port_id> off",
14587 (void *)&cmd_macsec_offload_off_set,
14588 (void *)&cmd_macsec_offload_off_macsec,
14589 (void *)&cmd_macsec_offload_off_offload,
14590 (void *)&cmd_macsec_offload_off_port_id,
14591 (void *)&cmd_macsec_offload_off_off,
14596 /* Common result structure for MACsec secure connection configure */
14597 struct cmd_macsec_sc_result {
14598 cmdline_fixed_string_t set;
14599 cmdline_fixed_string_t macsec;
14600 cmdline_fixed_string_t sc;
14601 cmdline_fixed_string_t tx_rx;
14603 struct rte_ether_addr mac;
14607 /* Common CLI fields for MACsec secure connection configure */
14608 cmdline_parse_token_string_t cmd_macsec_sc_set =
14609 TOKEN_STRING_INITIALIZER
14610 (struct cmd_macsec_sc_result,
14612 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14613 TOKEN_STRING_INITIALIZER
14614 (struct cmd_macsec_sc_result,
14616 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14617 TOKEN_STRING_INITIALIZER
14618 (struct cmd_macsec_sc_result,
14620 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14621 TOKEN_STRING_INITIALIZER
14622 (struct cmd_macsec_sc_result,
14624 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14625 TOKEN_NUM_INITIALIZER
14626 (struct cmd_macsec_sc_result,
14628 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14629 TOKEN_ETHERADDR_INITIALIZER
14630 (struct cmd_macsec_sc_result,
14632 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14633 TOKEN_NUM_INITIALIZER
14634 (struct cmd_macsec_sc_result,
14638 cmd_set_macsec_sc_parsed(
14639 void *parsed_result,
14640 __rte_unused struct cmdline *cl,
14641 __rte_unused void *data)
14643 struct cmd_macsec_sc_result *res = parsed_result;
14644 int ret = -ENOTSUP;
14645 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14647 #ifdef RTE_LIBRTE_IXGBE_PMD
14649 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14650 res->mac.addr_bytes) :
14651 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14652 res->mac.addr_bytes, res->pi);
14654 RTE_SET_USED(is_tx);
14660 printf("invalid port_id %d\n", res->port_id);
14663 printf("not supported on port %d\n", res->port_id);
14666 printf("programming error: (%s)\n", strerror(-ret));
14670 cmdline_parse_inst_t cmd_set_macsec_sc = {
14671 .f = cmd_set_macsec_sc_parsed,
14673 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14675 (void *)&cmd_macsec_sc_set,
14676 (void *)&cmd_macsec_sc_macsec,
14677 (void *)&cmd_macsec_sc_sc,
14678 (void *)&cmd_macsec_sc_tx_rx,
14679 (void *)&cmd_macsec_sc_port_id,
14680 (void *)&cmd_macsec_sc_mac,
14681 (void *)&cmd_macsec_sc_pi,
14686 /* Common result structure for MACsec secure connection configure */
14687 struct cmd_macsec_sa_result {
14688 cmdline_fixed_string_t set;
14689 cmdline_fixed_string_t macsec;
14690 cmdline_fixed_string_t sa;
14691 cmdline_fixed_string_t tx_rx;
14696 cmdline_fixed_string_t key;
14699 /* Common CLI fields for MACsec secure connection configure */
14700 cmdline_parse_token_string_t cmd_macsec_sa_set =
14701 TOKEN_STRING_INITIALIZER
14702 (struct cmd_macsec_sa_result,
14704 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14705 TOKEN_STRING_INITIALIZER
14706 (struct cmd_macsec_sa_result,
14708 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14709 TOKEN_STRING_INITIALIZER
14710 (struct cmd_macsec_sa_result,
14712 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14713 TOKEN_STRING_INITIALIZER
14714 (struct cmd_macsec_sa_result,
14716 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14717 TOKEN_NUM_INITIALIZER
14718 (struct cmd_macsec_sa_result,
14720 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14721 TOKEN_NUM_INITIALIZER
14722 (struct cmd_macsec_sa_result,
14724 cmdline_parse_token_num_t cmd_macsec_sa_an =
14725 TOKEN_NUM_INITIALIZER
14726 (struct cmd_macsec_sa_result,
14728 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14729 TOKEN_NUM_INITIALIZER
14730 (struct cmd_macsec_sa_result,
14732 cmdline_parse_token_string_t cmd_macsec_sa_key =
14733 TOKEN_STRING_INITIALIZER
14734 (struct cmd_macsec_sa_result,
14738 cmd_set_macsec_sa_parsed(
14739 void *parsed_result,
14740 __rte_unused struct cmdline *cl,
14741 __rte_unused void *data)
14743 struct cmd_macsec_sa_result *res = parsed_result;
14744 int ret = -ENOTSUP;
14745 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14746 uint8_t key[16] = { 0 };
14752 key_len = strlen(res->key) / 2;
14756 for (i = 0; i < key_len; i++) {
14757 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14760 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14763 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14766 #ifdef RTE_LIBRTE_IXGBE_PMD
14768 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14769 res->idx, res->an, res->pn, key) :
14770 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14771 res->idx, res->an, res->pn, key);
14773 RTE_SET_USED(is_tx);
14780 printf("invalid idx %d or an %d\n", res->idx, res->an);
14783 printf("invalid port_id %d\n", res->port_id);
14786 printf("not supported on port %d\n", res->port_id);
14789 printf("programming error: (%s)\n", strerror(-ret));
14793 cmdline_parse_inst_t cmd_set_macsec_sa = {
14794 .f = cmd_set_macsec_sa_parsed,
14796 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14798 (void *)&cmd_macsec_sa_set,
14799 (void *)&cmd_macsec_sa_macsec,
14800 (void *)&cmd_macsec_sa_sa,
14801 (void *)&cmd_macsec_sa_tx_rx,
14802 (void *)&cmd_macsec_sa_port_id,
14803 (void *)&cmd_macsec_sa_idx,
14804 (void *)&cmd_macsec_sa_an,
14805 (void *)&cmd_macsec_sa_pn,
14806 (void *)&cmd_macsec_sa_key,
14811 /* VF unicast promiscuous mode configuration */
14813 /* Common result structure for VF unicast promiscuous mode */
14814 struct cmd_vf_promisc_result {
14815 cmdline_fixed_string_t set;
14816 cmdline_fixed_string_t vf;
14817 cmdline_fixed_string_t promisc;
14820 cmdline_fixed_string_t on_off;
14823 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14824 cmdline_parse_token_string_t cmd_vf_promisc_set =
14825 TOKEN_STRING_INITIALIZER
14826 (struct cmd_vf_promisc_result,
14828 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14829 TOKEN_STRING_INITIALIZER
14830 (struct cmd_vf_promisc_result,
14832 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14833 TOKEN_STRING_INITIALIZER
14834 (struct cmd_vf_promisc_result,
14835 promisc, "promisc");
14836 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14837 TOKEN_NUM_INITIALIZER
14838 (struct cmd_vf_promisc_result,
14840 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14841 TOKEN_NUM_INITIALIZER
14842 (struct cmd_vf_promisc_result,
14844 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14845 TOKEN_STRING_INITIALIZER
14846 (struct cmd_vf_promisc_result,
14850 cmd_set_vf_promisc_parsed(
14851 void *parsed_result,
14852 __rte_unused struct cmdline *cl,
14853 __rte_unused void *data)
14855 struct cmd_vf_promisc_result *res = parsed_result;
14856 int ret = -ENOTSUP;
14858 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14860 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14863 #ifdef RTE_LIBRTE_I40E_PMD
14864 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14865 res->vf_id, is_on);
14872 printf("invalid vf_id %d\n", res->vf_id);
14875 printf("invalid port_id %d\n", res->port_id);
14878 printf("function not implemented\n");
14881 printf("programming error: (%s)\n", strerror(-ret));
14885 cmdline_parse_inst_t cmd_set_vf_promisc = {
14886 .f = cmd_set_vf_promisc_parsed,
14888 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14889 "Set unicast promiscuous mode for a VF from the PF",
14891 (void *)&cmd_vf_promisc_set,
14892 (void *)&cmd_vf_promisc_vf,
14893 (void *)&cmd_vf_promisc_promisc,
14894 (void *)&cmd_vf_promisc_port_id,
14895 (void *)&cmd_vf_promisc_vf_id,
14896 (void *)&cmd_vf_promisc_on_off,
14901 /* VF multicast promiscuous mode configuration */
14903 /* Common result structure for VF multicast promiscuous mode */
14904 struct cmd_vf_allmulti_result {
14905 cmdline_fixed_string_t set;
14906 cmdline_fixed_string_t vf;
14907 cmdline_fixed_string_t allmulti;
14910 cmdline_fixed_string_t on_off;
14913 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14914 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14915 TOKEN_STRING_INITIALIZER
14916 (struct cmd_vf_allmulti_result,
14918 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14919 TOKEN_STRING_INITIALIZER
14920 (struct cmd_vf_allmulti_result,
14922 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14923 TOKEN_STRING_INITIALIZER
14924 (struct cmd_vf_allmulti_result,
14925 allmulti, "allmulti");
14926 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14927 TOKEN_NUM_INITIALIZER
14928 (struct cmd_vf_allmulti_result,
14930 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14931 TOKEN_NUM_INITIALIZER
14932 (struct cmd_vf_allmulti_result,
14934 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14935 TOKEN_STRING_INITIALIZER
14936 (struct cmd_vf_allmulti_result,
14940 cmd_set_vf_allmulti_parsed(
14941 void *parsed_result,
14942 __rte_unused struct cmdline *cl,
14943 __rte_unused void *data)
14945 struct cmd_vf_allmulti_result *res = parsed_result;
14946 int ret = -ENOTSUP;
14948 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14950 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14953 #ifdef RTE_LIBRTE_I40E_PMD
14954 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14955 res->vf_id, is_on);
14962 printf("invalid vf_id %d\n", res->vf_id);
14965 printf("invalid port_id %d\n", res->port_id);
14968 printf("function not implemented\n");
14971 printf("programming error: (%s)\n", strerror(-ret));
14975 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14976 .f = cmd_set_vf_allmulti_parsed,
14978 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14979 "Set multicast promiscuous mode for a VF from the PF",
14981 (void *)&cmd_vf_allmulti_set,
14982 (void *)&cmd_vf_allmulti_vf,
14983 (void *)&cmd_vf_allmulti_allmulti,
14984 (void *)&cmd_vf_allmulti_port_id,
14985 (void *)&cmd_vf_allmulti_vf_id,
14986 (void *)&cmd_vf_allmulti_on_off,
14991 /* vf broadcast mode configuration */
14993 /* Common result structure for vf broadcast */
14994 struct cmd_set_vf_broadcast_result {
14995 cmdline_fixed_string_t set;
14996 cmdline_fixed_string_t vf;
14997 cmdline_fixed_string_t broadcast;
15000 cmdline_fixed_string_t on_off;
15003 /* Common CLI fields for vf broadcast enable disable */
15004 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
15005 TOKEN_STRING_INITIALIZER
15006 (struct cmd_set_vf_broadcast_result,
15008 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
15009 TOKEN_STRING_INITIALIZER
15010 (struct cmd_set_vf_broadcast_result,
15012 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
15013 TOKEN_STRING_INITIALIZER
15014 (struct cmd_set_vf_broadcast_result,
15015 broadcast, "broadcast");
15016 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
15017 TOKEN_NUM_INITIALIZER
15018 (struct cmd_set_vf_broadcast_result,
15020 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
15021 TOKEN_NUM_INITIALIZER
15022 (struct cmd_set_vf_broadcast_result,
15024 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
15025 TOKEN_STRING_INITIALIZER
15026 (struct cmd_set_vf_broadcast_result,
15030 cmd_set_vf_broadcast_parsed(
15031 void *parsed_result,
15032 __rte_unused struct cmdline *cl,
15033 __rte_unused void *data)
15035 struct cmd_set_vf_broadcast_result *res = parsed_result;
15036 int ret = -ENOTSUP;
15038 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15040 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15043 #ifdef RTE_LIBRTE_I40E_PMD
15044 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
15045 res->vf_id, is_on);
15052 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15055 printf("invalid port_id %d\n", res->port_id);
15058 printf("function not implemented\n");
15061 printf("programming error: (%s)\n", strerror(-ret));
15065 cmdline_parse_inst_t cmd_set_vf_broadcast = {
15066 .f = cmd_set_vf_broadcast_parsed,
15068 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
15070 (void *)&cmd_set_vf_broadcast_set,
15071 (void *)&cmd_set_vf_broadcast_vf,
15072 (void *)&cmd_set_vf_broadcast_broadcast,
15073 (void *)&cmd_set_vf_broadcast_port_id,
15074 (void *)&cmd_set_vf_broadcast_vf_id,
15075 (void *)&cmd_set_vf_broadcast_on_off,
15080 /* vf vlan tag configuration */
15082 /* Common result structure for vf vlan tag */
15083 struct cmd_set_vf_vlan_tag_result {
15084 cmdline_fixed_string_t set;
15085 cmdline_fixed_string_t vf;
15086 cmdline_fixed_string_t vlan;
15087 cmdline_fixed_string_t tag;
15090 cmdline_fixed_string_t on_off;
15093 /* Common CLI fields for vf vlan tag enable disable */
15094 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
15095 TOKEN_STRING_INITIALIZER
15096 (struct cmd_set_vf_vlan_tag_result,
15098 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
15099 TOKEN_STRING_INITIALIZER
15100 (struct cmd_set_vf_vlan_tag_result,
15102 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
15103 TOKEN_STRING_INITIALIZER
15104 (struct cmd_set_vf_vlan_tag_result,
15106 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
15107 TOKEN_STRING_INITIALIZER
15108 (struct cmd_set_vf_vlan_tag_result,
15110 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
15111 TOKEN_NUM_INITIALIZER
15112 (struct cmd_set_vf_vlan_tag_result,
15114 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
15115 TOKEN_NUM_INITIALIZER
15116 (struct cmd_set_vf_vlan_tag_result,
15118 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
15119 TOKEN_STRING_INITIALIZER
15120 (struct cmd_set_vf_vlan_tag_result,
15124 cmd_set_vf_vlan_tag_parsed(
15125 void *parsed_result,
15126 __rte_unused struct cmdline *cl,
15127 __rte_unused void *data)
15129 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
15130 int ret = -ENOTSUP;
15132 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15134 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15137 #ifdef RTE_LIBRTE_I40E_PMD
15138 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
15139 res->vf_id, is_on);
15146 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15149 printf("invalid port_id %d\n", res->port_id);
15152 printf("function not implemented\n");
15155 printf("programming error: (%s)\n", strerror(-ret));
15159 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
15160 .f = cmd_set_vf_vlan_tag_parsed,
15162 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
15164 (void *)&cmd_set_vf_vlan_tag_set,
15165 (void *)&cmd_set_vf_vlan_tag_vf,
15166 (void *)&cmd_set_vf_vlan_tag_vlan,
15167 (void *)&cmd_set_vf_vlan_tag_tag,
15168 (void *)&cmd_set_vf_vlan_tag_port_id,
15169 (void *)&cmd_set_vf_vlan_tag_vf_id,
15170 (void *)&cmd_set_vf_vlan_tag_on_off,
15175 /* Common definition of VF and TC TX bandwidth configuration */
15176 struct cmd_vf_tc_bw_result {
15177 cmdline_fixed_string_t set;
15178 cmdline_fixed_string_t vf;
15179 cmdline_fixed_string_t tc;
15180 cmdline_fixed_string_t tx;
15181 cmdline_fixed_string_t min_bw;
15182 cmdline_fixed_string_t max_bw;
15183 cmdline_fixed_string_t strict_link_prio;
15188 cmdline_fixed_string_t bw_list;
15192 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
15193 TOKEN_STRING_INITIALIZER
15194 (struct cmd_vf_tc_bw_result,
15196 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
15197 TOKEN_STRING_INITIALIZER
15198 (struct cmd_vf_tc_bw_result,
15200 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
15201 TOKEN_STRING_INITIALIZER
15202 (struct cmd_vf_tc_bw_result,
15204 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
15205 TOKEN_STRING_INITIALIZER
15206 (struct cmd_vf_tc_bw_result,
15208 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
15209 TOKEN_STRING_INITIALIZER
15210 (struct cmd_vf_tc_bw_result,
15211 strict_link_prio, "strict-link-priority");
15212 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
15213 TOKEN_STRING_INITIALIZER
15214 (struct cmd_vf_tc_bw_result,
15215 min_bw, "min-bandwidth");
15216 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
15217 TOKEN_STRING_INITIALIZER
15218 (struct cmd_vf_tc_bw_result,
15219 max_bw, "max-bandwidth");
15220 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
15221 TOKEN_NUM_INITIALIZER
15222 (struct cmd_vf_tc_bw_result,
15224 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
15225 TOKEN_NUM_INITIALIZER
15226 (struct cmd_vf_tc_bw_result,
15228 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
15229 TOKEN_NUM_INITIALIZER
15230 (struct cmd_vf_tc_bw_result,
15232 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
15233 TOKEN_NUM_INITIALIZER
15234 (struct cmd_vf_tc_bw_result,
15236 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
15237 TOKEN_STRING_INITIALIZER
15238 (struct cmd_vf_tc_bw_result,
15240 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
15241 TOKEN_NUM_INITIALIZER
15242 (struct cmd_vf_tc_bw_result,
15245 /* VF max bandwidth setting */
15247 cmd_vf_max_bw_parsed(
15248 void *parsed_result,
15249 __rte_unused struct cmdline *cl,
15250 __rte_unused void *data)
15252 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 #ifdef RTE_LIBRTE_I40E_PMD
15259 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15260 res->vf_id, res->bw);
15267 printf("invalid vf_id %d or bandwidth %d\n",
15268 res->vf_id, res->bw);
15271 printf("invalid port_id %d\n", res->port_id);
15274 printf("function not implemented\n");
15277 printf("programming error: (%s)\n", strerror(-ret));
15281 cmdline_parse_inst_t cmd_vf_max_bw = {
15282 .f = cmd_vf_max_bw_parsed,
15284 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15286 (void *)&cmd_vf_tc_bw_set,
15287 (void *)&cmd_vf_tc_bw_vf,
15288 (void *)&cmd_vf_tc_bw_tx,
15289 (void *)&cmd_vf_tc_bw_max_bw,
15290 (void *)&cmd_vf_tc_bw_port_id,
15291 (void *)&cmd_vf_tc_bw_vf_id,
15292 (void *)&cmd_vf_tc_bw_bw,
15298 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15303 const char *p, *p0 = str;
15310 p = strchr(p0, '(');
15312 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15316 p0 = strchr(p, ')');
15318 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15322 if (size >= sizeof(s)) {
15323 printf("The string size exceeds the internal buffer size\n");
15326 snprintf(s, sizeof(s), "%.*s", size, p);
15327 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15329 printf("Failed to get the bandwidth list. ");
15333 for (i = 0; i < ret; i++)
15334 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15339 /* TC min bandwidth setting */
15341 cmd_vf_tc_min_bw_parsed(
15342 void *parsed_result,
15343 __rte_unused struct cmdline *cl,
15344 __rte_unused void *data)
15346 struct cmd_vf_tc_bw_result *res = parsed_result;
15349 int ret = -ENOTSUP;
15351 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15354 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15358 #ifdef RTE_LIBRTE_I40E_PMD
15359 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15367 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15370 printf("invalid port_id %d\n", res->port_id);
15373 printf("function not implemented\n");
15376 printf("programming error: (%s)\n", strerror(-ret));
15380 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15381 .f = cmd_vf_tc_min_bw_parsed,
15383 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15384 " <bw1, bw2, ...>",
15386 (void *)&cmd_vf_tc_bw_set,
15387 (void *)&cmd_vf_tc_bw_vf,
15388 (void *)&cmd_vf_tc_bw_tc,
15389 (void *)&cmd_vf_tc_bw_tx,
15390 (void *)&cmd_vf_tc_bw_min_bw,
15391 (void *)&cmd_vf_tc_bw_port_id,
15392 (void *)&cmd_vf_tc_bw_vf_id,
15393 (void *)&cmd_vf_tc_bw_bw_list,
15399 cmd_tc_min_bw_parsed(
15400 void *parsed_result,
15401 __rte_unused struct cmdline *cl,
15402 __rte_unused void *data)
15404 struct cmd_vf_tc_bw_result *res = parsed_result;
15405 struct rte_port *port;
15408 int ret = -ENOTSUP;
15410 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15413 port = &ports[res->port_id];
15414 /** Check if the port is not started **/
15415 if (port->port_status != RTE_PORT_STOPPED) {
15416 printf("Please stop port %d first\n", res->port_id);
15420 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15424 #ifdef RTE_LIBRTE_IXGBE_PMD
15425 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15432 printf("invalid bandwidth\n");
15435 printf("invalid port_id %d\n", res->port_id);
15438 printf("function not implemented\n");
15441 printf("programming error: (%s)\n", strerror(-ret));
15445 cmdline_parse_inst_t cmd_tc_min_bw = {
15446 .f = cmd_tc_min_bw_parsed,
15448 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15450 (void *)&cmd_vf_tc_bw_set,
15451 (void *)&cmd_vf_tc_bw_tc,
15452 (void *)&cmd_vf_tc_bw_tx,
15453 (void *)&cmd_vf_tc_bw_min_bw,
15454 (void *)&cmd_vf_tc_bw_port_id,
15455 (void *)&cmd_vf_tc_bw_bw_list,
15460 /* TC max bandwidth setting */
15462 cmd_vf_tc_max_bw_parsed(
15463 void *parsed_result,
15464 __rte_unused struct cmdline *cl,
15465 __rte_unused void *data)
15467 struct cmd_vf_tc_bw_result *res = parsed_result;
15468 int ret = -ENOTSUP;
15470 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15473 #ifdef RTE_LIBRTE_I40E_PMD
15474 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15475 res->tc_no, res->bw);
15482 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15483 res->vf_id, res->tc_no, res->bw);
15486 printf("invalid port_id %d\n", res->port_id);
15489 printf("function not implemented\n");
15492 printf("programming error: (%s)\n", strerror(-ret));
15496 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15497 .f = cmd_vf_tc_max_bw_parsed,
15499 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15502 (void *)&cmd_vf_tc_bw_set,
15503 (void *)&cmd_vf_tc_bw_vf,
15504 (void *)&cmd_vf_tc_bw_tc,
15505 (void *)&cmd_vf_tc_bw_tx,
15506 (void *)&cmd_vf_tc_bw_max_bw,
15507 (void *)&cmd_vf_tc_bw_port_id,
15508 (void *)&cmd_vf_tc_bw_vf_id,
15509 (void *)&cmd_vf_tc_bw_tc_no,
15510 (void *)&cmd_vf_tc_bw_bw,
15515 /** Set VXLAN encapsulation details */
15516 struct cmd_set_vxlan_result {
15517 cmdline_fixed_string_t set;
15518 cmdline_fixed_string_t vxlan;
15519 cmdline_fixed_string_t pos_token;
15520 cmdline_fixed_string_t ip_version;
15521 uint32_t vlan_present:1;
15525 cmdline_ipaddr_t ip_src;
15526 cmdline_ipaddr_t ip_dst;
15530 struct rte_ether_addr eth_src;
15531 struct rte_ether_addr eth_dst;
15534 cmdline_parse_token_string_t cmd_set_vxlan_set =
15535 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15536 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15537 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15538 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15539 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15541 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15542 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15543 "vxlan-with-vlan");
15544 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15545 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15547 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15548 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15550 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15551 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15553 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15554 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15555 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15556 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15558 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15559 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15560 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15561 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15563 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15564 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15565 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15566 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15568 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15569 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15570 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15571 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15573 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15574 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15575 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15576 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15578 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15579 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15580 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15581 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15583 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15584 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15585 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15586 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15588 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15589 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15590 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15591 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15593 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15594 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15595 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15596 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15598 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15599 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15601 static void cmd_set_vxlan_parsed(void *parsed_result,
15602 __rte_unused struct cmdline *cl,
15603 __rte_unused void *data)
15605 struct cmd_set_vxlan_result *res = parsed_result;
15610 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15613 vxlan_encap_conf.select_tos_ttl = 0;
15614 if (strcmp(res->vxlan, "vxlan") == 0)
15615 vxlan_encap_conf.select_vlan = 0;
15616 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15617 vxlan_encap_conf.select_vlan = 1;
15618 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15619 vxlan_encap_conf.select_vlan = 0;
15620 vxlan_encap_conf.select_tos_ttl = 1;
15622 if (strcmp(res->ip_version, "ipv4") == 0)
15623 vxlan_encap_conf.select_ipv4 = 1;
15624 else if (strcmp(res->ip_version, "ipv6") == 0)
15625 vxlan_encap_conf.select_ipv4 = 0;
15628 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15629 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15630 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15631 vxlan_encap_conf.ip_tos = res->tos;
15632 vxlan_encap_conf.ip_ttl = res->ttl;
15633 if (vxlan_encap_conf.select_ipv4) {
15634 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15635 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15637 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15638 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15640 if (vxlan_encap_conf.select_vlan)
15641 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15642 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15643 RTE_ETHER_ADDR_LEN);
15644 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15645 RTE_ETHER_ADDR_LEN);
15648 cmdline_parse_inst_t cmd_set_vxlan = {
15649 .f = cmd_set_vxlan_parsed,
15651 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15652 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15653 " eth-src <eth-src> eth-dst <eth-dst>",
15655 (void *)&cmd_set_vxlan_set,
15656 (void *)&cmd_set_vxlan_vxlan,
15657 (void *)&cmd_set_vxlan_ip_version,
15658 (void *)&cmd_set_vxlan_ip_version_value,
15659 (void *)&cmd_set_vxlan_vni,
15660 (void *)&cmd_set_vxlan_vni_value,
15661 (void *)&cmd_set_vxlan_udp_src,
15662 (void *)&cmd_set_vxlan_udp_src_value,
15663 (void *)&cmd_set_vxlan_udp_dst,
15664 (void *)&cmd_set_vxlan_udp_dst_value,
15665 (void *)&cmd_set_vxlan_ip_src,
15666 (void *)&cmd_set_vxlan_ip_src_value,
15667 (void *)&cmd_set_vxlan_ip_dst,
15668 (void *)&cmd_set_vxlan_ip_dst_value,
15669 (void *)&cmd_set_vxlan_eth_src,
15670 (void *)&cmd_set_vxlan_eth_src_value,
15671 (void *)&cmd_set_vxlan_eth_dst,
15672 (void *)&cmd_set_vxlan_eth_dst_value,
15677 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15678 .f = cmd_set_vxlan_parsed,
15680 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15681 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15682 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15683 " eth-dst <eth-dst>",
15685 (void *)&cmd_set_vxlan_set,
15686 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15687 (void *)&cmd_set_vxlan_ip_version,
15688 (void *)&cmd_set_vxlan_ip_version_value,
15689 (void *)&cmd_set_vxlan_vni,
15690 (void *)&cmd_set_vxlan_vni_value,
15691 (void *)&cmd_set_vxlan_udp_src,
15692 (void *)&cmd_set_vxlan_udp_src_value,
15693 (void *)&cmd_set_vxlan_udp_dst,
15694 (void *)&cmd_set_vxlan_udp_dst_value,
15695 (void *)&cmd_set_vxlan_ip_tos,
15696 (void *)&cmd_set_vxlan_ip_tos_value,
15697 (void *)&cmd_set_vxlan_ip_ttl,
15698 (void *)&cmd_set_vxlan_ip_ttl_value,
15699 (void *)&cmd_set_vxlan_ip_src,
15700 (void *)&cmd_set_vxlan_ip_src_value,
15701 (void *)&cmd_set_vxlan_ip_dst,
15702 (void *)&cmd_set_vxlan_ip_dst_value,
15703 (void *)&cmd_set_vxlan_eth_src,
15704 (void *)&cmd_set_vxlan_eth_src_value,
15705 (void *)&cmd_set_vxlan_eth_dst,
15706 (void *)&cmd_set_vxlan_eth_dst_value,
15711 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15712 .f = cmd_set_vxlan_parsed,
15714 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15715 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15716 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15719 (void *)&cmd_set_vxlan_set,
15720 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15721 (void *)&cmd_set_vxlan_ip_version,
15722 (void *)&cmd_set_vxlan_ip_version_value,
15723 (void *)&cmd_set_vxlan_vni,
15724 (void *)&cmd_set_vxlan_vni_value,
15725 (void *)&cmd_set_vxlan_udp_src,
15726 (void *)&cmd_set_vxlan_udp_src_value,
15727 (void *)&cmd_set_vxlan_udp_dst,
15728 (void *)&cmd_set_vxlan_udp_dst_value,
15729 (void *)&cmd_set_vxlan_ip_src,
15730 (void *)&cmd_set_vxlan_ip_src_value,
15731 (void *)&cmd_set_vxlan_ip_dst,
15732 (void *)&cmd_set_vxlan_ip_dst_value,
15733 (void *)&cmd_set_vxlan_vlan,
15734 (void *)&cmd_set_vxlan_vlan_value,
15735 (void *)&cmd_set_vxlan_eth_src,
15736 (void *)&cmd_set_vxlan_eth_src_value,
15737 (void *)&cmd_set_vxlan_eth_dst,
15738 (void *)&cmd_set_vxlan_eth_dst_value,
15743 /** Set NVGRE encapsulation details */
15744 struct cmd_set_nvgre_result {
15745 cmdline_fixed_string_t set;
15746 cmdline_fixed_string_t nvgre;
15747 cmdline_fixed_string_t pos_token;
15748 cmdline_fixed_string_t ip_version;
15750 cmdline_ipaddr_t ip_src;
15751 cmdline_ipaddr_t ip_dst;
15753 struct rte_ether_addr eth_src;
15754 struct rte_ether_addr eth_dst;
15757 cmdline_parse_token_string_t cmd_set_nvgre_set =
15758 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15759 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15760 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15761 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15762 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15763 "nvgre-with-vlan");
15764 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15765 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15767 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15768 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15770 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15771 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15773 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15774 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15775 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15776 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15778 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15779 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15780 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15781 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15783 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15784 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15785 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15786 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15788 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15789 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15790 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15791 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15793 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15794 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15795 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15796 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15798 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15799 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15801 static void cmd_set_nvgre_parsed(void *parsed_result,
15802 __rte_unused struct cmdline *cl,
15803 __rte_unused void *data)
15805 struct cmd_set_nvgre_result *res = parsed_result;
15807 uint32_t nvgre_tni;
15810 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15813 if (strcmp(res->nvgre, "nvgre") == 0)
15814 nvgre_encap_conf.select_vlan = 0;
15815 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15816 nvgre_encap_conf.select_vlan = 1;
15817 if (strcmp(res->ip_version, "ipv4") == 0)
15818 nvgre_encap_conf.select_ipv4 = 1;
15819 else if (strcmp(res->ip_version, "ipv6") == 0)
15820 nvgre_encap_conf.select_ipv4 = 0;
15823 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15824 if (nvgre_encap_conf.select_ipv4) {
15825 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15826 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15828 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15829 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15831 if (nvgre_encap_conf.select_vlan)
15832 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15833 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15834 RTE_ETHER_ADDR_LEN);
15835 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15836 RTE_ETHER_ADDR_LEN);
15839 cmdline_parse_inst_t cmd_set_nvgre = {
15840 .f = cmd_set_nvgre_parsed,
15842 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15843 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15844 " eth-dst <eth-dst>",
15846 (void *)&cmd_set_nvgre_set,
15847 (void *)&cmd_set_nvgre_nvgre,
15848 (void *)&cmd_set_nvgre_ip_version,
15849 (void *)&cmd_set_nvgre_ip_version_value,
15850 (void *)&cmd_set_nvgre_tni,
15851 (void *)&cmd_set_nvgre_tni_value,
15852 (void *)&cmd_set_nvgre_ip_src,
15853 (void *)&cmd_set_nvgre_ip_src_value,
15854 (void *)&cmd_set_nvgre_ip_dst,
15855 (void *)&cmd_set_nvgre_ip_dst_value,
15856 (void *)&cmd_set_nvgre_eth_src,
15857 (void *)&cmd_set_nvgre_eth_src_value,
15858 (void *)&cmd_set_nvgre_eth_dst,
15859 (void *)&cmd_set_nvgre_eth_dst_value,
15864 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15865 .f = cmd_set_nvgre_parsed,
15867 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15868 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15869 " eth-src <eth-src> eth-dst <eth-dst>",
15871 (void *)&cmd_set_nvgre_set,
15872 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15873 (void *)&cmd_set_nvgre_ip_version,
15874 (void *)&cmd_set_nvgre_ip_version_value,
15875 (void *)&cmd_set_nvgre_tni,
15876 (void *)&cmd_set_nvgre_tni_value,
15877 (void *)&cmd_set_nvgre_ip_src,
15878 (void *)&cmd_set_nvgre_ip_src_value,
15879 (void *)&cmd_set_nvgre_ip_dst,
15880 (void *)&cmd_set_nvgre_ip_dst_value,
15881 (void *)&cmd_set_nvgre_vlan,
15882 (void *)&cmd_set_nvgre_vlan_value,
15883 (void *)&cmd_set_nvgre_eth_src,
15884 (void *)&cmd_set_nvgre_eth_src_value,
15885 (void *)&cmd_set_nvgre_eth_dst,
15886 (void *)&cmd_set_nvgre_eth_dst_value,
15891 /** Set L2 encapsulation details */
15892 struct cmd_set_l2_encap_result {
15893 cmdline_fixed_string_t set;
15894 cmdline_fixed_string_t l2_encap;
15895 cmdline_fixed_string_t pos_token;
15896 cmdline_fixed_string_t ip_version;
15897 uint32_t vlan_present:1;
15899 struct rte_ether_addr eth_src;
15900 struct rte_ether_addr eth_dst;
15903 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15904 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15905 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15906 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15907 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15908 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15909 "l2_encap-with-vlan");
15910 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15911 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15913 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15914 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15916 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15917 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15919 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15920 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15921 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15922 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15924 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15925 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15926 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15927 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15929 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15930 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15932 static void cmd_set_l2_encap_parsed(void *parsed_result,
15933 __rte_unused struct cmdline *cl,
15934 __rte_unused void *data)
15936 struct cmd_set_l2_encap_result *res = parsed_result;
15938 if (strcmp(res->l2_encap, "l2_encap") == 0)
15939 l2_encap_conf.select_vlan = 0;
15940 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15941 l2_encap_conf.select_vlan = 1;
15942 if (strcmp(res->ip_version, "ipv4") == 0)
15943 l2_encap_conf.select_ipv4 = 1;
15944 else if (strcmp(res->ip_version, "ipv6") == 0)
15945 l2_encap_conf.select_ipv4 = 0;
15948 if (l2_encap_conf.select_vlan)
15949 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15950 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15951 RTE_ETHER_ADDR_LEN);
15952 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15953 RTE_ETHER_ADDR_LEN);
15956 cmdline_parse_inst_t cmd_set_l2_encap = {
15957 .f = cmd_set_l2_encap_parsed,
15959 .help_str = "set l2_encap ip-version ipv4|ipv6"
15960 " eth-src <eth-src> eth-dst <eth-dst>",
15962 (void *)&cmd_set_l2_encap_set,
15963 (void *)&cmd_set_l2_encap_l2_encap,
15964 (void *)&cmd_set_l2_encap_ip_version,
15965 (void *)&cmd_set_l2_encap_ip_version_value,
15966 (void *)&cmd_set_l2_encap_eth_src,
15967 (void *)&cmd_set_l2_encap_eth_src_value,
15968 (void *)&cmd_set_l2_encap_eth_dst,
15969 (void *)&cmd_set_l2_encap_eth_dst_value,
15974 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15975 .f = cmd_set_l2_encap_parsed,
15977 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15978 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15980 (void *)&cmd_set_l2_encap_set,
15981 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15982 (void *)&cmd_set_l2_encap_ip_version,
15983 (void *)&cmd_set_l2_encap_ip_version_value,
15984 (void *)&cmd_set_l2_encap_vlan,
15985 (void *)&cmd_set_l2_encap_vlan_value,
15986 (void *)&cmd_set_l2_encap_eth_src,
15987 (void *)&cmd_set_l2_encap_eth_src_value,
15988 (void *)&cmd_set_l2_encap_eth_dst,
15989 (void *)&cmd_set_l2_encap_eth_dst_value,
15994 /** Set L2 decapsulation details */
15995 struct cmd_set_l2_decap_result {
15996 cmdline_fixed_string_t set;
15997 cmdline_fixed_string_t l2_decap;
15998 cmdline_fixed_string_t pos_token;
15999 uint32_t vlan_present:1;
16002 cmdline_parse_token_string_t cmd_set_l2_decap_set =
16003 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
16004 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
16005 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
16007 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
16008 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
16009 "l2_decap-with-vlan");
16011 static void cmd_set_l2_decap_parsed(void *parsed_result,
16012 __rte_unused struct cmdline *cl,
16013 __rte_unused void *data)
16015 struct cmd_set_l2_decap_result *res = parsed_result;
16017 if (strcmp(res->l2_decap, "l2_decap") == 0)
16018 l2_decap_conf.select_vlan = 0;
16019 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
16020 l2_decap_conf.select_vlan = 1;
16023 cmdline_parse_inst_t cmd_set_l2_decap = {
16024 .f = cmd_set_l2_decap_parsed,
16026 .help_str = "set l2_decap",
16028 (void *)&cmd_set_l2_decap_set,
16029 (void *)&cmd_set_l2_decap_l2_decap,
16034 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
16035 .f = cmd_set_l2_decap_parsed,
16037 .help_str = "set l2_decap-with-vlan",
16039 (void *)&cmd_set_l2_decap_set,
16040 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
16045 /** Set MPLSoGRE encapsulation details */
16046 struct cmd_set_mplsogre_encap_result {
16047 cmdline_fixed_string_t set;
16048 cmdline_fixed_string_t mplsogre;
16049 cmdline_fixed_string_t pos_token;
16050 cmdline_fixed_string_t ip_version;
16051 uint32_t vlan_present:1;
16053 cmdline_ipaddr_t ip_src;
16054 cmdline_ipaddr_t ip_dst;
16056 struct rte_ether_addr eth_src;
16057 struct rte_ether_addr eth_dst;
16060 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
16061 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
16063 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
16064 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
16066 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
16067 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16068 mplsogre, "mplsogre_encap-with-vlan");
16069 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
16070 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16071 pos_token, "ip-version");
16072 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
16073 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16074 ip_version, "ipv4#ipv6");
16075 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
16076 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16077 pos_token, "label");
16078 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
16079 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
16081 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
16082 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16083 pos_token, "ip-src");
16084 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
16085 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
16086 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
16087 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16088 pos_token, "ip-dst");
16089 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
16090 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
16091 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
16092 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16093 pos_token, "vlan-tci");
16094 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
16095 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
16097 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
16098 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16099 pos_token, "eth-src");
16100 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
16101 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16103 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
16104 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16105 pos_token, "eth-dst");
16106 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
16107 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16110 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
16111 __rte_unused struct cmdline *cl,
16112 __rte_unused void *data)
16114 struct cmd_set_mplsogre_encap_result *res = parsed_result;
16116 uint32_t mplsogre_label;
16119 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
16122 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
16123 mplsogre_encap_conf.select_vlan = 0;
16124 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
16125 mplsogre_encap_conf.select_vlan = 1;
16126 if (strcmp(res->ip_version, "ipv4") == 0)
16127 mplsogre_encap_conf.select_ipv4 = 1;
16128 else if (strcmp(res->ip_version, "ipv6") == 0)
16129 mplsogre_encap_conf.select_ipv4 = 0;
16132 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
16133 if (mplsogre_encap_conf.select_ipv4) {
16134 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
16135 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
16137 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
16138 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
16140 if (mplsogre_encap_conf.select_vlan)
16141 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16142 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
16143 RTE_ETHER_ADDR_LEN);
16144 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16145 RTE_ETHER_ADDR_LEN);
16148 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
16149 .f = cmd_set_mplsogre_encap_parsed,
16151 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
16152 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
16153 " eth-dst <eth-dst>",
16155 (void *)&cmd_set_mplsogre_encap_set,
16156 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
16157 (void *)&cmd_set_mplsogre_encap_ip_version,
16158 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16159 (void *)&cmd_set_mplsogre_encap_label,
16160 (void *)&cmd_set_mplsogre_encap_label_value,
16161 (void *)&cmd_set_mplsogre_encap_ip_src,
16162 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16163 (void *)&cmd_set_mplsogre_encap_ip_dst,
16164 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16165 (void *)&cmd_set_mplsogre_encap_eth_src,
16166 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16167 (void *)&cmd_set_mplsogre_encap_eth_dst,
16168 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16173 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16174 .f = cmd_set_mplsogre_encap_parsed,
16176 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16177 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16178 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16180 (void *)&cmd_set_mplsogre_encap_set,
16181 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16182 (void *)&cmd_set_mplsogre_encap_ip_version,
16183 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16184 (void *)&cmd_set_mplsogre_encap_label,
16185 (void *)&cmd_set_mplsogre_encap_label_value,
16186 (void *)&cmd_set_mplsogre_encap_ip_src,
16187 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16188 (void *)&cmd_set_mplsogre_encap_ip_dst,
16189 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16190 (void *)&cmd_set_mplsogre_encap_vlan,
16191 (void *)&cmd_set_mplsogre_encap_vlan_value,
16192 (void *)&cmd_set_mplsogre_encap_eth_src,
16193 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16194 (void *)&cmd_set_mplsogre_encap_eth_dst,
16195 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16200 /** Set MPLSoGRE decapsulation details */
16201 struct cmd_set_mplsogre_decap_result {
16202 cmdline_fixed_string_t set;
16203 cmdline_fixed_string_t mplsogre;
16204 cmdline_fixed_string_t pos_token;
16205 cmdline_fixed_string_t ip_version;
16206 uint32_t vlan_present:1;
16209 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16210 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16212 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16213 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16215 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16216 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16217 mplsogre, "mplsogre_decap-with-vlan");
16218 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16219 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16220 pos_token, "ip-version");
16221 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16222 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16223 ip_version, "ipv4#ipv6");
16225 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16226 __rte_unused struct cmdline *cl,
16227 __rte_unused void *data)
16229 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16231 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16232 mplsogre_decap_conf.select_vlan = 0;
16233 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16234 mplsogre_decap_conf.select_vlan = 1;
16235 if (strcmp(res->ip_version, "ipv4") == 0)
16236 mplsogre_decap_conf.select_ipv4 = 1;
16237 else if (strcmp(res->ip_version, "ipv6") == 0)
16238 mplsogre_decap_conf.select_ipv4 = 0;
16241 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16242 .f = cmd_set_mplsogre_decap_parsed,
16244 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16246 (void *)&cmd_set_mplsogre_decap_set,
16247 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16248 (void *)&cmd_set_mplsogre_decap_ip_version,
16249 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16254 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16255 .f = cmd_set_mplsogre_decap_parsed,
16257 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16259 (void *)&cmd_set_mplsogre_decap_set,
16260 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16261 (void *)&cmd_set_mplsogre_decap_ip_version,
16262 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16267 /** Set MPLSoUDP encapsulation details */
16268 struct cmd_set_mplsoudp_encap_result {
16269 cmdline_fixed_string_t set;
16270 cmdline_fixed_string_t mplsoudp;
16271 cmdline_fixed_string_t pos_token;
16272 cmdline_fixed_string_t ip_version;
16273 uint32_t vlan_present:1;
16277 cmdline_ipaddr_t ip_src;
16278 cmdline_ipaddr_t ip_dst;
16280 struct rte_ether_addr eth_src;
16281 struct rte_ether_addr eth_dst;
16284 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16285 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16287 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16288 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16290 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16291 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16292 mplsoudp, "mplsoudp_encap-with-vlan");
16293 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16294 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16295 pos_token, "ip-version");
16296 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16297 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16298 ip_version, "ipv4#ipv6");
16299 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16300 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16301 pos_token, "label");
16302 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16303 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16305 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16306 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16307 pos_token, "udp-src");
16308 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16309 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16311 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16312 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16313 pos_token, "udp-dst");
16314 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16315 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16317 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16318 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16319 pos_token, "ip-src");
16320 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16321 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16322 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16323 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16324 pos_token, "ip-dst");
16325 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16326 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16327 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16328 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16329 pos_token, "vlan-tci");
16330 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16331 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16333 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16334 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16335 pos_token, "eth-src");
16336 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16337 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16339 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16340 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16341 pos_token, "eth-dst");
16342 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16343 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16346 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16347 __rte_unused struct cmdline *cl,
16348 __rte_unused void *data)
16350 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16352 uint32_t mplsoudp_label;
16355 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16358 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16359 mplsoudp_encap_conf.select_vlan = 0;
16360 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16361 mplsoudp_encap_conf.select_vlan = 1;
16362 if (strcmp(res->ip_version, "ipv4") == 0)
16363 mplsoudp_encap_conf.select_ipv4 = 1;
16364 else if (strcmp(res->ip_version, "ipv6") == 0)
16365 mplsoudp_encap_conf.select_ipv4 = 0;
16368 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16369 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16370 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16371 if (mplsoudp_encap_conf.select_ipv4) {
16372 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16373 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16375 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16376 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16378 if (mplsoudp_encap_conf.select_vlan)
16379 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16380 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16381 RTE_ETHER_ADDR_LEN);
16382 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16383 RTE_ETHER_ADDR_LEN);
16386 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16387 .f = cmd_set_mplsoudp_encap_parsed,
16389 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16390 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16391 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16393 (void *)&cmd_set_mplsoudp_encap_set,
16394 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16395 (void *)&cmd_set_mplsoudp_encap_ip_version,
16396 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16397 (void *)&cmd_set_mplsoudp_encap_label,
16398 (void *)&cmd_set_mplsoudp_encap_label_value,
16399 (void *)&cmd_set_mplsoudp_encap_udp_src,
16400 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16401 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16402 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16403 (void *)&cmd_set_mplsoudp_encap_ip_src,
16404 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16405 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16406 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16407 (void *)&cmd_set_mplsoudp_encap_eth_src,
16408 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16409 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16410 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16415 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16416 .f = cmd_set_mplsoudp_encap_parsed,
16418 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16419 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16420 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16421 " eth-src <eth-src> eth-dst <eth-dst>",
16423 (void *)&cmd_set_mplsoudp_encap_set,
16424 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16425 (void *)&cmd_set_mplsoudp_encap_ip_version,
16426 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16427 (void *)&cmd_set_mplsoudp_encap_label,
16428 (void *)&cmd_set_mplsoudp_encap_label_value,
16429 (void *)&cmd_set_mplsoudp_encap_udp_src,
16430 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16431 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16432 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16433 (void *)&cmd_set_mplsoudp_encap_ip_src,
16434 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16435 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16436 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16437 (void *)&cmd_set_mplsoudp_encap_vlan,
16438 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16439 (void *)&cmd_set_mplsoudp_encap_eth_src,
16440 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16441 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16442 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16447 /** Set MPLSoUDP decapsulation details */
16448 struct cmd_set_mplsoudp_decap_result {
16449 cmdline_fixed_string_t set;
16450 cmdline_fixed_string_t mplsoudp;
16451 cmdline_fixed_string_t pos_token;
16452 cmdline_fixed_string_t ip_version;
16453 uint32_t vlan_present:1;
16456 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16457 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16459 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16460 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16462 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16463 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16464 mplsoudp, "mplsoudp_decap-with-vlan");
16465 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16466 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16467 pos_token, "ip-version");
16468 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16469 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16470 ip_version, "ipv4#ipv6");
16472 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16473 __rte_unused struct cmdline *cl,
16474 __rte_unused void *data)
16476 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16478 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16479 mplsoudp_decap_conf.select_vlan = 0;
16480 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16481 mplsoudp_decap_conf.select_vlan = 1;
16482 if (strcmp(res->ip_version, "ipv4") == 0)
16483 mplsoudp_decap_conf.select_ipv4 = 1;
16484 else if (strcmp(res->ip_version, "ipv6") == 0)
16485 mplsoudp_decap_conf.select_ipv4 = 0;
16488 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16489 .f = cmd_set_mplsoudp_decap_parsed,
16491 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16493 (void *)&cmd_set_mplsoudp_decap_set,
16494 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16495 (void *)&cmd_set_mplsoudp_decap_ip_version,
16496 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16501 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16502 .f = cmd_set_mplsoudp_decap_parsed,
16504 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16506 (void *)&cmd_set_mplsoudp_decap_set,
16507 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16508 (void *)&cmd_set_mplsoudp_decap_ip_version,
16509 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16514 /* Strict link priority scheduling mode setting */
16516 cmd_strict_link_prio_parsed(
16517 void *parsed_result,
16518 __rte_unused struct cmdline *cl,
16519 __rte_unused void *data)
16521 struct cmd_vf_tc_bw_result *res = parsed_result;
16522 int ret = -ENOTSUP;
16524 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16527 #ifdef RTE_LIBRTE_I40E_PMD
16528 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16535 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16538 printf("invalid port_id %d\n", res->port_id);
16541 printf("function not implemented\n");
16544 printf("programming error: (%s)\n", strerror(-ret));
16548 cmdline_parse_inst_t cmd_strict_link_prio = {
16549 .f = cmd_strict_link_prio_parsed,
16551 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16553 (void *)&cmd_vf_tc_bw_set,
16554 (void *)&cmd_vf_tc_bw_tx,
16555 (void *)&cmd_vf_tc_bw_strict_link_prio,
16556 (void *)&cmd_vf_tc_bw_port_id,
16557 (void *)&cmd_vf_tc_bw_tc_map,
16562 /* Load dynamic device personalization*/
16563 struct cmd_ddp_add_result {
16564 cmdline_fixed_string_t ddp;
16565 cmdline_fixed_string_t add;
16570 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16571 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16572 cmdline_parse_token_string_t cmd_ddp_add_add =
16573 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16574 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16575 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16576 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16577 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16580 cmd_ddp_add_parsed(
16581 void *parsed_result,
16582 __rte_unused struct cmdline *cl,
16583 __rte_unused void *data)
16585 struct cmd_ddp_add_result *res = parsed_result;
16591 int ret = -ENOTSUP;
16593 if (!all_ports_stopped()) {
16594 printf("Please stop all ports first\n");
16598 filepath = strdup(res->filepath);
16599 if (filepath == NULL) {
16600 printf("Failed to allocate memory\n");
16603 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16605 buff = open_file(file_fld[0], &size);
16607 free((void *)filepath);
16611 #ifdef RTE_LIBRTE_I40E_PMD
16612 if (ret == -ENOTSUP)
16613 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16615 RTE_PMD_I40E_PKG_OP_WR_ADD);
16618 if (ret == -EEXIST)
16619 printf("Profile has already existed.\n");
16621 printf("Failed to load profile.\n");
16622 else if (file_num == 2)
16623 save_file(file_fld[1], buff, size);
16626 free((void *)filepath);
16629 cmdline_parse_inst_t cmd_ddp_add = {
16630 .f = cmd_ddp_add_parsed,
16632 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16634 (void *)&cmd_ddp_add_ddp,
16635 (void *)&cmd_ddp_add_add,
16636 (void *)&cmd_ddp_add_port_id,
16637 (void *)&cmd_ddp_add_filepath,
16642 /* Delete dynamic device personalization*/
16643 struct cmd_ddp_del_result {
16644 cmdline_fixed_string_t ddp;
16645 cmdline_fixed_string_t del;
16650 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16651 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16652 cmdline_parse_token_string_t cmd_ddp_del_del =
16653 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16654 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16655 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16656 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16657 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16660 cmd_ddp_del_parsed(
16661 void *parsed_result,
16662 __rte_unused struct cmdline *cl,
16663 __rte_unused void *data)
16665 struct cmd_ddp_del_result *res = parsed_result;
16668 int ret = -ENOTSUP;
16670 if (!all_ports_stopped()) {
16671 printf("Please stop all ports first\n");
16675 buff = open_file(res->filepath, &size);
16679 #ifdef RTE_LIBRTE_I40E_PMD
16680 if (ret == -ENOTSUP)
16681 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16683 RTE_PMD_I40E_PKG_OP_WR_DEL);
16686 if (ret == -EACCES)
16687 printf("Profile does not exist.\n");
16689 printf("Failed to delete profile.\n");
16694 cmdline_parse_inst_t cmd_ddp_del = {
16695 .f = cmd_ddp_del_parsed,
16697 .help_str = "ddp del <port_id> <backup_profile_path>",
16699 (void *)&cmd_ddp_del_ddp,
16700 (void *)&cmd_ddp_del_del,
16701 (void *)&cmd_ddp_del_port_id,
16702 (void *)&cmd_ddp_del_filepath,
16707 /* Get dynamic device personalization profile info */
16708 struct cmd_ddp_info_result {
16709 cmdline_fixed_string_t ddp;
16710 cmdline_fixed_string_t get;
16711 cmdline_fixed_string_t info;
16715 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16716 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16717 cmdline_parse_token_string_t cmd_ddp_info_get =
16718 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16719 cmdline_parse_token_string_t cmd_ddp_info_info =
16720 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16721 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16722 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16725 cmd_ddp_info_parsed(
16726 void *parsed_result,
16727 __rte_unused struct cmdline *cl,
16728 __rte_unused void *data)
16730 struct cmd_ddp_info_result *res = parsed_result;
16733 int ret = -ENOTSUP;
16734 #ifdef RTE_LIBRTE_I40E_PMD
16737 uint32_t buff_size = 0;
16738 struct rte_pmd_i40e_profile_info info;
16739 uint32_t dev_num = 0;
16740 struct rte_pmd_i40e_ddp_device_id *devs;
16741 uint32_t proto_num = 0;
16742 struct rte_pmd_i40e_proto_info *proto = NULL;
16743 uint32_t pctype_num = 0;
16744 struct rte_pmd_i40e_ptype_info *pctype;
16745 uint32_t ptype_num = 0;
16746 struct rte_pmd_i40e_ptype_info *ptype;
16751 pkg = open_file(res->filepath, &pkg_size);
16755 #ifdef RTE_LIBRTE_I40E_PMD
16756 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16757 (uint8_t *)&info, sizeof(info),
16758 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16760 printf("Global Track id: 0x%x\n", info.track_id);
16761 printf("Global Version: %d.%d.%d.%d\n",
16762 info.version.major,
16763 info.version.minor,
16764 info.version.update,
16765 info.version.draft);
16766 printf("Global Package name: %s\n\n", info.name);
16769 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16770 (uint8_t *)&info, sizeof(info),
16771 RTE_PMD_I40E_PKG_INFO_HEADER);
16773 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16774 printf("i40e Profile Version: %d.%d.%d.%d\n",
16775 info.version.major,
16776 info.version.minor,
16777 info.version.update,
16778 info.version.draft);
16779 printf("i40e Profile name: %s\n\n", info.name);
16782 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16783 (uint8_t *)&buff_size, sizeof(buff_size),
16784 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16785 if (!ret && buff_size) {
16786 buff = (uint8_t *)malloc(buff_size);
16788 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16790 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16792 printf("Package Notes:\n%s\n\n", buff);
16797 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16798 (uint8_t *)&dev_num, sizeof(dev_num),
16799 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16800 if (!ret && dev_num) {
16801 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16802 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16804 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16805 (uint8_t *)devs, buff_size,
16806 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16808 printf("List of supported devices:\n");
16809 for (i = 0; i < dev_num; i++) {
16810 printf(" %04X:%04X %04X:%04X\n",
16811 devs[i].vendor_dev_id >> 16,
16812 devs[i].vendor_dev_id & 0xFFFF,
16813 devs[i].sub_vendor_dev_id >> 16,
16814 devs[i].sub_vendor_dev_id & 0xFFFF);
16822 /* get information about protocols and packet types */
16823 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16824 (uint8_t *)&proto_num, sizeof(proto_num),
16825 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16826 if (ret || !proto_num)
16827 goto no_print_return;
16829 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16830 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16832 goto no_print_return;
16834 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16836 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16838 printf("List of used protocols:\n");
16839 for (i = 0; i < proto_num; i++)
16840 printf(" %2u: %s\n", proto[i].proto_id,
16844 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16845 (uint8_t *)&pctype_num, sizeof(pctype_num),
16846 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16847 if (ret || !pctype_num)
16848 goto no_print_pctypes;
16850 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16851 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16853 goto no_print_pctypes;
16855 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16857 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16860 goto no_print_pctypes;
16863 printf("List of defined packet classification types:\n");
16864 for (i = 0; i < pctype_num; i++) {
16865 printf(" %2u:", pctype[i].ptype_id);
16866 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16867 proto_id = pctype[i].protocols[j];
16868 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16869 for (n = 0; n < proto_num; n++) {
16870 if (proto[n].proto_id == proto_id) {
16871 printf(" %s", proto[n].name);
16884 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16886 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16887 if (ret || !ptype_num)
16888 goto no_print_return;
16890 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16891 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16893 goto no_print_return;
16895 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16897 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16900 goto no_print_return;
16902 printf("List of defined packet types:\n");
16903 for (i = 0; i < ptype_num; i++) {
16904 printf(" %2u:", ptype[i].ptype_id);
16905 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16906 proto_id = ptype[i].protocols[j];
16907 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16908 for (n = 0; n < proto_num; n++) {
16909 if (proto[n].proto_id == proto_id) {
16910 printf(" %s", proto[n].name);
16926 if (ret == -ENOTSUP)
16927 printf("Function not supported in PMD driver\n");
16931 cmdline_parse_inst_t cmd_ddp_get_info = {
16932 .f = cmd_ddp_info_parsed,
16934 .help_str = "ddp get info <profile_path>",
16936 (void *)&cmd_ddp_info_ddp,
16937 (void *)&cmd_ddp_info_get,
16938 (void *)&cmd_ddp_info_info,
16939 (void *)&cmd_ddp_info_filepath,
16944 /* Get dynamic device personalization profile info list*/
16945 #define PROFILE_INFO_SIZE 48
16946 #define MAX_PROFILE_NUM 16
16948 struct cmd_ddp_get_list_result {
16949 cmdline_fixed_string_t ddp;
16950 cmdline_fixed_string_t get;
16951 cmdline_fixed_string_t list;
16955 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16956 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16957 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16958 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16959 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16960 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16961 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16962 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16965 cmd_ddp_get_list_parsed(
16966 __rte_unused void *parsed_result,
16967 __rte_unused struct cmdline *cl,
16968 __rte_unused void *data)
16970 #ifdef RTE_LIBRTE_I40E_PMD
16971 struct cmd_ddp_get_list_result *res = parsed_result;
16972 struct rte_pmd_i40e_profile_list *p_list;
16973 struct rte_pmd_i40e_profile_info *p_info;
16978 int ret = -ENOTSUP;
16980 #ifdef RTE_LIBRTE_I40E_PMD
16981 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16982 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16984 printf("%s: Failed to malloc buffer\n", __func__);
16988 if (ret == -ENOTSUP)
16989 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16990 (uint8_t *)p_list, size);
16993 p_num = p_list->p_count;
16994 printf("Profile number is: %d\n\n", p_num);
16996 for (i = 0; i < p_num; i++) {
16997 p_info = &p_list->p_info[i];
16998 printf("Profile %d:\n", i);
16999 printf("Track id: 0x%x\n", p_info->track_id);
17000 printf("Version: %d.%d.%d.%d\n",
17001 p_info->version.major,
17002 p_info->version.minor,
17003 p_info->version.update,
17004 p_info->version.draft);
17005 printf("Profile name: %s\n\n", p_info->name);
17013 printf("Failed to get ddp list\n");
17016 cmdline_parse_inst_t cmd_ddp_get_list = {
17017 .f = cmd_ddp_get_list_parsed,
17019 .help_str = "ddp get list <port_id>",
17021 (void *)&cmd_ddp_get_list_ddp,
17022 (void *)&cmd_ddp_get_list_get,
17023 (void *)&cmd_ddp_get_list_list,
17024 (void *)&cmd_ddp_get_list_port_id,
17029 /* Configure input set */
17030 struct cmd_cfg_input_set_result {
17031 cmdline_fixed_string_t port;
17032 cmdline_fixed_string_t cfg;
17034 cmdline_fixed_string_t pctype;
17036 cmdline_fixed_string_t inset_type;
17037 cmdline_fixed_string_t opt;
17038 cmdline_fixed_string_t field;
17043 cmd_cfg_input_set_parsed(
17044 __rte_unused void *parsed_result,
17045 __rte_unused struct cmdline *cl,
17046 __rte_unused void *data)
17048 #ifdef RTE_LIBRTE_I40E_PMD
17049 struct cmd_cfg_input_set_result *res = parsed_result;
17050 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17051 struct rte_pmd_i40e_inset inset;
17053 int ret = -ENOTSUP;
17055 if (!all_ports_stopped()) {
17056 printf("Please stop all ports first\n");
17060 #ifdef RTE_LIBRTE_I40E_PMD
17061 if (!strcmp(res->inset_type, "hash_inset"))
17062 inset_type = INSET_HASH;
17063 else if (!strcmp(res->inset_type, "fdir_inset"))
17064 inset_type = INSET_FDIR;
17065 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17066 inset_type = INSET_FDIR_FLX;
17067 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
17068 &inset, inset_type);
17070 printf("Failed to get input set.\n");
17074 if (!strcmp(res->opt, "get")) {
17075 ret = rte_pmd_i40e_inset_field_get(inset.inset,
17078 printf("Field index %d is enabled.\n", res->field_idx);
17080 printf("Field index %d is disabled.\n", res->field_idx);
17082 } else if (!strcmp(res->opt, "set"))
17083 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
17085 else if (!strcmp(res->opt, "clear"))
17086 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
17089 printf("Failed to configure input set field.\n");
17093 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17094 &inset, inset_type);
17096 printf("Failed to set input set.\n");
17101 if (ret == -ENOTSUP)
17102 printf("Function not supported\n");
17105 cmdline_parse_token_string_t cmd_cfg_input_set_port =
17106 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17108 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
17109 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17111 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
17112 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17114 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
17115 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17117 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
17118 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17120 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
17121 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17123 "hash_inset#fdir_inset#fdir_flx_inset");
17124 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
17125 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17126 opt, "get#set#clear");
17127 cmdline_parse_token_string_t cmd_cfg_input_set_field =
17128 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17130 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
17131 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17134 cmdline_parse_inst_t cmd_cfg_input_set = {
17135 .f = cmd_cfg_input_set_parsed,
17137 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17138 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
17140 (void *)&cmd_cfg_input_set_port,
17141 (void *)&cmd_cfg_input_set_cfg,
17142 (void *)&cmd_cfg_input_set_port_id,
17143 (void *)&cmd_cfg_input_set_pctype,
17144 (void *)&cmd_cfg_input_set_pctype_id,
17145 (void *)&cmd_cfg_input_set_inset_type,
17146 (void *)&cmd_cfg_input_set_opt,
17147 (void *)&cmd_cfg_input_set_field,
17148 (void *)&cmd_cfg_input_set_field_idx,
17153 /* Clear input set */
17154 struct cmd_clear_input_set_result {
17155 cmdline_fixed_string_t port;
17156 cmdline_fixed_string_t cfg;
17158 cmdline_fixed_string_t pctype;
17160 cmdline_fixed_string_t inset_type;
17161 cmdline_fixed_string_t clear;
17162 cmdline_fixed_string_t all;
17166 cmd_clear_input_set_parsed(
17167 __rte_unused void *parsed_result,
17168 __rte_unused struct cmdline *cl,
17169 __rte_unused void *data)
17171 #ifdef RTE_LIBRTE_I40E_PMD
17172 struct cmd_clear_input_set_result *res = parsed_result;
17173 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17174 struct rte_pmd_i40e_inset inset;
17176 int ret = -ENOTSUP;
17178 if (!all_ports_stopped()) {
17179 printf("Please stop all ports first\n");
17183 #ifdef RTE_LIBRTE_I40E_PMD
17184 if (!strcmp(res->inset_type, "hash_inset"))
17185 inset_type = INSET_HASH;
17186 else if (!strcmp(res->inset_type, "fdir_inset"))
17187 inset_type = INSET_FDIR;
17188 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17189 inset_type = INSET_FDIR_FLX;
17191 memset(&inset, 0, sizeof(inset));
17193 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17194 &inset, inset_type);
17196 printf("Failed to clear input set.\n");
17202 if (ret == -ENOTSUP)
17203 printf("Function not supported\n");
17206 cmdline_parse_token_string_t cmd_clear_input_set_port =
17207 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17209 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17210 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17212 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17213 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17215 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17216 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17218 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17219 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17221 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17222 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17224 "hash_inset#fdir_inset#fdir_flx_inset");
17225 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17226 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17228 cmdline_parse_token_string_t cmd_clear_input_set_all =
17229 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17232 cmdline_parse_inst_t cmd_clear_input_set = {
17233 .f = cmd_clear_input_set_parsed,
17235 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17236 "fdir_inset|fdir_flx_inset clear all",
17238 (void *)&cmd_clear_input_set_port,
17239 (void *)&cmd_clear_input_set_cfg,
17240 (void *)&cmd_clear_input_set_port_id,
17241 (void *)&cmd_clear_input_set_pctype,
17242 (void *)&cmd_clear_input_set_pctype_id,
17243 (void *)&cmd_clear_input_set_inset_type,
17244 (void *)&cmd_clear_input_set_clear,
17245 (void *)&cmd_clear_input_set_all,
17250 /* show vf stats */
17252 /* Common result structure for show vf stats */
17253 struct cmd_show_vf_stats_result {
17254 cmdline_fixed_string_t show;
17255 cmdline_fixed_string_t vf;
17256 cmdline_fixed_string_t stats;
17261 /* Common CLI fields show vf stats*/
17262 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17263 TOKEN_STRING_INITIALIZER
17264 (struct cmd_show_vf_stats_result,
17266 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17267 TOKEN_STRING_INITIALIZER
17268 (struct cmd_show_vf_stats_result,
17270 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17271 TOKEN_STRING_INITIALIZER
17272 (struct cmd_show_vf_stats_result,
17274 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17275 TOKEN_NUM_INITIALIZER
17276 (struct cmd_show_vf_stats_result,
17278 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17279 TOKEN_NUM_INITIALIZER
17280 (struct cmd_show_vf_stats_result,
17284 cmd_show_vf_stats_parsed(
17285 void *parsed_result,
17286 __rte_unused struct cmdline *cl,
17287 __rte_unused void *data)
17289 struct cmd_show_vf_stats_result *res = parsed_result;
17290 struct rte_eth_stats stats;
17291 int ret = -ENOTSUP;
17292 static const char *nic_stats_border = "########################";
17294 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17297 memset(&stats, 0, sizeof(stats));
17299 #ifdef RTE_LIBRTE_I40E_PMD
17300 if (ret == -ENOTSUP)
17301 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17305 #ifdef RTE_LIBRTE_BNXT_PMD
17306 if (ret == -ENOTSUP)
17307 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17316 printf("invalid vf_id %d\n", res->vf_id);
17319 printf("invalid port_id %d\n", res->port_id);
17322 printf("function not implemented\n");
17325 printf("programming error: (%s)\n", strerror(-ret));
17328 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17329 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17331 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17333 stats.ipackets, stats.imissed, stats.ibytes);
17334 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17335 printf(" RX-nombuf: %-10"PRIu64"\n",
17337 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17339 stats.opackets, stats.oerrors, stats.obytes);
17341 printf(" %s############################%s\n",
17342 nic_stats_border, nic_stats_border);
17345 cmdline_parse_inst_t cmd_show_vf_stats = {
17346 .f = cmd_show_vf_stats_parsed,
17348 .help_str = "show vf stats <port_id> <vf_id>",
17350 (void *)&cmd_show_vf_stats_show,
17351 (void *)&cmd_show_vf_stats_vf,
17352 (void *)&cmd_show_vf_stats_stats,
17353 (void *)&cmd_show_vf_stats_port_id,
17354 (void *)&cmd_show_vf_stats_vf_id,
17359 /* clear vf stats */
17361 /* Common result structure for clear vf stats */
17362 struct cmd_clear_vf_stats_result {
17363 cmdline_fixed_string_t clear;
17364 cmdline_fixed_string_t vf;
17365 cmdline_fixed_string_t stats;
17370 /* Common CLI fields clear vf stats*/
17371 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17372 TOKEN_STRING_INITIALIZER
17373 (struct cmd_clear_vf_stats_result,
17375 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17376 TOKEN_STRING_INITIALIZER
17377 (struct cmd_clear_vf_stats_result,
17379 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17380 TOKEN_STRING_INITIALIZER
17381 (struct cmd_clear_vf_stats_result,
17383 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17384 TOKEN_NUM_INITIALIZER
17385 (struct cmd_clear_vf_stats_result,
17387 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17388 TOKEN_NUM_INITIALIZER
17389 (struct cmd_clear_vf_stats_result,
17393 cmd_clear_vf_stats_parsed(
17394 void *parsed_result,
17395 __rte_unused struct cmdline *cl,
17396 __rte_unused void *data)
17398 struct cmd_clear_vf_stats_result *res = parsed_result;
17399 int ret = -ENOTSUP;
17401 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17404 #ifdef RTE_LIBRTE_I40E_PMD
17405 if (ret == -ENOTSUP)
17406 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17409 #ifdef RTE_LIBRTE_BNXT_PMD
17410 if (ret == -ENOTSUP)
17411 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17419 printf("invalid vf_id %d\n", res->vf_id);
17422 printf("invalid port_id %d\n", res->port_id);
17425 printf("function not implemented\n");
17428 printf("programming error: (%s)\n", strerror(-ret));
17432 cmdline_parse_inst_t cmd_clear_vf_stats = {
17433 .f = cmd_clear_vf_stats_parsed,
17435 .help_str = "clear vf stats <port_id> <vf_id>",
17437 (void *)&cmd_clear_vf_stats_clear,
17438 (void *)&cmd_clear_vf_stats_vf,
17439 (void *)&cmd_clear_vf_stats_stats,
17440 (void *)&cmd_clear_vf_stats_port_id,
17441 (void *)&cmd_clear_vf_stats_vf_id,
17446 /* port config pctype mapping reset */
17448 /* Common result structure for port config pctype mapping reset */
17449 struct cmd_pctype_mapping_reset_result {
17450 cmdline_fixed_string_t port;
17451 cmdline_fixed_string_t config;
17453 cmdline_fixed_string_t pctype;
17454 cmdline_fixed_string_t mapping;
17455 cmdline_fixed_string_t reset;
17458 /* Common CLI fields for port config pctype mapping reset*/
17459 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17460 TOKEN_STRING_INITIALIZER
17461 (struct cmd_pctype_mapping_reset_result,
17463 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17464 TOKEN_STRING_INITIALIZER
17465 (struct cmd_pctype_mapping_reset_result,
17467 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17468 TOKEN_NUM_INITIALIZER
17469 (struct cmd_pctype_mapping_reset_result,
17471 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17472 TOKEN_STRING_INITIALIZER
17473 (struct cmd_pctype_mapping_reset_result,
17475 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17476 TOKEN_STRING_INITIALIZER
17477 (struct cmd_pctype_mapping_reset_result,
17478 mapping, "mapping");
17479 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17480 TOKEN_STRING_INITIALIZER
17481 (struct cmd_pctype_mapping_reset_result,
17485 cmd_pctype_mapping_reset_parsed(
17486 void *parsed_result,
17487 __rte_unused struct cmdline *cl,
17488 __rte_unused void *data)
17490 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17491 int ret = -ENOTSUP;
17493 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17496 #ifdef RTE_LIBRTE_I40E_PMD
17497 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17504 printf("invalid port_id %d\n", res->port_id);
17507 printf("function not implemented\n");
17510 printf("programming error: (%s)\n", strerror(-ret));
17514 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17515 .f = cmd_pctype_mapping_reset_parsed,
17517 .help_str = "port config <port_id> pctype mapping reset",
17519 (void *)&cmd_pctype_mapping_reset_port,
17520 (void *)&cmd_pctype_mapping_reset_config,
17521 (void *)&cmd_pctype_mapping_reset_port_id,
17522 (void *)&cmd_pctype_mapping_reset_pctype,
17523 (void *)&cmd_pctype_mapping_reset_mapping,
17524 (void *)&cmd_pctype_mapping_reset_reset,
17529 /* show port pctype mapping */
17531 /* Common result structure for show port pctype mapping */
17532 struct cmd_pctype_mapping_get_result {
17533 cmdline_fixed_string_t show;
17534 cmdline_fixed_string_t port;
17536 cmdline_fixed_string_t pctype;
17537 cmdline_fixed_string_t mapping;
17540 /* Common CLI fields for pctype mapping get */
17541 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17542 TOKEN_STRING_INITIALIZER
17543 (struct cmd_pctype_mapping_get_result,
17545 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17546 TOKEN_STRING_INITIALIZER
17547 (struct cmd_pctype_mapping_get_result,
17549 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17550 TOKEN_NUM_INITIALIZER
17551 (struct cmd_pctype_mapping_get_result,
17553 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17554 TOKEN_STRING_INITIALIZER
17555 (struct cmd_pctype_mapping_get_result,
17557 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17558 TOKEN_STRING_INITIALIZER
17559 (struct cmd_pctype_mapping_get_result,
17560 mapping, "mapping");
17563 cmd_pctype_mapping_get_parsed(
17564 void *parsed_result,
17565 __rte_unused struct cmdline *cl,
17566 __rte_unused void *data)
17568 struct cmd_pctype_mapping_get_result *res = parsed_result;
17569 int ret = -ENOTSUP;
17570 #ifdef RTE_LIBRTE_I40E_PMD
17571 struct rte_pmd_i40e_flow_type_mapping
17572 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17573 int i, j, first_pctype;
17576 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17579 #ifdef RTE_LIBRTE_I40E_PMD
17580 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17587 printf("invalid port_id %d\n", res->port_id);
17590 printf("function not implemented\n");
17593 printf("programming error: (%s)\n", strerror(-ret));
17597 #ifdef RTE_LIBRTE_I40E_PMD
17598 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17599 if (mapping[i].pctype != 0ULL) {
17602 printf("pctype: ");
17603 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17604 if (mapping[i].pctype & (1ULL << j)) {
17605 printf(first_pctype ?
17606 "%02d" : ",%02d", j);
17610 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17616 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17617 .f = cmd_pctype_mapping_get_parsed,
17619 .help_str = "show port <port_id> pctype mapping",
17621 (void *)&cmd_pctype_mapping_get_show,
17622 (void *)&cmd_pctype_mapping_get_port,
17623 (void *)&cmd_pctype_mapping_get_port_id,
17624 (void *)&cmd_pctype_mapping_get_pctype,
17625 (void *)&cmd_pctype_mapping_get_mapping,
17630 /* port config pctype mapping update */
17632 /* Common result structure for port config pctype mapping update */
17633 struct cmd_pctype_mapping_update_result {
17634 cmdline_fixed_string_t port;
17635 cmdline_fixed_string_t config;
17637 cmdline_fixed_string_t pctype;
17638 cmdline_fixed_string_t mapping;
17639 cmdline_fixed_string_t update;
17640 cmdline_fixed_string_t pctype_list;
17641 uint16_t flow_type;
17644 /* Common CLI fields for pctype mapping update*/
17645 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17646 TOKEN_STRING_INITIALIZER
17647 (struct cmd_pctype_mapping_update_result,
17649 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17650 TOKEN_STRING_INITIALIZER
17651 (struct cmd_pctype_mapping_update_result,
17653 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17654 TOKEN_NUM_INITIALIZER
17655 (struct cmd_pctype_mapping_update_result,
17657 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17658 TOKEN_STRING_INITIALIZER
17659 (struct cmd_pctype_mapping_update_result,
17661 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17662 TOKEN_STRING_INITIALIZER
17663 (struct cmd_pctype_mapping_update_result,
17664 mapping, "mapping");
17665 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17666 TOKEN_STRING_INITIALIZER
17667 (struct cmd_pctype_mapping_update_result,
17669 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17670 TOKEN_STRING_INITIALIZER
17671 (struct cmd_pctype_mapping_update_result,
17672 pctype_list, NULL);
17673 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17674 TOKEN_NUM_INITIALIZER
17675 (struct cmd_pctype_mapping_update_result,
17676 flow_type, UINT16);
17679 cmd_pctype_mapping_update_parsed(
17680 void *parsed_result,
17681 __rte_unused struct cmdline *cl,
17682 __rte_unused void *data)
17684 struct cmd_pctype_mapping_update_result *res = parsed_result;
17685 int ret = -ENOTSUP;
17686 #ifdef RTE_LIBRTE_I40E_PMD
17687 struct rte_pmd_i40e_flow_type_mapping mapping;
17689 unsigned int nb_item;
17690 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17693 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17696 #ifdef RTE_LIBRTE_I40E_PMD
17697 nb_item = parse_item_list(res->pctype_list, "pctypes",
17698 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17699 mapping.flow_type = res->flow_type;
17700 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17701 mapping.pctype |= (1ULL << pctype_list[i]);
17702 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17712 printf("invalid pctype or flow type\n");
17715 printf("invalid port_id %d\n", res->port_id);
17718 printf("function not implemented\n");
17721 printf("programming error: (%s)\n", strerror(-ret));
17725 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17726 .f = cmd_pctype_mapping_update_parsed,
17728 .help_str = "port config <port_id> pctype mapping update"
17729 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17731 (void *)&cmd_pctype_mapping_update_port,
17732 (void *)&cmd_pctype_mapping_update_config,
17733 (void *)&cmd_pctype_mapping_update_port_id,
17734 (void *)&cmd_pctype_mapping_update_pctype,
17735 (void *)&cmd_pctype_mapping_update_mapping,
17736 (void *)&cmd_pctype_mapping_update_update,
17737 (void *)&cmd_pctype_mapping_update_pc_type,
17738 (void *)&cmd_pctype_mapping_update_flow_type,
17743 /* ptype mapping get */
17745 /* Common result structure for ptype mapping get */
17746 struct cmd_ptype_mapping_get_result {
17747 cmdline_fixed_string_t ptype;
17748 cmdline_fixed_string_t mapping;
17749 cmdline_fixed_string_t get;
17751 uint8_t valid_only;
17754 /* Common CLI fields for ptype mapping get */
17755 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17756 TOKEN_STRING_INITIALIZER
17757 (struct cmd_ptype_mapping_get_result,
17759 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17760 TOKEN_STRING_INITIALIZER
17761 (struct cmd_ptype_mapping_get_result,
17762 mapping, "mapping");
17763 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17764 TOKEN_STRING_INITIALIZER
17765 (struct cmd_ptype_mapping_get_result,
17767 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17768 TOKEN_NUM_INITIALIZER
17769 (struct cmd_ptype_mapping_get_result,
17771 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17772 TOKEN_NUM_INITIALIZER
17773 (struct cmd_ptype_mapping_get_result,
17774 valid_only, UINT8);
17777 cmd_ptype_mapping_get_parsed(
17778 void *parsed_result,
17779 __rte_unused struct cmdline *cl,
17780 __rte_unused void *data)
17782 struct cmd_ptype_mapping_get_result *res = parsed_result;
17783 int ret = -ENOTSUP;
17784 #ifdef RTE_LIBRTE_I40E_PMD
17785 int max_ptype_num = 256;
17786 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17791 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17794 #ifdef RTE_LIBRTE_I40E_PMD
17795 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17806 printf("invalid port_id %d\n", res->port_id);
17809 printf("function not implemented\n");
17812 printf("programming error: (%s)\n", strerror(-ret));
17815 #ifdef RTE_LIBRTE_I40E_PMD
17817 for (i = 0; i < count; i++)
17818 printf("%3d\t0x%08x\n",
17819 mapping[i].hw_ptype, mapping[i].sw_ptype);
17824 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17825 .f = cmd_ptype_mapping_get_parsed,
17827 .help_str = "ptype mapping get <port_id> <valid_only>",
17829 (void *)&cmd_ptype_mapping_get_ptype,
17830 (void *)&cmd_ptype_mapping_get_mapping,
17831 (void *)&cmd_ptype_mapping_get_get,
17832 (void *)&cmd_ptype_mapping_get_port_id,
17833 (void *)&cmd_ptype_mapping_get_valid_only,
17838 /* ptype mapping replace */
17840 /* Common result structure for ptype mapping replace */
17841 struct cmd_ptype_mapping_replace_result {
17842 cmdline_fixed_string_t ptype;
17843 cmdline_fixed_string_t mapping;
17844 cmdline_fixed_string_t replace;
17851 /* Common CLI fields for ptype mapping replace */
17852 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17853 TOKEN_STRING_INITIALIZER
17854 (struct cmd_ptype_mapping_replace_result,
17856 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17857 TOKEN_STRING_INITIALIZER
17858 (struct cmd_ptype_mapping_replace_result,
17859 mapping, "mapping");
17860 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17861 TOKEN_STRING_INITIALIZER
17862 (struct cmd_ptype_mapping_replace_result,
17863 replace, "replace");
17864 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17865 TOKEN_NUM_INITIALIZER
17866 (struct cmd_ptype_mapping_replace_result,
17868 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17869 TOKEN_NUM_INITIALIZER
17870 (struct cmd_ptype_mapping_replace_result,
17872 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17873 TOKEN_NUM_INITIALIZER
17874 (struct cmd_ptype_mapping_replace_result,
17876 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17877 TOKEN_NUM_INITIALIZER
17878 (struct cmd_ptype_mapping_replace_result,
17882 cmd_ptype_mapping_replace_parsed(
17883 void *parsed_result,
17884 __rte_unused struct cmdline *cl,
17885 __rte_unused void *data)
17887 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17888 int ret = -ENOTSUP;
17890 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17893 #ifdef RTE_LIBRTE_I40E_PMD
17894 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17904 printf("invalid ptype 0x%8x or 0x%8x\n",
17905 res->target, res->pkt_type);
17908 printf("invalid port_id %d\n", res->port_id);
17911 printf("function not implemented\n");
17914 printf("programming error: (%s)\n", strerror(-ret));
17918 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17919 .f = cmd_ptype_mapping_replace_parsed,
17922 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17924 (void *)&cmd_ptype_mapping_replace_ptype,
17925 (void *)&cmd_ptype_mapping_replace_mapping,
17926 (void *)&cmd_ptype_mapping_replace_replace,
17927 (void *)&cmd_ptype_mapping_replace_port_id,
17928 (void *)&cmd_ptype_mapping_replace_target,
17929 (void *)&cmd_ptype_mapping_replace_mask,
17930 (void *)&cmd_ptype_mapping_replace_pkt_type,
17935 /* ptype mapping reset */
17937 /* Common result structure for ptype mapping reset */
17938 struct cmd_ptype_mapping_reset_result {
17939 cmdline_fixed_string_t ptype;
17940 cmdline_fixed_string_t mapping;
17941 cmdline_fixed_string_t reset;
17945 /* Common CLI fields for ptype mapping reset*/
17946 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17947 TOKEN_STRING_INITIALIZER
17948 (struct cmd_ptype_mapping_reset_result,
17950 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17951 TOKEN_STRING_INITIALIZER
17952 (struct cmd_ptype_mapping_reset_result,
17953 mapping, "mapping");
17954 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17955 TOKEN_STRING_INITIALIZER
17956 (struct cmd_ptype_mapping_reset_result,
17958 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17959 TOKEN_NUM_INITIALIZER
17960 (struct cmd_ptype_mapping_reset_result,
17964 cmd_ptype_mapping_reset_parsed(
17965 void *parsed_result,
17966 __rte_unused struct cmdline *cl,
17967 __rte_unused void *data)
17969 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17970 int ret = -ENOTSUP;
17972 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17975 #ifdef RTE_LIBRTE_I40E_PMD
17976 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17983 printf("invalid port_id %d\n", res->port_id);
17986 printf("function not implemented\n");
17989 printf("programming error: (%s)\n", strerror(-ret));
17993 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17994 .f = cmd_ptype_mapping_reset_parsed,
17996 .help_str = "ptype mapping reset <port_id>",
17998 (void *)&cmd_ptype_mapping_reset_ptype,
17999 (void *)&cmd_ptype_mapping_reset_mapping,
18000 (void *)&cmd_ptype_mapping_reset_reset,
18001 (void *)&cmd_ptype_mapping_reset_port_id,
18006 /* ptype mapping update */
18008 /* Common result structure for ptype mapping update */
18009 struct cmd_ptype_mapping_update_result {
18010 cmdline_fixed_string_t ptype;
18011 cmdline_fixed_string_t mapping;
18012 cmdline_fixed_string_t reset;
18018 /* Common CLI fields for ptype mapping update*/
18019 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
18020 TOKEN_STRING_INITIALIZER
18021 (struct cmd_ptype_mapping_update_result,
18023 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
18024 TOKEN_STRING_INITIALIZER
18025 (struct cmd_ptype_mapping_update_result,
18026 mapping, "mapping");
18027 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
18028 TOKEN_STRING_INITIALIZER
18029 (struct cmd_ptype_mapping_update_result,
18031 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
18032 TOKEN_NUM_INITIALIZER
18033 (struct cmd_ptype_mapping_update_result,
18035 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
18036 TOKEN_NUM_INITIALIZER
18037 (struct cmd_ptype_mapping_update_result,
18039 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
18040 TOKEN_NUM_INITIALIZER
18041 (struct cmd_ptype_mapping_update_result,
18045 cmd_ptype_mapping_update_parsed(
18046 void *parsed_result,
18047 __rte_unused struct cmdline *cl,
18048 __rte_unused void *data)
18050 struct cmd_ptype_mapping_update_result *res = parsed_result;
18051 int ret = -ENOTSUP;
18052 #ifdef RTE_LIBRTE_I40E_PMD
18053 struct rte_pmd_i40e_ptype_mapping mapping;
18055 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18058 #ifdef RTE_LIBRTE_I40E_PMD
18059 mapping.hw_ptype = res->hw_ptype;
18060 mapping.sw_ptype = res->sw_ptype;
18061 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
18071 printf("invalid ptype 0x%8x\n", res->sw_ptype);
18074 printf("invalid port_id %d\n", res->port_id);
18077 printf("function not implemented\n");
18080 printf("programming error: (%s)\n", strerror(-ret));
18084 cmdline_parse_inst_t cmd_ptype_mapping_update = {
18085 .f = cmd_ptype_mapping_update_parsed,
18087 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
18089 (void *)&cmd_ptype_mapping_update_ptype,
18090 (void *)&cmd_ptype_mapping_update_mapping,
18091 (void *)&cmd_ptype_mapping_update_update,
18092 (void *)&cmd_ptype_mapping_update_port_id,
18093 (void *)&cmd_ptype_mapping_update_hw_ptype,
18094 (void *)&cmd_ptype_mapping_update_sw_ptype,
18099 /* Common result structure for file commands */
18100 struct cmd_cmdfile_result {
18101 cmdline_fixed_string_t load;
18102 cmdline_fixed_string_t filename;
18105 /* Common CLI fields for file commands */
18106 cmdline_parse_token_string_t cmd_load_cmdfile =
18107 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
18108 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
18109 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
18112 cmd_load_from_file_parsed(
18113 void *parsed_result,
18114 __rte_unused struct cmdline *cl,
18115 __rte_unused void *data)
18117 struct cmd_cmdfile_result *res = parsed_result;
18119 cmdline_read_from_file(res->filename);
18122 cmdline_parse_inst_t cmd_load_from_file = {
18123 .f = cmd_load_from_file_parsed,
18125 .help_str = "load <filename>",
18127 (void *)&cmd_load_cmdfile,
18128 (void *)&cmd_load_cmdfile_filename,
18133 /* Get Rx offloads capabilities */
18134 struct cmd_rx_offload_get_capa_result {
18135 cmdline_fixed_string_t show;
18136 cmdline_fixed_string_t port;
18138 cmdline_fixed_string_t rx_offload;
18139 cmdline_fixed_string_t capabilities;
18142 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
18143 TOKEN_STRING_INITIALIZER
18144 (struct cmd_rx_offload_get_capa_result,
18146 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
18147 TOKEN_STRING_INITIALIZER
18148 (struct cmd_rx_offload_get_capa_result,
18150 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
18151 TOKEN_NUM_INITIALIZER
18152 (struct cmd_rx_offload_get_capa_result,
18154 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
18155 TOKEN_STRING_INITIALIZER
18156 (struct cmd_rx_offload_get_capa_result,
18157 rx_offload, "rx_offload");
18158 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
18159 TOKEN_STRING_INITIALIZER
18160 (struct cmd_rx_offload_get_capa_result,
18161 capabilities, "capabilities");
18164 print_rx_offloads(uint64_t offloads)
18166 uint64_t single_offload;
18174 begin = __builtin_ctzll(offloads);
18175 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18177 single_offload = 1ULL << begin;
18178 for (bit = begin; bit < end; bit++) {
18179 if (offloads & single_offload)
18181 rte_eth_dev_rx_offload_name(single_offload));
18182 single_offload <<= 1;
18187 cmd_rx_offload_get_capa_parsed(
18188 void *parsed_result,
18189 __rte_unused struct cmdline *cl,
18190 __rte_unused void *data)
18192 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18193 struct rte_eth_dev_info dev_info;
18194 portid_t port_id = res->port_id;
18195 uint64_t queue_offloads;
18196 uint64_t port_offloads;
18199 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18203 queue_offloads = dev_info.rx_queue_offload_capa;
18204 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18206 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18207 printf(" Per Queue :");
18208 print_rx_offloads(queue_offloads);
18211 printf(" Per Port :");
18212 print_rx_offloads(port_offloads);
18216 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18217 .f = cmd_rx_offload_get_capa_parsed,
18219 .help_str = "show port <port_id> rx_offload capabilities",
18221 (void *)&cmd_rx_offload_get_capa_show,
18222 (void *)&cmd_rx_offload_get_capa_port,
18223 (void *)&cmd_rx_offload_get_capa_port_id,
18224 (void *)&cmd_rx_offload_get_capa_rx_offload,
18225 (void *)&cmd_rx_offload_get_capa_capabilities,
18230 /* Get Rx offloads configuration */
18231 struct cmd_rx_offload_get_configuration_result {
18232 cmdline_fixed_string_t show;
18233 cmdline_fixed_string_t port;
18235 cmdline_fixed_string_t rx_offload;
18236 cmdline_fixed_string_t configuration;
18239 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18240 TOKEN_STRING_INITIALIZER
18241 (struct cmd_rx_offload_get_configuration_result,
18243 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18244 TOKEN_STRING_INITIALIZER
18245 (struct cmd_rx_offload_get_configuration_result,
18247 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18248 TOKEN_NUM_INITIALIZER
18249 (struct cmd_rx_offload_get_configuration_result,
18251 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18252 TOKEN_STRING_INITIALIZER
18253 (struct cmd_rx_offload_get_configuration_result,
18254 rx_offload, "rx_offload");
18255 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18256 TOKEN_STRING_INITIALIZER
18257 (struct cmd_rx_offload_get_configuration_result,
18258 configuration, "configuration");
18261 cmd_rx_offload_get_configuration_parsed(
18262 void *parsed_result,
18263 __rte_unused struct cmdline *cl,
18264 __rte_unused void *data)
18266 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18267 struct rte_eth_dev_info dev_info;
18268 portid_t port_id = res->port_id;
18269 struct rte_port *port = &ports[port_id];
18270 uint64_t port_offloads;
18271 uint64_t queue_offloads;
18272 uint16_t nb_rx_queues;
18276 printf("Rx Offloading Configuration of port %d :\n", port_id);
18278 port_offloads = port->dev_conf.rxmode.offloads;
18280 print_rx_offloads(port_offloads);
18283 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18287 nb_rx_queues = dev_info.nb_rx_queues;
18288 for (q = 0; q < nb_rx_queues; q++) {
18289 queue_offloads = port->rx_conf[q].offloads;
18290 printf(" Queue[%2d] :", q);
18291 print_rx_offloads(queue_offloads);
18297 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18298 .f = cmd_rx_offload_get_configuration_parsed,
18300 .help_str = "show port <port_id> rx_offload configuration",
18302 (void *)&cmd_rx_offload_get_configuration_show,
18303 (void *)&cmd_rx_offload_get_configuration_port,
18304 (void *)&cmd_rx_offload_get_configuration_port_id,
18305 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18306 (void *)&cmd_rx_offload_get_configuration_configuration,
18311 /* Enable/Disable a per port offloading */
18312 struct cmd_config_per_port_rx_offload_result {
18313 cmdline_fixed_string_t port;
18314 cmdline_fixed_string_t config;
18316 cmdline_fixed_string_t rx_offload;
18317 cmdline_fixed_string_t offload;
18318 cmdline_fixed_string_t on_off;
18321 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18322 TOKEN_STRING_INITIALIZER
18323 (struct cmd_config_per_port_rx_offload_result,
18325 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18326 TOKEN_STRING_INITIALIZER
18327 (struct cmd_config_per_port_rx_offload_result,
18329 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18330 TOKEN_NUM_INITIALIZER
18331 (struct cmd_config_per_port_rx_offload_result,
18333 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18334 TOKEN_STRING_INITIALIZER
18335 (struct cmd_config_per_port_rx_offload_result,
18336 rx_offload, "rx_offload");
18337 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18338 TOKEN_STRING_INITIALIZER
18339 (struct cmd_config_per_port_rx_offload_result,
18340 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18341 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18342 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18343 "scatter#timestamp#security#keep_crc#rss_hash");
18344 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18345 TOKEN_STRING_INITIALIZER
18346 (struct cmd_config_per_port_rx_offload_result,
18350 search_rx_offload(const char *name)
18352 uint64_t single_offload;
18353 const char *single_name;
18357 single_offload = 1;
18358 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18359 single_name = rte_eth_dev_rx_offload_name(single_offload);
18360 if (!strcasecmp(single_name, name)) {
18364 single_offload <<= 1;
18368 return single_offload;
18374 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18375 __rte_unused struct cmdline *cl,
18376 __rte_unused void *data)
18378 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18379 portid_t port_id = res->port_id;
18380 struct rte_eth_dev_info dev_info;
18381 struct rte_port *port = &ports[port_id];
18382 uint64_t single_offload;
18383 uint16_t nb_rx_queues;
18387 if (port->port_status != RTE_PORT_STOPPED) {
18388 printf("Error: Can't config offload when Port %d "
18389 "is not stopped\n", port_id);
18393 single_offload = search_rx_offload(res->offload);
18394 if (single_offload == 0) {
18395 printf("Unknown offload name: %s\n", res->offload);
18399 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18403 nb_rx_queues = dev_info.nb_rx_queues;
18404 if (!strcmp(res->on_off, "on")) {
18405 port->dev_conf.rxmode.offloads |= single_offload;
18406 for (q = 0; q < nb_rx_queues; q++)
18407 port->rx_conf[q].offloads |= single_offload;
18409 port->dev_conf.rxmode.offloads &= ~single_offload;
18410 for (q = 0; q < nb_rx_queues; q++)
18411 port->rx_conf[q].offloads &= ~single_offload;
18414 cmd_reconfig_device_queue(port_id, 1, 1);
18417 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18418 .f = cmd_config_per_port_rx_offload_parsed,
18420 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18421 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18422 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18423 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18426 (void *)&cmd_config_per_port_rx_offload_result_port,
18427 (void *)&cmd_config_per_port_rx_offload_result_config,
18428 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18429 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18430 (void *)&cmd_config_per_port_rx_offload_result_offload,
18431 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18436 /* Enable/Disable a per queue offloading */
18437 struct cmd_config_per_queue_rx_offload_result {
18438 cmdline_fixed_string_t port;
18440 cmdline_fixed_string_t rxq;
18442 cmdline_fixed_string_t rx_offload;
18443 cmdline_fixed_string_t offload;
18444 cmdline_fixed_string_t on_off;
18447 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18448 TOKEN_STRING_INITIALIZER
18449 (struct cmd_config_per_queue_rx_offload_result,
18451 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18452 TOKEN_NUM_INITIALIZER
18453 (struct cmd_config_per_queue_rx_offload_result,
18455 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18456 TOKEN_STRING_INITIALIZER
18457 (struct cmd_config_per_queue_rx_offload_result,
18459 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18460 TOKEN_NUM_INITIALIZER
18461 (struct cmd_config_per_queue_rx_offload_result,
18463 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18464 TOKEN_STRING_INITIALIZER
18465 (struct cmd_config_per_queue_rx_offload_result,
18466 rx_offload, "rx_offload");
18467 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18468 TOKEN_STRING_INITIALIZER
18469 (struct cmd_config_per_queue_rx_offload_result,
18470 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18471 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18472 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18473 "scatter#timestamp#security#keep_crc");
18474 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18475 TOKEN_STRING_INITIALIZER
18476 (struct cmd_config_per_queue_rx_offload_result,
18480 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18481 __rte_unused struct cmdline *cl,
18482 __rte_unused void *data)
18484 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18485 struct rte_eth_dev_info dev_info;
18486 portid_t port_id = res->port_id;
18487 uint16_t queue_id = res->queue_id;
18488 struct rte_port *port = &ports[port_id];
18489 uint64_t single_offload;
18492 if (port->port_status != RTE_PORT_STOPPED) {
18493 printf("Error: Can't config offload when Port %d "
18494 "is not stopped\n", port_id);
18498 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18502 if (queue_id >= dev_info.nb_rx_queues) {
18503 printf("Error: input queue_id should be 0 ... "
18504 "%d\n", dev_info.nb_rx_queues - 1);
18508 single_offload = search_rx_offload(res->offload);
18509 if (single_offload == 0) {
18510 printf("Unknown offload name: %s\n", res->offload);
18514 if (!strcmp(res->on_off, "on"))
18515 port->rx_conf[queue_id].offloads |= single_offload;
18517 port->rx_conf[queue_id].offloads &= ~single_offload;
18519 cmd_reconfig_device_queue(port_id, 1, 1);
18522 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18523 .f = cmd_config_per_queue_rx_offload_parsed,
18525 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18526 "vlan_strip|ipv4_cksum|"
18527 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18528 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18529 "jumbo_frame|scatter|timestamp|security|keep_crc "
18532 (void *)&cmd_config_per_queue_rx_offload_result_port,
18533 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18534 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18535 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18536 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18537 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18538 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18543 /* Get Tx offloads capabilities */
18544 struct cmd_tx_offload_get_capa_result {
18545 cmdline_fixed_string_t show;
18546 cmdline_fixed_string_t port;
18548 cmdline_fixed_string_t tx_offload;
18549 cmdline_fixed_string_t capabilities;
18552 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18553 TOKEN_STRING_INITIALIZER
18554 (struct cmd_tx_offload_get_capa_result,
18556 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18557 TOKEN_STRING_INITIALIZER
18558 (struct cmd_tx_offload_get_capa_result,
18560 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18561 TOKEN_NUM_INITIALIZER
18562 (struct cmd_tx_offload_get_capa_result,
18564 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18565 TOKEN_STRING_INITIALIZER
18566 (struct cmd_tx_offload_get_capa_result,
18567 tx_offload, "tx_offload");
18568 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18569 TOKEN_STRING_INITIALIZER
18570 (struct cmd_tx_offload_get_capa_result,
18571 capabilities, "capabilities");
18574 print_tx_offloads(uint64_t offloads)
18576 uint64_t single_offload;
18584 begin = __builtin_ctzll(offloads);
18585 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18587 single_offload = 1ULL << begin;
18588 for (bit = begin; bit < end; bit++) {
18589 if (offloads & single_offload)
18591 rte_eth_dev_tx_offload_name(single_offload));
18592 single_offload <<= 1;
18597 cmd_tx_offload_get_capa_parsed(
18598 void *parsed_result,
18599 __rte_unused struct cmdline *cl,
18600 __rte_unused void *data)
18602 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18603 struct rte_eth_dev_info dev_info;
18604 portid_t port_id = res->port_id;
18605 uint64_t queue_offloads;
18606 uint64_t port_offloads;
18609 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18613 queue_offloads = dev_info.tx_queue_offload_capa;
18614 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18616 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18617 printf(" Per Queue :");
18618 print_tx_offloads(queue_offloads);
18621 printf(" Per Port :");
18622 print_tx_offloads(port_offloads);
18626 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18627 .f = cmd_tx_offload_get_capa_parsed,
18629 .help_str = "show port <port_id> tx_offload capabilities",
18631 (void *)&cmd_tx_offload_get_capa_show,
18632 (void *)&cmd_tx_offload_get_capa_port,
18633 (void *)&cmd_tx_offload_get_capa_port_id,
18634 (void *)&cmd_tx_offload_get_capa_tx_offload,
18635 (void *)&cmd_tx_offload_get_capa_capabilities,
18640 /* Get Tx offloads configuration */
18641 struct cmd_tx_offload_get_configuration_result {
18642 cmdline_fixed_string_t show;
18643 cmdline_fixed_string_t port;
18645 cmdline_fixed_string_t tx_offload;
18646 cmdline_fixed_string_t configuration;
18649 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18650 TOKEN_STRING_INITIALIZER
18651 (struct cmd_tx_offload_get_configuration_result,
18653 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18654 TOKEN_STRING_INITIALIZER
18655 (struct cmd_tx_offload_get_configuration_result,
18657 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18658 TOKEN_NUM_INITIALIZER
18659 (struct cmd_tx_offload_get_configuration_result,
18661 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18662 TOKEN_STRING_INITIALIZER
18663 (struct cmd_tx_offload_get_configuration_result,
18664 tx_offload, "tx_offload");
18665 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18666 TOKEN_STRING_INITIALIZER
18667 (struct cmd_tx_offload_get_configuration_result,
18668 configuration, "configuration");
18671 cmd_tx_offload_get_configuration_parsed(
18672 void *parsed_result,
18673 __rte_unused struct cmdline *cl,
18674 __rte_unused void *data)
18676 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18677 struct rte_eth_dev_info dev_info;
18678 portid_t port_id = res->port_id;
18679 struct rte_port *port = &ports[port_id];
18680 uint64_t port_offloads;
18681 uint64_t queue_offloads;
18682 uint16_t nb_tx_queues;
18686 printf("Tx Offloading Configuration of port %d :\n", port_id);
18688 port_offloads = port->dev_conf.txmode.offloads;
18690 print_tx_offloads(port_offloads);
18693 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18697 nb_tx_queues = dev_info.nb_tx_queues;
18698 for (q = 0; q < nb_tx_queues; q++) {
18699 queue_offloads = port->tx_conf[q].offloads;
18700 printf(" Queue[%2d] :", q);
18701 print_tx_offloads(queue_offloads);
18707 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18708 .f = cmd_tx_offload_get_configuration_parsed,
18710 .help_str = "show port <port_id> tx_offload configuration",
18712 (void *)&cmd_tx_offload_get_configuration_show,
18713 (void *)&cmd_tx_offload_get_configuration_port,
18714 (void *)&cmd_tx_offload_get_configuration_port_id,
18715 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18716 (void *)&cmd_tx_offload_get_configuration_configuration,
18721 /* Enable/Disable a per port offloading */
18722 struct cmd_config_per_port_tx_offload_result {
18723 cmdline_fixed_string_t port;
18724 cmdline_fixed_string_t config;
18726 cmdline_fixed_string_t tx_offload;
18727 cmdline_fixed_string_t offload;
18728 cmdline_fixed_string_t on_off;
18731 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18732 TOKEN_STRING_INITIALIZER
18733 (struct cmd_config_per_port_tx_offload_result,
18735 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18736 TOKEN_STRING_INITIALIZER
18737 (struct cmd_config_per_port_tx_offload_result,
18739 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18740 TOKEN_NUM_INITIALIZER
18741 (struct cmd_config_per_port_tx_offload_result,
18743 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18744 TOKEN_STRING_INITIALIZER
18745 (struct cmd_config_per_port_tx_offload_result,
18746 tx_offload, "tx_offload");
18747 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18748 TOKEN_STRING_INITIALIZER
18749 (struct cmd_config_per_port_tx_offload_result,
18750 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18751 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18752 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18753 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18754 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18755 "send_on_timestamp");
18756 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18757 TOKEN_STRING_INITIALIZER
18758 (struct cmd_config_per_port_tx_offload_result,
18762 search_tx_offload(const char *name)
18764 uint64_t single_offload;
18765 const char *single_name;
18769 single_offload = 1;
18770 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18771 single_name = rte_eth_dev_tx_offload_name(single_offload);
18772 if (single_name == NULL)
18774 if (!strcasecmp(single_name, name)) {
18777 } else if (!strcasecmp(single_name, "UNKNOWN"))
18779 single_offload <<= 1;
18783 return single_offload;
18789 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18790 __rte_unused struct cmdline *cl,
18791 __rte_unused void *data)
18793 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18794 portid_t port_id = res->port_id;
18795 struct rte_eth_dev_info dev_info;
18796 struct rte_port *port = &ports[port_id];
18797 uint64_t single_offload;
18798 uint16_t nb_tx_queues;
18802 if (port->port_status != RTE_PORT_STOPPED) {
18803 printf("Error: Can't config offload when Port %d "
18804 "is not stopped\n", port_id);
18808 single_offload = search_tx_offload(res->offload);
18809 if (single_offload == 0) {
18810 printf("Unknown offload name: %s\n", res->offload);
18814 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18818 nb_tx_queues = dev_info.nb_tx_queues;
18819 if (!strcmp(res->on_off, "on")) {
18820 port->dev_conf.txmode.offloads |= single_offload;
18821 for (q = 0; q < nb_tx_queues; q++)
18822 port->tx_conf[q].offloads |= single_offload;
18824 port->dev_conf.txmode.offloads &= ~single_offload;
18825 for (q = 0; q < nb_tx_queues; q++)
18826 port->tx_conf[q].offloads &= ~single_offload;
18829 cmd_reconfig_device_queue(port_id, 1, 1);
18832 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18833 .f = cmd_config_per_port_tx_offload_parsed,
18835 .help_str = "port config <port_id> tx_offload "
18836 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18837 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18838 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18839 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18840 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18841 "send_on_timestamp on|off",
18843 (void *)&cmd_config_per_port_tx_offload_result_port,
18844 (void *)&cmd_config_per_port_tx_offload_result_config,
18845 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18846 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18847 (void *)&cmd_config_per_port_tx_offload_result_offload,
18848 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18853 /* Enable/Disable a per queue offloading */
18854 struct cmd_config_per_queue_tx_offload_result {
18855 cmdline_fixed_string_t port;
18857 cmdline_fixed_string_t txq;
18859 cmdline_fixed_string_t tx_offload;
18860 cmdline_fixed_string_t offload;
18861 cmdline_fixed_string_t on_off;
18864 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18865 TOKEN_STRING_INITIALIZER
18866 (struct cmd_config_per_queue_tx_offload_result,
18868 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18869 TOKEN_NUM_INITIALIZER
18870 (struct cmd_config_per_queue_tx_offload_result,
18872 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18873 TOKEN_STRING_INITIALIZER
18874 (struct cmd_config_per_queue_tx_offload_result,
18876 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18877 TOKEN_NUM_INITIALIZER
18878 (struct cmd_config_per_queue_tx_offload_result,
18880 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18881 TOKEN_STRING_INITIALIZER
18882 (struct cmd_config_per_queue_tx_offload_result,
18883 tx_offload, "tx_offload");
18884 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18885 TOKEN_STRING_INITIALIZER
18886 (struct cmd_config_per_queue_tx_offload_result,
18887 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18888 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18889 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18890 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18891 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18892 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18893 TOKEN_STRING_INITIALIZER
18894 (struct cmd_config_per_queue_tx_offload_result,
18898 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18899 __rte_unused struct cmdline *cl,
18900 __rte_unused void *data)
18902 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18903 struct rte_eth_dev_info dev_info;
18904 portid_t port_id = res->port_id;
18905 uint16_t queue_id = res->queue_id;
18906 struct rte_port *port = &ports[port_id];
18907 uint64_t single_offload;
18910 if (port->port_status != RTE_PORT_STOPPED) {
18911 printf("Error: Can't config offload when Port %d "
18912 "is not stopped\n", port_id);
18916 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18920 if (queue_id >= dev_info.nb_tx_queues) {
18921 printf("Error: input queue_id should be 0 ... "
18922 "%d\n", dev_info.nb_tx_queues - 1);
18926 single_offload = search_tx_offload(res->offload);
18927 if (single_offload == 0) {
18928 printf("Unknown offload name: %s\n", res->offload);
18932 if (!strcmp(res->on_off, "on"))
18933 port->tx_conf[queue_id].offloads |= single_offload;
18935 port->tx_conf[queue_id].offloads &= ~single_offload;
18937 cmd_reconfig_device_queue(port_id, 1, 1);
18940 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18941 .f = cmd_config_per_queue_tx_offload_parsed,
18943 .help_str = "port <port_id> txq <queue_id> tx_offload "
18944 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18945 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18946 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18947 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18948 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18951 (void *)&cmd_config_per_queue_tx_offload_result_port,
18952 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18953 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18954 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18955 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18956 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18957 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18962 /* *** configure tx_metadata for specific port *** */
18963 struct cmd_config_tx_metadata_specific_result {
18964 cmdline_fixed_string_t port;
18965 cmdline_fixed_string_t keyword;
18967 cmdline_fixed_string_t item;
18972 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18973 __rte_unused struct cmdline *cl,
18974 __rte_unused void *data)
18976 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18978 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18980 ports[res->port_id].tx_metadata = res->value;
18981 /* Add/remove callback to insert valid metadata in every Tx packet. */
18982 if (ports[res->port_id].tx_metadata)
18983 add_tx_md_callback(res->port_id);
18985 remove_tx_md_callback(res->port_id);
18986 rte_flow_dynf_metadata_register();
18989 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18990 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18992 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18993 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18994 keyword, "config");
18995 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18996 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18998 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18999 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19000 item, "tx_metadata");
19001 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
19002 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19005 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
19006 .f = cmd_config_tx_metadata_specific_parsed,
19008 .help_str = "port config <port_id> tx_metadata <value>",
19010 (void *)&cmd_config_tx_metadata_specific_port,
19011 (void *)&cmd_config_tx_metadata_specific_keyword,
19012 (void *)&cmd_config_tx_metadata_specific_id,
19013 (void *)&cmd_config_tx_metadata_specific_item,
19014 (void *)&cmd_config_tx_metadata_specific_value,
19019 /* *** set dynf *** */
19020 struct cmd_config_tx_dynf_specific_result {
19021 cmdline_fixed_string_t port;
19022 cmdline_fixed_string_t keyword;
19024 cmdline_fixed_string_t item;
19025 cmdline_fixed_string_t name;
19026 cmdline_fixed_string_t value;
19030 cmd_config_dynf_specific_parsed(void *parsed_result,
19031 __rte_unused struct cmdline *cl,
19032 __rte_unused void *data)
19034 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
19035 struct rte_mbuf_dynflag desc_flag;
19037 uint64_t old_port_flags;
19039 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
19041 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
19043 if (strlcpy(desc_flag.name, res->name,
19044 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
19045 printf("Flag name too long\n");
19048 desc_flag.flags = 0;
19049 flag = rte_mbuf_dynflag_register(&desc_flag);
19051 printf("Can't register flag\n");
19054 strcpy(dynf_names[flag], desc_flag.name);
19056 old_port_flags = ports[res->port_id].mbuf_dynf;
19057 if (!strcmp(res->value, "set")) {
19058 ports[res->port_id].mbuf_dynf |= 1UL << flag;
19059 if (old_port_flags == 0)
19060 add_tx_dynf_callback(res->port_id);
19062 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
19063 if (ports[res->port_id].mbuf_dynf == 0)
19064 remove_tx_dynf_callback(res->port_id);
19068 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
19069 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19071 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
19072 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19073 keyword, "config");
19074 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
19075 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19077 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
19078 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19080 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
19081 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19083 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
19084 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19085 value, "set#clear");
19087 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
19088 .f = cmd_config_dynf_specific_parsed,
19090 .help_str = "port config <port id> dynf <name> set|clear",
19092 (void *)&cmd_config_tx_dynf_specific_port,
19093 (void *)&cmd_config_tx_dynf_specific_keyword,
19094 (void *)&cmd_config_tx_dynf_specific_port_id,
19095 (void *)&cmd_config_tx_dynf_specific_item,
19096 (void *)&cmd_config_tx_dynf_specific_name,
19097 (void *)&cmd_config_tx_dynf_specific_value,
19102 /* *** display tx_metadata per port configuration *** */
19103 struct cmd_show_tx_metadata_result {
19104 cmdline_fixed_string_t cmd_show;
19105 cmdline_fixed_string_t cmd_port;
19106 cmdline_fixed_string_t cmd_keyword;
19111 cmd_show_tx_metadata_parsed(void *parsed_result,
19112 __rte_unused struct cmdline *cl,
19113 __rte_unused void *data)
19115 struct cmd_show_tx_metadata_result *res = parsed_result;
19117 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19118 printf("invalid port id %u\n", res->cmd_pid);
19121 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
19122 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
19123 ports[res->cmd_pid].tx_metadata);
19127 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
19128 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19130 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
19131 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19133 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
19134 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
19136 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
19137 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19138 cmd_keyword, "tx_metadata");
19140 cmdline_parse_inst_t cmd_show_tx_metadata = {
19141 .f = cmd_show_tx_metadata_parsed,
19143 .help_str = "show port <port_id> tx_metadata",
19145 (void *)&cmd_show_tx_metadata_show,
19146 (void *)&cmd_show_tx_metadata_port,
19147 (void *)&cmd_show_tx_metadata_pid,
19148 (void *)&cmd_show_tx_metadata_keyword,
19153 /* show port supported ptypes */
19155 /* Common result structure for show port ptypes */
19156 struct cmd_show_port_supported_ptypes_result {
19157 cmdline_fixed_string_t show;
19158 cmdline_fixed_string_t port;
19160 cmdline_fixed_string_t ptypes;
19163 /* Common CLI fields for show port ptypes */
19164 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
19165 TOKEN_STRING_INITIALIZER
19166 (struct cmd_show_port_supported_ptypes_result,
19168 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
19169 TOKEN_STRING_INITIALIZER
19170 (struct cmd_show_port_supported_ptypes_result,
19172 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19173 TOKEN_NUM_INITIALIZER
19174 (struct cmd_show_port_supported_ptypes_result,
19176 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19177 TOKEN_STRING_INITIALIZER
19178 (struct cmd_show_port_supported_ptypes_result,
19182 cmd_show_port_supported_ptypes_parsed(
19183 void *parsed_result,
19184 __rte_unused struct cmdline *cl,
19185 __rte_unused void *data)
19187 #define RSVD_PTYPE_MASK 0xf0000000
19188 #define MAX_PTYPES_PER_LAYER 16
19189 #define LTYPE_NAMESIZE 32
19190 #define PTYPE_NAMESIZE 256
19191 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19192 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19193 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19194 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19195 uint16_t port_id = res->port_id;
19198 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19202 while (ptype_mask != RSVD_PTYPE_MASK) {
19204 switch (ptype_mask) {
19205 case RTE_PTYPE_L2_MASK:
19206 strlcpy(ltype, "L2", sizeof(ltype));
19208 case RTE_PTYPE_L3_MASK:
19209 strlcpy(ltype, "L3", sizeof(ltype));
19211 case RTE_PTYPE_L4_MASK:
19212 strlcpy(ltype, "L4", sizeof(ltype));
19214 case RTE_PTYPE_TUNNEL_MASK:
19215 strlcpy(ltype, "Tunnel", sizeof(ltype));
19217 case RTE_PTYPE_INNER_L2_MASK:
19218 strlcpy(ltype, "Inner L2", sizeof(ltype));
19220 case RTE_PTYPE_INNER_L3_MASK:
19221 strlcpy(ltype, "Inner L3", sizeof(ltype));
19223 case RTE_PTYPE_INNER_L4_MASK:
19224 strlcpy(ltype, "Inner L4", sizeof(ltype));
19230 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19231 ptype_mask, ptypes,
19232 MAX_PTYPES_PER_LAYER);
19235 printf("Supported %s ptypes:\n", ltype);
19237 printf("%s ptypes unsupported\n", ltype);
19239 for (i = 0; i < ret; ++i) {
19240 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19241 printf("%s\n", buf);
19248 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19249 .f = cmd_show_port_supported_ptypes_parsed,
19251 .help_str = "show port <port_id> ptypes",
19253 (void *)&cmd_show_port_supported_ptypes_show,
19254 (void *)&cmd_show_port_supported_ptypes_port,
19255 (void *)&cmd_show_port_supported_ptypes_port_id,
19256 (void *)&cmd_show_port_supported_ptypes_ptypes,
19261 /* *** display rx/tx descriptor status *** */
19262 struct cmd_show_rx_tx_desc_status_result {
19263 cmdline_fixed_string_t cmd_show;
19264 cmdline_fixed_string_t cmd_port;
19265 cmdline_fixed_string_t cmd_keyword;
19266 cmdline_fixed_string_t cmd_desc;
19267 cmdline_fixed_string_t cmd_status;
19274 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19275 __rte_unused struct cmdline *cl,
19276 __rte_unused void *data)
19278 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19281 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19282 printf("invalid port id %u\n", res->cmd_pid);
19286 if (!strcmp(res->cmd_keyword, "rxq")) {
19287 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19290 printf("Invalid queueid = %d\n", res->cmd_qid);
19293 if (rc == RTE_ETH_RX_DESC_AVAIL)
19294 printf("Desc status = AVAILABLE\n");
19295 else if (rc == RTE_ETH_RX_DESC_DONE)
19296 printf("Desc status = DONE\n");
19298 printf("Desc status = UNAVAILABLE\n");
19299 } else if (!strcmp(res->cmd_keyword, "txq")) {
19300 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19303 printf("Invalid queueid = %d\n", res->cmd_qid);
19306 if (rc == RTE_ETH_TX_DESC_FULL)
19307 printf("Desc status = FULL\n");
19308 else if (rc == RTE_ETH_TX_DESC_DONE)
19309 printf("Desc status = DONE\n");
19311 printf("Desc status = UNAVAILABLE\n");
19315 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19316 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19318 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19319 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19321 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19322 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19324 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19325 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19326 cmd_keyword, "rxq#txq");
19327 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19328 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19330 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19331 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19333 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19334 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19336 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19337 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19338 cmd_status, "status");
19339 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19340 .f = cmd_show_rx_tx_desc_status_parsed,
19342 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19345 (void *)&cmd_show_rx_tx_desc_status_show,
19346 (void *)&cmd_show_rx_tx_desc_status_port,
19347 (void *)&cmd_show_rx_tx_desc_status_pid,
19348 (void *)&cmd_show_rx_tx_desc_status_keyword,
19349 (void *)&cmd_show_rx_tx_desc_status_qid,
19350 (void *)&cmd_show_rx_tx_desc_status_desc,
19351 (void *)&cmd_show_rx_tx_desc_status_did,
19352 (void *)&cmd_show_rx_tx_desc_status_status,
19357 /* Common result structure for set port ptypes */
19358 struct cmd_set_port_ptypes_result {
19359 cmdline_fixed_string_t set;
19360 cmdline_fixed_string_t port;
19362 cmdline_fixed_string_t ptype_mask;
19366 /* Common CLI fields for set port ptypes */
19367 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19368 TOKEN_STRING_INITIALIZER
19369 (struct cmd_set_port_ptypes_result,
19371 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19372 TOKEN_STRING_INITIALIZER
19373 (struct cmd_set_port_ptypes_result,
19375 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19376 TOKEN_NUM_INITIALIZER
19377 (struct cmd_set_port_ptypes_result,
19379 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19380 TOKEN_STRING_INITIALIZER
19381 (struct cmd_set_port_ptypes_result,
19382 ptype_mask, "ptype_mask");
19383 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19384 TOKEN_NUM_INITIALIZER
19385 (struct cmd_set_port_ptypes_result,
19389 cmd_set_port_ptypes_parsed(
19390 void *parsed_result,
19391 __rte_unused struct cmdline *cl,
19392 __rte_unused void *data)
19394 struct cmd_set_port_ptypes_result *res = parsed_result;
19395 #define PTYPE_NAMESIZE 256
19396 char ptype_name[PTYPE_NAMESIZE];
19397 uint16_t port_id = res->port_id;
19398 uint32_t ptype_mask = res->mask;
19401 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19404 printf("Port %d doesn't support any ptypes.\n", port_id);
19408 uint32_t ptypes[ret];
19410 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19412 printf("Unable to set requested ptypes for Port %d\n", port_id);
19416 printf("Successfully set following ptypes for Port %d\n", port_id);
19417 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19418 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19419 printf("%s\n", ptype_name);
19422 clear_ptypes = false;
19425 cmdline_parse_inst_t cmd_set_port_ptypes = {
19426 .f = cmd_set_port_ptypes_parsed,
19428 .help_str = "set port <port_id> ptype_mask <mask>",
19430 (void *)&cmd_set_port_ptypes_set,
19431 (void *)&cmd_set_port_ptypes_port,
19432 (void *)&cmd_set_port_ptypes_port_id,
19433 (void *)&cmd_set_port_ptypes_mask_str,
19434 (void *)&cmd_set_port_ptypes_mask_u32,
19439 /* *** display mac addresses added to a port *** */
19440 struct cmd_showport_macs_result {
19441 cmdline_fixed_string_t cmd_show;
19442 cmdline_fixed_string_t cmd_port;
19443 cmdline_fixed_string_t cmd_keyword;
19448 cmd_showport_macs_parsed(void *parsed_result,
19449 __rte_unused struct cmdline *cl,
19450 __rte_unused void *data)
19452 struct cmd_showport_macs_result *res = parsed_result;
19454 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19457 if (!strcmp(res->cmd_keyword, "macs"))
19458 show_macs(res->cmd_pid);
19459 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19460 show_mcast_macs(res->cmd_pid);
19463 cmdline_parse_token_string_t cmd_showport_macs_show =
19464 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19466 cmdline_parse_token_string_t cmd_showport_macs_port =
19467 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19469 cmdline_parse_token_num_t cmd_showport_macs_pid =
19470 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19472 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19473 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19474 cmd_keyword, "macs#mcast_macs");
19476 cmdline_parse_inst_t cmd_showport_macs = {
19477 .f = cmd_showport_macs_parsed,
19479 .help_str = "show port <port_id> macs|mcast_macs",
19481 (void *)&cmd_showport_macs_show,
19482 (void *)&cmd_showport_macs_port,
19483 (void *)&cmd_showport_macs_pid,
19484 (void *)&cmd_showport_macs_keyword,
19489 /* ******************************************************************************** */
19491 /* list of instructions */
19492 cmdline_parse_ctx_t main_ctx[] = {
19493 (cmdline_parse_inst_t *)&cmd_help_brief,
19494 (cmdline_parse_inst_t *)&cmd_help_long,
19495 (cmdline_parse_inst_t *)&cmd_quit,
19496 (cmdline_parse_inst_t *)&cmd_load_from_file,
19497 (cmdline_parse_inst_t *)&cmd_showport,
19498 (cmdline_parse_inst_t *)&cmd_showqueue,
19499 (cmdline_parse_inst_t *)&cmd_showportall,
19500 (cmdline_parse_inst_t *)&cmd_showdevice,
19501 (cmdline_parse_inst_t *)&cmd_showcfg,
19502 (cmdline_parse_inst_t *)&cmd_showfwdall,
19503 (cmdline_parse_inst_t *)&cmd_start,
19504 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19505 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19506 (cmdline_parse_inst_t *)&cmd_set_link_up,
19507 (cmdline_parse_inst_t *)&cmd_set_link_down,
19508 (cmdline_parse_inst_t *)&cmd_reset,
19509 (cmdline_parse_inst_t *)&cmd_set_numbers,
19510 (cmdline_parse_inst_t *)&cmd_set_log,
19511 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19512 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19513 (cmdline_parse_inst_t *)&cmd_set_txtimes,
19514 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19515 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19516 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19517 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19518 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19519 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19520 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19521 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19522 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19523 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19524 (cmdline_parse_inst_t *)&cmd_set_link_check,
19525 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19526 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19527 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19528 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19529 #ifdef RTE_LIBRTE_PMD_BOND
19530 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19531 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19532 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19533 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19534 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19535 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19536 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19537 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19538 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19539 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19540 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19542 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19543 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19544 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19545 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19546 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19547 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19548 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19549 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19550 (cmdline_parse_inst_t *)&cmd_csum_set,
19551 (cmdline_parse_inst_t *)&cmd_csum_show,
19552 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19553 (cmdline_parse_inst_t *)&cmd_tso_set,
19554 (cmdline_parse_inst_t *)&cmd_tso_show,
19555 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19556 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19557 (cmdline_parse_inst_t *)&cmd_gro_enable,
19558 (cmdline_parse_inst_t *)&cmd_gro_flush,
19559 (cmdline_parse_inst_t *)&cmd_gro_show,
19560 (cmdline_parse_inst_t *)&cmd_gso_enable,
19561 (cmdline_parse_inst_t *)&cmd_gso_size,
19562 (cmdline_parse_inst_t *)&cmd_gso_show,
19563 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19564 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19565 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19566 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19567 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19568 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19569 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19570 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19571 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19572 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19573 (cmdline_parse_inst_t *)&cmd_config_dcb,
19574 (cmdline_parse_inst_t *)&cmd_read_reg,
19575 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19576 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19577 (cmdline_parse_inst_t *)&cmd_write_reg,
19578 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19579 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19580 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19581 (cmdline_parse_inst_t *)&cmd_stop,
19582 (cmdline_parse_inst_t *)&cmd_mac_addr,
19583 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19584 (cmdline_parse_inst_t *)&cmd_set_qmap,
19585 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19586 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
19587 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
19588 (cmdline_parse_inst_t *)&cmd_operate_port,
19589 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19590 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19591 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19592 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19593 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19594 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19595 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19596 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19597 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19598 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19599 (cmdline_parse_inst_t *)&cmd_config_mtu,
19600 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19601 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19602 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19603 (cmdline_parse_inst_t *)&cmd_config_rss,
19604 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19605 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19606 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19607 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19608 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19609 (cmdline_parse_inst_t *)&cmd_showport_reta,
19610 (cmdline_parse_inst_t *)&cmd_showport_macs,
19611 (cmdline_parse_inst_t *)&cmd_config_burst,
19612 (cmdline_parse_inst_t *)&cmd_config_thresh,
19613 (cmdline_parse_inst_t *)&cmd_config_threshold,
19614 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19615 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19616 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19617 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19618 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19619 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19620 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19621 (cmdline_parse_inst_t *)&cmd_global_config,
19622 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19623 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19624 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19625 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19626 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19627 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19628 (cmdline_parse_inst_t *)&cmd_dump,
19629 (cmdline_parse_inst_t *)&cmd_dump_one,
19630 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19631 (cmdline_parse_inst_t *)&cmd_syn_filter,
19632 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19633 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19634 (cmdline_parse_inst_t *)&cmd_flex_filter,
19635 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19636 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19637 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19638 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19639 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19640 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19641 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19642 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19643 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19644 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19645 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19646 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19647 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19648 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19649 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19650 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19651 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19652 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19653 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19654 (cmdline_parse_inst_t *)&cmd_flow,
19655 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19656 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19657 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19658 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19659 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19660 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19661 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19662 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19663 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19664 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19665 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19666 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19667 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19668 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19669 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19670 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19671 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19672 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19673 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19674 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19675 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19676 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19677 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19678 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19679 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19680 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19681 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19682 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19683 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19684 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19685 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19686 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19687 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19688 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19689 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19690 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19691 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19692 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19693 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19694 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19695 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19696 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19697 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19698 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19699 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19700 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19701 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19702 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19703 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19704 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19705 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19706 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19707 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19708 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19709 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19710 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19711 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19712 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19713 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19714 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19715 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19716 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19717 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19718 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19719 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19720 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19721 (cmdline_parse_inst_t *)&cmd_ddp_add,
19722 (cmdline_parse_inst_t *)&cmd_ddp_del,
19723 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19724 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19725 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19726 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19727 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19728 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19729 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19730 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19731 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19732 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19733 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19734 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19736 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19737 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19738 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19739 (cmdline_parse_inst_t *)&cmd_queue_region,
19740 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19741 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19742 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19743 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19744 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19745 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19746 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19747 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19748 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19749 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19750 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19751 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19752 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19753 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19754 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19755 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19756 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19757 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
19758 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19759 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19760 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19761 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19762 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19763 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19764 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19765 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19766 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19767 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19768 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19769 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19770 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19771 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19772 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19773 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19774 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19775 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19776 #ifdef RTE_LIBRTE_BPF
19777 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19778 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19780 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19781 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19782 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19783 (cmdline_parse_inst_t *)&cmd_set_raw,
19784 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19785 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19786 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
19790 /* read cmdline commands from file */
19792 cmdline_read_from_file(const char *filename)
19794 struct cmdline *cl;
19796 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19798 printf("Failed to create file based cmdline context: %s\n",
19803 cmdline_interact(cl);
19808 printf("Read CLI commands from %s\n", filename);
19811 /* prompt function, called from main on MASTER lcore */
19815 /* initialize non-constant commands */
19816 cmd_set_fwd_mode_init();
19817 cmd_set_fwd_retry_mode_init();
19819 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19820 if (testpmd_cl == NULL)
19822 cmdline_interact(testpmd_cl);
19823 cmdline_stdin_exit(testpmd_cl);
19829 if (testpmd_cl != NULL)
19830 cmdline_quit(testpmd_cl);
19834 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19836 if (id == (portid_t)RTE_PORT_ALL) {
19839 RTE_ETH_FOREACH_DEV(pid) {
19840 /* check if need_reconfig has been set to 1 */
19841 if (ports[pid].need_reconfig == 0)
19842 ports[pid].need_reconfig = dev;
19843 /* check if need_reconfig_queues has been set to 1 */
19844 if (ports[pid].need_reconfig_queues == 0)
19845 ports[pid].need_reconfig_queues = queue;
19847 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19848 /* check if need_reconfig has been set to 1 */
19849 if (ports[id].need_reconfig == 0)
19850 ports[id].need_reconfig = dev;
19851 /* check if need_reconfig_queues has been set to 1 */
19852 if (ports[id].need_reconfig_queues == 0)
19853 ports[id].need_reconfig_queues = queue;