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)\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 leaf node (port_id) (node_id) (parent_node_id)"
1234 " (priority) (weight) (level_id) (shaper_profile_id)"
1235 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1236 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1237 " Add port tm leaf node.\n\n"
1239 "del port tm node (port_id) (node_id)\n"
1240 " Delete port tm node.\n\n"
1242 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1243 " (priority) (weight)\n"
1244 " Set port tm node parent.\n\n"
1246 "suspend port tm node (port_id) (node_id)"
1247 " Suspend tm node.\n\n"
1249 "resume port tm node (port_id) (node_id)"
1250 " Resume tm node.\n\n"
1252 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1253 " Commit tm hierarchy.\n\n"
1255 "set port tm mark ip_ecn (port) (green) (yellow)"
1257 " Enables/Disables the traffic management marking"
1258 " for IP ECN (Explicit Congestion Notification)"
1259 " packets on a given port\n\n"
1261 "set port tm mark ip_dscp (port) (green) (yellow)"
1263 " Enables/Disables the traffic management marking"
1264 " on the port for IP dscp packets\n\n"
1266 "set port tm mark vlan_dei (port) (green) (yellow)"
1268 " Enables/Disables the traffic management marking"
1269 " on the port for VLAN packets with DEI enabled\n\n"
1273 if (show_all || !strcmp(res->section, "devices")) {
1277 "Device Operations:\n"
1279 "device detach (identifier)\n"
1280 " Detach device by identifier.\n\n"
1286 cmdline_parse_token_string_t cmd_help_long_help =
1287 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1289 cmdline_parse_token_string_t cmd_help_long_section =
1290 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1291 "all#control#display#config#"
1292 "ports#registers#filters#traffic_management#devices");
1294 cmdline_parse_inst_t cmd_help_long = {
1295 .f = cmd_help_long_parsed,
1297 .help_str = "help all|control|display|config|ports|register|"
1298 "filters|traffic_management|devices: "
1301 (void *)&cmd_help_long_help,
1302 (void *)&cmd_help_long_section,
1308 /* *** start/stop/close all ports *** */
1309 struct cmd_operate_port_result {
1310 cmdline_fixed_string_t keyword;
1311 cmdline_fixed_string_t name;
1312 cmdline_fixed_string_t value;
1315 static void cmd_operate_port_parsed(void *parsed_result,
1316 __rte_unused struct cmdline *cl,
1317 __rte_unused void *data)
1319 struct cmd_operate_port_result *res = parsed_result;
1321 if (!strcmp(res->name, "start"))
1322 start_port(RTE_PORT_ALL);
1323 else if (!strcmp(res->name, "stop"))
1324 stop_port(RTE_PORT_ALL);
1325 else if (!strcmp(res->name, "close"))
1326 close_port(RTE_PORT_ALL);
1327 else if (!strcmp(res->name, "reset"))
1328 reset_port(RTE_PORT_ALL);
1330 printf("Unknown parameter\n");
1333 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1334 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1336 cmdline_parse_token_string_t cmd_operate_port_all_port =
1337 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1338 "start#stop#close#reset");
1339 cmdline_parse_token_string_t cmd_operate_port_all_all =
1340 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1342 cmdline_parse_inst_t cmd_operate_port = {
1343 .f = cmd_operate_port_parsed,
1345 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1347 (void *)&cmd_operate_port_all_cmd,
1348 (void *)&cmd_operate_port_all_port,
1349 (void *)&cmd_operate_port_all_all,
1354 /* *** start/stop/close specific port *** */
1355 struct cmd_operate_specific_port_result {
1356 cmdline_fixed_string_t keyword;
1357 cmdline_fixed_string_t name;
1361 static void cmd_operate_specific_port_parsed(void *parsed_result,
1362 __rte_unused struct cmdline *cl,
1363 __rte_unused void *data)
1365 struct cmd_operate_specific_port_result *res = parsed_result;
1367 if (!strcmp(res->name, "start"))
1368 start_port(res->value);
1369 else if (!strcmp(res->name, "stop"))
1370 stop_port(res->value);
1371 else if (!strcmp(res->name, "close"))
1372 close_port(res->value);
1373 else if (!strcmp(res->name, "reset"))
1374 reset_port(res->value);
1376 printf("Unknown parameter\n");
1379 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1380 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1382 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1383 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1384 name, "start#stop#close#reset");
1385 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1386 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1389 cmdline_parse_inst_t cmd_operate_specific_port = {
1390 .f = cmd_operate_specific_port_parsed,
1392 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1394 (void *)&cmd_operate_specific_port_cmd,
1395 (void *)&cmd_operate_specific_port_port,
1396 (void *)&cmd_operate_specific_port_id,
1401 /* *** enable port setup (after attach) via iterator or event *** */
1402 struct cmd_set_port_setup_on_result {
1403 cmdline_fixed_string_t set;
1404 cmdline_fixed_string_t port;
1405 cmdline_fixed_string_t setup;
1406 cmdline_fixed_string_t on;
1407 cmdline_fixed_string_t mode;
1410 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1411 __rte_unused struct cmdline *cl,
1412 __rte_unused void *data)
1414 struct cmd_set_port_setup_on_result *res = parsed_result;
1416 if (strcmp(res->mode, "event") == 0)
1417 setup_on_probe_event = true;
1418 else if (strcmp(res->mode, "iterator") == 0)
1419 setup_on_probe_event = false;
1421 printf("Unknown mode\n");
1424 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1425 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1427 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1428 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1430 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1431 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1433 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1434 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1436 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1437 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1438 mode, "iterator#event");
1440 cmdline_parse_inst_t cmd_set_port_setup_on = {
1441 .f = cmd_set_port_setup_on_parsed,
1443 .help_str = "set port setup on iterator|event",
1445 (void *)&cmd_set_port_setup_on_set,
1446 (void *)&cmd_set_port_setup_on_port,
1447 (void *)&cmd_set_port_setup_on_setup,
1448 (void *)&cmd_set_port_setup_on_on,
1449 (void *)&cmd_set_port_setup_on_mode,
1454 /* *** attach a specified port *** */
1455 struct cmd_operate_attach_port_result {
1456 cmdline_fixed_string_t port;
1457 cmdline_fixed_string_t keyword;
1458 cmdline_multi_string_t identifier;
1461 static void cmd_operate_attach_port_parsed(void *parsed_result,
1462 __rte_unused struct cmdline *cl,
1463 __rte_unused void *data)
1465 struct cmd_operate_attach_port_result *res = parsed_result;
1467 if (!strcmp(res->keyword, "attach"))
1468 attach_port(res->identifier);
1470 printf("Unknown parameter\n");
1473 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1474 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1476 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1477 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1479 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1480 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1481 identifier, TOKEN_STRING_MULTI);
1483 cmdline_parse_inst_t cmd_operate_attach_port = {
1484 .f = cmd_operate_attach_port_parsed,
1486 .help_str = "port attach <identifier>: "
1487 "(identifier: pci address or virtual dev name)",
1489 (void *)&cmd_operate_attach_port_port,
1490 (void *)&cmd_operate_attach_port_keyword,
1491 (void *)&cmd_operate_attach_port_identifier,
1496 /* *** detach a specified port *** */
1497 struct cmd_operate_detach_port_result {
1498 cmdline_fixed_string_t port;
1499 cmdline_fixed_string_t keyword;
1503 static void cmd_operate_detach_port_parsed(void *parsed_result,
1504 __rte_unused struct cmdline *cl,
1505 __rte_unused void *data)
1507 struct cmd_operate_detach_port_result *res = parsed_result;
1509 if (!strcmp(res->keyword, "detach")) {
1510 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1511 detach_port_device(res->port_id);
1513 printf("Unknown parameter\n");
1517 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1518 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1520 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1521 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1523 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1524 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1527 cmdline_parse_inst_t cmd_operate_detach_port = {
1528 .f = cmd_operate_detach_port_parsed,
1530 .help_str = "port detach <port_id>",
1532 (void *)&cmd_operate_detach_port_port,
1533 (void *)&cmd_operate_detach_port_keyword,
1534 (void *)&cmd_operate_detach_port_port_id,
1539 /* *** detach device by identifier *** */
1540 struct cmd_operate_detach_device_result {
1541 cmdline_fixed_string_t device;
1542 cmdline_fixed_string_t keyword;
1543 cmdline_fixed_string_t identifier;
1546 static void cmd_operate_detach_device_parsed(void *parsed_result,
1547 __rte_unused struct cmdline *cl,
1548 __rte_unused void *data)
1550 struct cmd_operate_detach_device_result *res = parsed_result;
1552 if (!strcmp(res->keyword, "detach"))
1553 detach_devargs(res->identifier);
1555 printf("Unknown parameter\n");
1558 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1559 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1561 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1562 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1564 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1565 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1568 cmdline_parse_inst_t cmd_operate_detach_device = {
1569 .f = cmd_operate_detach_device_parsed,
1571 .help_str = "device detach <identifier>:"
1572 "(identifier: pci address or virtual dev name)",
1574 (void *)&cmd_operate_detach_device_device,
1575 (void *)&cmd_operate_detach_device_keyword,
1576 (void *)&cmd_operate_detach_device_identifier,
1580 /* *** configure speed for all ports *** */
1581 struct cmd_config_speed_all {
1582 cmdline_fixed_string_t port;
1583 cmdline_fixed_string_t keyword;
1584 cmdline_fixed_string_t all;
1585 cmdline_fixed_string_t item1;
1586 cmdline_fixed_string_t item2;
1587 cmdline_fixed_string_t value1;
1588 cmdline_fixed_string_t value2;
1592 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1597 if (!strcmp(duplexstr, "half")) {
1598 duplex = ETH_LINK_HALF_DUPLEX;
1599 } else if (!strcmp(duplexstr, "full")) {
1600 duplex = ETH_LINK_FULL_DUPLEX;
1601 } else if (!strcmp(duplexstr, "auto")) {
1602 duplex = ETH_LINK_FULL_DUPLEX;
1604 printf("Unknown duplex parameter\n");
1608 if (!strcmp(speedstr, "10")) {
1609 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1610 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1611 } else if (!strcmp(speedstr, "100")) {
1612 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1613 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1615 if (duplex != ETH_LINK_FULL_DUPLEX) {
1616 printf("Invalid speed/duplex parameters\n");
1619 if (!strcmp(speedstr, "1000")) {
1620 *speed = ETH_LINK_SPEED_1G;
1621 } else if (!strcmp(speedstr, "10000")) {
1622 *speed = ETH_LINK_SPEED_10G;
1623 } else if (!strcmp(speedstr, "25000")) {
1624 *speed = ETH_LINK_SPEED_25G;
1625 } else if (!strcmp(speedstr, "40000")) {
1626 *speed = ETH_LINK_SPEED_40G;
1627 } else if (!strcmp(speedstr, "50000")) {
1628 *speed = ETH_LINK_SPEED_50G;
1629 } else if (!strcmp(speedstr, "100000")) {
1630 *speed = ETH_LINK_SPEED_100G;
1631 } else if (!strcmp(speedstr, "200000")) {
1632 *speed = ETH_LINK_SPEED_200G;
1633 } else if (!strcmp(speedstr, "auto")) {
1634 *speed = ETH_LINK_SPEED_AUTONEG;
1636 printf("Unknown speed parameter\n");
1645 cmd_config_speed_all_parsed(void *parsed_result,
1646 __rte_unused struct cmdline *cl,
1647 __rte_unused void *data)
1649 struct cmd_config_speed_all *res = parsed_result;
1650 uint32_t link_speed;
1653 if (!all_ports_stopped()) {
1654 printf("Please stop all ports first\n");
1658 if (parse_and_check_speed_duplex(res->value1, res->value2,
1662 RTE_ETH_FOREACH_DEV(pid) {
1663 ports[pid].dev_conf.link_speeds = link_speed;
1666 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1669 cmdline_parse_token_string_t cmd_config_speed_all_port =
1670 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1671 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1672 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1674 cmdline_parse_token_string_t cmd_config_speed_all_all =
1675 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1676 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1677 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1678 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1679 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1680 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1681 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1682 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1683 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1684 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1687 cmdline_parse_inst_t cmd_config_speed_all = {
1688 .f = cmd_config_speed_all_parsed,
1690 .help_str = "port config all speed "
1691 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1694 (void *)&cmd_config_speed_all_port,
1695 (void *)&cmd_config_speed_all_keyword,
1696 (void *)&cmd_config_speed_all_all,
1697 (void *)&cmd_config_speed_all_item1,
1698 (void *)&cmd_config_speed_all_value1,
1699 (void *)&cmd_config_speed_all_item2,
1700 (void *)&cmd_config_speed_all_value2,
1705 /* *** configure speed for specific port *** */
1706 struct cmd_config_speed_specific {
1707 cmdline_fixed_string_t port;
1708 cmdline_fixed_string_t keyword;
1710 cmdline_fixed_string_t item1;
1711 cmdline_fixed_string_t item2;
1712 cmdline_fixed_string_t value1;
1713 cmdline_fixed_string_t value2;
1717 cmd_config_speed_specific_parsed(void *parsed_result,
1718 __rte_unused struct cmdline *cl,
1719 __rte_unused void *data)
1721 struct cmd_config_speed_specific *res = parsed_result;
1722 uint32_t link_speed;
1724 if (!all_ports_stopped()) {
1725 printf("Please stop all ports first\n");
1729 if (port_id_is_invalid(res->id, ENABLED_WARN))
1732 if (parse_and_check_speed_duplex(res->value1, res->value2,
1736 ports[res->id].dev_conf.link_speeds = link_speed;
1738 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1742 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1743 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1745 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1746 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1748 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1749 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1750 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1751 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1753 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1754 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1755 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1756 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1757 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1759 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1760 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1763 cmdline_parse_inst_t cmd_config_speed_specific = {
1764 .f = cmd_config_speed_specific_parsed,
1766 .help_str = "port config <port_id> speed "
1767 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1770 (void *)&cmd_config_speed_specific_port,
1771 (void *)&cmd_config_speed_specific_keyword,
1772 (void *)&cmd_config_speed_specific_id,
1773 (void *)&cmd_config_speed_specific_item1,
1774 (void *)&cmd_config_speed_specific_value1,
1775 (void *)&cmd_config_speed_specific_item2,
1776 (void *)&cmd_config_speed_specific_value2,
1781 /* *** configure loopback for all ports *** */
1782 struct cmd_config_loopback_all {
1783 cmdline_fixed_string_t port;
1784 cmdline_fixed_string_t keyword;
1785 cmdline_fixed_string_t all;
1786 cmdline_fixed_string_t item;
1791 cmd_config_loopback_all_parsed(void *parsed_result,
1792 __rte_unused struct cmdline *cl,
1793 __rte_unused void *data)
1795 struct cmd_config_loopback_all *res = parsed_result;
1798 if (!all_ports_stopped()) {
1799 printf("Please stop all ports first\n");
1803 RTE_ETH_FOREACH_DEV(pid) {
1804 ports[pid].dev_conf.lpbk_mode = res->mode;
1807 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1810 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1811 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1812 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1813 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1815 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1816 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1817 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1818 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1820 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1821 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1823 cmdline_parse_inst_t cmd_config_loopback_all = {
1824 .f = cmd_config_loopback_all_parsed,
1826 .help_str = "port config all loopback <mode>",
1828 (void *)&cmd_config_loopback_all_port,
1829 (void *)&cmd_config_loopback_all_keyword,
1830 (void *)&cmd_config_loopback_all_all,
1831 (void *)&cmd_config_loopback_all_item,
1832 (void *)&cmd_config_loopback_all_mode,
1837 /* *** configure loopback for specific port *** */
1838 struct cmd_config_loopback_specific {
1839 cmdline_fixed_string_t port;
1840 cmdline_fixed_string_t keyword;
1842 cmdline_fixed_string_t item;
1847 cmd_config_loopback_specific_parsed(void *parsed_result,
1848 __rte_unused struct cmdline *cl,
1849 __rte_unused void *data)
1851 struct cmd_config_loopback_specific *res = parsed_result;
1853 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1856 if (!port_is_stopped(res->port_id)) {
1857 printf("Please stop port %u first\n", res->port_id);
1861 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1863 cmd_reconfig_device_queue(res->port_id, 1, 1);
1867 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1868 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1870 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1871 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1873 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1874 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1876 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1877 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1879 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1880 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1883 cmdline_parse_inst_t cmd_config_loopback_specific = {
1884 .f = cmd_config_loopback_specific_parsed,
1886 .help_str = "port config <port_id> loopback <mode>",
1888 (void *)&cmd_config_loopback_specific_port,
1889 (void *)&cmd_config_loopback_specific_keyword,
1890 (void *)&cmd_config_loopback_specific_id,
1891 (void *)&cmd_config_loopback_specific_item,
1892 (void *)&cmd_config_loopback_specific_mode,
1897 /* *** configure txq/rxq, txd/rxd *** */
1898 struct cmd_config_rx_tx {
1899 cmdline_fixed_string_t port;
1900 cmdline_fixed_string_t keyword;
1901 cmdline_fixed_string_t all;
1902 cmdline_fixed_string_t name;
1907 cmd_config_rx_tx_parsed(void *parsed_result,
1908 __rte_unused struct cmdline *cl,
1909 __rte_unused void *data)
1911 struct cmd_config_rx_tx *res = parsed_result;
1913 if (!all_ports_stopped()) {
1914 printf("Please stop all ports first\n");
1917 if (!strcmp(res->name, "rxq")) {
1918 if (!res->value && !nb_txq) {
1919 printf("Warning: Either rx or tx queues should be non zero\n");
1922 if (check_nb_rxq(res->value) != 0)
1924 nb_rxq = res->value;
1926 else if (!strcmp(res->name, "txq")) {
1927 if (!res->value && !nb_rxq) {
1928 printf("Warning: Either rx or tx queues should be non zero\n");
1931 if (check_nb_txq(res->value) != 0)
1933 nb_txq = res->value;
1935 else if (!strcmp(res->name, "rxd")) {
1936 if (check_nb_rxd(res->value) != 0)
1938 nb_rxd = res->value;
1939 } else if (!strcmp(res->name, "txd")) {
1940 if (check_nb_txd(res->value) != 0)
1943 nb_txd = res->value;
1945 printf("Unknown parameter\n");
1953 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1956 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1957 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1958 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1959 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1960 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1961 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1962 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1963 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1965 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1966 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1968 cmdline_parse_inst_t cmd_config_rx_tx = {
1969 .f = cmd_config_rx_tx_parsed,
1971 .help_str = "port config all rxq|txq|rxd|txd <value>",
1973 (void *)&cmd_config_rx_tx_port,
1974 (void *)&cmd_config_rx_tx_keyword,
1975 (void *)&cmd_config_rx_tx_all,
1976 (void *)&cmd_config_rx_tx_name,
1977 (void *)&cmd_config_rx_tx_value,
1982 /* *** config max packet length *** */
1983 struct cmd_config_max_pkt_len_result {
1984 cmdline_fixed_string_t port;
1985 cmdline_fixed_string_t keyword;
1986 cmdline_fixed_string_t all;
1987 cmdline_fixed_string_t name;
1992 cmd_config_max_pkt_len_parsed(void *parsed_result,
1993 __rte_unused struct cmdline *cl,
1994 __rte_unused void *data)
1996 struct cmd_config_max_pkt_len_result *res = parsed_result;
1999 if (!all_ports_stopped()) {
2000 printf("Please stop all ports first\n");
2004 RTE_ETH_FOREACH_DEV(pid) {
2005 struct rte_port *port = &ports[pid];
2006 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
2008 if (!strcmp(res->name, "max-pkt-len")) {
2009 if (res->value < RTE_ETHER_MIN_LEN) {
2010 printf("max-pkt-len can not be less than %d\n",
2014 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2017 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2018 if (res->value > RTE_ETHER_MAX_LEN)
2019 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2021 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2022 port->dev_conf.rxmode.offloads = rx_offloads;
2024 printf("Unknown parameter\n");
2031 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2034 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2035 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2037 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2038 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2040 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2041 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2043 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2044 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2046 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2047 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2050 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2051 .f = cmd_config_max_pkt_len_parsed,
2053 .help_str = "port config all max-pkt-len <value>",
2055 (void *)&cmd_config_max_pkt_len_port,
2056 (void *)&cmd_config_max_pkt_len_keyword,
2057 (void *)&cmd_config_max_pkt_len_all,
2058 (void *)&cmd_config_max_pkt_len_name,
2059 (void *)&cmd_config_max_pkt_len_value,
2064 /* *** config max LRO aggregated packet size *** */
2065 struct cmd_config_max_lro_pkt_size_result {
2066 cmdline_fixed_string_t port;
2067 cmdline_fixed_string_t keyword;
2068 cmdline_fixed_string_t all;
2069 cmdline_fixed_string_t name;
2074 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2075 __rte_unused struct cmdline *cl,
2076 __rte_unused void *data)
2078 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2081 if (!all_ports_stopped()) {
2082 printf("Please stop all ports first\n");
2086 RTE_ETH_FOREACH_DEV(pid) {
2087 struct rte_port *port = &ports[pid];
2089 if (!strcmp(res->name, "max-lro-pkt-size")) {
2091 port->dev_conf.rxmode.max_lro_pkt_size)
2094 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2096 printf("Unknown parameter\n");
2103 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2106 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2107 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2109 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2110 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2112 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2113 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2115 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2116 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2117 name, "max-lro-pkt-size");
2118 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2119 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2122 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2123 .f = cmd_config_max_lro_pkt_size_parsed,
2125 .help_str = "port config all max-lro-pkt-size <value>",
2127 (void *)&cmd_config_max_lro_pkt_size_port,
2128 (void *)&cmd_config_max_lro_pkt_size_keyword,
2129 (void *)&cmd_config_max_lro_pkt_size_all,
2130 (void *)&cmd_config_max_lro_pkt_size_name,
2131 (void *)&cmd_config_max_lro_pkt_size_value,
2136 /* *** configure port MTU *** */
2137 struct cmd_config_mtu_result {
2138 cmdline_fixed_string_t port;
2139 cmdline_fixed_string_t keyword;
2140 cmdline_fixed_string_t mtu;
2146 cmd_config_mtu_parsed(void *parsed_result,
2147 __rte_unused struct cmdline *cl,
2148 __rte_unused void *data)
2150 struct cmd_config_mtu_result *res = parsed_result;
2152 if (res->value < RTE_ETHER_MIN_LEN) {
2153 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2156 port_mtu_set(res->port_id, res->value);
2159 cmdline_parse_token_string_t cmd_config_mtu_port =
2160 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2162 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2163 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2165 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2166 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2168 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2169 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2170 cmdline_parse_token_num_t cmd_config_mtu_value =
2171 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2173 cmdline_parse_inst_t cmd_config_mtu = {
2174 .f = cmd_config_mtu_parsed,
2176 .help_str = "port config mtu <port_id> <value>",
2178 (void *)&cmd_config_mtu_port,
2179 (void *)&cmd_config_mtu_keyword,
2180 (void *)&cmd_config_mtu_mtu,
2181 (void *)&cmd_config_mtu_port_id,
2182 (void *)&cmd_config_mtu_value,
2187 /* *** configure rx mode *** */
2188 struct cmd_config_rx_mode_flag {
2189 cmdline_fixed_string_t port;
2190 cmdline_fixed_string_t keyword;
2191 cmdline_fixed_string_t all;
2192 cmdline_fixed_string_t name;
2193 cmdline_fixed_string_t value;
2197 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2198 __rte_unused struct cmdline *cl,
2199 __rte_unused void *data)
2201 struct cmd_config_rx_mode_flag *res = parsed_result;
2203 if (!all_ports_stopped()) {
2204 printf("Please stop all ports first\n");
2208 if (!strcmp(res->name, "drop-en")) {
2209 if (!strcmp(res->value, "on"))
2211 else if (!strcmp(res->value, "off"))
2214 printf("Unknown parameter\n");
2218 printf("Unknown parameter\n");
2224 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2227 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2228 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2229 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2230 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2232 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2233 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2234 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2235 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2237 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2238 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2241 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2242 .f = cmd_config_rx_mode_flag_parsed,
2244 .help_str = "port config all drop-en on|off",
2246 (void *)&cmd_config_rx_mode_flag_port,
2247 (void *)&cmd_config_rx_mode_flag_keyword,
2248 (void *)&cmd_config_rx_mode_flag_all,
2249 (void *)&cmd_config_rx_mode_flag_name,
2250 (void *)&cmd_config_rx_mode_flag_value,
2255 /* *** configure rss *** */
2256 struct cmd_config_rss {
2257 cmdline_fixed_string_t port;
2258 cmdline_fixed_string_t keyword;
2259 cmdline_fixed_string_t all;
2260 cmdline_fixed_string_t name;
2261 cmdline_fixed_string_t value;
2265 cmd_config_rss_parsed(void *parsed_result,
2266 __rte_unused struct cmdline *cl,
2267 __rte_unused void *data)
2269 struct cmd_config_rss *res = parsed_result;
2270 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2271 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2272 int use_default = 0;
2273 int all_updated = 1;
2278 if (!strcmp(res->value, "all"))
2279 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2280 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2281 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2282 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU;
2283 else if (!strcmp(res->value, "eth"))
2284 rss_conf.rss_hf = ETH_RSS_ETH;
2285 else if (!strcmp(res->value, "vlan"))
2286 rss_conf.rss_hf = ETH_RSS_VLAN;
2287 else if (!strcmp(res->value, "ip"))
2288 rss_conf.rss_hf = ETH_RSS_IP;
2289 else if (!strcmp(res->value, "udp"))
2290 rss_conf.rss_hf = ETH_RSS_UDP;
2291 else if (!strcmp(res->value, "tcp"))
2292 rss_conf.rss_hf = ETH_RSS_TCP;
2293 else if (!strcmp(res->value, "sctp"))
2294 rss_conf.rss_hf = ETH_RSS_SCTP;
2295 else if (!strcmp(res->value, "ether"))
2296 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2297 else if (!strcmp(res->value, "port"))
2298 rss_conf.rss_hf = ETH_RSS_PORT;
2299 else if (!strcmp(res->value, "vxlan"))
2300 rss_conf.rss_hf = ETH_RSS_VXLAN;
2301 else if (!strcmp(res->value, "geneve"))
2302 rss_conf.rss_hf = ETH_RSS_GENEVE;
2303 else if (!strcmp(res->value, "nvgre"))
2304 rss_conf.rss_hf = ETH_RSS_NVGRE;
2305 else if (!strcmp(res->value, "l3-pre32"))
2306 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2307 else if (!strcmp(res->value, "l3-pre40"))
2308 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2309 else if (!strcmp(res->value, "l3-pre48"))
2310 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2311 else if (!strcmp(res->value, "l3-pre56"))
2312 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2313 else if (!strcmp(res->value, "l3-pre64"))
2314 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2315 else if (!strcmp(res->value, "l3-pre96"))
2316 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2317 else if (!strcmp(res->value, "l3-src-only"))
2318 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2319 else if (!strcmp(res->value, "l3-dst-only"))
2320 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2321 else if (!strcmp(res->value, "l4-src-only"))
2322 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2323 else if (!strcmp(res->value, "l4-dst-only"))
2324 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2325 else if (!strcmp(res->value, "l2-src-only"))
2326 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2327 else if (!strcmp(res->value, "l2-dst-only"))
2328 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2329 else if (!strcmp(res->value, "l2tpv3"))
2330 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2331 else if (!strcmp(res->value, "esp"))
2332 rss_conf.rss_hf = ETH_RSS_ESP;
2333 else if (!strcmp(res->value, "ah"))
2334 rss_conf.rss_hf = ETH_RSS_AH;
2335 else if (!strcmp(res->value, "pfcp"))
2336 rss_conf.rss_hf = ETH_RSS_PFCP;
2337 else if (!strcmp(res->value, "pppoe"))
2338 rss_conf.rss_hf = ETH_RSS_PPPOE;
2339 else if (!strcmp(res->value, "gtpu"))
2340 rss_conf.rss_hf = ETH_RSS_GTPU;
2341 else if (!strcmp(res->value, "none"))
2342 rss_conf.rss_hf = 0;
2343 else if (!strcmp(res->value, "default"))
2345 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2346 atoi(res->value) < 64)
2347 rss_conf.rss_hf = 1ULL << atoi(res->value);
2349 printf("Unknown parameter\n");
2352 rss_conf.rss_key = NULL;
2353 /* Update global configuration for RSS types. */
2354 RTE_ETH_FOREACH_DEV(i) {
2355 struct rte_eth_rss_conf local_rss_conf;
2357 ret = eth_dev_info_get_print_err(i, &dev_info);
2362 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2364 local_rss_conf = rss_conf;
2365 local_rss_conf.rss_hf = rss_conf.rss_hf &
2366 dev_info.flow_type_rss_offloads;
2367 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2368 printf("Port %u modified RSS hash function based on hardware support,"
2369 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2370 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2372 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2375 printf("Configuration of RSS hash at ethernet port %d "
2376 "failed with error (%d): %s.\n",
2377 i, -diag, strerror(-diag));
2380 if (all_updated && !use_default) {
2381 rss_hf = rss_conf.rss_hf;
2382 printf("rss_hf %#"PRIx64"\n", rss_hf);
2386 cmdline_parse_token_string_t cmd_config_rss_port =
2387 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2388 cmdline_parse_token_string_t cmd_config_rss_keyword =
2389 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2390 cmdline_parse_token_string_t cmd_config_rss_all =
2391 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2392 cmdline_parse_token_string_t cmd_config_rss_name =
2393 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2394 cmdline_parse_token_string_t cmd_config_rss_value =
2395 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2397 cmdline_parse_inst_t cmd_config_rss = {
2398 .f = cmd_config_rss_parsed,
2400 .help_str = "port config all rss "
2401 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2402 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|<flowtype_id>",
2404 (void *)&cmd_config_rss_port,
2405 (void *)&cmd_config_rss_keyword,
2406 (void *)&cmd_config_rss_all,
2407 (void *)&cmd_config_rss_name,
2408 (void *)&cmd_config_rss_value,
2413 /* *** configure rss hash key *** */
2414 struct cmd_config_rss_hash_key {
2415 cmdline_fixed_string_t port;
2416 cmdline_fixed_string_t config;
2418 cmdline_fixed_string_t rss_hash_key;
2419 cmdline_fixed_string_t rss_type;
2420 cmdline_fixed_string_t key;
2424 hexa_digit_to_value(char hexa_digit)
2426 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2427 return (uint8_t) (hexa_digit - '0');
2428 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2429 return (uint8_t) ((hexa_digit - 'a') + 10);
2430 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2431 return (uint8_t) ((hexa_digit - 'A') + 10);
2432 /* Invalid hexa digit */
2437 parse_and_check_key_hexa_digit(char *key, int idx)
2441 hexa_v = hexa_digit_to_value(key[idx]);
2443 printf("invalid key: character %c at position %d is not a "
2444 "valid hexa digit\n", key[idx], idx);
2449 cmd_config_rss_hash_key_parsed(void *parsed_result,
2450 __rte_unused struct cmdline *cl,
2451 __rte_unused void *data)
2453 struct cmd_config_rss_hash_key *res = parsed_result;
2454 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2458 struct rte_eth_dev_info dev_info;
2459 uint8_t hash_key_size;
2463 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2467 if (dev_info.hash_key_size > 0 &&
2468 dev_info.hash_key_size <= sizeof(hash_key))
2469 hash_key_size = dev_info.hash_key_size;
2471 printf("dev_info did not provide a valid hash key size\n");
2474 /* Check the length of the RSS hash key */
2475 key_len = strlen(res->key);
2476 if (key_len != (hash_key_size * 2)) {
2477 printf("key length: %d invalid - key must be a string of %d"
2478 " hexa-decimal numbers\n",
2479 (int) key_len, hash_key_size * 2);
2482 /* Translate RSS hash key into binary representation */
2483 for (i = 0; i < hash_key_size; i++) {
2484 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2487 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2490 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2492 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2496 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2497 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2498 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2499 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2501 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2502 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2503 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2504 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2505 rss_hash_key, "rss-hash-key");
2506 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2507 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2508 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2509 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2510 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2511 "ipv6-tcp-ex#ipv6-udp-ex#"
2512 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2513 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2514 "l2tpv3#esp#ah#pfcp#pppoe#gtpu");
2515 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2516 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2518 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2519 .f = cmd_config_rss_hash_key_parsed,
2521 .help_str = "port config <port_id> rss-hash-key "
2522 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2523 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2524 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2525 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2526 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2527 "l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2528 "<string of hex digits (variable length, NIC dependent)>",
2530 (void *)&cmd_config_rss_hash_key_port,
2531 (void *)&cmd_config_rss_hash_key_config,
2532 (void *)&cmd_config_rss_hash_key_port_id,
2533 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2534 (void *)&cmd_config_rss_hash_key_rss_type,
2535 (void *)&cmd_config_rss_hash_key_value,
2540 /* *** configure port rxq/txq ring size *** */
2541 struct cmd_config_rxtx_ring_size {
2542 cmdline_fixed_string_t port;
2543 cmdline_fixed_string_t config;
2545 cmdline_fixed_string_t rxtxq;
2547 cmdline_fixed_string_t rsize;
2552 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2553 __rte_unused struct cmdline *cl,
2554 __rte_unused void *data)
2556 struct cmd_config_rxtx_ring_size *res = parsed_result;
2557 struct rte_port *port;
2560 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2563 if (res->portid == (portid_t)RTE_PORT_ALL) {
2564 printf("Invalid port id\n");
2568 port = &ports[res->portid];
2570 if (!strcmp(res->rxtxq, "rxq"))
2572 else if (!strcmp(res->rxtxq, "txq"))
2575 printf("Unknown parameter\n");
2579 if (isrx && rx_queue_id_is_invalid(res->qid))
2581 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2584 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2585 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2591 port->nb_rx_desc[res->qid] = res->size;
2593 port->nb_tx_desc[res->qid] = res->size;
2595 cmd_reconfig_device_queue(res->portid, 0, 1);
2598 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2599 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2601 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2602 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2604 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2605 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2607 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2608 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2610 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2611 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2613 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2614 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2615 rsize, "ring_size");
2616 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2617 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2620 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2621 .f = cmd_config_rxtx_ring_size_parsed,
2623 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2625 (void *)&cmd_config_rxtx_ring_size_port,
2626 (void *)&cmd_config_rxtx_ring_size_config,
2627 (void *)&cmd_config_rxtx_ring_size_portid,
2628 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2629 (void *)&cmd_config_rxtx_ring_size_qid,
2630 (void *)&cmd_config_rxtx_ring_size_rsize,
2631 (void *)&cmd_config_rxtx_ring_size_size,
2636 /* *** configure port rxq/txq start/stop *** */
2637 struct cmd_config_rxtx_queue {
2638 cmdline_fixed_string_t port;
2640 cmdline_fixed_string_t rxtxq;
2642 cmdline_fixed_string_t opname;
2646 cmd_config_rxtx_queue_parsed(void *parsed_result,
2647 __rte_unused struct cmdline *cl,
2648 __rte_unused void *data)
2650 struct cmd_config_rxtx_queue *res = parsed_result;
2655 if (test_done == 0) {
2656 printf("Please stop forwarding first\n");
2660 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2663 if (port_is_started(res->portid) != 1) {
2664 printf("Please start port %u first\n", res->portid);
2668 if (!strcmp(res->rxtxq, "rxq"))
2670 else if (!strcmp(res->rxtxq, "txq"))
2673 printf("Unknown parameter\n");
2677 if (isrx && rx_queue_id_is_invalid(res->qid))
2679 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2682 if (!strcmp(res->opname, "start"))
2684 else if (!strcmp(res->opname, "stop"))
2687 printf("Unknown parameter\n");
2691 if (isstart && isrx)
2692 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2693 else if (!isstart && isrx)
2694 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2695 else if (isstart && !isrx)
2696 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2698 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2700 if (ret == -ENOTSUP)
2701 printf("Function not supported in PMD driver\n");
2704 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2705 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2706 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2707 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2708 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2709 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2710 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2711 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2712 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2713 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2716 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2717 .f = cmd_config_rxtx_queue_parsed,
2719 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2721 (void *)&cmd_config_rxtx_queue_port,
2722 (void *)&cmd_config_rxtx_queue_portid,
2723 (void *)&cmd_config_rxtx_queue_rxtxq,
2724 (void *)&cmd_config_rxtx_queue_qid,
2725 (void *)&cmd_config_rxtx_queue_opname,
2730 /* *** configure port rxq/txq deferred start on/off *** */
2731 struct cmd_config_deferred_start_rxtx_queue {
2732 cmdline_fixed_string_t port;
2734 cmdline_fixed_string_t rxtxq;
2736 cmdline_fixed_string_t opname;
2737 cmdline_fixed_string_t state;
2741 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2742 __rte_unused struct cmdline *cl,
2743 __rte_unused void *data)
2745 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2746 struct rte_port *port;
2749 uint8_t needreconfig = 0;
2751 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2754 if (port_is_started(res->port_id) != 0) {
2755 printf("Please stop port %u first\n", res->port_id);
2759 port = &ports[res->port_id];
2761 isrx = !strcmp(res->rxtxq, "rxq");
2763 if (isrx && rx_queue_id_is_invalid(res->qid))
2765 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2768 ison = !strcmp(res->state, "on");
2770 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2771 port->rx_conf[res->qid].rx_deferred_start = ison;
2773 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2774 port->tx_conf[res->qid].tx_deferred_start = ison;
2779 cmd_reconfig_device_queue(res->port_id, 0, 1);
2782 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2783 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2785 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2786 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2788 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2789 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2791 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2792 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2794 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2795 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2796 opname, "deferred_start");
2797 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2798 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2801 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2802 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2804 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2806 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2807 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2808 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2809 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2810 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2811 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2816 /* *** configure port rxq/txq setup *** */
2817 struct cmd_setup_rxtx_queue {
2818 cmdline_fixed_string_t port;
2820 cmdline_fixed_string_t rxtxq;
2822 cmdline_fixed_string_t setup;
2825 /* Common CLI fields for queue setup */
2826 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2827 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2828 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2829 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2830 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2831 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2832 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2833 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2834 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2835 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2838 cmd_setup_rxtx_queue_parsed(
2839 void *parsed_result,
2840 __rte_unused struct cmdline *cl,
2841 __rte_unused void *data)
2843 struct cmd_setup_rxtx_queue *res = parsed_result;
2844 struct rte_port *port;
2845 struct rte_mempool *mp;
2846 unsigned int socket_id;
2850 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2853 if (res->portid == (portid_t)RTE_PORT_ALL) {
2854 printf("Invalid port id\n");
2858 if (!strcmp(res->rxtxq, "rxq"))
2860 else if (!strcmp(res->rxtxq, "txq"))
2863 printf("Unknown parameter\n");
2867 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2868 printf("Invalid rx queue\n");
2870 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2871 printf("Invalid tx queue\n");
2875 port = &ports[res->portid];
2877 socket_id = rxring_numa[res->portid];
2878 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2879 socket_id = port->socket_id;
2881 mp = mbuf_pool_find(socket_id);
2883 printf("Failed to setup RX queue: "
2884 "No mempool allocation"
2885 " on the socket %d\n",
2886 rxring_numa[res->portid]);
2889 ret = rte_eth_rx_queue_setup(res->portid,
2891 port->nb_rx_desc[res->qid],
2893 &port->rx_conf[res->qid],
2896 printf("Failed to setup RX queue\n");
2898 socket_id = txring_numa[res->portid];
2899 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2900 socket_id = port->socket_id;
2902 ret = rte_eth_tx_queue_setup(res->portid,
2904 port->nb_tx_desc[res->qid],
2906 &port->tx_conf[res->qid]);
2908 printf("Failed to setup TX queue\n");
2912 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2913 .f = cmd_setup_rxtx_queue_parsed,
2915 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2917 (void *)&cmd_setup_rxtx_queue_port,
2918 (void *)&cmd_setup_rxtx_queue_portid,
2919 (void *)&cmd_setup_rxtx_queue_rxtxq,
2920 (void *)&cmd_setup_rxtx_queue_qid,
2921 (void *)&cmd_setup_rxtx_queue_setup,
2927 /* *** Configure RSS RETA *** */
2928 struct cmd_config_rss_reta {
2929 cmdline_fixed_string_t port;
2930 cmdline_fixed_string_t keyword;
2932 cmdline_fixed_string_t name;
2933 cmdline_fixed_string_t list_name;
2934 cmdline_fixed_string_t list_of_items;
2938 parse_reta_config(const char *str,
2939 struct rte_eth_rss_reta_entry64 *reta_conf,
2940 uint16_t nb_entries)
2944 uint16_t hash_index, idx, shift;
2947 const char *p, *p0 = str;
2954 unsigned long int_fld[_NUM_FLD];
2955 char *str_fld[_NUM_FLD];
2957 while ((p = strchr(p0,'(')) != NULL) {
2959 if((p0 = strchr(p,')')) == NULL)
2963 if(size >= sizeof(s))
2966 snprintf(s, sizeof(s), "%.*s", size, p);
2967 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2969 for (i = 0; i < _NUM_FLD; i++) {
2971 int_fld[i] = strtoul(str_fld[i], &end, 0);
2972 if (errno != 0 || end == str_fld[i] ||
2977 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2978 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2980 if (hash_index >= nb_entries) {
2981 printf("Invalid RETA hash index=%d\n", hash_index);
2985 idx = hash_index / RTE_RETA_GROUP_SIZE;
2986 shift = hash_index % RTE_RETA_GROUP_SIZE;
2987 reta_conf[idx].mask |= (1ULL << shift);
2988 reta_conf[idx].reta[shift] = nb_queue;
2995 cmd_set_rss_reta_parsed(void *parsed_result,
2996 __rte_unused struct cmdline *cl,
2997 __rte_unused void *data)
3000 struct rte_eth_dev_info dev_info;
3001 struct rte_eth_rss_reta_entry64 reta_conf[8];
3002 struct cmd_config_rss_reta *res = parsed_result;
3004 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3008 if (dev_info.reta_size == 0) {
3009 printf("Redirection table size is 0 which is "
3010 "invalid for RSS\n");
3013 printf("The reta size of port %d is %u\n",
3014 res->port_id, dev_info.reta_size);
3015 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3016 printf("Currently do not support more than %u entries of "
3017 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3021 memset(reta_conf, 0, sizeof(reta_conf));
3022 if (!strcmp(res->list_name, "reta")) {
3023 if (parse_reta_config(res->list_of_items, reta_conf,
3024 dev_info.reta_size)) {
3025 printf("Invalid RSS Redirection Table "
3026 "config entered\n");
3029 ret = rte_eth_dev_rss_reta_update(res->port_id,
3030 reta_conf, dev_info.reta_size);
3032 printf("Bad redirection table parameter, "
3033 "return code = %d \n", ret);
3037 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3038 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3039 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3040 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3041 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3042 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3043 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3044 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3045 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3046 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3047 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3048 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3050 cmdline_parse_inst_t cmd_config_rss_reta = {
3051 .f = cmd_set_rss_reta_parsed,
3053 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3055 (void *)&cmd_config_rss_reta_port,
3056 (void *)&cmd_config_rss_reta_keyword,
3057 (void *)&cmd_config_rss_reta_port_id,
3058 (void *)&cmd_config_rss_reta_name,
3059 (void *)&cmd_config_rss_reta_list_name,
3060 (void *)&cmd_config_rss_reta_list_of_items,
3065 /* *** SHOW PORT RETA INFO *** */
3066 struct cmd_showport_reta {
3067 cmdline_fixed_string_t show;
3068 cmdline_fixed_string_t port;
3070 cmdline_fixed_string_t rss;
3071 cmdline_fixed_string_t reta;
3073 cmdline_fixed_string_t list_of_items;
3077 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3078 uint16_t nb_entries,
3082 const char *p, *p0 = str;
3087 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3088 RTE_RETA_GROUP_SIZE;
3091 p = strchr(p0, '(');
3095 p0 = strchr(p, ')');
3099 if (size >= sizeof(s)) {
3100 printf("The string size exceeds the internal buffer size\n");
3103 snprintf(s, sizeof(s), "%.*s", size, p);
3104 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3105 if (ret <= 0 || ret != num) {
3106 printf("The bits of masks do not match the number of "
3107 "reta entries: %u\n", num);
3110 for (i = 0; i < ret; i++)
3111 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3117 cmd_showport_reta_parsed(void *parsed_result,
3118 __rte_unused struct cmdline *cl,
3119 __rte_unused void *data)
3121 struct cmd_showport_reta *res = parsed_result;
3122 struct rte_eth_rss_reta_entry64 reta_conf[8];
3123 struct rte_eth_dev_info dev_info;
3124 uint16_t max_reta_size;
3127 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3131 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3132 if (res->size == 0 || res->size > max_reta_size) {
3133 printf("Invalid redirection table size: %u (1-%u)\n",
3134 res->size, max_reta_size);
3138 memset(reta_conf, 0, sizeof(reta_conf));
3139 if (showport_parse_reta_config(reta_conf, res->size,
3140 res->list_of_items) < 0) {
3141 printf("Invalid string: %s for reta masks\n",
3142 res->list_of_items);
3145 port_rss_reta_info(res->port_id, reta_conf, res->size);
3148 cmdline_parse_token_string_t cmd_showport_reta_show =
3149 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3150 cmdline_parse_token_string_t cmd_showport_reta_port =
3151 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3152 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3153 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3154 cmdline_parse_token_string_t cmd_showport_reta_rss =
3155 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3156 cmdline_parse_token_string_t cmd_showport_reta_reta =
3157 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3158 cmdline_parse_token_num_t cmd_showport_reta_size =
3159 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3160 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3161 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3162 list_of_items, NULL);
3164 cmdline_parse_inst_t cmd_showport_reta = {
3165 .f = cmd_showport_reta_parsed,
3167 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3169 (void *)&cmd_showport_reta_show,
3170 (void *)&cmd_showport_reta_port,
3171 (void *)&cmd_showport_reta_port_id,
3172 (void *)&cmd_showport_reta_rss,
3173 (void *)&cmd_showport_reta_reta,
3174 (void *)&cmd_showport_reta_size,
3175 (void *)&cmd_showport_reta_list_of_items,
3180 /* *** Show RSS hash configuration *** */
3181 struct cmd_showport_rss_hash {
3182 cmdline_fixed_string_t show;
3183 cmdline_fixed_string_t port;
3185 cmdline_fixed_string_t rss_hash;
3186 cmdline_fixed_string_t rss_type;
3187 cmdline_fixed_string_t key; /* optional argument */
3190 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3191 __rte_unused struct cmdline *cl,
3194 struct cmd_showport_rss_hash *res = parsed_result;
3196 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3199 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3200 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3201 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3202 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3203 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3204 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3205 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3206 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3208 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3209 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3211 cmdline_parse_inst_t cmd_showport_rss_hash = {
3212 .f = cmd_showport_rss_hash_parsed,
3214 .help_str = "show port <port_id> rss-hash",
3216 (void *)&cmd_showport_rss_hash_show,
3217 (void *)&cmd_showport_rss_hash_port,
3218 (void *)&cmd_showport_rss_hash_port_id,
3219 (void *)&cmd_showport_rss_hash_rss_hash,
3224 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3225 .f = cmd_showport_rss_hash_parsed,
3227 .help_str = "show port <port_id> rss-hash key",
3229 (void *)&cmd_showport_rss_hash_show,
3230 (void *)&cmd_showport_rss_hash_port,
3231 (void *)&cmd_showport_rss_hash_port_id,
3232 (void *)&cmd_showport_rss_hash_rss_hash,
3233 (void *)&cmd_showport_rss_hash_rss_key,
3238 /* *** Configure DCB *** */
3239 struct cmd_config_dcb {
3240 cmdline_fixed_string_t port;
3241 cmdline_fixed_string_t config;
3243 cmdline_fixed_string_t dcb;
3244 cmdline_fixed_string_t vt;
3245 cmdline_fixed_string_t vt_en;
3247 cmdline_fixed_string_t pfc;
3248 cmdline_fixed_string_t pfc_en;
3252 cmd_config_dcb_parsed(void *parsed_result,
3253 __rte_unused struct cmdline *cl,
3254 __rte_unused void *data)
3256 struct cmd_config_dcb *res = parsed_result;
3257 portid_t port_id = res->port_id;
3258 struct rte_port *port;
3262 port = &ports[port_id];
3263 /** Check if the port is not started **/
3264 if (port->port_status != RTE_PORT_STOPPED) {
3265 printf("Please stop port %d first\n", port_id);
3269 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3270 printf("The invalid number of traffic class,"
3271 " only 4 or 8 allowed.\n");
3275 if (nb_fwd_lcores < res->num_tcs) {
3276 printf("nb_cores shouldn't be less than number of TCs.\n");
3279 if (!strncmp(res->pfc_en, "on", 2))
3284 /* DCB in VT mode */
3285 if (!strncmp(res->vt_en, "on", 2))
3286 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3287 (enum rte_eth_nb_tcs)res->num_tcs,
3290 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3291 (enum rte_eth_nb_tcs)res->num_tcs,
3296 printf("Cannot initialize network ports.\n");
3300 cmd_reconfig_device_queue(port_id, 1, 1);
3303 cmdline_parse_token_string_t cmd_config_dcb_port =
3304 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3305 cmdline_parse_token_string_t cmd_config_dcb_config =
3306 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3307 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3308 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3309 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3310 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3311 cmdline_parse_token_string_t cmd_config_dcb_vt =
3312 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3313 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3314 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3315 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3316 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3317 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3318 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3319 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3320 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3322 cmdline_parse_inst_t cmd_config_dcb = {
3323 .f = cmd_config_dcb_parsed,
3325 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3327 (void *)&cmd_config_dcb_port,
3328 (void *)&cmd_config_dcb_config,
3329 (void *)&cmd_config_dcb_port_id,
3330 (void *)&cmd_config_dcb_dcb,
3331 (void *)&cmd_config_dcb_vt,
3332 (void *)&cmd_config_dcb_vt_en,
3333 (void *)&cmd_config_dcb_num_tcs,
3334 (void *)&cmd_config_dcb_pfc,
3335 (void *)&cmd_config_dcb_pfc_en,
3340 /* *** configure number of packets per burst *** */
3341 struct cmd_config_burst {
3342 cmdline_fixed_string_t port;
3343 cmdline_fixed_string_t keyword;
3344 cmdline_fixed_string_t all;
3345 cmdline_fixed_string_t name;
3350 cmd_config_burst_parsed(void *parsed_result,
3351 __rte_unused struct cmdline *cl,
3352 __rte_unused void *data)
3354 struct cmd_config_burst *res = parsed_result;
3355 struct rte_eth_dev_info dev_info;
3356 uint16_t rec_nb_pkts;
3359 if (!all_ports_stopped()) {
3360 printf("Please stop all ports first\n");
3364 if (!strcmp(res->name, "burst")) {
3365 if (res->value == 0) {
3366 /* If user gives a value of zero, query the PMD for
3367 * its recommended Rx burst size. Testpmd uses a single
3368 * size for all ports, so assume all ports are the same
3369 * NIC model and use the values from Port 0.
3371 ret = eth_dev_info_get_print_err(0, &dev_info);
3375 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3377 if (rec_nb_pkts == 0) {
3378 printf("PMD does not recommend a burst size.\n"
3379 "User provided value must be between"
3380 " 1 and %d\n", MAX_PKT_BURST);
3382 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3383 printf("PMD recommended burst size of %d"
3384 " exceeds maximum value of %d\n",
3385 rec_nb_pkts, MAX_PKT_BURST);
3388 printf("Using PMD-provided burst value of %d\n",
3390 nb_pkt_per_burst = rec_nb_pkts;
3391 } else if (res->value > MAX_PKT_BURST) {
3392 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3395 nb_pkt_per_burst = res->value;
3397 printf("Unknown parameter\n");
3403 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3406 cmdline_parse_token_string_t cmd_config_burst_port =
3407 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3408 cmdline_parse_token_string_t cmd_config_burst_keyword =
3409 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3410 cmdline_parse_token_string_t cmd_config_burst_all =
3411 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3412 cmdline_parse_token_string_t cmd_config_burst_name =
3413 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3414 cmdline_parse_token_num_t cmd_config_burst_value =
3415 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3417 cmdline_parse_inst_t cmd_config_burst = {
3418 .f = cmd_config_burst_parsed,
3420 .help_str = "port config all burst <value>",
3422 (void *)&cmd_config_burst_port,
3423 (void *)&cmd_config_burst_keyword,
3424 (void *)&cmd_config_burst_all,
3425 (void *)&cmd_config_burst_name,
3426 (void *)&cmd_config_burst_value,
3431 /* *** configure rx/tx queues *** */
3432 struct cmd_config_thresh {
3433 cmdline_fixed_string_t port;
3434 cmdline_fixed_string_t keyword;
3435 cmdline_fixed_string_t all;
3436 cmdline_fixed_string_t name;
3441 cmd_config_thresh_parsed(void *parsed_result,
3442 __rte_unused struct cmdline *cl,
3443 __rte_unused void *data)
3445 struct cmd_config_thresh *res = parsed_result;
3447 if (!all_ports_stopped()) {
3448 printf("Please stop all ports first\n");
3452 if (!strcmp(res->name, "txpt"))
3453 tx_pthresh = res->value;
3454 else if(!strcmp(res->name, "txht"))
3455 tx_hthresh = res->value;
3456 else if(!strcmp(res->name, "txwt"))
3457 tx_wthresh = res->value;
3458 else if(!strcmp(res->name, "rxpt"))
3459 rx_pthresh = res->value;
3460 else if(!strcmp(res->name, "rxht"))
3461 rx_hthresh = res->value;
3462 else if(!strcmp(res->name, "rxwt"))
3463 rx_wthresh = res->value;
3465 printf("Unknown parameter\n");
3471 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3474 cmdline_parse_token_string_t cmd_config_thresh_port =
3475 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3476 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3477 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3478 cmdline_parse_token_string_t cmd_config_thresh_all =
3479 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3480 cmdline_parse_token_string_t cmd_config_thresh_name =
3481 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3482 "txpt#txht#txwt#rxpt#rxht#rxwt");
3483 cmdline_parse_token_num_t cmd_config_thresh_value =
3484 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3486 cmdline_parse_inst_t cmd_config_thresh = {
3487 .f = cmd_config_thresh_parsed,
3489 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3491 (void *)&cmd_config_thresh_port,
3492 (void *)&cmd_config_thresh_keyword,
3493 (void *)&cmd_config_thresh_all,
3494 (void *)&cmd_config_thresh_name,
3495 (void *)&cmd_config_thresh_value,
3500 /* *** configure free/rs threshold *** */
3501 struct cmd_config_threshold {
3502 cmdline_fixed_string_t port;
3503 cmdline_fixed_string_t keyword;
3504 cmdline_fixed_string_t all;
3505 cmdline_fixed_string_t name;
3510 cmd_config_threshold_parsed(void *parsed_result,
3511 __rte_unused struct cmdline *cl,
3512 __rte_unused void *data)
3514 struct cmd_config_threshold *res = parsed_result;
3516 if (!all_ports_stopped()) {
3517 printf("Please stop all ports first\n");
3521 if (!strcmp(res->name, "txfreet"))
3522 tx_free_thresh = res->value;
3523 else if (!strcmp(res->name, "txrst"))
3524 tx_rs_thresh = res->value;
3525 else if (!strcmp(res->name, "rxfreet"))
3526 rx_free_thresh = res->value;
3528 printf("Unknown parameter\n");
3534 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3537 cmdline_parse_token_string_t cmd_config_threshold_port =
3538 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3539 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3540 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3542 cmdline_parse_token_string_t cmd_config_threshold_all =
3543 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3544 cmdline_parse_token_string_t cmd_config_threshold_name =
3545 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3546 "txfreet#txrst#rxfreet");
3547 cmdline_parse_token_num_t cmd_config_threshold_value =
3548 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3550 cmdline_parse_inst_t cmd_config_threshold = {
3551 .f = cmd_config_threshold_parsed,
3553 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3555 (void *)&cmd_config_threshold_port,
3556 (void *)&cmd_config_threshold_keyword,
3557 (void *)&cmd_config_threshold_all,
3558 (void *)&cmd_config_threshold_name,
3559 (void *)&cmd_config_threshold_value,
3565 struct cmd_stop_result {
3566 cmdline_fixed_string_t stop;
3569 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3570 __rte_unused struct cmdline *cl,
3571 __rte_unused void *data)
3573 stop_packet_forwarding();
3576 cmdline_parse_token_string_t cmd_stop_stop =
3577 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3579 cmdline_parse_inst_t cmd_stop = {
3580 .f = cmd_stop_parsed,
3582 .help_str = "stop: Stop packet forwarding",
3584 (void *)&cmd_stop_stop,
3589 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3592 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3593 unsigned int *parsed_items, int check_unique_values)
3595 unsigned int nb_item;
3603 * First parse all items in the list and store their value.
3608 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3610 if ((c >= '0') && (c <= '9')) {
3611 value = (unsigned int) (value * 10 + (c - '0'));
3616 printf("character %c is not a decimal digit\n", c);
3620 printf("No valid value before comma\n");
3623 if (nb_item < max_items) {
3624 parsed_items[nb_item] = value;
3630 if (nb_item >= max_items) {
3631 printf("Number of %s = %u > %u (maximum items)\n",
3632 item_name, nb_item + 1, max_items);
3635 parsed_items[nb_item++] = value;
3636 if (! check_unique_values)
3640 * Then, check that all values in the list are differents.
3641 * No optimization here...
3643 for (i = 0; i < nb_item; i++) {
3644 for (j = i + 1; j < nb_item; j++) {
3645 if (parsed_items[j] == parsed_items[i]) {
3646 printf("duplicated %s %u at index %u and %u\n",
3647 item_name, parsed_items[i], i, j);
3655 struct cmd_set_list_result {
3656 cmdline_fixed_string_t cmd_keyword;
3657 cmdline_fixed_string_t list_name;
3658 cmdline_fixed_string_t list_of_items;
3661 static void cmd_set_list_parsed(void *parsed_result,
3662 __rte_unused struct cmdline *cl,
3663 __rte_unused void *data)
3665 struct cmd_set_list_result *res;
3667 unsigned int lcorelist[RTE_MAX_LCORE];
3668 unsigned int portlist[RTE_MAX_ETHPORTS];
3670 unsigned int nb_item;
3672 if (test_done == 0) {
3673 printf("Please stop forwarding first\n");
3677 res = parsed_result;
3678 if (!strcmp(res->list_name, "corelist")) {
3679 nb_item = parse_item_list(res->list_of_items, "core",
3681 parsed_items.lcorelist, 1);
3683 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3688 if (!strcmp(res->list_name, "portlist")) {
3689 nb_item = parse_item_list(res->list_of_items, "port",
3691 parsed_items.portlist, 1);
3693 set_fwd_ports_list(parsed_items.portlist, nb_item);
3699 cmdline_parse_token_string_t cmd_set_list_keyword =
3700 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3702 cmdline_parse_token_string_t cmd_set_list_name =
3703 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3704 "corelist#portlist");
3705 cmdline_parse_token_string_t cmd_set_list_of_items =
3706 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3709 cmdline_parse_inst_t cmd_set_fwd_list = {
3710 .f = cmd_set_list_parsed,
3712 .help_str = "set corelist|portlist <list0[,list1]*>",
3714 (void *)&cmd_set_list_keyword,
3715 (void *)&cmd_set_list_name,
3716 (void *)&cmd_set_list_of_items,
3721 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3723 struct cmd_setmask_result {
3724 cmdline_fixed_string_t set;
3725 cmdline_fixed_string_t mask;
3729 static void cmd_set_mask_parsed(void *parsed_result,
3730 __rte_unused struct cmdline *cl,
3731 __rte_unused void *data)
3733 struct cmd_setmask_result *res = parsed_result;
3735 if (test_done == 0) {
3736 printf("Please stop forwarding first\n");
3739 if (!strcmp(res->mask, "coremask")) {
3740 set_fwd_lcores_mask(res->hexavalue);
3742 } else if (!strcmp(res->mask, "portmask")) {
3743 set_fwd_ports_mask(res->hexavalue);
3748 cmdline_parse_token_string_t cmd_setmask_set =
3749 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3750 cmdline_parse_token_string_t cmd_setmask_mask =
3751 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3752 "coremask#portmask");
3753 cmdline_parse_token_num_t cmd_setmask_value =
3754 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3756 cmdline_parse_inst_t cmd_set_fwd_mask = {
3757 .f = cmd_set_mask_parsed,
3759 .help_str = "set coremask|portmask <hexadecimal value>",
3761 (void *)&cmd_setmask_set,
3762 (void *)&cmd_setmask_mask,
3763 (void *)&cmd_setmask_value,
3769 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3771 struct cmd_set_result {
3772 cmdline_fixed_string_t set;
3773 cmdline_fixed_string_t what;
3777 static void cmd_set_parsed(void *parsed_result,
3778 __rte_unused struct cmdline *cl,
3779 __rte_unused void *data)
3781 struct cmd_set_result *res = parsed_result;
3782 if (!strcmp(res->what, "nbport")) {
3783 set_fwd_ports_number(res->value);
3785 } else if (!strcmp(res->what, "nbcore")) {
3786 set_fwd_lcores_number(res->value);
3788 } else if (!strcmp(res->what, "burst"))
3789 set_nb_pkt_per_burst(res->value);
3790 else if (!strcmp(res->what, "verbose"))
3791 set_verbose_level(res->value);
3794 cmdline_parse_token_string_t cmd_set_set =
3795 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3796 cmdline_parse_token_string_t cmd_set_what =
3797 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3798 "nbport#nbcore#burst#verbose");
3799 cmdline_parse_token_num_t cmd_set_value =
3800 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3802 cmdline_parse_inst_t cmd_set_numbers = {
3803 .f = cmd_set_parsed,
3805 .help_str = "set nbport|nbcore|burst|verbose <value>",
3807 (void *)&cmd_set_set,
3808 (void *)&cmd_set_what,
3809 (void *)&cmd_set_value,
3814 /* *** SET LOG LEVEL CONFIGURATION *** */
3816 struct cmd_set_log_result {
3817 cmdline_fixed_string_t set;
3818 cmdline_fixed_string_t log;
3819 cmdline_fixed_string_t type;
3824 cmd_set_log_parsed(void *parsed_result,
3825 __rte_unused struct cmdline *cl,
3826 __rte_unused void *data)
3828 struct cmd_set_log_result *res;
3831 res = parsed_result;
3832 if (!strcmp(res->type, "global"))
3833 rte_log_set_global_level(res->level);
3835 ret = rte_log_set_level_regexp(res->type, res->level);
3837 printf("Unable to set log level\n");
3841 cmdline_parse_token_string_t cmd_set_log_set =
3842 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3843 cmdline_parse_token_string_t cmd_set_log_log =
3844 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3845 cmdline_parse_token_string_t cmd_set_log_type =
3846 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3847 cmdline_parse_token_num_t cmd_set_log_level =
3848 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3850 cmdline_parse_inst_t cmd_set_log = {
3851 .f = cmd_set_log_parsed,
3853 .help_str = "set log global|<type> <level>",
3855 (void *)&cmd_set_log_set,
3856 (void *)&cmd_set_log_log,
3857 (void *)&cmd_set_log_type,
3858 (void *)&cmd_set_log_level,
3863 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3865 struct cmd_set_txpkts_result {
3866 cmdline_fixed_string_t cmd_keyword;
3867 cmdline_fixed_string_t txpkts;
3868 cmdline_fixed_string_t seg_lengths;
3872 cmd_set_txpkts_parsed(void *parsed_result,
3873 __rte_unused struct cmdline *cl,
3874 __rte_unused void *data)
3876 struct cmd_set_txpkts_result *res;
3877 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3878 unsigned int nb_segs;
3880 res = parsed_result;
3881 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3882 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3884 set_tx_pkt_segments(seg_lengths, nb_segs);
3887 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3888 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3889 cmd_keyword, "set");
3890 cmdline_parse_token_string_t cmd_set_txpkts_name =
3891 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3893 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3894 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3897 cmdline_parse_inst_t cmd_set_txpkts = {
3898 .f = cmd_set_txpkts_parsed,
3900 .help_str = "set txpkts <len0[,len1]*>",
3902 (void *)&cmd_set_txpkts_keyword,
3903 (void *)&cmd_set_txpkts_name,
3904 (void *)&cmd_set_txpkts_lengths,
3909 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3911 struct cmd_set_txsplit_result {
3912 cmdline_fixed_string_t cmd_keyword;
3913 cmdline_fixed_string_t txsplit;
3914 cmdline_fixed_string_t mode;
3918 cmd_set_txsplit_parsed(void *parsed_result,
3919 __rte_unused struct cmdline *cl,
3920 __rte_unused void *data)
3922 struct cmd_set_txsplit_result *res;
3924 res = parsed_result;
3925 set_tx_pkt_split(res->mode);
3928 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3929 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3930 cmd_keyword, "set");
3931 cmdline_parse_token_string_t cmd_set_txsplit_name =
3932 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3933 txsplit, "txsplit");
3934 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3935 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3938 cmdline_parse_inst_t cmd_set_txsplit = {
3939 .f = cmd_set_txsplit_parsed,
3941 .help_str = "set txsplit on|off|rand",
3943 (void *)&cmd_set_txsplit_keyword,
3944 (void *)&cmd_set_txsplit_name,
3945 (void *)&cmd_set_txsplit_mode,
3950 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
3952 struct cmd_set_txtimes_result {
3953 cmdline_fixed_string_t cmd_keyword;
3954 cmdline_fixed_string_t txtimes;
3955 cmdline_fixed_string_t tx_times;
3959 cmd_set_txtimes_parsed(void *parsed_result,
3960 __rte_unused struct cmdline *cl,
3961 __rte_unused void *data)
3963 struct cmd_set_txtimes_result *res;
3964 unsigned int tx_times[2] = {0, 0};
3965 unsigned int n_times;
3967 res = parsed_result;
3968 n_times = parse_item_list(res->tx_times, "tx times",
3971 set_tx_pkt_times(tx_times);
3974 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
3975 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3976 cmd_keyword, "set");
3977 cmdline_parse_token_string_t cmd_set_txtimes_name =
3978 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3979 txtimes, "txtimes");
3980 cmdline_parse_token_string_t cmd_set_txtimes_value =
3981 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3984 cmdline_parse_inst_t cmd_set_txtimes = {
3985 .f = cmd_set_txtimes_parsed,
3987 .help_str = "set txtimes <inter_burst>,<intra_burst>",
3989 (void *)&cmd_set_txtimes_keyword,
3990 (void *)&cmd_set_txtimes_name,
3991 (void *)&cmd_set_txtimes_value,
3996 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3997 struct cmd_rx_vlan_filter_all_result {
3998 cmdline_fixed_string_t rx_vlan;
3999 cmdline_fixed_string_t what;
4000 cmdline_fixed_string_t all;
4005 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4006 __rte_unused struct cmdline *cl,
4007 __rte_unused void *data)
4009 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4011 if (!strcmp(res->what, "add"))
4012 rx_vlan_all_filter_set(res->port_id, 1);
4014 rx_vlan_all_filter_set(res->port_id, 0);
4017 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4018 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4019 rx_vlan, "rx_vlan");
4020 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4021 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4023 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4024 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4026 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4027 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4030 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4031 .f = cmd_rx_vlan_filter_all_parsed,
4033 .help_str = "rx_vlan add|rm all <port_id>: "
4034 "Add/Remove all identifiers to/from the set of VLAN "
4035 "identifiers filtered by a port",
4037 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4038 (void *)&cmd_rx_vlan_filter_all_what,
4039 (void *)&cmd_rx_vlan_filter_all_all,
4040 (void *)&cmd_rx_vlan_filter_all_portid,
4045 /* *** VLAN OFFLOAD SET ON A PORT *** */
4046 struct cmd_vlan_offload_result {
4047 cmdline_fixed_string_t vlan;
4048 cmdline_fixed_string_t set;
4049 cmdline_fixed_string_t vlan_type;
4050 cmdline_fixed_string_t what;
4051 cmdline_fixed_string_t on;
4052 cmdline_fixed_string_t port_id;
4056 cmd_vlan_offload_parsed(void *parsed_result,
4057 __rte_unused struct cmdline *cl,
4058 __rte_unused void *data)
4061 struct cmd_vlan_offload_result *res = parsed_result;
4064 portid_t port_id = 0;
4068 len = strnlen(str, STR_TOKEN_SIZE);
4070 /* Get port_id first */
4078 tmp = strtoul(str, NULL, 0);
4079 /* If port_id greater that what portid_t can represent, return */
4080 if(tmp >= RTE_MAX_ETHPORTS)
4082 port_id = (portid_t)tmp;
4084 if (!strcmp(res->on, "on"))
4089 if (!strcmp(res->what, "strip"))
4090 rx_vlan_strip_set(port_id, on);
4091 else if(!strcmp(res->what, "stripq")){
4092 uint16_t queue_id = 0;
4094 /* No queue_id, return */
4096 printf("must specify (port,queue_id)\n");
4099 tmp = strtoul(str + i + 1, NULL, 0);
4100 /* If queue_id greater that what 16-bits can represent, return */
4104 queue_id = (uint16_t)tmp;
4105 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4107 else if (!strcmp(res->what, "filter"))
4108 rx_vlan_filter_set(port_id, on);
4109 else if (!strcmp(res->what, "qinq_strip"))
4110 rx_vlan_qinq_strip_set(port_id, on);
4112 vlan_extend_set(port_id, on);
4117 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4118 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4120 cmdline_parse_token_string_t cmd_vlan_offload_set =
4121 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4123 cmdline_parse_token_string_t cmd_vlan_offload_what =
4124 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4125 what, "strip#filter#qinq_strip#extend#stripq");
4126 cmdline_parse_token_string_t cmd_vlan_offload_on =
4127 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4129 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4130 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4133 cmdline_parse_inst_t cmd_vlan_offload = {
4134 .f = cmd_vlan_offload_parsed,
4136 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4137 "<port_id[,queue_id]>: "
4138 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4140 (void *)&cmd_vlan_offload_vlan,
4141 (void *)&cmd_vlan_offload_set,
4142 (void *)&cmd_vlan_offload_what,
4143 (void *)&cmd_vlan_offload_on,
4144 (void *)&cmd_vlan_offload_portid,
4149 /* *** VLAN TPID SET ON A PORT *** */
4150 struct cmd_vlan_tpid_result {
4151 cmdline_fixed_string_t vlan;
4152 cmdline_fixed_string_t set;
4153 cmdline_fixed_string_t vlan_type;
4154 cmdline_fixed_string_t what;
4160 cmd_vlan_tpid_parsed(void *parsed_result,
4161 __rte_unused struct cmdline *cl,
4162 __rte_unused void *data)
4164 struct cmd_vlan_tpid_result *res = parsed_result;
4165 enum rte_vlan_type vlan_type;
4167 if (!strcmp(res->vlan_type, "inner"))
4168 vlan_type = ETH_VLAN_TYPE_INNER;
4169 else if (!strcmp(res->vlan_type, "outer"))
4170 vlan_type = ETH_VLAN_TYPE_OUTER;
4172 printf("Unknown vlan type\n");
4175 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4178 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4179 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4181 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4182 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4184 cmdline_parse_token_string_t cmd_vlan_type =
4185 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4186 vlan_type, "inner#outer");
4187 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4188 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4190 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4191 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4193 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4194 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4197 cmdline_parse_inst_t cmd_vlan_tpid = {
4198 .f = cmd_vlan_tpid_parsed,
4200 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4201 "Set the VLAN Ether type",
4203 (void *)&cmd_vlan_tpid_vlan,
4204 (void *)&cmd_vlan_tpid_set,
4205 (void *)&cmd_vlan_type,
4206 (void *)&cmd_vlan_tpid_what,
4207 (void *)&cmd_vlan_tpid_tpid,
4208 (void *)&cmd_vlan_tpid_portid,
4213 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4214 struct cmd_rx_vlan_filter_result {
4215 cmdline_fixed_string_t rx_vlan;
4216 cmdline_fixed_string_t what;
4222 cmd_rx_vlan_filter_parsed(void *parsed_result,
4223 __rte_unused struct cmdline *cl,
4224 __rte_unused void *data)
4226 struct cmd_rx_vlan_filter_result *res = parsed_result;
4228 if (!strcmp(res->what, "add"))
4229 rx_vft_set(res->port_id, res->vlan_id, 1);
4231 rx_vft_set(res->port_id, res->vlan_id, 0);
4234 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4235 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4236 rx_vlan, "rx_vlan");
4237 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4238 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4240 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4241 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4243 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4244 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4247 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4248 .f = cmd_rx_vlan_filter_parsed,
4250 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4251 "Add/Remove a VLAN identifier to/from the set of VLAN "
4252 "identifiers filtered by a port",
4254 (void *)&cmd_rx_vlan_filter_rx_vlan,
4255 (void *)&cmd_rx_vlan_filter_what,
4256 (void *)&cmd_rx_vlan_filter_vlanid,
4257 (void *)&cmd_rx_vlan_filter_portid,
4262 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4263 struct cmd_tx_vlan_set_result {
4264 cmdline_fixed_string_t tx_vlan;
4265 cmdline_fixed_string_t set;
4271 cmd_tx_vlan_set_parsed(void *parsed_result,
4272 __rte_unused struct cmdline *cl,
4273 __rte_unused void *data)
4275 struct cmd_tx_vlan_set_result *res = parsed_result;
4277 if (!port_is_stopped(res->port_id)) {
4278 printf("Please stop port %d first\n", res->port_id);
4282 tx_vlan_set(res->port_id, res->vlan_id);
4284 cmd_reconfig_device_queue(res->port_id, 1, 1);
4287 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4288 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4289 tx_vlan, "tx_vlan");
4290 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4291 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4293 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4294 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4296 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4297 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4300 cmdline_parse_inst_t cmd_tx_vlan_set = {
4301 .f = cmd_tx_vlan_set_parsed,
4303 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4304 "Enable hardware insertion of a single VLAN header "
4305 "with a given TAG Identifier in packets sent on a port",
4307 (void *)&cmd_tx_vlan_set_tx_vlan,
4308 (void *)&cmd_tx_vlan_set_set,
4309 (void *)&cmd_tx_vlan_set_portid,
4310 (void *)&cmd_tx_vlan_set_vlanid,
4315 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4316 struct cmd_tx_vlan_set_qinq_result {
4317 cmdline_fixed_string_t tx_vlan;
4318 cmdline_fixed_string_t set;
4321 uint16_t vlan_id_outer;
4325 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4326 __rte_unused struct cmdline *cl,
4327 __rte_unused void *data)
4329 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4331 if (!port_is_stopped(res->port_id)) {
4332 printf("Please stop port %d first\n", res->port_id);
4336 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4338 cmd_reconfig_device_queue(res->port_id, 1, 1);
4341 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4342 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4343 tx_vlan, "tx_vlan");
4344 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4345 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4347 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4348 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4350 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4351 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4353 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4354 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4355 vlan_id_outer, UINT16);
4357 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4358 .f = cmd_tx_vlan_set_qinq_parsed,
4360 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4361 "Enable hardware insertion of double VLAN header "
4362 "with given TAG Identifiers in packets sent on a port",
4364 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4365 (void *)&cmd_tx_vlan_set_qinq_set,
4366 (void *)&cmd_tx_vlan_set_qinq_portid,
4367 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4368 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4373 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4374 struct cmd_tx_vlan_set_pvid_result {
4375 cmdline_fixed_string_t tx_vlan;
4376 cmdline_fixed_string_t set;
4377 cmdline_fixed_string_t pvid;
4380 cmdline_fixed_string_t mode;
4384 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4385 __rte_unused struct cmdline *cl,
4386 __rte_unused void *data)
4388 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4390 if (strcmp(res->mode, "on") == 0)
4391 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4393 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4396 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4397 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4398 tx_vlan, "tx_vlan");
4399 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4400 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4402 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4403 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4405 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4406 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4408 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4409 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4411 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4412 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4415 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4416 .f = cmd_tx_vlan_set_pvid_parsed,
4418 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4420 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4421 (void *)&cmd_tx_vlan_set_pvid_set,
4422 (void *)&cmd_tx_vlan_set_pvid_pvid,
4423 (void *)&cmd_tx_vlan_set_pvid_port_id,
4424 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4425 (void *)&cmd_tx_vlan_set_pvid_mode,
4430 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4431 struct cmd_tx_vlan_reset_result {
4432 cmdline_fixed_string_t tx_vlan;
4433 cmdline_fixed_string_t reset;
4438 cmd_tx_vlan_reset_parsed(void *parsed_result,
4439 __rte_unused struct cmdline *cl,
4440 __rte_unused void *data)
4442 struct cmd_tx_vlan_reset_result *res = parsed_result;
4444 if (!port_is_stopped(res->port_id)) {
4445 printf("Please stop port %d first\n", res->port_id);
4449 tx_vlan_reset(res->port_id);
4451 cmd_reconfig_device_queue(res->port_id, 1, 1);
4454 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4455 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4456 tx_vlan, "tx_vlan");
4457 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4458 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4460 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4461 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4464 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4465 .f = cmd_tx_vlan_reset_parsed,
4467 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4468 "VLAN header in packets sent on a port",
4470 (void *)&cmd_tx_vlan_reset_tx_vlan,
4471 (void *)&cmd_tx_vlan_reset_reset,
4472 (void *)&cmd_tx_vlan_reset_portid,
4478 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4479 struct cmd_csum_result {
4480 cmdline_fixed_string_t csum;
4481 cmdline_fixed_string_t mode;
4482 cmdline_fixed_string_t proto;
4483 cmdline_fixed_string_t hwsw;
4488 csum_show(int port_id)
4490 struct rte_eth_dev_info dev_info;
4491 uint64_t tx_offloads;
4494 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4495 printf("Parse tunnel is %s\n",
4496 (ports[port_id].parse_tunnel) ? "on" : "off");
4497 printf("IP checksum offload is %s\n",
4498 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4499 printf("UDP checksum offload is %s\n",
4500 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4501 printf("TCP checksum offload is %s\n",
4502 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4503 printf("SCTP checksum offload is %s\n",
4504 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4505 printf("Outer-Ip checksum offload is %s\n",
4506 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4507 printf("Outer-Udp checksum offload is %s\n",
4508 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4510 /* display warnings if configuration is not supported by the NIC */
4511 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4515 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4516 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4517 printf("Warning: hardware IP checksum enabled but not "
4518 "supported by port %d\n", port_id);
4520 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4521 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4522 printf("Warning: hardware UDP checksum enabled but not "
4523 "supported by port %d\n", port_id);
4525 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4526 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4527 printf("Warning: hardware TCP checksum enabled but not "
4528 "supported by port %d\n", port_id);
4530 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4531 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4532 printf("Warning: hardware SCTP checksum enabled but not "
4533 "supported by port %d\n", port_id);
4535 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4536 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4537 printf("Warning: hardware outer IP checksum enabled but not "
4538 "supported by port %d\n", port_id);
4540 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4541 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4543 printf("Warning: hardware outer UDP checksum enabled but not "
4544 "supported by port %d\n", port_id);
4549 cmd_config_queue_tx_offloads(struct rte_port *port)
4553 /* Apply queue tx offloads configuration */
4554 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4555 port->tx_conf[k].offloads =
4556 port->dev_conf.txmode.offloads;
4560 cmd_csum_parsed(void *parsed_result,
4561 __rte_unused struct cmdline *cl,
4562 __rte_unused void *data)
4564 struct cmd_csum_result *res = parsed_result;
4566 uint64_t csum_offloads = 0;
4567 struct rte_eth_dev_info dev_info;
4570 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4571 printf("invalid port %d\n", res->port_id);
4574 if (!port_is_stopped(res->port_id)) {
4575 printf("Please stop port %d first\n", res->port_id);
4579 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4583 if (!strcmp(res->mode, "set")) {
4585 if (!strcmp(res->hwsw, "hw"))
4588 if (!strcmp(res->proto, "ip")) {
4589 if (hw == 0 || (dev_info.tx_offload_capa &
4590 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4591 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4593 printf("IP checksum offload is not supported "
4594 "by port %u\n", res->port_id);
4596 } else if (!strcmp(res->proto, "udp")) {
4597 if (hw == 0 || (dev_info.tx_offload_capa &
4598 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4599 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4601 printf("UDP checksum offload is not supported "
4602 "by port %u\n", res->port_id);
4604 } else if (!strcmp(res->proto, "tcp")) {
4605 if (hw == 0 || (dev_info.tx_offload_capa &
4606 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4607 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4609 printf("TCP checksum offload is not supported "
4610 "by port %u\n", res->port_id);
4612 } else if (!strcmp(res->proto, "sctp")) {
4613 if (hw == 0 || (dev_info.tx_offload_capa &
4614 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4615 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4617 printf("SCTP checksum offload is not supported "
4618 "by port %u\n", res->port_id);
4620 } else if (!strcmp(res->proto, "outer-ip")) {
4621 if (hw == 0 || (dev_info.tx_offload_capa &
4622 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4624 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4626 printf("Outer IP checksum offload is not "
4627 "supported by port %u\n", res->port_id);
4629 } else if (!strcmp(res->proto, "outer-udp")) {
4630 if (hw == 0 || (dev_info.tx_offload_capa &
4631 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4633 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4635 printf("Outer UDP checksum offload is not "
4636 "supported by port %u\n", res->port_id);
4641 ports[res->port_id].dev_conf.txmode.offloads |=
4644 ports[res->port_id].dev_conf.txmode.offloads &=
4647 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4649 csum_show(res->port_id);
4651 cmd_reconfig_device_queue(res->port_id, 1, 1);
4654 cmdline_parse_token_string_t cmd_csum_csum =
4655 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4657 cmdline_parse_token_string_t cmd_csum_mode =
4658 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4660 cmdline_parse_token_string_t cmd_csum_proto =
4661 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4662 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4663 cmdline_parse_token_string_t cmd_csum_hwsw =
4664 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4666 cmdline_parse_token_num_t cmd_csum_portid =
4667 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4670 cmdline_parse_inst_t cmd_csum_set = {
4671 .f = cmd_csum_parsed,
4673 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4674 "Enable/Disable hardware calculation of L3/L4 checksum when "
4675 "using csum forward engine",
4677 (void *)&cmd_csum_csum,
4678 (void *)&cmd_csum_mode,
4679 (void *)&cmd_csum_proto,
4680 (void *)&cmd_csum_hwsw,
4681 (void *)&cmd_csum_portid,
4686 cmdline_parse_token_string_t cmd_csum_mode_show =
4687 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4690 cmdline_parse_inst_t cmd_csum_show = {
4691 .f = cmd_csum_parsed,
4693 .help_str = "csum show <port_id>: Show checksum offload configuration",
4695 (void *)&cmd_csum_csum,
4696 (void *)&cmd_csum_mode_show,
4697 (void *)&cmd_csum_portid,
4702 /* Enable/disable tunnel parsing */
4703 struct cmd_csum_tunnel_result {
4704 cmdline_fixed_string_t csum;
4705 cmdline_fixed_string_t parse;
4706 cmdline_fixed_string_t onoff;
4711 cmd_csum_tunnel_parsed(void *parsed_result,
4712 __rte_unused struct cmdline *cl,
4713 __rte_unused void *data)
4715 struct cmd_csum_tunnel_result *res = parsed_result;
4717 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4720 if (!strcmp(res->onoff, "on"))
4721 ports[res->port_id].parse_tunnel = 1;
4723 ports[res->port_id].parse_tunnel = 0;
4725 csum_show(res->port_id);
4728 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4729 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4731 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4732 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4733 parse, "parse-tunnel");
4734 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4735 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4737 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4738 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4741 cmdline_parse_inst_t cmd_csum_tunnel = {
4742 .f = cmd_csum_tunnel_parsed,
4744 .help_str = "csum parse-tunnel on|off <port_id>: "
4745 "Enable/Disable parsing of tunnels for csum engine",
4747 (void *)&cmd_csum_tunnel_csum,
4748 (void *)&cmd_csum_tunnel_parse,
4749 (void *)&cmd_csum_tunnel_onoff,
4750 (void *)&cmd_csum_tunnel_portid,
4755 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4756 struct cmd_tso_set_result {
4757 cmdline_fixed_string_t tso;
4758 cmdline_fixed_string_t mode;
4764 cmd_tso_set_parsed(void *parsed_result,
4765 __rte_unused struct cmdline *cl,
4766 __rte_unused void *data)
4768 struct cmd_tso_set_result *res = parsed_result;
4769 struct rte_eth_dev_info dev_info;
4772 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4774 if (!port_is_stopped(res->port_id)) {
4775 printf("Please stop port %d first\n", res->port_id);
4779 if (!strcmp(res->mode, "set"))
4780 ports[res->port_id].tso_segsz = res->tso_segsz;
4782 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4786 if ((ports[res->port_id].tso_segsz != 0) &&
4787 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4788 printf("Error: TSO is not supported by port %d\n",
4793 if (ports[res->port_id].tso_segsz == 0) {
4794 ports[res->port_id].dev_conf.txmode.offloads &=
4795 ~DEV_TX_OFFLOAD_TCP_TSO;
4796 printf("TSO for non-tunneled packets is disabled\n");
4798 ports[res->port_id].dev_conf.txmode.offloads |=
4799 DEV_TX_OFFLOAD_TCP_TSO;
4800 printf("TSO segment size for non-tunneled packets is %d\n",
4801 ports[res->port_id].tso_segsz);
4803 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4805 /* display warnings if configuration is not supported by the NIC */
4806 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4810 if ((ports[res->port_id].tso_segsz != 0) &&
4811 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4812 printf("Warning: TSO enabled but not "
4813 "supported by port %d\n", res->port_id);
4816 cmd_reconfig_device_queue(res->port_id, 1, 1);
4819 cmdline_parse_token_string_t cmd_tso_set_tso =
4820 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4822 cmdline_parse_token_string_t cmd_tso_set_mode =
4823 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4825 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4826 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4828 cmdline_parse_token_num_t cmd_tso_set_portid =
4829 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4832 cmdline_parse_inst_t cmd_tso_set = {
4833 .f = cmd_tso_set_parsed,
4835 .help_str = "tso set <tso_segsz> <port_id>: "
4836 "Set TSO segment size of non-tunneled packets for csum engine "
4839 (void *)&cmd_tso_set_tso,
4840 (void *)&cmd_tso_set_mode,
4841 (void *)&cmd_tso_set_tso_segsz,
4842 (void *)&cmd_tso_set_portid,
4847 cmdline_parse_token_string_t cmd_tso_show_mode =
4848 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4852 cmdline_parse_inst_t cmd_tso_show = {
4853 .f = cmd_tso_set_parsed,
4855 .help_str = "tso show <port_id>: "
4856 "Show TSO segment size of non-tunneled packets for csum engine",
4858 (void *)&cmd_tso_set_tso,
4859 (void *)&cmd_tso_show_mode,
4860 (void *)&cmd_tso_set_portid,
4865 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4866 struct cmd_tunnel_tso_set_result {
4867 cmdline_fixed_string_t tso;
4868 cmdline_fixed_string_t mode;
4873 static struct rte_eth_dev_info
4874 check_tunnel_tso_nic_support(portid_t port_id)
4876 struct rte_eth_dev_info dev_info;
4878 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4881 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4882 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4883 "not enabled for port %d\n", port_id);
4884 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4885 printf("Warning: GRE TUNNEL TSO not supported therefore "
4886 "not enabled for port %d\n", port_id);
4887 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4888 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4889 "not enabled for port %d\n", port_id);
4890 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4891 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4892 "not enabled for port %d\n", port_id);
4893 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4894 printf("Warning: IP TUNNEL TSO not supported therefore "
4895 "not enabled for port %d\n", port_id);
4896 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4897 printf("Warning: UDP TUNNEL TSO not supported therefore "
4898 "not enabled for port %d\n", port_id);
4903 cmd_tunnel_tso_set_parsed(void *parsed_result,
4904 __rte_unused struct cmdline *cl,
4905 __rte_unused void *data)
4907 struct cmd_tunnel_tso_set_result *res = parsed_result;
4908 struct rte_eth_dev_info dev_info;
4910 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4912 if (!port_is_stopped(res->port_id)) {
4913 printf("Please stop port %d first\n", res->port_id);
4917 if (!strcmp(res->mode, "set"))
4918 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4920 dev_info = check_tunnel_tso_nic_support(res->port_id);
4921 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4922 ports[res->port_id].dev_conf.txmode.offloads &=
4923 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4924 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4925 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4926 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4927 DEV_TX_OFFLOAD_IP_TNL_TSO |
4928 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4929 printf("TSO for tunneled packets is disabled\n");
4931 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4932 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4933 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4934 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4935 DEV_TX_OFFLOAD_IP_TNL_TSO |
4936 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4938 ports[res->port_id].dev_conf.txmode.offloads |=
4939 (tso_offloads & dev_info.tx_offload_capa);
4940 printf("TSO segment size for tunneled packets is %d\n",
4941 ports[res->port_id].tunnel_tso_segsz);
4943 /* Below conditions are needed to make it work:
4944 * (1) tunnel TSO is supported by the NIC;
4945 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4947 * (3) for tunneled pkts with outer L3 of IPv4,
4948 * "csum set outer-ip" must be set to hw, because after tso,
4949 * total_len of outer IP header is changed, and the checksum
4950 * of outer IP header calculated by sw should be wrong; that
4951 * is not necessary for IPv6 tunneled pkts because there's no
4952 * checksum in IP header anymore.
4955 if (!ports[res->port_id].parse_tunnel)
4956 printf("Warning: csum parse_tunnel must be set "
4957 "so that tunneled packets are recognized\n");
4958 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4959 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4960 printf("Warning: csum set outer-ip must be set to hw "
4961 "if outer L3 is IPv4; not necessary for IPv6\n");
4964 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4965 cmd_reconfig_device_queue(res->port_id, 1, 1);
4968 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4969 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4971 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4972 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4974 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4975 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4977 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4978 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4981 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4982 .f = cmd_tunnel_tso_set_parsed,
4984 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4985 "Set TSO segment size of tunneled packets for csum engine "
4988 (void *)&cmd_tunnel_tso_set_tso,
4989 (void *)&cmd_tunnel_tso_set_mode,
4990 (void *)&cmd_tunnel_tso_set_tso_segsz,
4991 (void *)&cmd_tunnel_tso_set_portid,
4996 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4997 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5001 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5002 .f = cmd_tunnel_tso_set_parsed,
5004 .help_str = "tunnel_tso show <port_id> "
5005 "Show TSO segment size of tunneled packets for csum engine",
5007 (void *)&cmd_tunnel_tso_set_tso,
5008 (void *)&cmd_tunnel_tso_show_mode,
5009 (void *)&cmd_tunnel_tso_set_portid,
5014 /* *** SET GRO FOR A PORT *** */
5015 struct cmd_gro_enable_result {
5016 cmdline_fixed_string_t cmd_set;
5017 cmdline_fixed_string_t cmd_port;
5018 cmdline_fixed_string_t cmd_keyword;
5019 cmdline_fixed_string_t cmd_onoff;
5024 cmd_gro_enable_parsed(void *parsed_result,
5025 __rte_unused struct cmdline *cl,
5026 __rte_unused void *data)
5028 struct cmd_gro_enable_result *res;
5030 res = parsed_result;
5031 if (!strcmp(res->cmd_keyword, "gro"))
5032 setup_gro(res->cmd_onoff, res->cmd_pid);
5035 cmdline_parse_token_string_t cmd_gro_enable_set =
5036 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5038 cmdline_parse_token_string_t cmd_gro_enable_port =
5039 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5040 cmd_keyword, "port");
5041 cmdline_parse_token_num_t cmd_gro_enable_pid =
5042 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5044 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5045 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5046 cmd_keyword, "gro");
5047 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5048 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5049 cmd_onoff, "on#off");
5051 cmdline_parse_inst_t cmd_gro_enable = {
5052 .f = cmd_gro_enable_parsed,
5054 .help_str = "set port <port_id> gro on|off",
5056 (void *)&cmd_gro_enable_set,
5057 (void *)&cmd_gro_enable_port,
5058 (void *)&cmd_gro_enable_pid,
5059 (void *)&cmd_gro_enable_keyword,
5060 (void *)&cmd_gro_enable_onoff,
5065 /* *** DISPLAY GRO CONFIGURATION *** */
5066 struct cmd_gro_show_result {
5067 cmdline_fixed_string_t cmd_show;
5068 cmdline_fixed_string_t cmd_port;
5069 cmdline_fixed_string_t cmd_keyword;
5074 cmd_gro_show_parsed(void *parsed_result,
5075 __rte_unused struct cmdline *cl,
5076 __rte_unused void *data)
5078 struct cmd_gro_show_result *res;
5080 res = parsed_result;
5081 if (!strcmp(res->cmd_keyword, "gro"))
5082 show_gro(res->cmd_pid);
5085 cmdline_parse_token_string_t cmd_gro_show_show =
5086 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5088 cmdline_parse_token_string_t cmd_gro_show_port =
5089 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5091 cmdline_parse_token_num_t cmd_gro_show_pid =
5092 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5094 cmdline_parse_token_string_t cmd_gro_show_keyword =
5095 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5096 cmd_keyword, "gro");
5098 cmdline_parse_inst_t cmd_gro_show = {
5099 .f = cmd_gro_show_parsed,
5101 .help_str = "show port <port_id> gro",
5103 (void *)&cmd_gro_show_show,
5104 (void *)&cmd_gro_show_port,
5105 (void *)&cmd_gro_show_pid,
5106 (void *)&cmd_gro_show_keyword,
5111 /* *** SET FLUSH CYCLES FOR GRO *** */
5112 struct cmd_gro_flush_result {
5113 cmdline_fixed_string_t cmd_set;
5114 cmdline_fixed_string_t cmd_keyword;
5115 cmdline_fixed_string_t cmd_flush;
5120 cmd_gro_flush_parsed(void *parsed_result,
5121 __rte_unused struct cmdline *cl,
5122 __rte_unused void *data)
5124 struct cmd_gro_flush_result *res;
5126 res = parsed_result;
5127 if ((!strcmp(res->cmd_keyword, "gro")) &&
5128 (!strcmp(res->cmd_flush, "flush")))
5129 setup_gro_flush_cycles(res->cmd_cycles);
5132 cmdline_parse_token_string_t cmd_gro_flush_set =
5133 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5135 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5136 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5137 cmd_keyword, "gro");
5138 cmdline_parse_token_string_t cmd_gro_flush_flush =
5139 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5140 cmd_flush, "flush");
5141 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5142 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5145 cmdline_parse_inst_t cmd_gro_flush = {
5146 .f = cmd_gro_flush_parsed,
5148 .help_str = "set gro flush <cycles>",
5150 (void *)&cmd_gro_flush_set,
5151 (void *)&cmd_gro_flush_keyword,
5152 (void *)&cmd_gro_flush_flush,
5153 (void *)&cmd_gro_flush_cycles,
5158 /* *** ENABLE/DISABLE GSO *** */
5159 struct cmd_gso_enable_result {
5160 cmdline_fixed_string_t cmd_set;
5161 cmdline_fixed_string_t cmd_port;
5162 cmdline_fixed_string_t cmd_keyword;
5163 cmdline_fixed_string_t cmd_mode;
5168 cmd_gso_enable_parsed(void *parsed_result,
5169 __rte_unused struct cmdline *cl,
5170 __rte_unused void *data)
5172 struct cmd_gso_enable_result *res;
5174 res = parsed_result;
5175 if (!strcmp(res->cmd_keyword, "gso"))
5176 setup_gso(res->cmd_mode, res->cmd_pid);
5179 cmdline_parse_token_string_t cmd_gso_enable_set =
5180 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5182 cmdline_parse_token_string_t cmd_gso_enable_port =
5183 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5185 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5186 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5187 cmd_keyword, "gso");
5188 cmdline_parse_token_string_t cmd_gso_enable_mode =
5189 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5190 cmd_mode, "on#off");
5191 cmdline_parse_token_num_t cmd_gso_enable_pid =
5192 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5195 cmdline_parse_inst_t cmd_gso_enable = {
5196 .f = cmd_gso_enable_parsed,
5198 .help_str = "set port <port_id> gso on|off",
5200 (void *)&cmd_gso_enable_set,
5201 (void *)&cmd_gso_enable_port,
5202 (void *)&cmd_gso_enable_pid,
5203 (void *)&cmd_gso_enable_keyword,
5204 (void *)&cmd_gso_enable_mode,
5209 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5210 struct cmd_gso_size_result {
5211 cmdline_fixed_string_t cmd_set;
5212 cmdline_fixed_string_t cmd_keyword;
5213 cmdline_fixed_string_t cmd_segsz;
5218 cmd_gso_size_parsed(void *parsed_result,
5219 __rte_unused struct cmdline *cl,
5220 __rte_unused void *data)
5222 struct cmd_gso_size_result *res = parsed_result;
5224 if (test_done == 0) {
5225 printf("Before setting GSO segsz, please first"
5226 " stop forwarding\n");
5230 if (!strcmp(res->cmd_keyword, "gso") &&
5231 !strcmp(res->cmd_segsz, "segsz")) {
5232 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5233 printf("gso_size should be larger than %zu."
5234 " Please input a legal value\n",
5235 RTE_GSO_SEG_SIZE_MIN);
5237 gso_max_segment_size = res->cmd_size;
5241 cmdline_parse_token_string_t cmd_gso_size_set =
5242 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5244 cmdline_parse_token_string_t cmd_gso_size_keyword =
5245 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5246 cmd_keyword, "gso");
5247 cmdline_parse_token_string_t cmd_gso_size_segsz =
5248 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5249 cmd_segsz, "segsz");
5250 cmdline_parse_token_num_t cmd_gso_size_size =
5251 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5254 cmdline_parse_inst_t cmd_gso_size = {
5255 .f = cmd_gso_size_parsed,
5257 .help_str = "set gso segsz <length>",
5259 (void *)&cmd_gso_size_set,
5260 (void *)&cmd_gso_size_keyword,
5261 (void *)&cmd_gso_size_segsz,
5262 (void *)&cmd_gso_size_size,
5267 /* *** SHOW GSO CONFIGURATION *** */
5268 struct cmd_gso_show_result {
5269 cmdline_fixed_string_t cmd_show;
5270 cmdline_fixed_string_t cmd_port;
5271 cmdline_fixed_string_t cmd_keyword;
5276 cmd_gso_show_parsed(void *parsed_result,
5277 __rte_unused struct cmdline *cl,
5278 __rte_unused void *data)
5280 struct cmd_gso_show_result *res = parsed_result;
5282 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5283 printf("invalid port id %u\n", res->cmd_pid);
5286 if (!strcmp(res->cmd_keyword, "gso")) {
5287 if (gso_ports[res->cmd_pid].enable) {
5288 printf("Max GSO'd packet size: %uB\n"
5289 "Supported GSO types: TCP/IPv4, "
5290 "UDP/IPv4, VxLAN with inner "
5291 "TCP/IPv4 packet, GRE with inner "
5292 "TCP/IPv4 packet\n",
5293 gso_max_segment_size);
5295 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5299 cmdline_parse_token_string_t cmd_gso_show_show =
5300 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5302 cmdline_parse_token_string_t cmd_gso_show_port =
5303 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5305 cmdline_parse_token_string_t cmd_gso_show_keyword =
5306 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5307 cmd_keyword, "gso");
5308 cmdline_parse_token_num_t cmd_gso_show_pid =
5309 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5312 cmdline_parse_inst_t cmd_gso_show = {
5313 .f = cmd_gso_show_parsed,
5315 .help_str = "show port <port_id> gso",
5317 (void *)&cmd_gso_show_show,
5318 (void *)&cmd_gso_show_port,
5319 (void *)&cmd_gso_show_pid,
5320 (void *)&cmd_gso_show_keyword,
5325 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5326 struct cmd_set_flush_rx {
5327 cmdline_fixed_string_t set;
5328 cmdline_fixed_string_t flush_rx;
5329 cmdline_fixed_string_t mode;
5333 cmd_set_flush_rx_parsed(void *parsed_result,
5334 __rte_unused struct cmdline *cl,
5335 __rte_unused void *data)
5337 struct cmd_set_flush_rx *res = parsed_result;
5338 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5341 cmdline_parse_token_string_t cmd_setflushrx_set =
5342 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5344 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5345 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5346 flush_rx, "flush_rx");
5347 cmdline_parse_token_string_t cmd_setflushrx_mode =
5348 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5352 cmdline_parse_inst_t cmd_set_flush_rx = {
5353 .f = cmd_set_flush_rx_parsed,
5354 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5357 (void *)&cmd_setflushrx_set,
5358 (void *)&cmd_setflushrx_flush_rx,
5359 (void *)&cmd_setflushrx_mode,
5364 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5365 struct cmd_set_link_check {
5366 cmdline_fixed_string_t set;
5367 cmdline_fixed_string_t link_check;
5368 cmdline_fixed_string_t mode;
5372 cmd_set_link_check_parsed(void *parsed_result,
5373 __rte_unused struct cmdline *cl,
5374 __rte_unused void *data)
5376 struct cmd_set_link_check *res = parsed_result;
5377 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5380 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5381 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5383 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5384 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5385 link_check, "link_check");
5386 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5387 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5391 cmdline_parse_inst_t cmd_set_link_check = {
5392 .f = cmd_set_link_check_parsed,
5393 .help_str = "set link_check on|off: Enable/Disable link status check "
5394 "when starting/stopping a port",
5397 (void *)&cmd_setlinkcheck_set,
5398 (void *)&cmd_setlinkcheck_link_check,
5399 (void *)&cmd_setlinkcheck_mode,
5404 /* *** SET NIC BYPASS MODE *** */
5405 struct cmd_set_bypass_mode_result {
5406 cmdline_fixed_string_t set;
5407 cmdline_fixed_string_t bypass;
5408 cmdline_fixed_string_t mode;
5409 cmdline_fixed_string_t value;
5414 cmd_set_bypass_mode_parsed(void *parsed_result,
5415 __rte_unused struct cmdline *cl,
5416 __rte_unused void *data)
5418 struct cmd_set_bypass_mode_result *res = parsed_result;
5419 portid_t port_id = res->port_id;
5420 int32_t rc = -EINVAL;
5422 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5423 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5425 if (!strcmp(res->value, "bypass"))
5426 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5427 else if (!strcmp(res->value, "isolate"))
5428 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5430 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5432 /* Set the bypass mode for the relevant port. */
5433 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5436 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5439 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5440 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5442 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5443 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5445 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5446 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5448 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5449 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5450 value, "normal#bypass#isolate");
5451 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5452 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5455 cmdline_parse_inst_t cmd_set_bypass_mode = {
5456 .f = cmd_set_bypass_mode_parsed,
5457 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5458 "Set the NIC bypass mode for port_id",
5461 (void *)&cmd_setbypass_mode_set,
5462 (void *)&cmd_setbypass_mode_bypass,
5463 (void *)&cmd_setbypass_mode_mode,
5464 (void *)&cmd_setbypass_mode_value,
5465 (void *)&cmd_setbypass_mode_port,
5470 /* *** SET NIC BYPASS EVENT *** */
5471 struct cmd_set_bypass_event_result {
5472 cmdline_fixed_string_t set;
5473 cmdline_fixed_string_t bypass;
5474 cmdline_fixed_string_t event;
5475 cmdline_fixed_string_t event_value;
5476 cmdline_fixed_string_t mode;
5477 cmdline_fixed_string_t mode_value;
5482 cmd_set_bypass_event_parsed(void *parsed_result,
5483 __rte_unused struct cmdline *cl,
5484 __rte_unused void *data)
5486 int32_t rc = -EINVAL;
5487 struct cmd_set_bypass_event_result *res = parsed_result;
5488 portid_t port_id = res->port_id;
5490 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5491 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5492 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5494 if (!strcmp(res->event_value, "timeout"))
5495 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5496 else if (!strcmp(res->event_value, "os_on"))
5497 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5498 else if (!strcmp(res->event_value, "os_off"))
5499 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5500 else if (!strcmp(res->event_value, "power_on"))
5501 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5502 else if (!strcmp(res->event_value, "power_off"))
5503 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5505 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5507 if (!strcmp(res->mode_value, "bypass"))
5508 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5509 else if (!strcmp(res->mode_value, "isolate"))
5510 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5512 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5514 /* Set the watchdog timeout. */
5515 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5518 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5519 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5523 printf("Failed to set timeout value %u "
5524 "for port %d, errto code: %d.\n",
5525 bypass_timeout, port_id, rc);
5529 /* Set the bypass event to transition to bypass mode. */
5530 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5535 printf("\t Failed to set bypass event for port = %d.\n",
5539 cmdline_parse_token_string_t cmd_setbypass_event_set =
5540 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5542 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5543 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5545 cmdline_parse_token_string_t cmd_setbypass_event_event =
5546 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5548 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5549 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5550 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5551 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5552 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5554 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5555 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5556 mode_value, "normal#bypass#isolate");
5557 cmdline_parse_token_num_t cmd_setbypass_event_port =
5558 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5561 cmdline_parse_inst_t cmd_set_bypass_event = {
5562 .f = cmd_set_bypass_event_parsed,
5563 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5564 "power_off mode normal|bypass|isolate <port_id>: "
5565 "Set the NIC bypass event mode for port_id",
5568 (void *)&cmd_setbypass_event_set,
5569 (void *)&cmd_setbypass_event_bypass,
5570 (void *)&cmd_setbypass_event_event,
5571 (void *)&cmd_setbypass_event_event_value,
5572 (void *)&cmd_setbypass_event_mode,
5573 (void *)&cmd_setbypass_event_mode_value,
5574 (void *)&cmd_setbypass_event_port,
5580 /* *** SET NIC BYPASS TIMEOUT *** */
5581 struct cmd_set_bypass_timeout_result {
5582 cmdline_fixed_string_t set;
5583 cmdline_fixed_string_t bypass;
5584 cmdline_fixed_string_t timeout;
5585 cmdline_fixed_string_t value;
5589 cmd_set_bypass_timeout_parsed(void *parsed_result,
5590 __rte_unused struct cmdline *cl,
5591 __rte_unused void *data)
5593 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5595 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5596 if (!strcmp(res->value, "1.5"))
5597 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5598 else if (!strcmp(res->value, "2"))
5599 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5600 else if (!strcmp(res->value, "3"))
5601 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5602 else if (!strcmp(res->value, "4"))
5603 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5604 else if (!strcmp(res->value, "8"))
5605 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5606 else if (!strcmp(res->value, "16"))
5607 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5608 else if (!strcmp(res->value, "32"))
5609 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5611 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5615 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5616 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5618 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5619 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5621 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5622 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5623 timeout, "timeout");
5624 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5625 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5626 value, "0#1.5#2#3#4#8#16#32");
5628 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5629 .f = cmd_set_bypass_timeout_parsed,
5630 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5631 "Set the NIC bypass watchdog timeout in seconds",
5634 (void *)&cmd_setbypass_timeout_set,
5635 (void *)&cmd_setbypass_timeout_bypass,
5636 (void *)&cmd_setbypass_timeout_timeout,
5637 (void *)&cmd_setbypass_timeout_value,
5642 /* *** SHOW NIC BYPASS MODE *** */
5643 struct cmd_show_bypass_config_result {
5644 cmdline_fixed_string_t show;
5645 cmdline_fixed_string_t bypass;
5646 cmdline_fixed_string_t config;
5651 cmd_show_bypass_config_parsed(void *parsed_result,
5652 __rte_unused struct cmdline *cl,
5653 __rte_unused void *data)
5655 struct cmd_show_bypass_config_result *res = parsed_result;
5656 portid_t port_id = res->port_id;
5658 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5659 uint32_t event_mode;
5660 uint32_t bypass_mode;
5661 uint32_t timeout = bypass_timeout;
5664 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5665 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5666 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5667 {"UNKNOWN", "normal", "bypass", "isolate"};
5668 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5676 /* Display the bypass mode.*/
5677 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5678 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5682 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5683 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5685 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5688 /* Display the bypass timeout.*/
5689 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5690 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5692 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5694 /* Display the bypass events and associated modes. */
5695 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5697 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5698 printf("\tFailed to get bypass mode for event = %s\n",
5701 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5702 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5704 printf("\tbypass event: %-16s = %s\n", events[i],
5710 printf("\tFailed to get bypass configuration for port = %d\n",
5714 cmdline_parse_token_string_t cmd_showbypass_config_show =
5715 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5717 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5718 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5720 cmdline_parse_token_string_t cmd_showbypass_config_config =
5721 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5723 cmdline_parse_token_num_t cmd_showbypass_config_port =
5724 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5727 cmdline_parse_inst_t cmd_show_bypass_config = {
5728 .f = cmd_show_bypass_config_parsed,
5729 .help_str = "show bypass config <port_id>: "
5730 "Show the NIC bypass config for port_id",
5733 (void *)&cmd_showbypass_config_show,
5734 (void *)&cmd_showbypass_config_bypass,
5735 (void *)&cmd_showbypass_config_config,
5736 (void *)&cmd_showbypass_config_port,
5741 #ifdef RTE_LIBRTE_PMD_BOND
5742 /* *** SET BONDING MODE *** */
5743 struct cmd_set_bonding_mode_result {
5744 cmdline_fixed_string_t set;
5745 cmdline_fixed_string_t bonding;
5746 cmdline_fixed_string_t mode;
5751 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5752 __rte_unused struct cmdline *cl,
5753 __rte_unused void *data)
5755 struct cmd_set_bonding_mode_result *res = parsed_result;
5756 portid_t port_id = res->port_id;
5758 /* Set the bonding mode for the relevant port. */
5759 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5760 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5763 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5764 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5766 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5767 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5768 bonding, "bonding");
5769 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5770 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5772 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5773 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5775 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5776 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5779 cmdline_parse_inst_t cmd_set_bonding_mode = {
5780 .f = cmd_set_bonding_mode_parsed,
5781 .help_str = "set bonding mode <mode_value> <port_id>: "
5782 "Set the bonding mode for port_id",
5785 (void *) &cmd_setbonding_mode_set,
5786 (void *) &cmd_setbonding_mode_bonding,
5787 (void *) &cmd_setbonding_mode_mode,
5788 (void *) &cmd_setbonding_mode_value,
5789 (void *) &cmd_setbonding_mode_port,
5794 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5795 struct cmd_set_bonding_lacp_dedicated_queues_result {
5796 cmdline_fixed_string_t set;
5797 cmdline_fixed_string_t bonding;
5798 cmdline_fixed_string_t lacp;
5799 cmdline_fixed_string_t dedicated_queues;
5801 cmdline_fixed_string_t mode;
5804 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5805 __rte_unused struct cmdline *cl,
5806 __rte_unused void *data)
5808 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5809 portid_t port_id = res->port_id;
5810 struct rte_port *port;
5812 port = &ports[port_id];
5814 /** Check if the port is not started **/
5815 if (port->port_status != RTE_PORT_STOPPED) {
5816 printf("Please stop port %d first\n", port_id);
5820 if (!strcmp(res->mode, "enable")) {
5821 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5822 printf("Dedicate queues for LACP control packets"
5825 printf("Enabling dedicate queues for LACP control "
5826 "packets on port %d failed\n", port_id);
5827 } else if (!strcmp(res->mode, "disable")) {
5828 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5829 printf("Dedicated queues for LACP control packets "
5832 printf("Disabling dedicated queues for LACP control "
5833 "traffic on port %d failed\n", port_id);
5837 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5838 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5840 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5841 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5842 bonding, "bonding");
5843 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5844 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5846 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5847 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5848 dedicated_queues, "dedicated_queues");
5849 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5850 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5852 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5853 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5854 mode, "enable#disable");
5856 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5857 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5858 .help_str = "set bonding lacp dedicated_queues <port_id> "
5860 "Enable/disable dedicated queues for LACP control traffic for port_id",
5863 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5864 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5865 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5866 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5867 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5868 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5873 /* *** SET BALANCE XMIT POLICY *** */
5874 struct cmd_set_bonding_balance_xmit_policy_result {
5875 cmdline_fixed_string_t set;
5876 cmdline_fixed_string_t bonding;
5877 cmdline_fixed_string_t balance_xmit_policy;
5879 cmdline_fixed_string_t policy;
5882 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5883 __rte_unused struct cmdline *cl,
5884 __rte_unused void *data)
5886 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5887 portid_t port_id = res->port_id;
5890 if (!strcmp(res->policy, "l2")) {
5891 policy = BALANCE_XMIT_POLICY_LAYER2;
5892 } else if (!strcmp(res->policy, "l23")) {
5893 policy = BALANCE_XMIT_POLICY_LAYER23;
5894 } else if (!strcmp(res->policy, "l34")) {
5895 policy = BALANCE_XMIT_POLICY_LAYER34;
5897 printf("\t Invalid xmit policy selection");
5901 /* Set the bonding mode for the relevant port. */
5902 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5903 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5908 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5909 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5911 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5912 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5913 bonding, "bonding");
5914 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5915 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5916 balance_xmit_policy, "balance_xmit_policy");
5917 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5918 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5920 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5921 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5922 policy, "l2#l23#l34");
5924 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5925 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5926 .help_str = "set bonding balance_xmit_policy <port_id> "
5928 "Set the bonding balance_xmit_policy for port_id",
5931 (void *)&cmd_setbonding_balance_xmit_policy_set,
5932 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5933 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5934 (void *)&cmd_setbonding_balance_xmit_policy_port,
5935 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5940 /* *** SHOW NIC BONDING CONFIGURATION *** */
5941 struct cmd_show_bonding_config_result {
5942 cmdline_fixed_string_t show;
5943 cmdline_fixed_string_t bonding;
5944 cmdline_fixed_string_t config;
5948 static void cmd_show_bonding_config_parsed(void *parsed_result,
5949 __rte_unused struct cmdline *cl,
5950 __rte_unused void *data)
5952 struct cmd_show_bonding_config_result *res = parsed_result;
5953 int bonding_mode, agg_mode;
5954 portid_t slaves[RTE_MAX_ETHPORTS];
5955 int num_slaves, num_active_slaves;
5958 portid_t port_id = res->port_id;
5960 /* Display the bonding mode.*/
5961 bonding_mode = rte_eth_bond_mode_get(port_id);
5962 if (bonding_mode < 0) {
5963 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5966 printf("\tBonding mode: %d\n", bonding_mode);
5968 if (bonding_mode == BONDING_MODE_BALANCE) {
5969 int balance_xmit_policy;
5971 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5972 if (balance_xmit_policy < 0) {
5973 printf("\tFailed to get balance xmit policy for port = %d\n",
5977 printf("\tBalance Xmit Policy: ");
5979 switch (balance_xmit_policy) {
5980 case BALANCE_XMIT_POLICY_LAYER2:
5981 printf("BALANCE_XMIT_POLICY_LAYER2");
5983 case BALANCE_XMIT_POLICY_LAYER23:
5984 printf("BALANCE_XMIT_POLICY_LAYER23");
5986 case BALANCE_XMIT_POLICY_LAYER34:
5987 printf("BALANCE_XMIT_POLICY_LAYER34");
5994 if (bonding_mode == BONDING_MODE_8023AD) {
5995 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5996 printf("\tIEEE802.3AD Aggregator Mode: ");
5999 printf("bandwidth");
6011 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6013 if (num_slaves < 0) {
6014 printf("\tFailed to get slave list for port = %d\n", port_id);
6017 if (num_slaves > 0) {
6018 printf("\tSlaves (%d): [", num_slaves);
6019 for (i = 0; i < num_slaves - 1; i++)
6020 printf("%d ", slaves[i]);
6022 printf("%d]\n", slaves[num_slaves - 1]);
6024 printf("\tSlaves: []\n");
6028 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6031 if (num_active_slaves < 0) {
6032 printf("\tFailed to get active slave list for port = %d\n", port_id);
6035 if (num_active_slaves > 0) {
6036 printf("\tActive Slaves (%d): [", num_active_slaves);
6037 for (i = 0; i < num_active_slaves - 1; i++)
6038 printf("%d ", slaves[i]);
6040 printf("%d]\n", slaves[num_active_slaves - 1]);
6043 printf("\tActive Slaves: []\n");
6047 primary_id = rte_eth_bond_primary_get(port_id);
6048 if (primary_id < 0) {
6049 printf("\tFailed to get primary slave for port = %d\n", port_id);
6052 printf("\tPrimary: [%d]\n", primary_id);
6056 cmdline_parse_token_string_t cmd_showbonding_config_show =
6057 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6059 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6060 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6061 bonding, "bonding");
6062 cmdline_parse_token_string_t cmd_showbonding_config_config =
6063 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6065 cmdline_parse_token_num_t cmd_showbonding_config_port =
6066 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6069 cmdline_parse_inst_t cmd_show_bonding_config = {
6070 .f = cmd_show_bonding_config_parsed,
6071 .help_str = "show bonding config <port_id>: "
6072 "Show the bonding config for port_id",
6075 (void *)&cmd_showbonding_config_show,
6076 (void *)&cmd_showbonding_config_bonding,
6077 (void *)&cmd_showbonding_config_config,
6078 (void *)&cmd_showbonding_config_port,
6083 /* *** SET BONDING PRIMARY *** */
6084 struct cmd_set_bonding_primary_result {
6085 cmdline_fixed_string_t set;
6086 cmdline_fixed_string_t bonding;
6087 cmdline_fixed_string_t primary;
6092 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6093 __rte_unused struct cmdline *cl,
6094 __rte_unused void *data)
6096 struct cmd_set_bonding_primary_result *res = parsed_result;
6097 portid_t master_port_id = res->port_id;
6098 portid_t slave_port_id = res->slave_id;
6100 /* Set the primary slave for a bonded device. */
6101 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6102 printf("\t Failed to set primary slave for port = %d.\n",
6109 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6110 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6112 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6113 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6114 bonding, "bonding");
6115 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6116 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6117 primary, "primary");
6118 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6119 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6121 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6122 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6125 cmdline_parse_inst_t cmd_set_bonding_primary = {
6126 .f = cmd_set_bonding_primary_parsed,
6127 .help_str = "set bonding primary <slave_id> <port_id>: "
6128 "Set the primary slave for port_id",
6131 (void *)&cmd_setbonding_primary_set,
6132 (void *)&cmd_setbonding_primary_bonding,
6133 (void *)&cmd_setbonding_primary_primary,
6134 (void *)&cmd_setbonding_primary_slave,
6135 (void *)&cmd_setbonding_primary_port,
6140 /* *** ADD SLAVE *** */
6141 struct cmd_add_bonding_slave_result {
6142 cmdline_fixed_string_t add;
6143 cmdline_fixed_string_t bonding;
6144 cmdline_fixed_string_t slave;
6149 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6150 __rte_unused struct cmdline *cl,
6151 __rte_unused void *data)
6153 struct cmd_add_bonding_slave_result *res = parsed_result;
6154 portid_t master_port_id = res->port_id;
6155 portid_t slave_port_id = res->slave_id;
6157 /* add the slave for a bonded device. */
6158 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6159 printf("\t Failed to add slave %d to master port = %d.\n",
6160 slave_port_id, master_port_id);
6164 set_port_slave_flag(slave_port_id);
6167 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6168 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6170 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6171 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6172 bonding, "bonding");
6173 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6174 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6176 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6177 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6179 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6180 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6183 cmdline_parse_inst_t cmd_add_bonding_slave = {
6184 .f = cmd_add_bonding_slave_parsed,
6185 .help_str = "add bonding slave <slave_id> <port_id>: "
6186 "Add a slave device to a bonded device",
6189 (void *)&cmd_addbonding_slave_add,
6190 (void *)&cmd_addbonding_slave_bonding,
6191 (void *)&cmd_addbonding_slave_slave,
6192 (void *)&cmd_addbonding_slave_slaveid,
6193 (void *)&cmd_addbonding_slave_port,
6198 /* *** REMOVE SLAVE *** */
6199 struct cmd_remove_bonding_slave_result {
6200 cmdline_fixed_string_t remove;
6201 cmdline_fixed_string_t bonding;
6202 cmdline_fixed_string_t slave;
6207 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6208 __rte_unused struct cmdline *cl,
6209 __rte_unused void *data)
6211 struct cmd_remove_bonding_slave_result *res = parsed_result;
6212 portid_t master_port_id = res->port_id;
6213 portid_t slave_port_id = res->slave_id;
6215 /* remove the slave from a bonded device. */
6216 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6217 printf("\t Failed to remove slave %d from master port = %d.\n",
6218 slave_port_id, master_port_id);
6222 clear_port_slave_flag(slave_port_id);
6225 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6226 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6228 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6229 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6230 bonding, "bonding");
6231 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6232 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6234 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6235 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6237 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6238 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6241 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6242 .f = cmd_remove_bonding_slave_parsed,
6243 .help_str = "remove bonding slave <slave_id> <port_id>: "
6244 "Remove a slave device from a bonded device",
6247 (void *)&cmd_removebonding_slave_remove,
6248 (void *)&cmd_removebonding_slave_bonding,
6249 (void *)&cmd_removebonding_slave_slave,
6250 (void *)&cmd_removebonding_slave_slaveid,
6251 (void *)&cmd_removebonding_slave_port,
6256 /* *** CREATE BONDED DEVICE *** */
6257 struct cmd_create_bonded_device_result {
6258 cmdline_fixed_string_t create;
6259 cmdline_fixed_string_t bonded;
6260 cmdline_fixed_string_t device;
6265 static int bond_dev_num = 0;
6267 static void cmd_create_bonded_device_parsed(void *parsed_result,
6268 __rte_unused struct cmdline *cl,
6269 __rte_unused void *data)
6271 struct cmd_create_bonded_device_result *res = parsed_result;
6272 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6276 if (test_done == 0) {
6277 printf("Please stop forwarding first\n");
6281 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6284 /* Create a new bonded device. */
6285 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6287 printf("\t Failed to create bonded device.\n");
6290 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6293 /* Update number of ports */
6294 nb_ports = rte_eth_dev_count_avail();
6295 reconfig(port_id, res->socket);
6296 ret = rte_eth_promiscuous_enable(port_id);
6298 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6299 port_id, rte_strerror(-ret));
6301 ports[port_id].need_setup = 0;
6302 ports[port_id].port_status = RTE_PORT_STOPPED;
6307 cmdline_parse_token_string_t cmd_createbonded_device_create =
6308 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6310 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6311 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6313 cmdline_parse_token_string_t cmd_createbonded_device_device =
6314 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6316 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6317 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6319 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6320 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6323 cmdline_parse_inst_t cmd_create_bonded_device = {
6324 .f = cmd_create_bonded_device_parsed,
6325 .help_str = "create bonded device <mode> <socket>: "
6326 "Create a new bonded device with specific bonding mode and socket",
6329 (void *)&cmd_createbonded_device_create,
6330 (void *)&cmd_createbonded_device_bonded,
6331 (void *)&cmd_createbonded_device_device,
6332 (void *)&cmd_createbonded_device_mode,
6333 (void *)&cmd_createbonded_device_socket,
6338 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6339 struct cmd_set_bond_mac_addr_result {
6340 cmdline_fixed_string_t set;
6341 cmdline_fixed_string_t bonding;
6342 cmdline_fixed_string_t mac_addr;
6344 struct rte_ether_addr address;
6347 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6348 __rte_unused struct cmdline *cl,
6349 __rte_unused void *data)
6351 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6354 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6357 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6359 /* check the return value and print it if is < 0 */
6361 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6364 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6365 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6366 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6367 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6369 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6370 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6372 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6373 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6375 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6376 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6378 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6379 .f = cmd_set_bond_mac_addr_parsed,
6381 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6383 (void *)&cmd_set_bond_mac_addr_set,
6384 (void *)&cmd_set_bond_mac_addr_bonding,
6385 (void *)&cmd_set_bond_mac_addr_mac,
6386 (void *)&cmd_set_bond_mac_addr_portnum,
6387 (void *)&cmd_set_bond_mac_addr_addr,
6393 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6394 struct cmd_set_bond_mon_period_result {
6395 cmdline_fixed_string_t set;
6396 cmdline_fixed_string_t bonding;
6397 cmdline_fixed_string_t mon_period;
6402 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6403 __rte_unused struct cmdline *cl,
6404 __rte_unused void *data)
6406 struct cmd_set_bond_mon_period_result *res = parsed_result;
6409 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6411 /* check the return value and print it if is < 0 */
6413 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6416 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6417 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6419 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6420 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6421 bonding, "bonding");
6422 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6423 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6424 mon_period, "mon_period");
6425 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6426 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6428 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6429 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6432 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6433 .f = cmd_set_bond_mon_period_parsed,
6435 .help_str = "set bonding mon_period <port_id> <period_ms>",
6437 (void *)&cmd_set_bond_mon_period_set,
6438 (void *)&cmd_set_bond_mon_period_bonding,
6439 (void *)&cmd_set_bond_mon_period_mon_period,
6440 (void *)&cmd_set_bond_mon_period_portnum,
6441 (void *)&cmd_set_bond_mon_period_period_ms,
6448 struct cmd_set_bonding_agg_mode_policy_result {
6449 cmdline_fixed_string_t set;
6450 cmdline_fixed_string_t bonding;
6451 cmdline_fixed_string_t agg_mode;
6453 cmdline_fixed_string_t policy;
6458 cmd_set_bonding_agg_mode(void *parsed_result,
6459 __rte_unused struct cmdline *cl,
6460 __rte_unused void *data)
6462 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6463 uint8_t policy = AGG_BANDWIDTH;
6465 if (!strcmp(res->policy, "bandwidth"))
6466 policy = AGG_BANDWIDTH;
6467 else if (!strcmp(res->policy, "stable"))
6468 policy = AGG_STABLE;
6469 else if (!strcmp(res->policy, "count"))
6472 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6476 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6477 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6479 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6480 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6481 bonding, "bonding");
6483 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6484 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6485 agg_mode, "agg_mode");
6487 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6488 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6491 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6492 TOKEN_STRING_INITIALIZER(
6493 struct cmd_set_bonding_balance_xmit_policy_result,
6494 policy, "stable#bandwidth#count");
6496 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6497 .f = cmd_set_bonding_agg_mode,
6499 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6501 (void *)&cmd_set_bonding_agg_mode_set,
6502 (void *)&cmd_set_bonding_agg_mode_bonding,
6503 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6504 (void *)&cmd_set_bonding_agg_mode_portnum,
6505 (void *)&cmd_set_bonding_agg_mode_policy_string,
6511 #endif /* RTE_LIBRTE_PMD_BOND */
6513 /* *** SET FORWARDING MODE *** */
6514 struct cmd_set_fwd_mode_result {
6515 cmdline_fixed_string_t set;
6516 cmdline_fixed_string_t fwd;
6517 cmdline_fixed_string_t mode;
6520 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6521 __rte_unused struct cmdline *cl,
6522 __rte_unused void *data)
6524 struct cmd_set_fwd_mode_result *res = parsed_result;
6527 set_pkt_forwarding_mode(res->mode);
6530 cmdline_parse_token_string_t cmd_setfwd_set =
6531 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6532 cmdline_parse_token_string_t cmd_setfwd_fwd =
6533 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6534 cmdline_parse_token_string_t cmd_setfwd_mode =
6535 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6536 "" /* defined at init */);
6538 cmdline_parse_inst_t cmd_set_fwd_mode = {
6539 .f = cmd_set_fwd_mode_parsed,
6541 .help_str = NULL, /* defined at init */
6543 (void *)&cmd_setfwd_set,
6544 (void *)&cmd_setfwd_fwd,
6545 (void *)&cmd_setfwd_mode,
6550 static void cmd_set_fwd_mode_init(void)
6553 static char token[128];
6554 static char help[256];
6555 cmdline_parse_token_string_t *token_struct;
6557 modes = list_pkt_forwarding_modes();
6558 snprintf(help, sizeof(help), "set fwd %s: "
6559 "Set packet forwarding mode", modes);
6560 cmd_set_fwd_mode.help_str = help;
6562 /* string token separator is # */
6563 for (c = token; *modes != '\0'; modes++)
6568 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6569 token_struct->string_data.str = token;
6572 /* *** SET RETRY FORWARDING MODE *** */
6573 struct cmd_set_fwd_retry_mode_result {
6574 cmdline_fixed_string_t set;
6575 cmdline_fixed_string_t fwd;
6576 cmdline_fixed_string_t mode;
6577 cmdline_fixed_string_t retry;
6580 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6581 __rte_unused struct cmdline *cl,
6582 __rte_unused void *data)
6584 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6587 set_pkt_forwarding_mode(res->mode);
6590 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6591 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6593 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6594 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6596 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6597 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6599 "" /* defined at init */);
6600 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6601 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6604 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6605 .f = cmd_set_fwd_retry_mode_parsed,
6607 .help_str = NULL, /* defined at init */
6609 (void *)&cmd_setfwd_retry_set,
6610 (void *)&cmd_setfwd_retry_fwd,
6611 (void *)&cmd_setfwd_retry_mode,
6612 (void *)&cmd_setfwd_retry_retry,
6617 static void cmd_set_fwd_retry_mode_init(void)
6620 static char token[128];
6621 static char help[256];
6622 cmdline_parse_token_string_t *token_struct;
6624 modes = list_pkt_forwarding_retry_modes();
6625 snprintf(help, sizeof(help), "set fwd %s retry: "
6626 "Set packet forwarding mode with retry", modes);
6627 cmd_set_fwd_retry_mode.help_str = help;
6629 /* string token separator is # */
6630 for (c = token; *modes != '\0'; modes++)
6635 token_struct = (cmdline_parse_token_string_t *)
6636 cmd_set_fwd_retry_mode.tokens[2];
6637 token_struct->string_data.str = token;
6640 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6641 struct cmd_set_burst_tx_retry_result {
6642 cmdline_fixed_string_t set;
6643 cmdline_fixed_string_t burst;
6644 cmdline_fixed_string_t tx;
6645 cmdline_fixed_string_t delay;
6647 cmdline_fixed_string_t retry;
6651 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6652 __rte_unused struct cmdline *cl,
6653 __rte_unused void *data)
6655 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6657 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6658 && !strcmp(res->tx, "tx")) {
6659 if (!strcmp(res->delay, "delay"))
6660 burst_tx_delay_time = res->time;
6661 if (!strcmp(res->retry, "retry"))
6662 burst_tx_retry_num = res->retry_num;
6667 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6668 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6669 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6670 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6672 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6673 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6674 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6675 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6676 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6677 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6678 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6679 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6680 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6681 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6683 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6684 .f = cmd_set_burst_tx_retry_parsed,
6685 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6687 (void *)&cmd_set_burst_tx_retry_set,
6688 (void *)&cmd_set_burst_tx_retry_burst,
6689 (void *)&cmd_set_burst_tx_retry_tx,
6690 (void *)&cmd_set_burst_tx_retry_delay,
6691 (void *)&cmd_set_burst_tx_retry_time,
6692 (void *)&cmd_set_burst_tx_retry_retry,
6693 (void *)&cmd_set_burst_tx_retry_retry_num,
6698 /* *** SET PROMISC MODE *** */
6699 struct cmd_set_promisc_mode_result {
6700 cmdline_fixed_string_t set;
6701 cmdline_fixed_string_t promisc;
6702 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6703 uint16_t port_num; /* valid if "allports" argument == 0 */
6704 cmdline_fixed_string_t mode;
6707 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6708 __rte_unused struct cmdline *cl,
6711 struct cmd_set_promisc_mode_result *res = parsed_result;
6715 if (!strcmp(res->mode, "on"))
6722 RTE_ETH_FOREACH_DEV(i)
6723 eth_set_promisc_mode(i, enable);
6725 eth_set_promisc_mode(res->port_num, enable);
6729 cmdline_parse_token_string_t cmd_setpromisc_set =
6730 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6731 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6732 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6734 cmdline_parse_token_string_t cmd_setpromisc_portall =
6735 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6737 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6738 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6740 cmdline_parse_token_string_t cmd_setpromisc_mode =
6741 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6744 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6745 .f = cmd_set_promisc_mode_parsed,
6747 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6749 (void *)&cmd_setpromisc_set,
6750 (void *)&cmd_setpromisc_promisc,
6751 (void *)&cmd_setpromisc_portall,
6752 (void *)&cmd_setpromisc_mode,
6757 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6758 .f = cmd_set_promisc_mode_parsed,
6760 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6762 (void *)&cmd_setpromisc_set,
6763 (void *)&cmd_setpromisc_promisc,
6764 (void *)&cmd_setpromisc_portnum,
6765 (void *)&cmd_setpromisc_mode,
6770 /* *** SET ALLMULTI MODE *** */
6771 struct cmd_set_allmulti_mode_result {
6772 cmdline_fixed_string_t set;
6773 cmdline_fixed_string_t allmulti;
6774 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6775 uint16_t port_num; /* valid if "allports" argument == 0 */
6776 cmdline_fixed_string_t mode;
6779 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6780 __rte_unused struct cmdline *cl,
6783 struct cmd_set_allmulti_mode_result *res = parsed_result;
6787 if (!strcmp(res->mode, "on"))
6794 RTE_ETH_FOREACH_DEV(i) {
6795 eth_set_allmulticast_mode(i, enable);
6799 eth_set_allmulticast_mode(res->port_num, enable);
6803 cmdline_parse_token_string_t cmd_setallmulti_set =
6804 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6805 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6806 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6808 cmdline_parse_token_string_t cmd_setallmulti_portall =
6809 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6811 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6812 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6814 cmdline_parse_token_string_t cmd_setallmulti_mode =
6815 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6818 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6819 .f = cmd_set_allmulti_mode_parsed,
6821 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6823 (void *)&cmd_setallmulti_set,
6824 (void *)&cmd_setallmulti_allmulti,
6825 (void *)&cmd_setallmulti_portall,
6826 (void *)&cmd_setallmulti_mode,
6831 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6832 .f = cmd_set_allmulti_mode_parsed,
6834 .help_str = "set allmulti <port_id> on|off: "
6835 "Set allmulti mode on port_id",
6837 (void *)&cmd_setallmulti_set,
6838 (void *)&cmd_setallmulti_allmulti,
6839 (void *)&cmd_setallmulti_portnum,
6840 (void *)&cmd_setallmulti_mode,
6845 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6846 struct cmd_link_flow_ctrl_set_result {
6847 cmdline_fixed_string_t set;
6848 cmdline_fixed_string_t flow_ctrl;
6849 cmdline_fixed_string_t rx;
6850 cmdline_fixed_string_t rx_lfc_mode;
6851 cmdline_fixed_string_t tx;
6852 cmdline_fixed_string_t tx_lfc_mode;
6853 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6854 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6855 cmdline_fixed_string_t autoneg_str;
6856 cmdline_fixed_string_t autoneg;
6857 cmdline_fixed_string_t hw_str;
6858 uint32_t high_water;
6859 cmdline_fixed_string_t lw_str;
6861 cmdline_fixed_string_t pt_str;
6862 uint16_t pause_time;
6863 cmdline_fixed_string_t xon_str;
6868 cmdline_parse_token_string_t cmd_lfc_set_set =
6869 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6871 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6872 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6873 flow_ctrl, "flow_ctrl");
6874 cmdline_parse_token_string_t cmd_lfc_set_rx =
6875 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6877 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6878 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6879 rx_lfc_mode, "on#off");
6880 cmdline_parse_token_string_t cmd_lfc_set_tx =
6881 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6883 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6884 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6885 tx_lfc_mode, "on#off");
6886 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6887 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6888 hw_str, "high_water");
6889 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6890 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6891 high_water, UINT32);
6892 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6893 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6894 lw_str, "low_water");
6895 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6896 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6898 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6899 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6900 pt_str, "pause_time");
6901 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6902 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6903 pause_time, UINT16);
6904 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6905 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6906 xon_str, "send_xon");
6907 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6908 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6910 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6911 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6912 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6913 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6914 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6915 mac_ctrl_frame_fwd_mode, "on#off");
6916 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6917 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6918 autoneg_str, "autoneg");
6919 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6920 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6922 cmdline_parse_token_num_t cmd_lfc_set_portid =
6923 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6926 /* forward declaration */
6928 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6931 cmdline_parse_inst_t cmd_link_flow_control_set = {
6932 .f = cmd_link_flow_ctrl_set_parsed,
6934 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6935 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6936 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6938 (void *)&cmd_lfc_set_set,
6939 (void *)&cmd_lfc_set_flow_ctrl,
6940 (void *)&cmd_lfc_set_rx,
6941 (void *)&cmd_lfc_set_rx_mode,
6942 (void *)&cmd_lfc_set_tx,
6943 (void *)&cmd_lfc_set_tx_mode,
6944 (void *)&cmd_lfc_set_high_water,
6945 (void *)&cmd_lfc_set_low_water,
6946 (void *)&cmd_lfc_set_pause_time,
6947 (void *)&cmd_lfc_set_send_xon,
6948 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6949 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6950 (void *)&cmd_lfc_set_autoneg_str,
6951 (void *)&cmd_lfc_set_autoneg,
6952 (void *)&cmd_lfc_set_portid,
6957 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6958 .f = cmd_link_flow_ctrl_set_parsed,
6959 .data = (void *)&cmd_link_flow_control_set_rx,
6960 .help_str = "set flow_ctrl rx on|off <port_id>: "
6961 "Change rx flow control parameter",
6963 (void *)&cmd_lfc_set_set,
6964 (void *)&cmd_lfc_set_flow_ctrl,
6965 (void *)&cmd_lfc_set_rx,
6966 (void *)&cmd_lfc_set_rx_mode,
6967 (void *)&cmd_lfc_set_portid,
6972 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6973 .f = cmd_link_flow_ctrl_set_parsed,
6974 .data = (void *)&cmd_link_flow_control_set_tx,
6975 .help_str = "set flow_ctrl tx on|off <port_id>: "
6976 "Change tx flow control parameter",
6978 (void *)&cmd_lfc_set_set,
6979 (void *)&cmd_lfc_set_flow_ctrl,
6980 (void *)&cmd_lfc_set_tx,
6981 (void *)&cmd_lfc_set_tx_mode,
6982 (void *)&cmd_lfc_set_portid,
6987 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6988 .f = cmd_link_flow_ctrl_set_parsed,
6989 .data = (void *)&cmd_link_flow_control_set_hw,
6990 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6991 "Change high water flow control parameter",
6993 (void *)&cmd_lfc_set_set,
6994 (void *)&cmd_lfc_set_flow_ctrl,
6995 (void *)&cmd_lfc_set_high_water_str,
6996 (void *)&cmd_lfc_set_high_water,
6997 (void *)&cmd_lfc_set_portid,
7002 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7003 .f = cmd_link_flow_ctrl_set_parsed,
7004 .data = (void *)&cmd_link_flow_control_set_lw,
7005 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7006 "Change low water flow control parameter",
7008 (void *)&cmd_lfc_set_set,
7009 (void *)&cmd_lfc_set_flow_ctrl,
7010 (void *)&cmd_lfc_set_low_water_str,
7011 (void *)&cmd_lfc_set_low_water,
7012 (void *)&cmd_lfc_set_portid,
7017 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7018 .f = cmd_link_flow_ctrl_set_parsed,
7019 .data = (void *)&cmd_link_flow_control_set_pt,
7020 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7021 "Change pause time flow control parameter",
7023 (void *)&cmd_lfc_set_set,
7024 (void *)&cmd_lfc_set_flow_ctrl,
7025 (void *)&cmd_lfc_set_pause_time_str,
7026 (void *)&cmd_lfc_set_pause_time,
7027 (void *)&cmd_lfc_set_portid,
7032 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7033 .f = cmd_link_flow_ctrl_set_parsed,
7034 .data = (void *)&cmd_link_flow_control_set_xon,
7035 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7036 "Change send_xon flow control parameter",
7038 (void *)&cmd_lfc_set_set,
7039 (void *)&cmd_lfc_set_flow_ctrl,
7040 (void *)&cmd_lfc_set_send_xon_str,
7041 (void *)&cmd_lfc_set_send_xon,
7042 (void *)&cmd_lfc_set_portid,
7047 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7048 .f = cmd_link_flow_ctrl_set_parsed,
7049 .data = (void *)&cmd_link_flow_control_set_macfwd,
7050 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7051 "Change mac ctrl fwd flow control parameter",
7053 (void *)&cmd_lfc_set_set,
7054 (void *)&cmd_lfc_set_flow_ctrl,
7055 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7056 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7057 (void *)&cmd_lfc_set_portid,
7062 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7063 .f = cmd_link_flow_ctrl_set_parsed,
7064 .data = (void *)&cmd_link_flow_control_set_autoneg,
7065 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7066 "Change autoneg flow control parameter",
7068 (void *)&cmd_lfc_set_set,
7069 (void *)&cmd_lfc_set_flow_ctrl,
7070 (void *)&cmd_lfc_set_autoneg_str,
7071 (void *)&cmd_lfc_set_autoneg,
7072 (void *)&cmd_lfc_set_portid,
7078 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7079 __rte_unused struct cmdline *cl,
7082 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7083 cmdline_parse_inst_t *cmd = data;
7084 struct rte_eth_fc_conf fc_conf;
7090 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7091 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7092 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7093 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7095 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7096 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7099 /* Partial command line, retrieve current configuration */
7101 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7103 printf("cannot get current flow ctrl parameters, return"
7104 "code = %d\n", ret);
7108 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7109 (fc_conf.mode == RTE_FC_FULL))
7111 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7112 (fc_conf.mode == RTE_FC_FULL))
7116 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7117 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7119 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7120 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7122 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7124 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7125 fc_conf.high_water = res->high_water;
7127 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7128 fc_conf.low_water = res->low_water;
7130 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7131 fc_conf.pause_time = res->pause_time;
7133 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7134 fc_conf.send_xon = res->send_xon;
7136 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7137 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7138 fc_conf.mac_ctrl_frame_fwd = 1;
7140 fc_conf.mac_ctrl_frame_fwd = 0;
7143 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7144 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7146 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7148 printf("bad flow contrl parameter, return code = %d \n", ret);
7151 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7152 struct cmd_priority_flow_ctrl_set_result {
7153 cmdline_fixed_string_t set;
7154 cmdline_fixed_string_t pfc_ctrl;
7155 cmdline_fixed_string_t rx;
7156 cmdline_fixed_string_t rx_pfc_mode;
7157 cmdline_fixed_string_t tx;
7158 cmdline_fixed_string_t tx_pfc_mode;
7159 uint32_t high_water;
7161 uint16_t pause_time;
7167 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7168 __rte_unused struct cmdline *cl,
7169 __rte_unused void *data)
7171 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7172 struct rte_eth_pfc_conf pfc_conf;
7173 int rx_fc_enable, tx_fc_enable;
7177 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7178 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7179 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7180 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7182 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7183 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7186 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7187 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7188 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7189 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7190 pfc_conf.fc.high_water = res->high_water;
7191 pfc_conf.fc.low_water = res->low_water;
7192 pfc_conf.fc.pause_time = res->pause_time;
7193 pfc_conf.priority = res->priority;
7195 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7197 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7200 cmdline_parse_token_string_t cmd_pfc_set_set =
7201 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7203 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7204 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7205 pfc_ctrl, "pfc_ctrl");
7206 cmdline_parse_token_string_t cmd_pfc_set_rx =
7207 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7209 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7210 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7211 rx_pfc_mode, "on#off");
7212 cmdline_parse_token_string_t cmd_pfc_set_tx =
7213 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7215 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7216 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7217 tx_pfc_mode, "on#off");
7218 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7219 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7220 high_water, UINT32);
7221 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7222 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7224 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7225 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7226 pause_time, UINT16);
7227 cmdline_parse_token_num_t cmd_pfc_set_priority =
7228 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7230 cmdline_parse_token_num_t cmd_pfc_set_portid =
7231 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7234 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7235 .f = cmd_priority_flow_ctrl_set_parsed,
7237 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7238 "<pause_time> <priority> <port_id>: "
7239 "Configure the Ethernet priority flow control",
7241 (void *)&cmd_pfc_set_set,
7242 (void *)&cmd_pfc_set_flow_ctrl,
7243 (void *)&cmd_pfc_set_rx,
7244 (void *)&cmd_pfc_set_rx_mode,
7245 (void *)&cmd_pfc_set_tx,
7246 (void *)&cmd_pfc_set_tx_mode,
7247 (void *)&cmd_pfc_set_high_water,
7248 (void *)&cmd_pfc_set_low_water,
7249 (void *)&cmd_pfc_set_pause_time,
7250 (void *)&cmd_pfc_set_priority,
7251 (void *)&cmd_pfc_set_portid,
7256 /* *** RESET CONFIGURATION *** */
7257 struct cmd_reset_result {
7258 cmdline_fixed_string_t reset;
7259 cmdline_fixed_string_t def;
7262 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7264 __rte_unused void *data)
7266 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7267 set_def_fwd_config();
7270 cmdline_parse_token_string_t cmd_reset_set =
7271 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7272 cmdline_parse_token_string_t cmd_reset_def =
7273 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7276 cmdline_parse_inst_t cmd_reset = {
7277 .f = cmd_reset_parsed,
7279 .help_str = "set default: Reset default forwarding configuration",
7281 (void *)&cmd_reset_set,
7282 (void *)&cmd_reset_def,
7287 /* *** START FORWARDING *** */
7288 struct cmd_start_result {
7289 cmdline_fixed_string_t start;
7292 cmdline_parse_token_string_t cmd_start_start =
7293 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7295 static void cmd_start_parsed(__rte_unused void *parsed_result,
7296 __rte_unused struct cmdline *cl,
7297 __rte_unused void *data)
7299 start_packet_forwarding(0);
7302 cmdline_parse_inst_t cmd_start = {
7303 .f = cmd_start_parsed,
7305 .help_str = "start: Start packet forwarding",
7307 (void *)&cmd_start_start,
7312 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7313 struct cmd_start_tx_first_result {
7314 cmdline_fixed_string_t start;
7315 cmdline_fixed_string_t tx_first;
7319 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7320 __rte_unused struct cmdline *cl,
7321 __rte_unused void *data)
7323 start_packet_forwarding(1);
7326 cmdline_parse_token_string_t cmd_start_tx_first_start =
7327 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7329 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7330 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7331 tx_first, "tx_first");
7333 cmdline_parse_inst_t cmd_start_tx_first = {
7334 .f = cmd_start_tx_first_parsed,
7336 .help_str = "start tx_first: Start packet forwarding, "
7337 "after sending 1 burst of packets",
7339 (void *)&cmd_start_tx_first_start,
7340 (void *)&cmd_start_tx_first_tx_first,
7345 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7346 struct cmd_start_tx_first_n_result {
7347 cmdline_fixed_string_t start;
7348 cmdline_fixed_string_t tx_first;
7353 cmd_start_tx_first_n_parsed(void *parsed_result,
7354 __rte_unused struct cmdline *cl,
7355 __rte_unused void *data)
7357 struct cmd_start_tx_first_n_result *res = parsed_result;
7359 start_packet_forwarding(res->tx_num);
7362 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7363 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7365 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7366 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7367 tx_first, "tx_first");
7368 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7369 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7372 cmdline_parse_inst_t cmd_start_tx_first_n = {
7373 .f = cmd_start_tx_first_n_parsed,
7375 .help_str = "start tx_first <num>: "
7376 "packet forwarding, after sending <num> bursts of packets",
7378 (void *)&cmd_start_tx_first_n_start,
7379 (void *)&cmd_start_tx_first_n_tx_first,
7380 (void *)&cmd_start_tx_first_n_tx_num,
7385 /* *** SET LINK UP *** */
7386 struct cmd_set_link_up_result {
7387 cmdline_fixed_string_t set;
7388 cmdline_fixed_string_t link_up;
7389 cmdline_fixed_string_t port;
7393 cmdline_parse_token_string_t cmd_set_link_up_set =
7394 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7395 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7396 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7398 cmdline_parse_token_string_t cmd_set_link_up_port =
7399 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7400 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7401 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7403 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7404 __rte_unused struct cmdline *cl,
7405 __rte_unused void *data)
7407 struct cmd_set_link_up_result *res = parsed_result;
7408 dev_set_link_up(res->port_id);
7411 cmdline_parse_inst_t cmd_set_link_up = {
7412 .f = cmd_set_link_up_parsed,
7414 .help_str = "set link-up port <port id>",
7416 (void *)&cmd_set_link_up_set,
7417 (void *)&cmd_set_link_up_link_up,
7418 (void *)&cmd_set_link_up_port,
7419 (void *)&cmd_set_link_up_port_id,
7424 /* *** SET LINK DOWN *** */
7425 struct cmd_set_link_down_result {
7426 cmdline_fixed_string_t set;
7427 cmdline_fixed_string_t link_down;
7428 cmdline_fixed_string_t port;
7432 cmdline_parse_token_string_t cmd_set_link_down_set =
7433 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7434 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7435 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7437 cmdline_parse_token_string_t cmd_set_link_down_port =
7438 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7439 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7440 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7442 static void cmd_set_link_down_parsed(
7443 __rte_unused void *parsed_result,
7444 __rte_unused struct cmdline *cl,
7445 __rte_unused void *data)
7447 struct cmd_set_link_down_result *res = parsed_result;
7448 dev_set_link_down(res->port_id);
7451 cmdline_parse_inst_t cmd_set_link_down = {
7452 .f = cmd_set_link_down_parsed,
7454 .help_str = "set link-down port <port id>",
7456 (void *)&cmd_set_link_down_set,
7457 (void *)&cmd_set_link_down_link_down,
7458 (void *)&cmd_set_link_down_port,
7459 (void *)&cmd_set_link_down_port_id,
7464 /* *** SHOW CFG *** */
7465 struct cmd_showcfg_result {
7466 cmdline_fixed_string_t show;
7467 cmdline_fixed_string_t cfg;
7468 cmdline_fixed_string_t what;
7471 static void cmd_showcfg_parsed(void *parsed_result,
7472 __rte_unused struct cmdline *cl,
7473 __rte_unused void *data)
7475 struct cmd_showcfg_result *res = parsed_result;
7476 if (!strcmp(res->what, "rxtx"))
7477 rxtx_config_display();
7478 else if (!strcmp(res->what, "cores"))
7479 fwd_lcores_config_display();
7480 else if (!strcmp(res->what, "fwd"))
7481 pkt_fwd_config_display(&cur_fwd_config);
7482 else if (!strcmp(res->what, "txpkts"))
7483 show_tx_pkt_segments();
7484 else if (!strcmp(res->what, "txtimes"))
7485 show_tx_pkt_times();
7488 cmdline_parse_token_string_t cmd_showcfg_show =
7489 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7490 cmdline_parse_token_string_t cmd_showcfg_port =
7491 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7492 cmdline_parse_token_string_t cmd_showcfg_what =
7493 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7494 "rxtx#cores#fwd#txpkts#txtimes");
7496 cmdline_parse_inst_t cmd_showcfg = {
7497 .f = cmd_showcfg_parsed,
7499 .help_str = "show config rxtx|cores|fwd|txpkts|txtimes",
7501 (void *)&cmd_showcfg_show,
7502 (void *)&cmd_showcfg_port,
7503 (void *)&cmd_showcfg_what,
7508 /* *** SHOW ALL PORT INFO *** */
7509 struct cmd_showportall_result {
7510 cmdline_fixed_string_t show;
7511 cmdline_fixed_string_t port;
7512 cmdline_fixed_string_t what;
7513 cmdline_fixed_string_t all;
7516 static void cmd_showportall_parsed(void *parsed_result,
7517 __rte_unused struct cmdline *cl,
7518 __rte_unused void *data)
7522 struct cmd_showportall_result *res = parsed_result;
7523 if (!strcmp(res->show, "clear")) {
7524 if (!strcmp(res->what, "stats"))
7525 RTE_ETH_FOREACH_DEV(i)
7527 else if (!strcmp(res->what, "xstats"))
7528 RTE_ETH_FOREACH_DEV(i)
7529 nic_xstats_clear(i);
7530 } else if (!strcmp(res->what, "info"))
7531 RTE_ETH_FOREACH_DEV(i)
7532 port_infos_display(i);
7533 else if (!strcmp(res->what, "summary")) {
7534 port_summary_header_display();
7535 RTE_ETH_FOREACH_DEV(i)
7536 port_summary_display(i);
7538 else if (!strcmp(res->what, "stats"))
7539 RTE_ETH_FOREACH_DEV(i)
7540 nic_stats_display(i);
7541 else if (!strcmp(res->what, "xstats"))
7542 RTE_ETH_FOREACH_DEV(i)
7543 nic_xstats_display(i);
7544 else if (!strcmp(res->what, "fdir"))
7545 RTE_ETH_FOREACH_DEV(i)
7547 else if (!strcmp(res->what, "stat_qmap"))
7548 RTE_ETH_FOREACH_DEV(i)
7549 nic_stats_mapping_display(i);
7550 else if (!strcmp(res->what, "dcb_tc"))
7551 RTE_ETH_FOREACH_DEV(i)
7552 port_dcb_info_display(i);
7553 else if (!strcmp(res->what, "cap"))
7554 RTE_ETH_FOREACH_DEV(i)
7555 port_offload_cap_display(i);
7558 cmdline_parse_token_string_t cmd_showportall_show =
7559 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7561 cmdline_parse_token_string_t cmd_showportall_port =
7562 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7563 cmdline_parse_token_string_t cmd_showportall_what =
7564 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7565 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7566 cmdline_parse_token_string_t cmd_showportall_all =
7567 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7568 cmdline_parse_inst_t cmd_showportall = {
7569 .f = cmd_showportall_parsed,
7571 .help_str = "show|clear port "
7572 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7574 (void *)&cmd_showportall_show,
7575 (void *)&cmd_showportall_port,
7576 (void *)&cmd_showportall_what,
7577 (void *)&cmd_showportall_all,
7582 /* *** SHOW PORT INFO *** */
7583 struct cmd_showport_result {
7584 cmdline_fixed_string_t show;
7585 cmdline_fixed_string_t port;
7586 cmdline_fixed_string_t what;
7590 static void cmd_showport_parsed(void *parsed_result,
7591 __rte_unused struct cmdline *cl,
7592 __rte_unused void *data)
7594 struct cmd_showport_result *res = parsed_result;
7595 if (!strcmp(res->show, "clear")) {
7596 if (!strcmp(res->what, "stats"))
7597 nic_stats_clear(res->portnum);
7598 else if (!strcmp(res->what, "xstats"))
7599 nic_xstats_clear(res->portnum);
7600 } else if (!strcmp(res->what, "info"))
7601 port_infos_display(res->portnum);
7602 else if (!strcmp(res->what, "summary")) {
7603 port_summary_header_display();
7604 port_summary_display(res->portnum);
7606 else if (!strcmp(res->what, "stats"))
7607 nic_stats_display(res->portnum);
7608 else if (!strcmp(res->what, "xstats"))
7609 nic_xstats_display(res->portnum);
7610 else if (!strcmp(res->what, "fdir"))
7611 fdir_get_infos(res->portnum);
7612 else if (!strcmp(res->what, "stat_qmap"))
7613 nic_stats_mapping_display(res->portnum);
7614 else if (!strcmp(res->what, "dcb_tc"))
7615 port_dcb_info_display(res->portnum);
7616 else if (!strcmp(res->what, "cap"))
7617 port_offload_cap_display(res->portnum);
7620 cmdline_parse_token_string_t cmd_showport_show =
7621 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7623 cmdline_parse_token_string_t cmd_showport_port =
7624 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7625 cmdline_parse_token_string_t cmd_showport_what =
7626 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7627 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7628 cmdline_parse_token_num_t cmd_showport_portnum =
7629 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7631 cmdline_parse_inst_t cmd_showport = {
7632 .f = cmd_showport_parsed,
7634 .help_str = "show|clear port "
7635 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7638 (void *)&cmd_showport_show,
7639 (void *)&cmd_showport_port,
7640 (void *)&cmd_showport_what,
7641 (void *)&cmd_showport_portnum,
7646 /* *** SHOW DEVICE INFO *** */
7647 struct cmd_showdevice_result {
7648 cmdline_fixed_string_t show;
7649 cmdline_fixed_string_t device;
7650 cmdline_fixed_string_t what;
7651 cmdline_fixed_string_t identifier;
7654 static void cmd_showdevice_parsed(void *parsed_result,
7655 __rte_unused struct cmdline *cl,
7656 __rte_unused void *data)
7658 struct cmd_showdevice_result *res = parsed_result;
7659 if (!strcmp(res->what, "info")) {
7660 if (!strcmp(res->identifier, "all"))
7661 device_infos_display(NULL);
7663 device_infos_display(res->identifier);
7667 cmdline_parse_token_string_t cmd_showdevice_show =
7668 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7670 cmdline_parse_token_string_t cmd_showdevice_device =
7671 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7672 cmdline_parse_token_string_t cmd_showdevice_what =
7673 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7675 cmdline_parse_token_string_t cmd_showdevice_identifier =
7676 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7679 cmdline_parse_inst_t cmd_showdevice = {
7680 .f = cmd_showdevice_parsed,
7682 .help_str = "show device info <identifier>|all",
7684 (void *)&cmd_showdevice_show,
7685 (void *)&cmd_showdevice_device,
7686 (void *)&cmd_showdevice_what,
7687 (void *)&cmd_showdevice_identifier,
7691 /* *** SHOW QUEUE INFO *** */
7692 struct cmd_showqueue_result {
7693 cmdline_fixed_string_t show;
7694 cmdline_fixed_string_t type;
7695 cmdline_fixed_string_t what;
7701 cmd_showqueue_parsed(void *parsed_result,
7702 __rte_unused struct cmdline *cl,
7703 __rte_unused void *data)
7705 struct cmd_showqueue_result *res = parsed_result;
7707 if (!strcmp(res->type, "rxq"))
7708 rx_queue_infos_display(res->portnum, res->queuenum);
7709 else if (!strcmp(res->type, "txq"))
7710 tx_queue_infos_display(res->portnum, res->queuenum);
7713 cmdline_parse_token_string_t cmd_showqueue_show =
7714 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7715 cmdline_parse_token_string_t cmd_showqueue_type =
7716 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7717 cmdline_parse_token_string_t cmd_showqueue_what =
7718 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7719 cmdline_parse_token_num_t cmd_showqueue_portnum =
7720 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7721 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7722 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7724 cmdline_parse_inst_t cmd_showqueue = {
7725 .f = cmd_showqueue_parsed,
7727 .help_str = "show rxq|txq info <port_id> <queue_id>",
7729 (void *)&cmd_showqueue_show,
7730 (void *)&cmd_showqueue_type,
7731 (void *)&cmd_showqueue_what,
7732 (void *)&cmd_showqueue_portnum,
7733 (void *)&cmd_showqueue_queuenum,
7738 /* show/clear fwd engine statistics */
7740 cmdline_fixed_string_t action;
7741 cmdline_fixed_string_t fwd;
7742 cmdline_fixed_string_t stats;
7743 cmdline_fixed_string_t all;
7746 cmdline_parse_token_string_t cmd_fwd_action =
7747 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7748 cmdline_parse_token_string_t cmd_fwd_fwd =
7749 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7750 cmdline_parse_token_string_t cmd_fwd_stats =
7751 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7752 cmdline_parse_token_string_t cmd_fwd_all =
7753 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7756 cmd_showfwdall_parsed(void *parsed_result,
7757 __rte_unused struct cmdline *cl,
7758 __rte_unused void *data)
7760 struct fwd_result *res = parsed_result;
7762 if (!strcmp(res->action, "show"))
7763 fwd_stats_display();
7768 static cmdline_parse_inst_t cmd_showfwdall = {
7769 .f = cmd_showfwdall_parsed,
7771 .help_str = "show|clear fwd stats all",
7773 (void *)&cmd_fwd_action,
7774 (void *)&cmd_fwd_fwd,
7775 (void *)&cmd_fwd_stats,
7776 (void *)&cmd_fwd_all,
7781 /* *** READ PORT REGISTER *** */
7782 struct cmd_read_reg_result {
7783 cmdline_fixed_string_t read;
7784 cmdline_fixed_string_t reg;
7790 cmd_read_reg_parsed(void *parsed_result,
7791 __rte_unused struct cmdline *cl,
7792 __rte_unused void *data)
7794 struct cmd_read_reg_result *res = parsed_result;
7795 port_reg_display(res->port_id, res->reg_off);
7798 cmdline_parse_token_string_t cmd_read_reg_read =
7799 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7800 cmdline_parse_token_string_t cmd_read_reg_reg =
7801 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7802 cmdline_parse_token_num_t cmd_read_reg_port_id =
7803 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7804 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7805 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7807 cmdline_parse_inst_t cmd_read_reg = {
7808 .f = cmd_read_reg_parsed,
7810 .help_str = "read reg <port_id> <reg_off>",
7812 (void *)&cmd_read_reg_read,
7813 (void *)&cmd_read_reg_reg,
7814 (void *)&cmd_read_reg_port_id,
7815 (void *)&cmd_read_reg_reg_off,
7820 /* *** READ PORT REGISTER BIT FIELD *** */
7821 struct cmd_read_reg_bit_field_result {
7822 cmdline_fixed_string_t read;
7823 cmdline_fixed_string_t regfield;
7831 cmd_read_reg_bit_field_parsed(void *parsed_result,
7832 __rte_unused struct cmdline *cl,
7833 __rte_unused void *data)
7835 struct cmd_read_reg_bit_field_result *res = parsed_result;
7836 port_reg_bit_field_display(res->port_id, res->reg_off,
7837 res->bit1_pos, res->bit2_pos);
7840 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7841 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7843 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7844 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7845 regfield, "regfield");
7846 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7847 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7849 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7850 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7852 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7853 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7855 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7856 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7859 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7860 .f = cmd_read_reg_bit_field_parsed,
7862 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7863 "Read register bit field between bit_x and bit_y included",
7865 (void *)&cmd_read_reg_bit_field_read,
7866 (void *)&cmd_read_reg_bit_field_regfield,
7867 (void *)&cmd_read_reg_bit_field_port_id,
7868 (void *)&cmd_read_reg_bit_field_reg_off,
7869 (void *)&cmd_read_reg_bit_field_bit1_pos,
7870 (void *)&cmd_read_reg_bit_field_bit2_pos,
7875 /* *** READ PORT REGISTER BIT *** */
7876 struct cmd_read_reg_bit_result {
7877 cmdline_fixed_string_t read;
7878 cmdline_fixed_string_t regbit;
7885 cmd_read_reg_bit_parsed(void *parsed_result,
7886 __rte_unused struct cmdline *cl,
7887 __rte_unused void *data)
7889 struct cmd_read_reg_bit_result *res = parsed_result;
7890 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7893 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7894 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7895 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7896 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7898 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7899 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7900 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7901 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7902 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7903 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7905 cmdline_parse_inst_t cmd_read_reg_bit = {
7906 .f = cmd_read_reg_bit_parsed,
7908 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7910 (void *)&cmd_read_reg_bit_read,
7911 (void *)&cmd_read_reg_bit_regbit,
7912 (void *)&cmd_read_reg_bit_port_id,
7913 (void *)&cmd_read_reg_bit_reg_off,
7914 (void *)&cmd_read_reg_bit_bit_pos,
7919 /* *** WRITE PORT REGISTER *** */
7920 struct cmd_write_reg_result {
7921 cmdline_fixed_string_t write;
7922 cmdline_fixed_string_t reg;
7929 cmd_write_reg_parsed(void *parsed_result,
7930 __rte_unused struct cmdline *cl,
7931 __rte_unused void *data)
7933 struct cmd_write_reg_result *res = parsed_result;
7934 port_reg_set(res->port_id, res->reg_off, res->value);
7937 cmdline_parse_token_string_t cmd_write_reg_write =
7938 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7939 cmdline_parse_token_string_t cmd_write_reg_reg =
7940 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7941 cmdline_parse_token_num_t cmd_write_reg_port_id =
7942 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7943 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7944 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7945 cmdline_parse_token_num_t cmd_write_reg_value =
7946 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7948 cmdline_parse_inst_t cmd_write_reg = {
7949 .f = cmd_write_reg_parsed,
7951 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7953 (void *)&cmd_write_reg_write,
7954 (void *)&cmd_write_reg_reg,
7955 (void *)&cmd_write_reg_port_id,
7956 (void *)&cmd_write_reg_reg_off,
7957 (void *)&cmd_write_reg_value,
7962 /* *** WRITE PORT REGISTER BIT FIELD *** */
7963 struct cmd_write_reg_bit_field_result {
7964 cmdline_fixed_string_t write;
7965 cmdline_fixed_string_t regfield;
7974 cmd_write_reg_bit_field_parsed(void *parsed_result,
7975 __rte_unused struct cmdline *cl,
7976 __rte_unused void *data)
7978 struct cmd_write_reg_bit_field_result *res = parsed_result;
7979 port_reg_bit_field_set(res->port_id, res->reg_off,
7980 res->bit1_pos, res->bit2_pos, res->value);
7983 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7984 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7986 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7987 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7988 regfield, "regfield");
7989 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7990 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7992 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7993 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7995 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7996 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7998 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7999 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8001 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8002 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8005 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8006 .f = cmd_write_reg_bit_field_parsed,
8008 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8010 "Set register bit field between bit_x and bit_y included",
8012 (void *)&cmd_write_reg_bit_field_write,
8013 (void *)&cmd_write_reg_bit_field_regfield,
8014 (void *)&cmd_write_reg_bit_field_port_id,
8015 (void *)&cmd_write_reg_bit_field_reg_off,
8016 (void *)&cmd_write_reg_bit_field_bit1_pos,
8017 (void *)&cmd_write_reg_bit_field_bit2_pos,
8018 (void *)&cmd_write_reg_bit_field_value,
8023 /* *** WRITE PORT REGISTER BIT *** */
8024 struct cmd_write_reg_bit_result {
8025 cmdline_fixed_string_t write;
8026 cmdline_fixed_string_t regbit;
8034 cmd_write_reg_bit_parsed(void *parsed_result,
8035 __rte_unused struct cmdline *cl,
8036 __rte_unused void *data)
8038 struct cmd_write_reg_bit_result *res = parsed_result;
8039 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8042 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8043 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8045 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8046 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8048 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8049 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
8050 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8051 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
8052 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8053 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
8054 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8055 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
8057 cmdline_parse_inst_t cmd_write_reg_bit = {
8058 .f = cmd_write_reg_bit_parsed,
8060 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8063 (void *)&cmd_write_reg_bit_write,
8064 (void *)&cmd_write_reg_bit_regbit,
8065 (void *)&cmd_write_reg_bit_port_id,
8066 (void *)&cmd_write_reg_bit_reg_off,
8067 (void *)&cmd_write_reg_bit_bit_pos,
8068 (void *)&cmd_write_reg_bit_value,
8073 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8074 struct cmd_read_rxd_txd_result {
8075 cmdline_fixed_string_t read;
8076 cmdline_fixed_string_t rxd_txd;
8083 cmd_read_rxd_txd_parsed(void *parsed_result,
8084 __rte_unused struct cmdline *cl,
8085 __rte_unused void *data)
8087 struct cmd_read_rxd_txd_result *res = parsed_result;
8089 if (!strcmp(res->rxd_txd, "rxd"))
8090 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8091 else if (!strcmp(res->rxd_txd, "txd"))
8092 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8095 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8096 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8097 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8098 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8100 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8101 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8102 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8103 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8104 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8105 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8107 cmdline_parse_inst_t cmd_read_rxd_txd = {
8108 .f = cmd_read_rxd_txd_parsed,
8110 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8112 (void *)&cmd_read_rxd_txd_read,
8113 (void *)&cmd_read_rxd_txd_rxd_txd,
8114 (void *)&cmd_read_rxd_txd_port_id,
8115 (void *)&cmd_read_rxd_txd_queue_id,
8116 (void *)&cmd_read_rxd_txd_desc_id,
8122 struct cmd_quit_result {
8123 cmdline_fixed_string_t quit;
8126 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8128 __rte_unused void *data)
8133 cmdline_parse_token_string_t cmd_quit_quit =
8134 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8136 cmdline_parse_inst_t cmd_quit = {
8137 .f = cmd_quit_parsed,
8139 .help_str = "quit: Exit application",
8141 (void *)&cmd_quit_quit,
8146 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8147 struct cmd_mac_addr_result {
8148 cmdline_fixed_string_t mac_addr_cmd;
8149 cmdline_fixed_string_t what;
8151 struct rte_ether_addr address;
8154 static void cmd_mac_addr_parsed(void *parsed_result,
8155 __rte_unused struct cmdline *cl,
8156 __rte_unused void *data)
8158 struct cmd_mac_addr_result *res = parsed_result;
8161 if (strcmp(res->what, "add") == 0)
8162 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8163 else if (strcmp(res->what, "set") == 0)
8164 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8167 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8169 /* check the return value and print it if is < 0 */
8171 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8175 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8176 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8178 cmdline_parse_token_string_t cmd_mac_addr_what =
8179 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8181 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8182 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8184 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8185 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8187 cmdline_parse_inst_t cmd_mac_addr = {
8188 .f = cmd_mac_addr_parsed,
8190 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8191 "Add/Remove/Set MAC address on port_id",
8193 (void *)&cmd_mac_addr_cmd,
8194 (void *)&cmd_mac_addr_what,
8195 (void *)&cmd_mac_addr_portnum,
8196 (void *)&cmd_mac_addr_addr,
8201 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8202 struct cmd_eth_peer_result {
8203 cmdline_fixed_string_t set;
8204 cmdline_fixed_string_t eth_peer;
8206 cmdline_fixed_string_t peer_addr;
8209 static void cmd_set_eth_peer_parsed(void *parsed_result,
8210 __rte_unused struct cmdline *cl,
8211 __rte_unused void *data)
8213 struct cmd_eth_peer_result *res = parsed_result;
8215 if (test_done == 0) {
8216 printf("Please stop forwarding first\n");
8219 if (!strcmp(res->eth_peer, "eth-peer")) {
8220 set_fwd_eth_peer(res->port_id, res->peer_addr);
8224 cmdline_parse_token_string_t cmd_eth_peer_set =
8225 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8226 cmdline_parse_token_string_t cmd_eth_peer =
8227 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8228 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8229 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8230 cmdline_parse_token_string_t cmd_eth_peer_addr =
8231 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8233 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8234 .f = cmd_set_eth_peer_parsed,
8236 .help_str = "set eth-peer <port_id> <peer_mac>",
8238 (void *)&cmd_eth_peer_set,
8239 (void *)&cmd_eth_peer,
8240 (void *)&cmd_eth_peer_port_id,
8241 (void *)&cmd_eth_peer_addr,
8246 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8247 struct cmd_set_qmap_result {
8248 cmdline_fixed_string_t set;
8249 cmdline_fixed_string_t qmap;
8250 cmdline_fixed_string_t what;
8257 cmd_set_qmap_parsed(void *parsed_result,
8258 __rte_unused struct cmdline *cl,
8259 __rte_unused void *data)
8261 struct cmd_set_qmap_result *res = parsed_result;
8262 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8264 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8267 cmdline_parse_token_string_t cmd_setqmap_set =
8268 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8270 cmdline_parse_token_string_t cmd_setqmap_qmap =
8271 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8273 cmdline_parse_token_string_t cmd_setqmap_what =
8274 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8276 cmdline_parse_token_num_t cmd_setqmap_portid =
8277 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8279 cmdline_parse_token_num_t cmd_setqmap_queueid =
8280 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8282 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8283 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8286 cmdline_parse_inst_t cmd_set_qmap = {
8287 .f = cmd_set_qmap_parsed,
8289 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8290 "Set statistics mapping value on tx|rx queue_id of port_id",
8292 (void *)&cmd_setqmap_set,
8293 (void *)&cmd_setqmap_qmap,
8294 (void *)&cmd_setqmap_what,
8295 (void *)&cmd_setqmap_portid,
8296 (void *)&cmd_setqmap_queueid,
8297 (void *)&cmd_setqmap_mapvalue,
8302 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8303 struct cmd_set_xstats_hide_zero_result {
8304 cmdline_fixed_string_t keyword;
8305 cmdline_fixed_string_t name;
8306 cmdline_fixed_string_t on_off;
8310 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8311 __rte_unused struct cmdline *cl,
8312 __rte_unused void *data)
8314 struct cmd_set_xstats_hide_zero_result *res;
8315 uint16_t on_off = 0;
8317 res = parsed_result;
8318 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8319 set_xstats_hide_zero(on_off);
8322 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8323 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8325 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8326 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8327 name, "xstats-hide-zero");
8328 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8329 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8332 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8333 .f = cmd_set_xstats_hide_zero_parsed,
8335 .help_str = "set xstats-hide-zero on|off",
8337 (void *)&cmd_set_xstats_hide_zero_keyword,
8338 (void *)&cmd_set_xstats_hide_zero_name,
8339 (void *)&cmd_set_xstats_hide_zero_on_off,
8344 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8345 struct cmd_set_record_core_cycles_result {
8346 cmdline_fixed_string_t keyword;
8347 cmdline_fixed_string_t name;
8348 cmdline_fixed_string_t on_off;
8352 cmd_set_record_core_cycles_parsed(void *parsed_result,
8353 __rte_unused struct cmdline *cl,
8354 __rte_unused void *data)
8356 struct cmd_set_record_core_cycles_result *res;
8357 uint16_t on_off = 0;
8359 res = parsed_result;
8360 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8361 set_record_core_cycles(on_off);
8364 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8365 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8367 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8368 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8369 name, "record-core-cycles");
8370 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8371 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8374 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8375 .f = cmd_set_record_core_cycles_parsed,
8377 .help_str = "set record-core-cycles on|off",
8379 (void *)&cmd_set_record_core_cycles_keyword,
8380 (void *)&cmd_set_record_core_cycles_name,
8381 (void *)&cmd_set_record_core_cycles_on_off,
8386 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8387 struct cmd_set_record_burst_stats_result {
8388 cmdline_fixed_string_t keyword;
8389 cmdline_fixed_string_t name;
8390 cmdline_fixed_string_t on_off;
8394 cmd_set_record_burst_stats_parsed(void *parsed_result,
8395 __rte_unused struct cmdline *cl,
8396 __rte_unused void *data)
8398 struct cmd_set_record_burst_stats_result *res;
8399 uint16_t on_off = 0;
8401 res = parsed_result;
8402 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8403 set_record_burst_stats(on_off);
8406 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8407 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8409 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8410 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8411 name, "record-burst-stats");
8412 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8413 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8416 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8417 .f = cmd_set_record_burst_stats_parsed,
8419 .help_str = "set record-burst-stats on|off",
8421 (void *)&cmd_set_record_burst_stats_keyword,
8422 (void *)&cmd_set_record_burst_stats_name,
8423 (void *)&cmd_set_record_burst_stats_on_off,
8428 /* *** CONFIGURE UNICAST HASH TABLE *** */
8429 struct cmd_set_uc_hash_table {
8430 cmdline_fixed_string_t set;
8431 cmdline_fixed_string_t port;
8433 cmdline_fixed_string_t what;
8434 struct rte_ether_addr address;
8435 cmdline_fixed_string_t mode;
8439 cmd_set_uc_hash_parsed(void *parsed_result,
8440 __rte_unused struct cmdline *cl,
8441 __rte_unused void *data)
8444 struct cmd_set_uc_hash_table *res = parsed_result;
8446 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8448 if (strcmp(res->what, "uta") == 0)
8449 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8450 &res->address,(uint8_t)is_on);
8452 printf("bad unicast hash table parameter, return code = %d \n", ret);
8456 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8457 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8459 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8460 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8462 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8463 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8465 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8466 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8468 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8469 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8471 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8472 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8475 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8476 .f = cmd_set_uc_hash_parsed,
8478 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8480 (void *)&cmd_set_uc_hash_set,
8481 (void *)&cmd_set_uc_hash_port,
8482 (void *)&cmd_set_uc_hash_portid,
8483 (void *)&cmd_set_uc_hash_what,
8484 (void *)&cmd_set_uc_hash_mac,
8485 (void *)&cmd_set_uc_hash_mode,
8490 struct cmd_set_uc_all_hash_table {
8491 cmdline_fixed_string_t set;
8492 cmdline_fixed_string_t port;
8494 cmdline_fixed_string_t what;
8495 cmdline_fixed_string_t value;
8496 cmdline_fixed_string_t mode;
8500 cmd_set_uc_all_hash_parsed(void *parsed_result,
8501 __rte_unused struct cmdline *cl,
8502 __rte_unused void *data)
8505 struct cmd_set_uc_all_hash_table *res = parsed_result;
8507 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8509 if ((strcmp(res->what, "uta") == 0) &&
8510 (strcmp(res->value, "all") == 0))
8511 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8513 printf("bad unicast hash table parameter,"
8514 "return code = %d \n", ret);
8517 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8518 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8520 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8521 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8523 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8524 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8526 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8527 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8529 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8530 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8532 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8533 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8536 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8537 .f = cmd_set_uc_all_hash_parsed,
8539 .help_str = "set port <port_id> uta all on|off",
8541 (void *)&cmd_set_uc_all_hash_set,
8542 (void *)&cmd_set_uc_all_hash_port,
8543 (void *)&cmd_set_uc_all_hash_portid,
8544 (void *)&cmd_set_uc_all_hash_what,
8545 (void *)&cmd_set_uc_all_hash_value,
8546 (void *)&cmd_set_uc_all_hash_mode,
8551 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8552 struct cmd_set_vf_macvlan_filter {
8553 cmdline_fixed_string_t set;
8554 cmdline_fixed_string_t port;
8556 cmdline_fixed_string_t vf;
8558 struct rte_ether_addr address;
8559 cmdline_fixed_string_t filter_type;
8560 cmdline_fixed_string_t mode;
8564 cmd_set_vf_macvlan_parsed(void *parsed_result,
8565 __rte_unused struct cmdline *cl,
8566 __rte_unused void *data)
8569 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8570 struct rte_eth_mac_filter filter;
8572 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8574 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8576 /* set VF MAC filter */
8580 filter.dst_id = res->vf_id;
8582 if (!strcmp(res->filter_type, "exact-mac"))
8583 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8584 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8585 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8586 else if (!strcmp(res->filter_type, "hashmac"))
8587 filter.filter_type = RTE_MAC_HASH_MATCH;
8588 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8589 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8591 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8594 ret = rte_eth_dev_filter_ctrl(res->port_id,
8595 RTE_ETH_FILTER_MACVLAN,
8599 ret = rte_eth_dev_filter_ctrl(res->port_id,
8600 RTE_ETH_FILTER_MACVLAN,
8601 RTE_ETH_FILTER_DELETE,
8605 printf("bad set MAC hash parameter, return code = %d\n", ret);
8609 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8610 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8612 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8613 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8615 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8616 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8618 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8619 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8621 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8622 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8624 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8625 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8627 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8628 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8629 filter_type, "exact-mac#exact-mac-vlan"
8630 "#hashmac#hashmac-vlan");
8631 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8632 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8635 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8636 .f = cmd_set_vf_macvlan_parsed,
8638 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8639 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8640 "Exact match rule: exact match of MAC or MAC and VLAN; "
8641 "hash match rule: hash match of MAC and exact match of VLAN",
8643 (void *)&cmd_set_vf_macvlan_set,
8644 (void *)&cmd_set_vf_macvlan_port,
8645 (void *)&cmd_set_vf_macvlan_portid,
8646 (void *)&cmd_set_vf_macvlan_vf,
8647 (void *)&cmd_set_vf_macvlan_vf_id,
8648 (void *)&cmd_set_vf_macvlan_mac,
8649 (void *)&cmd_set_vf_macvlan_filter_type,
8650 (void *)&cmd_set_vf_macvlan_mode,
8655 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8656 struct cmd_set_vf_traffic {
8657 cmdline_fixed_string_t set;
8658 cmdline_fixed_string_t port;
8660 cmdline_fixed_string_t vf;
8662 cmdline_fixed_string_t what;
8663 cmdline_fixed_string_t mode;
8667 cmd_set_vf_traffic_parsed(void *parsed_result,
8668 __rte_unused struct cmdline *cl,
8669 __rte_unused void *data)
8671 struct cmd_set_vf_traffic *res = parsed_result;
8672 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8673 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8675 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8678 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8679 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8681 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8682 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8684 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8685 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8687 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8688 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8690 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8691 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8693 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8694 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8696 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8697 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8700 cmdline_parse_inst_t cmd_set_vf_traffic = {
8701 .f = cmd_set_vf_traffic_parsed,
8703 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8705 (void *)&cmd_setvf_traffic_set,
8706 (void *)&cmd_setvf_traffic_port,
8707 (void *)&cmd_setvf_traffic_portid,
8708 (void *)&cmd_setvf_traffic_vf,
8709 (void *)&cmd_setvf_traffic_vfid,
8710 (void *)&cmd_setvf_traffic_what,
8711 (void *)&cmd_setvf_traffic_mode,
8716 /* *** CONFIGURE VF RECEIVE MODE *** */
8717 struct cmd_set_vf_rxmode {
8718 cmdline_fixed_string_t set;
8719 cmdline_fixed_string_t port;
8721 cmdline_fixed_string_t vf;
8723 cmdline_fixed_string_t what;
8724 cmdline_fixed_string_t mode;
8725 cmdline_fixed_string_t on;
8729 cmd_set_vf_rxmode_parsed(void *parsed_result,
8730 __rte_unused struct cmdline *cl,
8731 __rte_unused void *data)
8734 uint16_t vf_rxmode = 0;
8735 struct cmd_set_vf_rxmode *res = parsed_result;
8737 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8738 if (!strcmp(res->what,"rxmode")) {
8739 if (!strcmp(res->mode, "AUPE"))
8740 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8741 else if (!strcmp(res->mode, "ROPE"))
8742 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8743 else if (!strcmp(res->mode, "BAM"))
8744 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8745 else if (!strncmp(res->mode, "MPE",3))
8746 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8749 RTE_SET_USED(is_on);
8751 #ifdef RTE_LIBRTE_IXGBE_PMD
8752 if (ret == -ENOTSUP)
8753 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8754 vf_rxmode, (uint8_t)is_on);
8756 #ifdef RTE_LIBRTE_BNXT_PMD
8757 if (ret == -ENOTSUP)
8758 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8759 vf_rxmode, (uint8_t)is_on);
8762 printf("bad VF receive mode parameter, return code = %d \n",
8766 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8767 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8769 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8770 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8772 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8773 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8775 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8776 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8778 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8779 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8781 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8782 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8784 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8785 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8786 mode, "AUPE#ROPE#BAM#MPE");
8787 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8788 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8791 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8792 .f = cmd_set_vf_rxmode_parsed,
8794 .help_str = "set port <port_id> vf <vf_id> rxmode "
8795 "AUPE|ROPE|BAM|MPE on|off",
8797 (void *)&cmd_set_vf_rxmode_set,
8798 (void *)&cmd_set_vf_rxmode_port,
8799 (void *)&cmd_set_vf_rxmode_portid,
8800 (void *)&cmd_set_vf_rxmode_vf,
8801 (void *)&cmd_set_vf_rxmode_vfid,
8802 (void *)&cmd_set_vf_rxmode_what,
8803 (void *)&cmd_set_vf_rxmode_mode,
8804 (void *)&cmd_set_vf_rxmode_on,
8809 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8810 struct cmd_vf_mac_addr_result {
8811 cmdline_fixed_string_t mac_addr_cmd;
8812 cmdline_fixed_string_t what;
8813 cmdline_fixed_string_t port;
8815 cmdline_fixed_string_t vf;
8817 struct rte_ether_addr address;
8820 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8821 __rte_unused struct cmdline *cl,
8822 __rte_unused void *data)
8824 struct cmd_vf_mac_addr_result *res = parsed_result;
8827 if (strcmp(res->what, "add") != 0)
8830 #ifdef RTE_LIBRTE_I40E_PMD
8831 if (ret == -ENOTSUP)
8832 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8835 #ifdef RTE_LIBRTE_BNXT_PMD
8836 if (ret == -ENOTSUP)
8837 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8842 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8846 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8847 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8848 mac_addr_cmd,"mac_addr");
8849 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8850 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8852 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8853 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8855 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8856 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8858 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8859 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8861 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8862 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8864 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8865 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8868 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8869 .f = cmd_vf_mac_addr_parsed,
8871 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8872 "Add MAC address filtering for a VF on port_id",
8874 (void *)&cmd_vf_mac_addr_cmd,
8875 (void *)&cmd_vf_mac_addr_what,
8876 (void *)&cmd_vf_mac_addr_port,
8877 (void *)&cmd_vf_mac_addr_portnum,
8878 (void *)&cmd_vf_mac_addr_vf,
8879 (void *)&cmd_vf_mac_addr_vfnum,
8880 (void *)&cmd_vf_mac_addr_addr,
8885 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8886 struct cmd_vf_rx_vlan_filter {
8887 cmdline_fixed_string_t rx_vlan;
8888 cmdline_fixed_string_t what;
8890 cmdline_fixed_string_t port;
8892 cmdline_fixed_string_t vf;
8897 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8898 __rte_unused struct cmdline *cl,
8899 __rte_unused void *data)
8901 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8904 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8906 #ifdef RTE_LIBRTE_IXGBE_PMD
8907 if (ret == -ENOTSUP)
8908 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8909 res->vlan_id, res->vf_mask, is_add);
8911 #ifdef RTE_LIBRTE_I40E_PMD
8912 if (ret == -ENOTSUP)
8913 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8914 res->vlan_id, res->vf_mask, is_add);
8916 #ifdef RTE_LIBRTE_BNXT_PMD
8917 if (ret == -ENOTSUP)
8918 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8919 res->vlan_id, res->vf_mask, is_add);
8926 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8927 res->vlan_id, res->vf_mask);
8930 printf("invalid port_id %d\n", res->port_id);
8933 printf("function not implemented or supported\n");
8936 printf("programming error: (%s)\n", strerror(-ret));
8940 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8941 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8942 rx_vlan, "rx_vlan");
8943 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8944 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8946 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8947 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8949 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8950 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8952 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8953 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8955 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8956 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8958 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8959 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8962 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8963 .f = cmd_vf_rx_vlan_filter_parsed,
8965 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8966 "(vf_mask = hexadecimal VF mask)",
8968 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8969 (void *)&cmd_vf_rx_vlan_filter_what,
8970 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8971 (void *)&cmd_vf_rx_vlan_filter_port,
8972 (void *)&cmd_vf_rx_vlan_filter_portid,
8973 (void *)&cmd_vf_rx_vlan_filter_vf,
8974 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8979 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8980 struct cmd_queue_rate_limit_result {
8981 cmdline_fixed_string_t set;
8982 cmdline_fixed_string_t port;
8984 cmdline_fixed_string_t queue;
8986 cmdline_fixed_string_t rate;
8990 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8991 __rte_unused struct cmdline *cl,
8992 __rte_unused void *data)
8994 struct cmd_queue_rate_limit_result *res = parsed_result;
8997 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8998 && (strcmp(res->queue, "queue") == 0)
8999 && (strcmp(res->rate, "rate") == 0))
9000 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9003 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
9007 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9008 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9010 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9011 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9013 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9014 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9016 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9017 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9019 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9020 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9022 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9023 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9025 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9026 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9029 cmdline_parse_inst_t cmd_queue_rate_limit = {
9030 .f = cmd_queue_rate_limit_parsed,
9032 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9033 "Set rate limit for a queue on port_id",
9035 (void *)&cmd_queue_rate_limit_set,
9036 (void *)&cmd_queue_rate_limit_port,
9037 (void *)&cmd_queue_rate_limit_portnum,
9038 (void *)&cmd_queue_rate_limit_queue,
9039 (void *)&cmd_queue_rate_limit_queuenum,
9040 (void *)&cmd_queue_rate_limit_rate,
9041 (void *)&cmd_queue_rate_limit_ratenum,
9046 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9047 struct cmd_vf_rate_limit_result {
9048 cmdline_fixed_string_t set;
9049 cmdline_fixed_string_t port;
9051 cmdline_fixed_string_t vf;
9053 cmdline_fixed_string_t rate;
9055 cmdline_fixed_string_t q_msk;
9059 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9060 __rte_unused struct cmdline *cl,
9061 __rte_unused void *data)
9063 struct cmd_vf_rate_limit_result *res = parsed_result;
9066 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9067 && (strcmp(res->vf, "vf") == 0)
9068 && (strcmp(res->rate, "rate") == 0)
9069 && (strcmp(res->q_msk, "queue_mask") == 0))
9070 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9071 res->rate_num, res->q_msk_val);
9073 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9077 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9078 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9080 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9081 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9083 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9084 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9086 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9087 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9089 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9090 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9092 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9093 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9095 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9096 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9098 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9099 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9100 q_msk, "queue_mask");
9101 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9102 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9105 cmdline_parse_inst_t cmd_vf_rate_limit = {
9106 .f = cmd_vf_rate_limit_parsed,
9108 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9109 "queue_mask <queue_mask_value>: "
9110 "Set rate limit for queues of VF on port_id",
9112 (void *)&cmd_vf_rate_limit_set,
9113 (void *)&cmd_vf_rate_limit_port,
9114 (void *)&cmd_vf_rate_limit_portnum,
9115 (void *)&cmd_vf_rate_limit_vf,
9116 (void *)&cmd_vf_rate_limit_vfnum,
9117 (void *)&cmd_vf_rate_limit_rate,
9118 (void *)&cmd_vf_rate_limit_ratenum,
9119 (void *)&cmd_vf_rate_limit_q_msk,
9120 (void *)&cmd_vf_rate_limit_q_msk_val,
9125 /* *** ADD TUNNEL FILTER OF A PORT *** */
9126 struct cmd_tunnel_filter_result {
9127 cmdline_fixed_string_t cmd;
9128 cmdline_fixed_string_t what;
9130 struct rte_ether_addr outer_mac;
9131 struct rte_ether_addr inner_mac;
9132 cmdline_ipaddr_t ip_value;
9133 uint16_t inner_vlan;
9134 cmdline_fixed_string_t tunnel_type;
9135 cmdline_fixed_string_t filter_type;
9141 cmd_tunnel_filter_parsed(void *parsed_result,
9142 __rte_unused struct cmdline *cl,
9143 __rte_unused void *data)
9145 struct cmd_tunnel_filter_result *res = parsed_result;
9146 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
9149 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
9151 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
9152 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
9153 tunnel_filter_conf.inner_vlan = res->inner_vlan;
9155 if (res->ip_value.family == AF_INET) {
9156 tunnel_filter_conf.ip_addr.ipv4_addr =
9157 res->ip_value.addr.ipv4.s_addr;
9158 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
9160 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
9161 &(res->ip_value.addr.ipv6),
9162 sizeof(struct in6_addr));
9163 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
9166 if (!strcmp(res->filter_type, "imac-ivlan"))
9167 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
9168 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
9169 tunnel_filter_conf.filter_type =
9170 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
9171 else if (!strcmp(res->filter_type, "imac-tenid"))
9172 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
9173 else if (!strcmp(res->filter_type, "imac"))
9174 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
9175 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
9176 tunnel_filter_conf.filter_type =
9177 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
9178 else if (!strcmp(res->filter_type, "oip"))
9179 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9180 else if (!strcmp(res->filter_type, "iip"))
9181 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9183 printf("The filter type is not supported");
9187 if (!strcmp(res->tunnel_type, "vxlan"))
9188 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9189 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9190 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9191 else if (!strcmp(res->tunnel_type, "nvgre"))
9192 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9193 else if (!strcmp(res->tunnel_type, "ipingre"))
9194 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9196 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9200 tunnel_filter_conf.tenant_id = res->tenant_id;
9201 tunnel_filter_conf.queue_id = res->queue_num;
9202 if (!strcmp(res->what, "add"))
9203 ret = rte_eth_dev_filter_ctrl(res->port_id,
9204 RTE_ETH_FILTER_TUNNEL,
9206 &tunnel_filter_conf);
9208 ret = rte_eth_dev_filter_ctrl(res->port_id,
9209 RTE_ETH_FILTER_TUNNEL,
9210 RTE_ETH_FILTER_DELETE,
9211 &tunnel_filter_conf);
9213 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9217 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9218 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9219 cmd, "tunnel_filter");
9220 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9221 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9223 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9224 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9226 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9227 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9229 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9230 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9232 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9233 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9234 inner_vlan, UINT16);
9235 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9236 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9238 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9239 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9240 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9242 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9243 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9244 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9245 "imac#omac-imac-tenid");
9246 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9247 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9249 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9250 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9253 cmdline_parse_inst_t cmd_tunnel_filter = {
9254 .f = cmd_tunnel_filter_parsed,
9256 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9257 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9258 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9259 "<queue_id>: Add/Rm tunnel filter of a port",
9261 (void *)&cmd_tunnel_filter_cmd,
9262 (void *)&cmd_tunnel_filter_what,
9263 (void *)&cmd_tunnel_filter_port_id,
9264 (void *)&cmd_tunnel_filter_outer_mac,
9265 (void *)&cmd_tunnel_filter_inner_mac,
9266 (void *)&cmd_tunnel_filter_ip_value,
9267 (void *)&cmd_tunnel_filter_innner_vlan,
9268 (void *)&cmd_tunnel_filter_tunnel_type,
9269 (void *)&cmd_tunnel_filter_filter_type,
9270 (void *)&cmd_tunnel_filter_tenant_id,
9271 (void *)&cmd_tunnel_filter_queue_num,
9276 /* *** CONFIGURE TUNNEL UDP PORT *** */
9277 struct cmd_tunnel_udp_config {
9278 cmdline_fixed_string_t cmd;
9279 cmdline_fixed_string_t what;
9285 cmd_tunnel_udp_config_parsed(void *parsed_result,
9286 __rte_unused struct cmdline *cl,
9287 __rte_unused void *data)
9289 struct cmd_tunnel_udp_config *res = parsed_result;
9290 struct rte_eth_udp_tunnel tunnel_udp;
9293 tunnel_udp.udp_port = res->udp_port;
9295 if (!strcmp(res->cmd, "rx_vxlan_port"))
9296 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9298 if (!strcmp(res->what, "add"))
9299 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9302 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9306 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9309 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9310 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9311 cmd, "rx_vxlan_port");
9312 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9313 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9315 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9316 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9318 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9319 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9322 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9323 .f = cmd_tunnel_udp_config_parsed,
9325 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9326 "Add/Remove a tunneling UDP port filter",
9328 (void *)&cmd_tunnel_udp_config_cmd,
9329 (void *)&cmd_tunnel_udp_config_what,
9330 (void *)&cmd_tunnel_udp_config_udp_port,
9331 (void *)&cmd_tunnel_udp_config_port_id,
9336 struct cmd_config_tunnel_udp_port {
9337 cmdline_fixed_string_t port;
9338 cmdline_fixed_string_t config;
9340 cmdline_fixed_string_t udp_tunnel_port;
9341 cmdline_fixed_string_t action;
9342 cmdline_fixed_string_t tunnel_type;
9347 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9348 __rte_unused struct cmdline *cl,
9349 __rte_unused void *data)
9351 struct cmd_config_tunnel_udp_port *res = parsed_result;
9352 struct rte_eth_udp_tunnel tunnel_udp;
9355 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9358 tunnel_udp.udp_port = res->udp_port;
9360 if (!strcmp(res->tunnel_type, "vxlan")) {
9361 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9362 } else if (!strcmp(res->tunnel_type, "geneve")) {
9363 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9364 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9365 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9367 printf("Invalid tunnel type\n");
9371 if (!strcmp(res->action, "add"))
9372 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9375 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9379 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9382 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9383 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9385 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9386 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9388 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9389 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9391 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9392 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9395 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9396 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9398 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9399 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9400 "vxlan#geneve#vxlan-gpe");
9401 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9402 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9405 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9406 .f = cmd_cfg_tunnel_udp_port_parsed,
9408 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9410 (void *)&cmd_config_tunnel_udp_port_port,
9411 (void *)&cmd_config_tunnel_udp_port_config,
9412 (void *)&cmd_config_tunnel_udp_port_port_id,
9413 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9414 (void *)&cmd_config_tunnel_udp_port_action,
9415 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9416 (void *)&cmd_config_tunnel_udp_port_value,
9421 /* *** GLOBAL CONFIG *** */
9422 struct cmd_global_config_result {
9423 cmdline_fixed_string_t cmd;
9425 cmdline_fixed_string_t cfg_type;
9430 cmd_global_config_parsed(void *parsed_result,
9431 __rte_unused struct cmdline *cl,
9432 __rte_unused void *data)
9434 struct cmd_global_config_result *res = parsed_result;
9435 struct rte_eth_global_cfg conf;
9438 memset(&conf, 0, sizeof(conf));
9439 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9440 conf.cfg.gre_key_len = res->len;
9441 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9442 RTE_ETH_FILTER_SET, &conf);
9443 #ifdef RTE_LIBRTE_I40E_PMD
9444 if (ret == -ENOTSUP)
9445 ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len);
9448 printf("Global config error\n");
9451 cmdline_parse_token_string_t cmd_global_config_cmd =
9452 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9454 cmdline_parse_token_num_t cmd_global_config_port_id =
9455 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9457 cmdline_parse_token_string_t cmd_global_config_type =
9458 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9459 cfg_type, "gre-key-len");
9460 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9461 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9464 cmdline_parse_inst_t cmd_global_config = {
9465 .f = cmd_global_config_parsed,
9466 .data = (void *)NULL,
9467 .help_str = "global_config <port_id> gre-key-len <key_len>",
9469 (void *)&cmd_global_config_cmd,
9470 (void *)&cmd_global_config_port_id,
9471 (void *)&cmd_global_config_type,
9472 (void *)&cmd_global_config_gre_key_len,
9477 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9478 struct cmd_set_mirror_mask_result {
9479 cmdline_fixed_string_t set;
9480 cmdline_fixed_string_t port;
9482 cmdline_fixed_string_t mirror;
9484 cmdline_fixed_string_t what;
9485 cmdline_fixed_string_t value;
9486 cmdline_fixed_string_t dstpool;
9488 cmdline_fixed_string_t on;
9491 cmdline_parse_token_string_t cmd_mirror_mask_set =
9492 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9494 cmdline_parse_token_string_t cmd_mirror_mask_port =
9495 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9497 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9498 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9500 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9501 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9502 mirror, "mirror-rule");
9503 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9504 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9506 cmdline_parse_token_string_t cmd_mirror_mask_what =
9507 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9508 what, "pool-mirror-up#pool-mirror-down"
9510 cmdline_parse_token_string_t cmd_mirror_mask_value =
9511 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9513 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9514 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9515 dstpool, "dst-pool");
9516 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9517 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9519 cmdline_parse_token_string_t cmd_mirror_mask_on =
9520 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9524 cmd_set_mirror_mask_parsed(void *parsed_result,
9525 __rte_unused struct cmdline *cl,
9526 __rte_unused void *data)
9529 struct cmd_set_mirror_mask_result *res = parsed_result;
9530 struct rte_eth_mirror_conf mr_conf;
9532 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9534 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9536 mr_conf.dst_pool = res->dstpool_id;
9538 if (!strcmp(res->what, "pool-mirror-up")) {
9539 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9540 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9541 } else if (!strcmp(res->what, "pool-mirror-down")) {
9542 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9543 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9544 } else if (!strcmp(res->what, "vlan-mirror")) {
9545 mr_conf.rule_type = ETH_MIRROR_VLAN;
9546 nb_item = parse_item_list(res->value, "vlan",
9547 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9551 for (i = 0; i < nb_item; i++) {
9552 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9553 printf("Invalid vlan_id: must be < 4096\n");
9557 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9558 mr_conf.vlan.vlan_mask |= 1ULL << i;
9562 if (!strcmp(res->on, "on"))
9563 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9566 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9569 printf("mirror rule add error: (%s)\n", strerror(-ret));
9572 cmdline_parse_inst_t cmd_set_mirror_mask = {
9573 .f = cmd_set_mirror_mask_parsed,
9575 .help_str = "set port <port_id> mirror-rule <rule_id> "
9576 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9577 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9579 (void *)&cmd_mirror_mask_set,
9580 (void *)&cmd_mirror_mask_port,
9581 (void *)&cmd_mirror_mask_portid,
9582 (void *)&cmd_mirror_mask_mirror,
9583 (void *)&cmd_mirror_mask_ruleid,
9584 (void *)&cmd_mirror_mask_what,
9585 (void *)&cmd_mirror_mask_value,
9586 (void *)&cmd_mirror_mask_dstpool,
9587 (void *)&cmd_mirror_mask_poolid,
9588 (void *)&cmd_mirror_mask_on,
9593 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9594 struct cmd_set_mirror_link_result {
9595 cmdline_fixed_string_t set;
9596 cmdline_fixed_string_t port;
9598 cmdline_fixed_string_t mirror;
9600 cmdline_fixed_string_t what;
9601 cmdline_fixed_string_t dstpool;
9603 cmdline_fixed_string_t on;
9606 cmdline_parse_token_string_t cmd_mirror_link_set =
9607 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9609 cmdline_parse_token_string_t cmd_mirror_link_port =
9610 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9612 cmdline_parse_token_num_t cmd_mirror_link_portid =
9613 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9615 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9616 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9617 mirror, "mirror-rule");
9618 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9619 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9621 cmdline_parse_token_string_t cmd_mirror_link_what =
9622 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9623 what, "uplink-mirror#downlink-mirror");
9624 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9625 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9626 dstpool, "dst-pool");
9627 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9628 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9630 cmdline_parse_token_string_t cmd_mirror_link_on =
9631 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9635 cmd_set_mirror_link_parsed(void *parsed_result,
9636 __rte_unused struct cmdline *cl,
9637 __rte_unused void *data)
9640 struct cmd_set_mirror_link_result *res = parsed_result;
9641 struct rte_eth_mirror_conf mr_conf;
9643 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9644 if (!strcmp(res->what, "uplink-mirror"))
9645 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9647 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9649 mr_conf.dst_pool = res->dstpool_id;
9651 if (!strcmp(res->on, "on"))
9652 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9655 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9658 /* check the return value and print it if is < 0 */
9660 printf("mirror rule add error: (%s)\n", strerror(-ret));
9664 cmdline_parse_inst_t cmd_set_mirror_link = {
9665 .f = cmd_set_mirror_link_parsed,
9667 .help_str = "set port <port_id> mirror-rule <rule_id> "
9668 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9670 (void *)&cmd_mirror_link_set,
9671 (void *)&cmd_mirror_link_port,
9672 (void *)&cmd_mirror_link_portid,
9673 (void *)&cmd_mirror_link_mirror,
9674 (void *)&cmd_mirror_link_ruleid,
9675 (void *)&cmd_mirror_link_what,
9676 (void *)&cmd_mirror_link_dstpool,
9677 (void *)&cmd_mirror_link_poolid,
9678 (void *)&cmd_mirror_link_on,
9683 /* *** RESET VM MIRROR RULE *** */
9684 struct cmd_rm_mirror_rule_result {
9685 cmdline_fixed_string_t reset;
9686 cmdline_fixed_string_t port;
9688 cmdline_fixed_string_t mirror;
9692 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9693 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9695 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9696 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9698 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9699 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9701 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9702 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9703 mirror, "mirror-rule");
9704 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9705 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9709 cmd_reset_mirror_rule_parsed(void *parsed_result,
9710 __rte_unused struct cmdline *cl,
9711 __rte_unused void *data)
9714 struct cmd_set_mirror_link_result *res = parsed_result;
9716 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9718 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9721 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9722 .f = cmd_reset_mirror_rule_parsed,
9724 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9726 (void *)&cmd_rm_mirror_rule_reset,
9727 (void *)&cmd_rm_mirror_rule_port,
9728 (void *)&cmd_rm_mirror_rule_portid,
9729 (void *)&cmd_rm_mirror_rule_mirror,
9730 (void *)&cmd_rm_mirror_rule_ruleid,
9735 /* ******************************************************************************** */
9737 struct cmd_dump_result {
9738 cmdline_fixed_string_t dump;
9742 dump_struct_sizes(void)
9744 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9745 DUMP_SIZE(struct rte_mbuf);
9746 DUMP_SIZE(struct rte_mempool);
9747 DUMP_SIZE(struct rte_ring);
9752 /* Dump the socket memory statistics on console */
9754 dump_socket_mem(FILE *f)
9756 struct rte_malloc_socket_stats socket_stats;
9761 unsigned int n_alloc = 0;
9762 unsigned int n_free = 0;
9763 static size_t last_allocs;
9764 static size_t last_total;
9767 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9768 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9769 !socket_stats.heap_totalsz_bytes)
9771 total += socket_stats.heap_totalsz_bytes;
9772 alloc += socket_stats.heap_allocsz_bytes;
9773 free += socket_stats.heap_freesz_bytes;
9774 n_alloc += socket_stats.alloc_count;
9775 n_free += socket_stats.free_count;
9777 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9779 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9780 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9781 (double)socket_stats.heap_allocsz_bytes * 100 /
9782 (double)socket_stats.heap_totalsz_bytes,
9783 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9784 socket_stats.alloc_count,
9785 socket_stats.free_count);
9788 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9789 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9790 (double)alloc * 100 / (double)total,
9791 (double)free / (1024 * 1024),
9794 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9795 ((double)total - (double)last_total) / (1024 * 1024),
9796 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9797 last_allocs = alloc;
9801 static void cmd_dump_parsed(void *parsed_result,
9802 __rte_unused struct cmdline *cl,
9803 __rte_unused void *data)
9805 struct cmd_dump_result *res = parsed_result;
9807 if (!strcmp(res->dump, "dump_physmem"))
9808 rte_dump_physmem_layout(stdout);
9809 else if (!strcmp(res->dump, "dump_socket_mem"))
9810 dump_socket_mem(stdout);
9811 else if (!strcmp(res->dump, "dump_memzone"))
9812 rte_memzone_dump(stdout);
9813 else if (!strcmp(res->dump, "dump_struct_sizes"))
9814 dump_struct_sizes();
9815 else if (!strcmp(res->dump, "dump_ring"))
9816 rte_ring_list_dump(stdout);
9817 else if (!strcmp(res->dump, "dump_mempool"))
9818 rte_mempool_list_dump(stdout);
9819 else if (!strcmp(res->dump, "dump_devargs"))
9820 rte_devargs_dump(stdout);
9821 else if (!strcmp(res->dump, "dump_log_types"))
9822 rte_log_dump(stdout);
9825 cmdline_parse_token_string_t cmd_dump_dump =
9826 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9830 "dump_struct_sizes#"
9836 cmdline_parse_inst_t cmd_dump = {
9837 .f = cmd_dump_parsed, /* function to call */
9838 .data = NULL, /* 2nd arg of func */
9839 .help_str = "Dump status",
9840 .tokens = { /* token list, NULL terminated */
9841 (void *)&cmd_dump_dump,
9846 /* ******************************************************************************** */
9848 struct cmd_dump_one_result {
9849 cmdline_fixed_string_t dump;
9850 cmdline_fixed_string_t name;
9853 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9854 __rte_unused void *data)
9856 struct cmd_dump_one_result *res = parsed_result;
9858 if (!strcmp(res->dump, "dump_ring")) {
9860 r = rte_ring_lookup(res->name);
9862 cmdline_printf(cl, "Cannot find ring\n");
9865 rte_ring_dump(stdout, r);
9866 } else if (!strcmp(res->dump, "dump_mempool")) {
9867 struct rte_mempool *mp;
9868 mp = rte_mempool_lookup(res->name);
9870 cmdline_printf(cl, "Cannot find mempool\n");
9873 rte_mempool_dump(stdout, mp);
9877 cmdline_parse_token_string_t cmd_dump_one_dump =
9878 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9879 "dump_ring#dump_mempool");
9881 cmdline_parse_token_string_t cmd_dump_one_name =
9882 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9884 cmdline_parse_inst_t cmd_dump_one = {
9885 .f = cmd_dump_one_parsed, /* function to call */
9886 .data = NULL, /* 2nd arg of func */
9887 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9888 .tokens = { /* token list, NULL terminated */
9889 (void *)&cmd_dump_one_dump,
9890 (void *)&cmd_dump_one_name,
9895 /* *** Add/Del syn filter *** */
9896 struct cmd_syn_filter_result {
9897 cmdline_fixed_string_t filter;
9899 cmdline_fixed_string_t ops;
9900 cmdline_fixed_string_t priority;
9901 cmdline_fixed_string_t high;
9902 cmdline_fixed_string_t queue;
9907 cmd_syn_filter_parsed(void *parsed_result,
9908 __rte_unused struct cmdline *cl,
9909 __rte_unused void *data)
9911 struct cmd_syn_filter_result *res = parsed_result;
9912 struct rte_eth_syn_filter syn_filter;
9915 ret = rte_eth_dev_filter_supported(res->port_id,
9916 RTE_ETH_FILTER_SYN);
9918 printf("syn filter is not supported on port %u.\n",
9923 memset(&syn_filter, 0, sizeof(syn_filter));
9925 if (!strcmp(res->ops, "add")) {
9926 if (!strcmp(res->high, "high"))
9927 syn_filter.hig_pri = 1;
9929 syn_filter.hig_pri = 0;
9931 syn_filter.queue = res->queue_id;
9932 ret = rte_eth_dev_filter_ctrl(res->port_id,
9937 ret = rte_eth_dev_filter_ctrl(res->port_id,
9939 RTE_ETH_FILTER_DELETE,
9943 printf("syn filter programming error: (%s)\n",
9947 cmdline_parse_token_string_t cmd_syn_filter_filter =
9948 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9949 filter, "syn_filter");
9950 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9951 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9953 cmdline_parse_token_string_t cmd_syn_filter_ops =
9954 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9956 cmdline_parse_token_string_t cmd_syn_filter_priority =
9957 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9958 priority, "priority");
9959 cmdline_parse_token_string_t cmd_syn_filter_high =
9960 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9962 cmdline_parse_token_string_t cmd_syn_filter_queue =
9963 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9965 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9966 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9969 cmdline_parse_inst_t cmd_syn_filter = {
9970 .f = cmd_syn_filter_parsed,
9972 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9973 "<queue_id>: Add/Delete syn filter",
9975 (void *)&cmd_syn_filter_filter,
9976 (void *)&cmd_syn_filter_port_id,
9977 (void *)&cmd_syn_filter_ops,
9978 (void *)&cmd_syn_filter_priority,
9979 (void *)&cmd_syn_filter_high,
9980 (void *)&cmd_syn_filter_queue,
9981 (void *)&cmd_syn_filter_queue_id,
9986 /* *** queue region set *** */
9987 struct cmd_queue_region_result {
9988 cmdline_fixed_string_t set;
9989 cmdline_fixed_string_t port;
9991 cmdline_fixed_string_t cmd;
9992 cmdline_fixed_string_t region;
9994 cmdline_fixed_string_t queue_start_index;
9996 cmdline_fixed_string_t queue_num;
9997 uint8_t queue_num_value;
10001 cmd_queue_region_parsed(void *parsed_result,
10002 __rte_unused struct cmdline *cl,
10003 __rte_unused void *data)
10005 struct cmd_queue_region_result *res = parsed_result;
10006 int ret = -ENOTSUP;
10007 #ifdef RTE_LIBRTE_I40E_PMD
10008 struct rte_pmd_i40e_queue_region_conf region_conf;
10009 enum rte_pmd_i40e_queue_region_op op_type;
10012 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10015 #ifdef RTE_LIBRTE_I40E_PMD
10016 memset(®ion_conf, 0, sizeof(region_conf));
10017 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
10018 region_conf.region_id = res->region_id;
10019 region_conf.queue_num = res->queue_num_value;
10020 region_conf.queue_start_index = res->queue_id;
10022 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10023 op_type, ®ion_conf);
10030 printf("function not implemented or supported\n");
10033 printf("queue region config error: (%s)\n", strerror(-ret));
10037 cmdline_parse_token_string_t cmd_queue_region_set =
10038 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10040 cmdline_parse_token_string_t cmd_queue_region_port =
10041 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10042 cmdline_parse_token_num_t cmd_queue_region_port_id =
10043 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10045 cmdline_parse_token_string_t cmd_queue_region_cmd =
10046 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10047 cmd, "queue-region");
10048 cmdline_parse_token_string_t cmd_queue_region_id =
10049 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10050 region, "region_id");
10051 cmdline_parse_token_num_t cmd_queue_region_index =
10052 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10054 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10055 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10056 queue_start_index, "queue_start_index");
10057 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10058 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10060 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10061 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10062 queue_num, "queue_num");
10063 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10064 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10065 queue_num_value, UINT8);
10067 cmdline_parse_inst_t cmd_queue_region = {
10068 .f = cmd_queue_region_parsed,
10070 .help_str = "set port <port_id> queue-region region_id <value> "
10071 "queue_start_index <value> queue_num <value>: Set a queue region",
10073 (void *)&cmd_queue_region_set,
10074 (void *)&cmd_queue_region_port,
10075 (void *)&cmd_queue_region_port_id,
10076 (void *)&cmd_queue_region_cmd,
10077 (void *)&cmd_queue_region_id,
10078 (void *)&cmd_queue_region_index,
10079 (void *)&cmd_queue_region_queue_start_index,
10080 (void *)&cmd_queue_region_queue_id,
10081 (void *)&cmd_queue_region_queue_num,
10082 (void *)&cmd_queue_region_queue_num_value,
10087 /* *** queue region and flowtype set *** */
10088 struct cmd_region_flowtype_result {
10089 cmdline_fixed_string_t set;
10090 cmdline_fixed_string_t port;
10092 cmdline_fixed_string_t cmd;
10093 cmdline_fixed_string_t region;
10095 cmdline_fixed_string_t flowtype;
10096 uint8_t flowtype_id;
10100 cmd_region_flowtype_parsed(void *parsed_result,
10101 __rte_unused struct cmdline *cl,
10102 __rte_unused void *data)
10104 struct cmd_region_flowtype_result *res = parsed_result;
10105 int ret = -ENOTSUP;
10106 #ifdef RTE_LIBRTE_I40E_PMD
10107 struct rte_pmd_i40e_queue_region_conf region_conf;
10108 enum rte_pmd_i40e_queue_region_op op_type;
10111 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10114 #ifdef RTE_LIBRTE_I40E_PMD
10115 memset(®ion_conf, 0, sizeof(region_conf));
10117 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10118 region_conf.region_id = res->region_id;
10119 region_conf.hw_flowtype = res->flowtype_id;
10121 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10122 op_type, ®ion_conf);
10129 printf("function not implemented or supported\n");
10132 printf("region flowtype config error: (%s)\n", strerror(-ret));
10136 cmdline_parse_token_string_t cmd_region_flowtype_set =
10137 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10139 cmdline_parse_token_string_t cmd_region_flowtype_port =
10140 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10142 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10143 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10145 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10146 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10147 cmd, "queue-region");
10148 cmdline_parse_token_string_t cmd_region_flowtype_index =
10149 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10150 region, "region_id");
10151 cmdline_parse_token_num_t cmd_region_flowtype_id =
10152 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10154 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10155 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10156 flowtype, "flowtype");
10157 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10158 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10159 flowtype_id, UINT8);
10160 cmdline_parse_inst_t cmd_region_flowtype = {
10161 .f = cmd_region_flowtype_parsed,
10163 .help_str = "set port <port_id> queue-region region_id <value> "
10164 "flowtype <value>: Set a flowtype region index",
10166 (void *)&cmd_region_flowtype_set,
10167 (void *)&cmd_region_flowtype_port,
10168 (void *)&cmd_region_flowtype_port_index,
10169 (void *)&cmd_region_flowtype_cmd,
10170 (void *)&cmd_region_flowtype_index,
10171 (void *)&cmd_region_flowtype_id,
10172 (void *)&cmd_region_flowtype_flow_index,
10173 (void *)&cmd_region_flowtype_flow_id,
10178 /* *** User Priority (UP) to queue region (region_id) set *** */
10179 struct cmd_user_priority_region_result {
10180 cmdline_fixed_string_t set;
10181 cmdline_fixed_string_t port;
10183 cmdline_fixed_string_t cmd;
10184 cmdline_fixed_string_t user_priority;
10185 uint8_t user_priority_id;
10186 cmdline_fixed_string_t region;
10191 cmd_user_priority_region_parsed(void *parsed_result,
10192 __rte_unused struct cmdline *cl,
10193 __rte_unused void *data)
10195 struct cmd_user_priority_region_result *res = parsed_result;
10196 int ret = -ENOTSUP;
10197 #ifdef RTE_LIBRTE_I40E_PMD
10198 struct rte_pmd_i40e_queue_region_conf region_conf;
10199 enum rte_pmd_i40e_queue_region_op op_type;
10202 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10205 #ifdef RTE_LIBRTE_I40E_PMD
10206 memset(®ion_conf, 0, sizeof(region_conf));
10207 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10208 region_conf.user_priority = res->user_priority_id;
10209 region_conf.region_id = res->region_id;
10211 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10212 op_type, ®ion_conf);
10219 printf("function not implemented or supported\n");
10222 printf("user_priority region config error: (%s)\n",
10227 cmdline_parse_token_string_t cmd_user_priority_region_set =
10228 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10230 cmdline_parse_token_string_t cmd_user_priority_region_port =
10231 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10233 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10234 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10236 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10237 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10238 cmd, "queue-region");
10239 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10240 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10241 user_priority, "UP");
10242 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10243 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10244 user_priority_id, UINT8);
10245 cmdline_parse_token_string_t cmd_user_priority_region_region =
10246 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10247 region, "region_id");
10248 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10249 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10252 cmdline_parse_inst_t cmd_user_priority_region = {
10253 .f = cmd_user_priority_region_parsed,
10255 .help_str = "set port <port_id> queue-region UP <value> "
10256 "region_id <value>: Set the mapping of User Priority (UP) "
10257 "to queue region (region_id) ",
10259 (void *)&cmd_user_priority_region_set,
10260 (void *)&cmd_user_priority_region_port,
10261 (void *)&cmd_user_priority_region_port_index,
10262 (void *)&cmd_user_priority_region_cmd,
10263 (void *)&cmd_user_priority_region_UP,
10264 (void *)&cmd_user_priority_region_UP_id,
10265 (void *)&cmd_user_priority_region_region,
10266 (void *)&cmd_user_priority_region_region_id,
10271 /* *** flush all queue region related configuration *** */
10272 struct cmd_flush_queue_region_result {
10273 cmdline_fixed_string_t set;
10274 cmdline_fixed_string_t port;
10276 cmdline_fixed_string_t cmd;
10277 cmdline_fixed_string_t flush;
10278 cmdline_fixed_string_t what;
10282 cmd_flush_queue_region_parsed(void *parsed_result,
10283 __rte_unused struct cmdline *cl,
10284 __rte_unused void *data)
10286 struct cmd_flush_queue_region_result *res = parsed_result;
10287 int ret = -ENOTSUP;
10288 #ifdef RTE_LIBRTE_I40E_PMD
10289 struct rte_pmd_i40e_queue_region_conf region_conf;
10290 enum rte_pmd_i40e_queue_region_op op_type;
10293 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10296 #ifdef RTE_LIBRTE_I40E_PMD
10297 memset(®ion_conf, 0, sizeof(region_conf));
10299 if (strcmp(res->what, "on") == 0)
10300 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10302 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10304 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10305 op_type, ®ion_conf);
10312 printf("function not implemented or supported\n");
10315 printf("queue region config flush error: (%s)\n",
10320 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10321 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10323 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10324 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10326 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10327 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10329 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10330 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10331 cmd, "queue-region");
10332 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10333 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10335 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10336 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10339 cmdline_parse_inst_t cmd_flush_queue_region = {
10340 .f = cmd_flush_queue_region_parsed,
10342 .help_str = "set port <port_id> queue-region flush on|off"
10343 ": flush all queue region related configuration",
10345 (void *)&cmd_flush_queue_region_set,
10346 (void *)&cmd_flush_queue_region_port,
10347 (void *)&cmd_flush_queue_region_port_index,
10348 (void *)&cmd_flush_queue_region_cmd,
10349 (void *)&cmd_flush_queue_region_flush,
10350 (void *)&cmd_flush_queue_region_what,
10355 /* *** get all queue region related configuration info *** */
10356 struct cmd_show_queue_region_info {
10357 cmdline_fixed_string_t show;
10358 cmdline_fixed_string_t port;
10360 cmdline_fixed_string_t cmd;
10364 cmd_show_queue_region_info_parsed(void *parsed_result,
10365 __rte_unused struct cmdline *cl,
10366 __rte_unused void *data)
10368 struct cmd_show_queue_region_info *res = parsed_result;
10369 int ret = -ENOTSUP;
10370 #ifdef RTE_LIBRTE_I40E_PMD
10371 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10372 enum rte_pmd_i40e_queue_region_op op_type;
10375 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10378 #ifdef RTE_LIBRTE_I40E_PMD
10379 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10381 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10383 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10384 op_type, &rte_pmd_regions);
10386 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10393 printf("function not implemented or supported\n");
10396 printf("queue region config info show error: (%s)\n",
10401 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10402 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10404 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10405 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10407 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10408 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10410 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10411 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10412 cmd, "queue-region");
10414 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10415 .f = cmd_show_queue_region_info_parsed,
10417 .help_str = "show port <port_id> queue-region"
10418 ": show all queue region related configuration info",
10420 (void *)&cmd_show_queue_region_info_get,
10421 (void *)&cmd_show_queue_region_info_port,
10422 (void *)&cmd_show_queue_region_info_port_index,
10423 (void *)&cmd_show_queue_region_info_cmd,
10428 /* *** ADD/REMOVE A 2tuple FILTER *** */
10429 struct cmd_2tuple_filter_result {
10430 cmdline_fixed_string_t filter;
10432 cmdline_fixed_string_t ops;
10433 cmdline_fixed_string_t dst_port;
10434 uint16_t dst_port_value;
10435 cmdline_fixed_string_t protocol;
10436 uint8_t protocol_value;
10437 cmdline_fixed_string_t mask;
10438 uint8_t mask_value;
10439 cmdline_fixed_string_t tcp_flags;
10440 uint8_t tcp_flags_value;
10441 cmdline_fixed_string_t priority;
10442 uint8_t priority_value;
10443 cmdline_fixed_string_t queue;
10448 cmd_2tuple_filter_parsed(void *parsed_result,
10449 __rte_unused struct cmdline *cl,
10450 __rte_unused void *data)
10452 struct rte_eth_ntuple_filter filter;
10453 struct cmd_2tuple_filter_result *res = parsed_result;
10456 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10458 printf("ntuple filter is not supported on port %u.\n",
10463 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10465 filter.flags = RTE_2TUPLE_FLAGS;
10466 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10467 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10468 filter.proto = res->protocol_value;
10469 filter.priority = res->priority_value;
10470 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10471 printf("nonzero tcp_flags is only meaningful"
10472 " when protocol is TCP.\n");
10475 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10476 printf("invalid TCP flags.\n");
10480 if (res->tcp_flags_value != 0) {
10481 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10482 filter.tcp_flags = res->tcp_flags_value;
10485 /* need convert to big endian. */
10486 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10487 filter.queue = res->queue_id;
10489 if (!strcmp(res->ops, "add"))
10490 ret = rte_eth_dev_filter_ctrl(res->port_id,
10491 RTE_ETH_FILTER_NTUPLE,
10492 RTE_ETH_FILTER_ADD,
10495 ret = rte_eth_dev_filter_ctrl(res->port_id,
10496 RTE_ETH_FILTER_NTUPLE,
10497 RTE_ETH_FILTER_DELETE,
10500 printf("2tuple filter programming error: (%s)\n",
10505 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10506 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10507 filter, "2tuple_filter");
10508 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10509 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10511 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10512 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10514 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10515 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10516 dst_port, "dst_port");
10517 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10518 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10519 dst_port_value, UINT16);
10520 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10521 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10522 protocol, "protocol");
10523 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10524 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10525 protocol_value, UINT8);
10526 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10527 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10529 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10530 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10532 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10533 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10534 tcp_flags, "tcp_flags");
10535 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10536 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10537 tcp_flags_value, UINT8);
10538 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10539 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10540 priority, "priority");
10541 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10542 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10543 priority_value, UINT8);
10544 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10545 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10547 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10548 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10551 cmdline_parse_inst_t cmd_2tuple_filter = {
10552 .f = cmd_2tuple_filter_parsed,
10554 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10555 "<value> mask <value> tcp_flags <value> priority <value> queue "
10556 "<queue_id>: Add a 2tuple filter",
10558 (void *)&cmd_2tuple_filter_filter,
10559 (void *)&cmd_2tuple_filter_port_id,
10560 (void *)&cmd_2tuple_filter_ops,
10561 (void *)&cmd_2tuple_filter_dst_port,
10562 (void *)&cmd_2tuple_filter_dst_port_value,
10563 (void *)&cmd_2tuple_filter_protocol,
10564 (void *)&cmd_2tuple_filter_protocol_value,
10565 (void *)&cmd_2tuple_filter_mask,
10566 (void *)&cmd_2tuple_filter_mask_value,
10567 (void *)&cmd_2tuple_filter_tcp_flags,
10568 (void *)&cmd_2tuple_filter_tcp_flags_value,
10569 (void *)&cmd_2tuple_filter_priority,
10570 (void *)&cmd_2tuple_filter_priority_value,
10571 (void *)&cmd_2tuple_filter_queue,
10572 (void *)&cmd_2tuple_filter_queue_id,
10577 /* *** ADD/REMOVE A 5tuple FILTER *** */
10578 struct cmd_5tuple_filter_result {
10579 cmdline_fixed_string_t filter;
10581 cmdline_fixed_string_t ops;
10582 cmdline_fixed_string_t dst_ip;
10583 cmdline_ipaddr_t dst_ip_value;
10584 cmdline_fixed_string_t src_ip;
10585 cmdline_ipaddr_t src_ip_value;
10586 cmdline_fixed_string_t dst_port;
10587 uint16_t dst_port_value;
10588 cmdline_fixed_string_t src_port;
10589 uint16_t src_port_value;
10590 cmdline_fixed_string_t protocol;
10591 uint8_t protocol_value;
10592 cmdline_fixed_string_t mask;
10593 uint8_t mask_value;
10594 cmdline_fixed_string_t tcp_flags;
10595 uint8_t tcp_flags_value;
10596 cmdline_fixed_string_t priority;
10597 uint8_t priority_value;
10598 cmdline_fixed_string_t queue;
10603 cmd_5tuple_filter_parsed(void *parsed_result,
10604 __rte_unused struct cmdline *cl,
10605 __rte_unused void *data)
10607 struct rte_eth_ntuple_filter filter;
10608 struct cmd_5tuple_filter_result *res = parsed_result;
10611 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10613 printf("ntuple filter is not supported on port %u.\n",
10618 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10620 filter.flags = RTE_5TUPLE_FLAGS;
10621 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10622 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10623 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10624 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10625 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10626 filter.proto = res->protocol_value;
10627 filter.priority = res->priority_value;
10628 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10629 printf("nonzero tcp_flags is only meaningful"
10630 " when protocol is TCP.\n");
10633 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10634 printf("invalid TCP flags.\n");
10638 if (res->tcp_flags_value != 0) {
10639 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10640 filter.tcp_flags = res->tcp_flags_value;
10643 if (res->dst_ip_value.family == AF_INET)
10644 /* no need to convert, already big endian. */
10645 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10647 if (filter.dst_ip_mask == 0) {
10648 printf("can not support ipv6 involved compare.\n");
10654 if (res->src_ip_value.family == AF_INET)
10655 /* no need to convert, already big endian. */
10656 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10658 if (filter.src_ip_mask == 0) {
10659 printf("can not support ipv6 involved compare.\n");
10664 /* need convert to big endian. */
10665 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10666 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10667 filter.queue = res->queue_id;
10669 if (!strcmp(res->ops, "add"))
10670 ret = rte_eth_dev_filter_ctrl(res->port_id,
10671 RTE_ETH_FILTER_NTUPLE,
10672 RTE_ETH_FILTER_ADD,
10675 ret = rte_eth_dev_filter_ctrl(res->port_id,
10676 RTE_ETH_FILTER_NTUPLE,
10677 RTE_ETH_FILTER_DELETE,
10680 printf("5tuple filter programming error: (%s)\n",
10684 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10685 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10686 filter, "5tuple_filter");
10687 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10688 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10690 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10691 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10693 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10694 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10696 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10697 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10699 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10700 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10702 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10703 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10705 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10706 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10707 dst_port, "dst_port");
10708 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10709 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10710 dst_port_value, UINT16);
10711 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10712 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10713 src_port, "src_port");
10714 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10715 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10716 src_port_value, UINT16);
10717 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10718 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10719 protocol, "protocol");
10720 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10721 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10722 protocol_value, UINT8);
10723 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10724 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10726 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10727 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10729 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10730 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10731 tcp_flags, "tcp_flags");
10732 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10733 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10734 tcp_flags_value, UINT8);
10735 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10736 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10737 priority, "priority");
10738 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10739 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10740 priority_value, UINT8);
10741 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10742 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10744 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10745 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10748 cmdline_parse_inst_t cmd_5tuple_filter = {
10749 .f = cmd_5tuple_filter_parsed,
10751 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10752 "src_ip <value> dst_port <value> src_port <value> "
10753 "protocol <value> mask <value> tcp_flags <value> "
10754 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10756 (void *)&cmd_5tuple_filter_filter,
10757 (void *)&cmd_5tuple_filter_port_id,
10758 (void *)&cmd_5tuple_filter_ops,
10759 (void *)&cmd_5tuple_filter_dst_ip,
10760 (void *)&cmd_5tuple_filter_dst_ip_value,
10761 (void *)&cmd_5tuple_filter_src_ip,
10762 (void *)&cmd_5tuple_filter_src_ip_value,
10763 (void *)&cmd_5tuple_filter_dst_port,
10764 (void *)&cmd_5tuple_filter_dst_port_value,
10765 (void *)&cmd_5tuple_filter_src_port,
10766 (void *)&cmd_5tuple_filter_src_port_value,
10767 (void *)&cmd_5tuple_filter_protocol,
10768 (void *)&cmd_5tuple_filter_protocol_value,
10769 (void *)&cmd_5tuple_filter_mask,
10770 (void *)&cmd_5tuple_filter_mask_value,
10771 (void *)&cmd_5tuple_filter_tcp_flags,
10772 (void *)&cmd_5tuple_filter_tcp_flags_value,
10773 (void *)&cmd_5tuple_filter_priority,
10774 (void *)&cmd_5tuple_filter_priority_value,
10775 (void *)&cmd_5tuple_filter_queue,
10776 (void *)&cmd_5tuple_filter_queue_id,
10781 /* *** ADD/REMOVE A flex FILTER *** */
10782 struct cmd_flex_filter_result {
10783 cmdline_fixed_string_t filter;
10784 cmdline_fixed_string_t ops;
10786 cmdline_fixed_string_t len;
10788 cmdline_fixed_string_t bytes;
10789 cmdline_fixed_string_t bytes_value;
10790 cmdline_fixed_string_t mask;
10791 cmdline_fixed_string_t mask_value;
10792 cmdline_fixed_string_t priority;
10793 uint8_t priority_value;
10794 cmdline_fixed_string_t queue;
10798 static int xdigit2val(unsigned char c)
10803 else if (isupper(c))
10804 val = c - 'A' + 10;
10806 val = c - 'a' + 10;
10811 cmd_flex_filter_parsed(void *parsed_result,
10812 __rte_unused struct cmdline *cl,
10813 __rte_unused void *data)
10816 struct rte_eth_flex_filter filter;
10817 struct cmd_flex_filter_result *res = parsed_result;
10818 char *bytes_ptr, *mask_ptr;
10819 uint16_t len, i, j = 0;
10824 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10825 printf("the len exceed the max length 128\n");
10828 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10829 filter.len = res->len_value;
10830 filter.priority = res->priority_value;
10831 filter.queue = res->queue_id;
10832 bytes_ptr = res->bytes_value;
10833 mask_ptr = res->mask_value;
10835 /* translate bytes string to array. */
10836 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10837 (bytes_ptr[1] == 'X')))
10839 len = strnlen(bytes_ptr, res->len_value * 2);
10840 if (len == 0 || (len % 8 != 0)) {
10841 printf("please check len and bytes input\n");
10844 for (i = 0; i < len; i++) {
10846 if (isxdigit(c) == 0) {
10847 /* invalid characters. */
10848 printf("invalid input\n");
10851 val = xdigit2val(c);
10854 filter.bytes[j] = byte;
10855 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10862 /* translate mask string to uint8_t array. */
10863 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10864 (mask_ptr[1] == 'X')))
10866 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10868 printf("invalid input\n");
10873 for (i = 0; i < len; i++) {
10875 if (isxdigit(c) == 0) {
10876 /* invalid characters. */
10877 printf("invalid input\n");
10880 val = xdigit2val(c);
10883 filter.mask[j] = byte;
10884 printf("mask[%d]:%02x ", j, filter.mask[j]);
10892 if (!strcmp(res->ops, "add"))
10893 ret = rte_eth_dev_filter_ctrl(res->port_id,
10894 RTE_ETH_FILTER_FLEXIBLE,
10895 RTE_ETH_FILTER_ADD,
10898 ret = rte_eth_dev_filter_ctrl(res->port_id,
10899 RTE_ETH_FILTER_FLEXIBLE,
10900 RTE_ETH_FILTER_DELETE,
10904 printf("flex filter setting error: (%s)\n", strerror(-ret));
10907 cmdline_parse_token_string_t cmd_flex_filter_filter =
10908 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10909 filter, "flex_filter");
10910 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10911 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10913 cmdline_parse_token_string_t cmd_flex_filter_ops =
10914 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10916 cmdline_parse_token_string_t cmd_flex_filter_len =
10917 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10919 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10920 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10922 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10923 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10925 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10926 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10927 bytes_value, NULL);
10928 cmdline_parse_token_string_t cmd_flex_filter_mask =
10929 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10931 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10932 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10934 cmdline_parse_token_string_t cmd_flex_filter_priority =
10935 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10936 priority, "priority");
10937 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10938 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10939 priority_value, UINT8);
10940 cmdline_parse_token_string_t cmd_flex_filter_queue =
10941 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10943 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10944 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10946 cmdline_parse_inst_t cmd_flex_filter = {
10947 .f = cmd_flex_filter_parsed,
10949 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10950 "<value> mask <value> priority <value> queue <queue_id>: "
10951 "Add/Del a flex filter",
10953 (void *)&cmd_flex_filter_filter,
10954 (void *)&cmd_flex_filter_port_id,
10955 (void *)&cmd_flex_filter_ops,
10956 (void *)&cmd_flex_filter_len,
10957 (void *)&cmd_flex_filter_len_value,
10958 (void *)&cmd_flex_filter_bytes,
10959 (void *)&cmd_flex_filter_bytes_value,
10960 (void *)&cmd_flex_filter_mask,
10961 (void *)&cmd_flex_filter_mask_value,
10962 (void *)&cmd_flex_filter_priority,
10963 (void *)&cmd_flex_filter_priority_value,
10964 (void *)&cmd_flex_filter_queue,
10965 (void *)&cmd_flex_filter_queue_id,
10970 /* *** Filters Control *** */
10972 /* *** deal with ethertype filter *** */
10973 struct cmd_ethertype_filter_result {
10974 cmdline_fixed_string_t filter;
10976 cmdline_fixed_string_t ops;
10977 cmdline_fixed_string_t mac;
10978 struct rte_ether_addr mac_addr;
10979 cmdline_fixed_string_t ethertype;
10980 uint16_t ethertype_value;
10981 cmdline_fixed_string_t drop;
10982 cmdline_fixed_string_t queue;
10986 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10987 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10988 filter, "ethertype_filter");
10989 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10990 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10992 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10993 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10995 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10996 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10997 mac, "mac_addr#mac_ignr");
10998 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10999 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
11001 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
11002 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11003 ethertype, "ethertype");
11004 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
11005 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
11006 ethertype_value, UINT16);
11007 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
11008 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11010 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
11011 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11013 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
11014 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
11018 cmd_ethertype_filter_parsed(void *parsed_result,
11019 __rte_unused struct cmdline *cl,
11020 __rte_unused void *data)
11022 struct cmd_ethertype_filter_result *res = parsed_result;
11023 struct rte_eth_ethertype_filter filter;
11026 ret = rte_eth_dev_filter_supported(res->port_id,
11027 RTE_ETH_FILTER_ETHERTYPE);
11029 printf("ethertype filter is not supported on port %u.\n",
11034 memset(&filter, 0, sizeof(filter));
11035 if (!strcmp(res->mac, "mac_addr")) {
11036 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
11037 rte_memcpy(&filter.mac_addr, &res->mac_addr,
11038 sizeof(struct rte_ether_addr));
11040 if (!strcmp(res->drop, "drop"))
11041 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
11042 filter.ether_type = res->ethertype_value;
11043 filter.queue = res->queue_id;
11045 if (!strcmp(res->ops, "add"))
11046 ret = rte_eth_dev_filter_ctrl(res->port_id,
11047 RTE_ETH_FILTER_ETHERTYPE,
11048 RTE_ETH_FILTER_ADD,
11051 ret = rte_eth_dev_filter_ctrl(res->port_id,
11052 RTE_ETH_FILTER_ETHERTYPE,
11053 RTE_ETH_FILTER_DELETE,
11056 printf("ethertype filter programming error: (%s)\n",
11060 cmdline_parse_inst_t cmd_ethertype_filter = {
11061 .f = cmd_ethertype_filter_parsed,
11063 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
11064 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
11065 "Add or delete an ethertype filter entry",
11067 (void *)&cmd_ethertype_filter_filter,
11068 (void *)&cmd_ethertype_filter_port_id,
11069 (void *)&cmd_ethertype_filter_ops,
11070 (void *)&cmd_ethertype_filter_mac,
11071 (void *)&cmd_ethertype_filter_mac_addr,
11072 (void *)&cmd_ethertype_filter_ethertype,
11073 (void *)&cmd_ethertype_filter_ethertype_value,
11074 (void *)&cmd_ethertype_filter_drop,
11075 (void *)&cmd_ethertype_filter_queue,
11076 (void *)&cmd_ethertype_filter_queue_id,
11081 /* *** deal with flow director filter *** */
11082 struct cmd_flow_director_result {
11083 cmdline_fixed_string_t flow_director_filter;
11085 cmdline_fixed_string_t mode;
11086 cmdline_fixed_string_t mode_value;
11087 cmdline_fixed_string_t ops;
11088 cmdline_fixed_string_t flow;
11089 cmdline_fixed_string_t flow_type;
11090 cmdline_fixed_string_t ether;
11091 uint16_t ether_type;
11092 cmdline_fixed_string_t src;
11093 cmdline_ipaddr_t ip_src;
11095 cmdline_fixed_string_t dst;
11096 cmdline_ipaddr_t ip_dst;
11098 cmdline_fixed_string_t verify_tag;
11099 uint32_t verify_tag_value;
11100 cmdline_fixed_string_t tos;
11102 cmdline_fixed_string_t proto;
11103 uint8_t proto_value;
11104 cmdline_fixed_string_t ttl;
11106 cmdline_fixed_string_t vlan;
11107 uint16_t vlan_value;
11108 cmdline_fixed_string_t flexbytes;
11109 cmdline_fixed_string_t flexbytes_value;
11110 cmdline_fixed_string_t pf_vf;
11111 cmdline_fixed_string_t drop;
11112 cmdline_fixed_string_t queue;
11114 cmdline_fixed_string_t fd_id;
11115 uint32_t fd_id_value;
11116 cmdline_fixed_string_t mac;
11117 struct rte_ether_addr mac_addr;
11118 cmdline_fixed_string_t tunnel;
11119 cmdline_fixed_string_t tunnel_type;
11120 cmdline_fixed_string_t tunnel_id;
11121 uint32_t tunnel_id_value;
11122 cmdline_fixed_string_t packet;
11127 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
11130 const char *p, *p0 = q_arg;
11132 unsigned long int_fld;
11133 char *str_fld[max_num];
11138 p = strchr(p0, '(');
11142 p0 = strchr(p, ')');
11147 if (size >= sizeof(s))
11150 snprintf(s, sizeof(s), "%.*s", size, p);
11151 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11152 if (ret < 0 || ret > max_num)
11154 for (i = 0; i < ret; i++) {
11156 int_fld = strtoul(str_fld[i], &end, 0);
11157 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
11159 flexbytes[i] = (uint8_t)int_fld;
11165 str2flowtype(char *string)
11168 static const struct {
11171 } flowtype_str[] = {
11172 {"raw", RTE_ETH_FLOW_RAW},
11173 {"ipv4", RTE_ETH_FLOW_IPV4},
11174 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11175 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11176 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11177 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11178 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11179 {"ipv6", RTE_ETH_FLOW_IPV6},
11180 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11181 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11182 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11183 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11184 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11185 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11188 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
11189 if (!strcmp(flowtype_str[i].str, string))
11190 return flowtype_str[i].type;
11193 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
11194 return (uint16_t)atoi(string);
11196 return RTE_ETH_FLOW_UNKNOWN;
11199 static enum rte_eth_fdir_tunnel_type
11200 str2fdir_tunneltype(char *string)
11204 static const struct {
11206 enum rte_eth_fdir_tunnel_type type;
11207 } tunneltype_str[] = {
11208 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
11209 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
11212 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
11213 if (!strcmp(tunneltype_str[i].str, string))
11214 return tunneltype_str[i].type;
11216 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
11219 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
11221 if ((ip_addr).family == AF_INET) \
11222 (ip) = (ip_addr).addr.ipv4.s_addr; \
11224 printf("invalid parameter.\n"); \
11229 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
11231 if ((ip_addr).family == AF_INET6) \
11232 rte_memcpy(&(ip), \
11233 &((ip_addr).addr.ipv6), \
11234 sizeof(struct in6_addr)); \
11236 printf("invalid parameter.\n"); \
11242 cmd_flow_director_filter_parsed(void *parsed_result,
11243 __rte_unused struct cmdline *cl,
11244 __rte_unused void *data)
11246 struct cmd_flow_director_result *res = parsed_result;
11247 struct rte_eth_fdir_filter entry;
11248 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11250 unsigned long vf_id;
11253 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11255 printf("flow director is not supported on port %u.\n",
11259 memset(flexbytes, 0, sizeof(flexbytes));
11260 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11262 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11263 if (strcmp(res->mode_value, "MAC-VLAN")) {
11264 printf("Please set mode to MAC-VLAN.\n");
11267 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11268 if (strcmp(res->mode_value, "Tunnel")) {
11269 printf("Please set mode to Tunnel.\n");
11273 if (!strcmp(res->mode_value, "raw")) {
11274 #ifdef RTE_LIBRTE_I40E_PMD
11275 struct rte_pmd_i40e_flow_type_mapping
11276 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11277 struct rte_pmd_i40e_pkt_template_conf conf;
11278 uint16_t flow_type = str2flowtype(res->flow_type);
11279 uint16_t i, port = res->port_id;
11282 memset(&conf, 0, sizeof(conf));
11284 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11285 printf("Invalid flow type specified.\n");
11288 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11292 if (mapping[flow_type].pctype == 0ULL) {
11293 printf("Invalid flow type specified.\n");
11296 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11297 if (mapping[flow_type].pctype & (1ULL << i)) {
11298 conf.input.pctype = i;
11303 conf.input.packet = open_file(res->filepath,
11304 &conf.input.length);
11305 if (!conf.input.packet)
11307 if (!strcmp(res->drop, "drop"))
11308 conf.action.behavior =
11309 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11311 conf.action.behavior =
11312 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11313 conf.action.report_status =
11314 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11315 conf.action.rx_queue = res->queue_id;
11316 conf.soft_id = res->fd_id_value;
11317 add = strcmp(res->ops, "del") ? 1 : 0;
11318 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11322 printf("flow director config error: (%s)\n",
11324 close_file(conf.input.packet);
11327 } else if (strcmp(res->mode_value, "IP")) {
11328 printf("Please set mode to IP or raw.\n");
11331 entry.input.flow_type = str2flowtype(res->flow_type);
11334 ret = parse_flexbytes(res->flexbytes_value,
11336 RTE_ETH_FDIR_MAX_FLEXLEN);
11338 printf("error: Cannot parse flexbytes input.\n");
11342 switch (entry.input.flow_type) {
11343 case RTE_ETH_FLOW_FRAG_IPV4:
11344 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11345 entry.input.flow.ip4_flow.proto = res->proto_value;
11347 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11348 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11349 IPV4_ADDR_TO_UINT(res->ip_dst,
11350 entry.input.flow.ip4_flow.dst_ip);
11351 IPV4_ADDR_TO_UINT(res->ip_src,
11352 entry.input.flow.ip4_flow.src_ip);
11353 entry.input.flow.ip4_flow.tos = res->tos_value;
11354 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11355 /* need convert to big endian. */
11356 entry.input.flow.udp4_flow.dst_port =
11357 rte_cpu_to_be_16(res->port_dst);
11358 entry.input.flow.udp4_flow.src_port =
11359 rte_cpu_to_be_16(res->port_src);
11361 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11362 IPV4_ADDR_TO_UINT(res->ip_dst,
11363 entry.input.flow.sctp4_flow.ip.dst_ip);
11364 IPV4_ADDR_TO_UINT(res->ip_src,
11365 entry.input.flow.sctp4_flow.ip.src_ip);
11366 entry.input.flow.ip4_flow.tos = res->tos_value;
11367 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11368 /* need convert to big endian. */
11369 entry.input.flow.sctp4_flow.dst_port =
11370 rte_cpu_to_be_16(res->port_dst);
11371 entry.input.flow.sctp4_flow.src_port =
11372 rte_cpu_to_be_16(res->port_src);
11373 entry.input.flow.sctp4_flow.verify_tag =
11374 rte_cpu_to_be_32(res->verify_tag_value);
11376 case RTE_ETH_FLOW_FRAG_IPV6:
11377 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11378 entry.input.flow.ipv6_flow.proto = res->proto_value;
11380 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11381 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11382 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11383 entry.input.flow.ipv6_flow.dst_ip);
11384 IPV6_ADDR_TO_ARRAY(res->ip_src,
11385 entry.input.flow.ipv6_flow.src_ip);
11386 entry.input.flow.ipv6_flow.tc = res->tos_value;
11387 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11388 /* need convert to big endian. */
11389 entry.input.flow.udp6_flow.dst_port =
11390 rte_cpu_to_be_16(res->port_dst);
11391 entry.input.flow.udp6_flow.src_port =
11392 rte_cpu_to_be_16(res->port_src);
11394 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11395 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11396 entry.input.flow.sctp6_flow.ip.dst_ip);
11397 IPV6_ADDR_TO_ARRAY(res->ip_src,
11398 entry.input.flow.sctp6_flow.ip.src_ip);
11399 entry.input.flow.ipv6_flow.tc = res->tos_value;
11400 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11401 /* need convert to big endian. */
11402 entry.input.flow.sctp6_flow.dst_port =
11403 rte_cpu_to_be_16(res->port_dst);
11404 entry.input.flow.sctp6_flow.src_port =
11405 rte_cpu_to_be_16(res->port_src);
11406 entry.input.flow.sctp6_flow.verify_tag =
11407 rte_cpu_to_be_32(res->verify_tag_value);
11409 case RTE_ETH_FLOW_L2_PAYLOAD:
11410 entry.input.flow.l2_flow.ether_type =
11411 rte_cpu_to_be_16(res->ether_type);
11417 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11418 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11420 sizeof(struct rte_ether_addr));
11422 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11423 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11425 sizeof(struct rte_ether_addr));
11426 entry.input.flow.tunnel_flow.tunnel_type =
11427 str2fdir_tunneltype(res->tunnel_type);
11428 entry.input.flow.tunnel_flow.tunnel_id =
11429 rte_cpu_to_be_32(res->tunnel_id_value);
11432 rte_memcpy(entry.input.flow_ext.flexbytes,
11434 RTE_ETH_FDIR_MAX_FLEXLEN);
11436 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11438 entry.action.flex_off = 0; /*use 0 by default */
11439 if (!strcmp(res->drop, "drop"))
11440 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11442 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11444 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11445 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11446 if (!strcmp(res->pf_vf, "pf"))
11447 entry.input.flow_ext.is_vf = 0;
11448 else if (!strncmp(res->pf_vf, "vf", 2)) {
11449 struct rte_eth_dev_info dev_info;
11451 ret = eth_dev_info_get_print_err(res->port_id,
11457 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11458 if (errno != 0 || *end != '\0' ||
11459 vf_id >= dev_info.max_vfs) {
11460 printf("invalid parameter %s.\n", res->pf_vf);
11463 entry.input.flow_ext.is_vf = 1;
11464 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11466 printf("invalid parameter %s.\n", res->pf_vf);
11471 /* set to report FD ID by default */
11472 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11473 entry.action.rx_queue = res->queue_id;
11474 entry.soft_id = res->fd_id_value;
11475 if (!strcmp(res->ops, "add"))
11476 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11477 RTE_ETH_FILTER_ADD, &entry);
11478 else if (!strcmp(res->ops, "del"))
11479 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11480 RTE_ETH_FILTER_DELETE, &entry);
11482 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11483 RTE_ETH_FILTER_UPDATE, &entry);
11485 printf("flow director programming error: (%s)\n",
11489 cmdline_parse_token_string_t cmd_flow_director_filter =
11490 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11491 flow_director_filter, "flow_director_filter");
11492 cmdline_parse_token_num_t cmd_flow_director_port_id =
11493 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11495 cmdline_parse_token_string_t cmd_flow_director_ops =
11496 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11497 ops, "add#del#update");
11498 cmdline_parse_token_string_t cmd_flow_director_flow =
11499 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11501 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11502 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11504 cmdline_parse_token_string_t cmd_flow_director_ether =
11505 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11507 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11508 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11509 ether_type, UINT16);
11510 cmdline_parse_token_string_t cmd_flow_director_src =
11511 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11513 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11514 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11516 cmdline_parse_token_num_t cmd_flow_director_port_src =
11517 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11519 cmdline_parse_token_string_t cmd_flow_director_dst =
11520 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11522 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11523 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11525 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11526 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11528 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11529 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11530 verify_tag, "verify_tag");
11531 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11532 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11533 verify_tag_value, UINT32);
11534 cmdline_parse_token_string_t cmd_flow_director_tos =
11535 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11537 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11538 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11540 cmdline_parse_token_string_t cmd_flow_director_proto =
11541 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11543 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11544 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11545 proto_value, UINT8);
11546 cmdline_parse_token_string_t cmd_flow_director_ttl =
11547 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11549 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11550 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11552 cmdline_parse_token_string_t cmd_flow_director_vlan =
11553 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11555 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11556 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11557 vlan_value, UINT16);
11558 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11559 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11560 flexbytes, "flexbytes");
11561 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11562 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11563 flexbytes_value, NULL);
11564 cmdline_parse_token_string_t cmd_flow_director_drop =
11565 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11567 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11568 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11570 cmdline_parse_token_string_t cmd_flow_director_queue =
11571 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11573 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11574 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11576 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11577 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11579 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11580 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11581 fd_id_value, UINT32);
11583 cmdline_parse_token_string_t cmd_flow_director_mode =
11584 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11586 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11587 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11589 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11590 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11591 mode_value, "MAC-VLAN");
11592 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11593 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11594 mode_value, "Tunnel");
11595 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11596 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11597 mode_value, "raw");
11598 cmdline_parse_token_string_t cmd_flow_director_mac =
11599 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11601 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11602 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11604 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11605 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11607 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11608 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11609 tunnel_type, "NVGRE#VxLAN");
11610 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11611 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11612 tunnel_id, "tunnel-id");
11613 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11614 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11615 tunnel_id_value, UINT32);
11616 cmdline_parse_token_string_t cmd_flow_director_packet =
11617 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11619 cmdline_parse_token_string_t cmd_flow_director_filepath =
11620 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11623 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11624 .f = cmd_flow_director_filter_parsed,
11626 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11627 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11628 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11629 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11630 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11631 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11632 "fd_id <fd_id_value>: "
11633 "Add or delete an ip flow director entry on NIC",
11635 (void *)&cmd_flow_director_filter,
11636 (void *)&cmd_flow_director_port_id,
11637 (void *)&cmd_flow_director_mode,
11638 (void *)&cmd_flow_director_mode_ip,
11639 (void *)&cmd_flow_director_ops,
11640 (void *)&cmd_flow_director_flow,
11641 (void *)&cmd_flow_director_flow_type,
11642 (void *)&cmd_flow_director_src,
11643 (void *)&cmd_flow_director_ip_src,
11644 (void *)&cmd_flow_director_dst,
11645 (void *)&cmd_flow_director_ip_dst,
11646 (void *)&cmd_flow_director_tos,
11647 (void *)&cmd_flow_director_tos_value,
11648 (void *)&cmd_flow_director_proto,
11649 (void *)&cmd_flow_director_proto_value,
11650 (void *)&cmd_flow_director_ttl,
11651 (void *)&cmd_flow_director_ttl_value,
11652 (void *)&cmd_flow_director_vlan,
11653 (void *)&cmd_flow_director_vlan_value,
11654 (void *)&cmd_flow_director_flexbytes,
11655 (void *)&cmd_flow_director_flexbytes_value,
11656 (void *)&cmd_flow_director_drop,
11657 (void *)&cmd_flow_director_pf_vf,
11658 (void *)&cmd_flow_director_queue,
11659 (void *)&cmd_flow_director_queue_id,
11660 (void *)&cmd_flow_director_fd_id,
11661 (void *)&cmd_flow_director_fd_id_value,
11666 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11667 .f = cmd_flow_director_filter_parsed,
11669 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11670 "director entry on NIC",
11672 (void *)&cmd_flow_director_filter,
11673 (void *)&cmd_flow_director_port_id,
11674 (void *)&cmd_flow_director_mode,
11675 (void *)&cmd_flow_director_mode_ip,
11676 (void *)&cmd_flow_director_ops,
11677 (void *)&cmd_flow_director_flow,
11678 (void *)&cmd_flow_director_flow_type,
11679 (void *)&cmd_flow_director_src,
11680 (void *)&cmd_flow_director_ip_src,
11681 (void *)&cmd_flow_director_port_src,
11682 (void *)&cmd_flow_director_dst,
11683 (void *)&cmd_flow_director_ip_dst,
11684 (void *)&cmd_flow_director_port_dst,
11685 (void *)&cmd_flow_director_tos,
11686 (void *)&cmd_flow_director_tos_value,
11687 (void *)&cmd_flow_director_ttl,
11688 (void *)&cmd_flow_director_ttl_value,
11689 (void *)&cmd_flow_director_vlan,
11690 (void *)&cmd_flow_director_vlan_value,
11691 (void *)&cmd_flow_director_flexbytes,
11692 (void *)&cmd_flow_director_flexbytes_value,
11693 (void *)&cmd_flow_director_drop,
11694 (void *)&cmd_flow_director_pf_vf,
11695 (void *)&cmd_flow_director_queue,
11696 (void *)&cmd_flow_director_queue_id,
11697 (void *)&cmd_flow_director_fd_id,
11698 (void *)&cmd_flow_director_fd_id_value,
11703 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11704 .f = cmd_flow_director_filter_parsed,
11706 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11707 "director entry on NIC",
11709 (void *)&cmd_flow_director_filter,
11710 (void *)&cmd_flow_director_port_id,
11711 (void *)&cmd_flow_director_mode,
11712 (void *)&cmd_flow_director_mode_ip,
11713 (void *)&cmd_flow_director_ops,
11714 (void *)&cmd_flow_director_flow,
11715 (void *)&cmd_flow_director_flow_type,
11716 (void *)&cmd_flow_director_src,
11717 (void *)&cmd_flow_director_ip_src,
11718 (void *)&cmd_flow_director_port_src,
11719 (void *)&cmd_flow_director_dst,
11720 (void *)&cmd_flow_director_ip_dst,
11721 (void *)&cmd_flow_director_port_dst,
11722 (void *)&cmd_flow_director_verify_tag,
11723 (void *)&cmd_flow_director_verify_tag_value,
11724 (void *)&cmd_flow_director_tos,
11725 (void *)&cmd_flow_director_tos_value,
11726 (void *)&cmd_flow_director_ttl,
11727 (void *)&cmd_flow_director_ttl_value,
11728 (void *)&cmd_flow_director_vlan,
11729 (void *)&cmd_flow_director_vlan_value,
11730 (void *)&cmd_flow_director_flexbytes,
11731 (void *)&cmd_flow_director_flexbytes_value,
11732 (void *)&cmd_flow_director_drop,
11733 (void *)&cmd_flow_director_pf_vf,
11734 (void *)&cmd_flow_director_queue,
11735 (void *)&cmd_flow_director_queue_id,
11736 (void *)&cmd_flow_director_fd_id,
11737 (void *)&cmd_flow_director_fd_id_value,
11742 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11743 .f = cmd_flow_director_filter_parsed,
11745 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11746 "director entry on NIC",
11748 (void *)&cmd_flow_director_filter,
11749 (void *)&cmd_flow_director_port_id,
11750 (void *)&cmd_flow_director_mode,
11751 (void *)&cmd_flow_director_mode_ip,
11752 (void *)&cmd_flow_director_ops,
11753 (void *)&cmd_flow_director_flow,
11754 (void *)&cmd_flow_director_flow_type,
11755 (void *)&cmd_flow_director_ether,
11756 (void *)&cmd_flow_director_ether_type,
11757 (void *)&cmd_flow_director_flexbytes,
11758 (void *)&cmd_flow_director_flexbytes_value,
11759 (void *)&cmd_flow_director_drop,
11760 (void *)&cmd_flow_director_pf_vf,
11761 (void *)&cmd_flow_director_queue,
11762 (void *)&cmd_flow_director_queue_id,
11763 (void *)&cmd_flow_director_fd_id,
11764 (void *)&cmd_flow_director_fd_id_value,
11769 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11770 .f = cmd_flow_director_filter_parsed,
11772 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11773 "director entry on NIC",
11775 (void *)&cmd_flow_director_filter,
11776 (void *)&cmd_flow_director_port_id,
11777 (void *)&cmd_flow_director_mode,
11778 (void *)&cmd_flow_director_mode_mac_vlan,
11779 (void *)&cmd_flow_director_ops,
11780 (void *)&cmd_flow_director_mac,
11781 (void *)&cmd_flow_director_mac_addr,
11782 (void *)&cmd_flow_director_vlan,
11783 (void *)&cmd_flow_director_vlan_value,
11784 (void *)&cmd_flow_director_flexbytes,
11785 (void *)&cmd_flow_director_flexbytes_value,
11786 (void *)&cmd_flow_director_drop,
11787 (void *)&cmd_flow_director_queue,
11788 (void *)&cmd_flow_director_queue_id,
11789 (void *)&cmd_flow_director_fd_id,
11790 (void *)&cmd_flow_director_fd_id_value,
11795 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11796 .f = cmd_flow_director_filter_parsed,
11798 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11799 "director entry on NIC",
11801 (void *)&cmd_flow_director_filter,
11802 (void *)&cmd_flow_director_port_id,
11803 (void *)&cmd_flow_director_mode,
11804 (void *)&cmd_flow_director_mode_tunnel,
11805 (void *)&cmd_flow_director_ops,
11806 (void *)&cmd_flow_director_mac,
11807 (void *)&cmd_flow_director_mac_addr,
11808 (void *)&cmd_flow_director_vlan,
11809 (void *)&cmd_flow_director_vlan_value,
11810 (void *)&cmd_flow_director_tunnel,
11811 (void *)&cmd_flow_director_tunnel_type,
11812 (void *)&cmd_flow_director_tunnel_id,
11813 (void *)&cmd_flow_director_tunnel_id_value,
11814 (void *)&cmd_flow_director_flexbytes,
11815 (void *)&cmd_flow_director_flexbytes_value,
11816 (void *)&cmd_flow_director_drop,
11817 (void *)&cmd_flow_director_queue,
11818 (void *)&cmd_flow_director_queue_id,
11819 (void *)&cmd_flow_director_fd_id,
11820 (void *)&cmd_flow_director_fd_id_value,
11825 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11826 .f = cmd_flow_director_filter_parsed,
11828 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11829 "director entry on NIC",
11831 (void *)&cmd_flow_director_filter,
11832 (void *)&cmd_flow_director_port_id,
11833 (void *)&cmd_flow_director_mode,
11834 (void *)&cmd_flow_director_mode_raw,
11835 (void *)&cmd_flow_director_ops,
11836 (void *)&cmd_flow_director_flow,
11837 (void *)&cmd_flow_director_flow_type,
11838 (void *)&cmd_flow_director_drop,
11839 (void *)&cmd_flow_director_queue,
11840 (void *)&cmd_flow_director_queue_id,
11841 (void *)&cmd_flow_director_fd_id,
11842 (void *)&cmd_flow_director_fd_id_value,
11843 (void *)&cmd_flow_director_packet,
11844 (void *)&cmd_flow_director_filepath,
11849 struct cmd_flush_flow_director_result {
11850 cmdline_fixed_string_t flush_flow_director;
11854 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11855 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11856 flush_flow_director, "flush_flow_director");
11857 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11858 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11862 cmd_flush_flow_director_parsed(void *parsed_result,
11863 __rte_unused struct cmdline *cl,
11864 __rte_unused void *data)
11866 struct cmd_flow_director_result *res = parsed_result;
11869 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11871 printf("flow director is not supported on port %u.\n",
11876 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11877 RTE_ETH_FILTER_FLUSH, NULL);
11879 printf("flow director table flushing error: (%s)\n",
11883 cmdline_parse_inst_t cmd_flush_flow_director = {
11884 .f = cmd_flush_flow_director_parsed,
11886 .help_str = "flush_flow_director <port_id>: "
11887 "Flush all flow director entries of a device on NIC",
11889 (void *)&cmd_flush_flow_director_flush,
11890 (void *)&cmd_flush_flow_director_port_id,
11895 /* *** deal with flow director mask *** */
11896 struct cmd_flow_director_mask_result {
11897 cmdline_fixed_string_t flow_director_mask;
11899 cmdline_fixed_string_t mode;
11900 cmdline_fixed_string_t mode_value;
11901 cmdline_fixed_string_t vlan;
11902 uint16_t vlan_mask;
11903 cmdline_fixed_string_t src_mask;
11904 cmdline_ipaddr_t ipv4_src;
11905 cmdline_ipaddr_t ipv6_src;
11907 cmdline_fixed_string_t dst_mask;
11908 cmdline_ipaddr_t ipv4_dst;
11909 cmdline_ipaddr_t ipv6_dst;
11911 cmdline_fixed_string_t mac;
11912 uint8_t mac_addr_byte_mask;
11913 cmdline_fixed_string_t tunnel_id;
11914 uint32_t tunnel_id_mask;
11915 cmdline_fixed_string_t tunnel_type;
11916 uint8_t tunnel_type_mask;
11920 cmd_flow_director_mask_parsed(void *parsed_result,
11921 __rte_unused struct cmdline *cl,
11922 __rte_unused void *data)
11924 struct cmd_flow_director_mask_result *res = parsed_result;
11925 struct rte_eth_fdir_masks *mask;
11926 struct rte_port *port;
11928 port = &ports[res->port_id];
11929 /** Check if the port is not started **/
11930 if (port->port_status != RTE_PORT_STOPPED) {
11931 printf("Please stop port %d first\n", res->port_id);
11935 mask = &port->dev_conf.fdir_conf.mask;
11937 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11938 if (strcmp(res->mode_value, "MAC-VLAN")) {
11939 printf("Please set mode to MAC-VLAN.\n");
11943 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11944 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11945 if (strcmp(res->mode_value, "Tunnel")) {
11946 printf("Please set mode to Tunnel.\n");
11950 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11951 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11952 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11953 mask->tunnel_type_mask = res->tunnel_type_mask;
11955 if (strcmp(res->mode_value, "IP")) {
11956 printf("Please set mode to IP.\n");
11960 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11961 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11962 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11963 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11964 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11965 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11966 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11969 cmd_reconfig_device_queue(res->port_id, 1, 1);
11972 cmdline_parse_token_string_t cmd_flow_director_mask =
11973 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11974 flow_director_mask, "flow_director_mask");
11975 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11976 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11978 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11979 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11981 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11982 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11983 vlan_mask, UINT16);
11984 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11985 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11986 src_mask, "src_mask");
11987 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11988 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11990 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11991 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11993 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11994 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11996 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11997 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11998 dst_mask, "dst_mask");
11999 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
12000 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12002 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
12003 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12005 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
12006 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12009 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
12010 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12012 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
12013 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12015 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
12016 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12017 mode_value, "MAC-VLAN");
12018 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
12019 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12020 mode_value, "Tunnel");
12021 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
12022 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12024 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
12025 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12026 mac_addr_byte_mask, UINT8);
12027 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
12028 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12029 tunnel_type, "tunnel-type");
12030 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
12031 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12032 tunnel_type_mask, UINT8);
12033 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
12034 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12035 tunnel_id, "tunnel-id");
12036 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
12037 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12038 tunnel_id_mask, UINT32);
12040 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
12041 .f = cmd_flow_director_mask_parsed,
12043 .help_str = "flow_director_mask ... : "
12044 "Set IP mode flow director's mask on NIC",
12046 (void *)&cmd_flow_director_mask,
12047 (void *)&cmd_flow_director_mask_port_id,
12048 (void *)&cmd_flow_director_mask_mode,
12049 (void *)&cmd_flow_director_mask_mode_ip,
12050 (void *)&cmd_flow_director_mask_vlan,
12051 (void *)&cmd_flow_director_mask_vlan_value,
12052 (void *)&cmd_flow_director_mask_src,
12053 (void *)&cmd_flow_director_mask_ipv4_src,
12054 (void *)&cmd_flow_director_mask_ipv6_src,
12055 (void *)&cmd_flow_director_mask_port_src,
12056 (void *)&cmd_flow_director_mask_dst,
12057 (void *)&cmd_flow_director_mask_ipv4_dst,
12058 (void *)&cmd_flow_director_mask_ipv6_dst,
12059 (void *)&cmd_flow_director_mask_port_dst,
12064 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
12065 .f = cmd_flow_director_mask_parsed,
12067 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
12068 "flow director's mask on NIC",
12070 (void *)&cmd_flow_director_mask,
12071 (void *)&cmd_flow_director_mask_port_id,
12072 (void *)&cmd_flow_director_mask_mode,
12073 (void *)&cmd_flow_director_mask_mode_mac_vlan,
12074 (void *)&cmd_flow_director_mask_vlan,
12075 (void *)&cmd_flow_director_mask_vlan_value,
12080 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
12081 .f = cmd_flow_director_mask_parsed,
12083 .help_str = "flow_director_mask ... : Set tunnel mode "
12084 "flow director's mask on NIC",
12086 (void *)&cmd_flow_director_mask,
12087 (void *)&cmd_flow_director_mask_port_id,
12088 (void *)&cmd_flow_director_mask_mode,
12089 (void *)&cmd_flow_director_mask_mode_tunnel,
12090 (void *)&cmd_flow_director_mask_vlan,
12091 (void *)&cmd_flow_director_mask_vlan_value,
12092 (void *)&cmd_flow_director_mask_mac,
12093 (void *)&cmd_flow_director_mask_mac_value,
12094 (void *)&cmd_flow_director_mask_tunnel_type,
12095 (void *)&cmd_flow_director_mask_tunnel_type_value,
12096 (void *)&cmd_flow_director_mask_tunnel_id,
12097 (void *)&cmd_flow_director_mask_tunnel_id_value,
12102 /* *** deal with flow director mask on flexible payload *** */
12103 struct cmd_flow_director_flex_mask_result {
12104 cmdline_fixed_string_t flow_director_flexmask;
12106 cmdline_fixed_string_t flow;
12107 cmdline_fixed_string_t flow_type;
12108 cmdline_fixed_string_t mask;
12112 cmd_flow_director_flex_mask_parsed(void *parsed_result,
12113 __rte_unused struct cmdline *cl,
12114 __rte_unused void *data)
12116 struct cmd_flow_director_flex_mask_result *res = parsed_result;
12117 struct rte_eth_fdir_info fdir_info;
12118 struct rte_eth_fdir_flex_mask flex_mask;
12119 struct rte_port *port;
12120 uint64_t flow_type_mask;
12124 port = &ports[res->port_id];
12125 /** Check if the port is not started **/
12126 if (port->port_status != RTE_PORT_STOPPED) {
12127 printf("Please stop port %d first\n", res->port_id);
12131 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
12132 ret = parse_flexbytes(res->mask,
12134 RTE_ETH_FDIR_MAX_FLEXLEN);
12136 printf("error: Cannot parse mask input.\n");
12140 memset(&fdir_info, 0, sizeof(fdir_info));
12141 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12142 RTE_ETH_FILTER_INFO, &fdir_info);
12144 printf("Cannot get FDir filter info\n");
12148 if (!strcmp(res->flow_type, "none")) {
12149 /* means don't specify the flow type */
12150 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
12151 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
12152 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
12153 0, sizeof(struct rte_eth_fdir_flex_mask));
12154 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
12155 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
12157 sizeof(struct rte_eth_fdir_flex_mask));
12158 cmd_reconfig_device_queue(res->port_id, 1, 1);
12161 flow_type_mask = fdir_info.flow_types_mask[0];
12162 if (!strcmp(res->flow_type, "all")) {
12163 if (!flow_type_mask) {
12164 printf("No flow type supported\n");
12167 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
12168 if (flow_type_mask & (1ULL << i)) {
12169 flex_mask.flow_type = i;
12170 fdir_set_flex_mask(res->port_id, &flex_mask);
12173 cmd_reconfig_device_queue(res->port_id, 1, 1);
12176 flex_mask.flow_type = str2flowtype(res->flow_type);
12177 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
12178 printf("Flow type %s not supported on port %d\n",
12179 res->flow_type, res->port_id);
12182 fdir_set_flex_mask(res->port_id, &flex_mask);
12183 cmd_reconfig_device_queue(res->port_id, 1, 1);
12186 cmdline_parse_token_string_t cmd_flow_director_flexmask =
12187 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12188 flow_director_flexmask,
12189 "flow_director_flex_mask");
12190 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
12191 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12193 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
12194 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12196 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
12197 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12198 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
12199 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
12200 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
12201 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12204 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
12205 .f = cmd_flow_director_flex_mask_parsed,
12207 .help_str = "flow_director_flex_mask ... : "
12208 "Set flow director's flex mask on NIC",
12210 (void *)&cmd_flow_director_flexmask,
12211 (void *)&cmd_flow_director_flexmask_port_id,
12212 (void *)&cmd_flow_director_flexmask_flow,
12213 (void *)&cmd_flow_director_flexmask_flow_type,
12214 (void *)&cmd_flow_director_flexmask_mask,
12219 /* *** deal with flow director flexible payload configuration *** */
12220 struct cmd_flow_director_flexpayload_result {
12221 cmdline_fixed_string_t flow_director_flexpayload;
12223 cmdline_fixed_string_t payload_layer;
12224 cmdline_fixed_string_t payload_cfg;
12228 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
12231 const char *p, *p0 = q_arg;
12233 unsigned long int_fld;
12234 char *str_fld[max_num];
12239 p = strchr(p0, '(');
12243 p0 = strchr(p, ')');
12248 if (size >= sizeof(s))
12251 snprintf(s, sizeof(s), "%.*s", size, p);
12252 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12253 if (ret < 0 || ret > max_num)
12255 for (i = 0; i < ret; i++) {
12257 int_fld = strtoul(str_fld[i], &end, 0);
12258 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12260 offsets[i] = (uint16_t)int_fld;
12266 cmd_flow_director_flxpld_parsed(void *parsed_result,
12267 __rte_unused struct cmdline *cl,
12268 __rte_unused void *data)
12270 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12271 struct rte_eth_flex_payload_cfg flex_cfg;
12272 struct rte_port *port;
12275 port = &ports[res->port_id];
12276 /** Check if the port is not started **/
12277 if (port->port_status != RTE_PORT_STOPPED) {
12278 printf("Please stop port %d first\n", res->port_id);
12282 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12284 if (!strcmp(res->payload_layer, "raw"))
12285 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12286 else if (!strcmp(res->payload_layer, "l2"))
12287 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12288 else if (!strcmp(res->payload_layer, "l3"))
12289 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12290 else if (!strcmp(res->payload_layer, "l4"))
12291 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12293 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12294 RTE_ETH_FDIR_MAX_FLEXLEN);
12296 printf("error: Cannot parse flex payload input.\n");
12300 fdir_set_flex_payload(res->port_id, &flex_cfg);
12301 cmd_reconfig_device_queue(res->port_id, 1, 1);
12304 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12305 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12306 flow_director_flexpayload,
12307 "flow_director_flex_payload");
12308 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12309 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12311 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12312 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12313 payload_layer, "raw#l2#l3#l4");
12314 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12315 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12316 payload_cfg, NULL);
12318 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12319 .f = cmd_flow_director_flxpld_parsed,
12321 .help_str = "flow_director_flexpayload ... : "
12322 "Set flow director's flex payload on NIC",
12324 (void *)&cmd_flow_director_flexpayload,
12325 (void *)&cmd_flow_director_flexpayload_port_id,
12326 (void *)&cmd_flow_director_flexpayload_payload_layer,
12327 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12332 /* Generic flow interface command. */
12333 extern cmdline_parse_inst_t cmd_flow;
12335 /* *** Classification Filters Control *** */
12336 /* *** Get symmetric hash enable per port *** */
12337 struct cmd_get_sym_hash_ena_per_port_result {
12338 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12343 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12344 __rte_unused struct cmdline *cl,
12345 __rte_unused void *data)
12347 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12348 struct rte_eth_hash_filter_info info;
12351 if (rte_eth_dev_filter_supported(res->port_id,
12352 RTE_ETH_FILTER_HASH) < 0) {
12353 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12358 memset(&info, 0, sizeof(info));
12359 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12360 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12361 RTE_ETH_FILTER_GET, &info);
12364 printf("Cannot get symmetric hash enable per port "
12365 "on port %u\n", res->port_id);
12369 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12370 "enabled" : "disabled", res->port_id);
12373 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12374 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12375 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12376 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12377 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12380 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12381 .f = cmd_get_sym_hash_per_port_parsed,
12383 .help_str = "get_sym_hash_ena_per_port <port_id>",
12385 (void *)&cmd_get_sym_hash_ena_per_port_all,
12386 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12391 /* *** Set symmetric hash enable per port *** */
12392 struct cmd_set_sym_hash_ena_per_port_result {
12393 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12394 cmdline_fixed_string_t enable;
12399 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12400 __rte_unused struct cmdline *cl,
12401 __rte_unused void *data)
12403 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12404 struct rte_eth_hash_filter_info info;
12407 if (rte_eth_dev_filter_supported(res->port_id,
12408 RTE_ETH_FILTER_HASH) < 0) {
12409 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12414 memset(&info, 0, sizeof(info));
12415 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12416 if (!strcmp(res->enable, "enable"))
12417 info.info.enable = 1;
12418 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12419 RTE_ETH_FILTER_SET, &info);
12421 printf("Cannot set symmetric hash enable per port on "
12422 "port %u\n", res->port_id);
12425 printf("Symmetric hash has been set to %s on port %u\n",
12426 res->enable, res->port_id);
12429 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12430 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12431 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12432 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12433 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12435 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12436 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12437 enable, "enable#disable");
12439 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12440 .f = cmd_set_sym_hash_per_port_parsed,
12442 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12444 (void *)&cmd_set_sym_hash_ena_per_port_all,
12445 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12446 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12451 /* Get global config of hash function */
12452 struct cmd_get_hash_global_config_result {
12453 cmdline_fixed_string_t get_hash_global_config;
12458 flowtype_to_str(uint16_t ftype)
12464 } ftype_table[] = {
12465 {"ipv4", RTE_ETH_FLOW_IPV4},
12466 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12467 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12468 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12469 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12470 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12471 {"ipv6", RTE_ETH_FLOW_IPV6},
12472 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12473 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12474 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12475 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12476 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12477 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12478 {"port", RTE_ETH_FLOW_PORT},
12479 {"vxlan", RTE_ETH_FLOW_VXLAN},
12480 {"geneve", RTE_ETH_FLOW_GENEVE},
12481 {"nvgre", RTE_ETH_FLOW_NVGRE},
12482 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12485 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12486 if (ftype_table[i].ftype == ftype)
12487 return ftype_table[i].str;
12494 cmd_get_hash_global_config_parsed(void *parsed_result,
12495 __rte_unused struct cmdline *cl,
12496 __rte_unused void *data)
12498 struct cmd_get_hash_global_config_result *res = parsed_result;
12499 struct rte_eth_hash_filter_info info;
12500 uint32_t idx, offset;
12505 if (rte_eth_dev_filter_supported(res->port_id,
12506 RTE_ETH_FILTER_HASH) < 0) {
12507 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12512 memset(&info, 0, sizeof(info));
12513 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12514 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12515 RTE_ETH_FILTER_GET, &info);
12517 printf("Cannot get hash global configurations by port %d\n",
12522 switch (info.info.global_conf.hash_func) {
12523 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12524 printf("Hash function is Toeplitz\n");
12526 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12527 printf("Hash function is Simple XOR\n");
12529 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12530 printf("Hash function is Symmetric Toeplitz\n");
12533 printf("Unknown hash function\n");
12537 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12538 idx = i / UINT64_BIT;
12539 offset = i % UINT64_BIT;
12540 if (!(info.info.global_conf.valid_bit_mask[idx] &
12543 str = flowtype_to_str(i);
12546 printf("Symmetric hash is %s globally for flow type %s "
12548 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12549 (1ULL << offset)) ? "enabled" : "disabled"), str,
12554 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12555 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12556 get_hash_global_config, "get_hash_global_config");
12557 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12558 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12561 cmdline_parse_inst_t cmd_get_hash_global_config = {
12562 .f = cmd_get_hash_global_config_parsed,
12564 .help_str = "get_hash_global_config <port_id>",
12566 (void *)&cmd_get_hash_global_config_all,
12567 (void *)&cmd_get_hash_global_config_port_id,
12572 /* Set global config of hash function */
12573 struct cmd_set_hash_global_config_result {
12574 cmdline_fixed_string_t set_hash_global_config;
12576 cmdline_fixed_string_t hash_func;
12577 cmdline_fixed_string_t flow_type;
12578 cmdline_fixed_string_t enable;
12582 cmd_set_hash_global_config_parsed(void *parsed_result,
12583 __rte_unused struct cmdline *cl,
12584 __rte_unused void *data)
12586 struct cmd_set_hash_global_config_result *res = parsed_result;
12587 struct rte_eth_hash_filter_info info;
12588 uint32_t ftype, idx, offset;
12591 if (rte_eth_dev_filter_supported(res->port_id,
12592 RTE_ETH_FILTER_HASH) < 0) {
12593 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12597 memset(&info, 0, sizeof(info));
12598 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12599 if (!strcmp(res->hash_func, "toeplitz"))
12600 info.info.global_conf.hash_func =
12601 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12602 else if (!strcmp(res->hash_func, "simple_xor"))
12603 info.info.global_conf.hash_func =
12604 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12605 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12606 info.info.global_conf.hash_func =
12607 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12608 else if (!strcmp(res->hash_func, "default"))
12609 info.info.global_conf.hash_func =
12610 RTE_ETH_HASH_FUNCTION_DEFAULT;
12612 ftype = str2flowtype(res->flow_type);
12613 idx = ftype / UINT64_BIT;
12614 offset = ftype % UINT64_BIT;
12615 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12616 if (!strcmp(res->enable, "enable"))
12617 info.info.global_conf.sym_hash_enable_mask[idx] |=
12619 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12620 RTE_ETH_FILTER_SET, &info);
12622 printf("Cannot set global hash configurations by port %d\n",
12625 printf("Global hash configurations have been set "
12626 "successfully by port %d\n", res->port_id);
12629 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12630 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12631 set_hash_global_config, "set_hash_global_config");
12632 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12633 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12635 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12636 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12637 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12638 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12639 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12641 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12642 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12643 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12644 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12645 enable, "enable#disable");
12647 cmdline_parse_inst_t cmd_set_hash_global_config = {
12648 .f = cmd_set_hash_global_config_parsed,
12650 .help_str = "set_hash_global_config <port_id> "
12651 "toeplitz|simple_xor|symmetric_toeplitz|default "
12652 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12653 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12654 "l2_payload enable|disable",
12656 (void *)&cmd_set_hash_global_config_all,
12657 (void *)&cmd_set_hash_global_config_port_id,
12658 (void *)&cmd_set_hash_global_config_hash_func,
12659 (void *)&cmd_set_hash_global_config_flow_type,
12660 (void *)&cmd_set_hash_global_config_enable,
12665 /* Set hash input set */
12666 struct cmd_set_hash_input_set_result {
12667 cmdline_fixed_string_t set_hash_input_set;
12669 cmdline_fixed_string_t flow_type;
12670 cmdline_fixed_string_t inset_field;
12671 cmdline_fixed_string_t select;
12674 static enum rte_eth_input_set_field
12675 str2inset(char *string)
12679 static const struct {
12681 enum rte_eth_input_set_field inset;
12682 } inset_table[] = {
12683 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12684 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12685 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12686 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12687 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12688 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12689 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12690 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12691 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12692 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12693 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12694 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12695 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12696 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12697 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12698 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12699 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12700 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12701 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12702 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12703 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12704 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12705 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12706 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12707 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12708 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12709 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12710 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12711 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12712 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12713 {"none", RTE_ETH_INPUT_SET_NONE},
12716 for (i = 0; i < RTE_DIM(inset_table); i++) {
12717 if (!strcmp(string, inset_table[i].str))
12718 return inset_table[i].inset;
12721 return RTE_ETH_INPUT_SET_UNKNOWN;
12725 cmd_set_hash_input_set_parsed(void *parsed_result,
12726 __rte_unused struct cmdline *cl,
12727 __rte_unused void *data)
12729 struct cmd_set_hash_input_set_result *res = parsed_result;
12730 struct rte_eth_hash_filter_info info;
12732 memset(&info, 0, sizeof(info));
12733 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12734 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12735 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12736 info.info.input_set_conf.inset_size = 1;
12737 if (!strcmp(res->select, "select"))
12738 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12739 else if (!strcmp(res->select, "add"))
12740 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12741 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12742 RTE_ETH_FILTER_SET, &info);
12745 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12746 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12747 set_hash_input_set, "set_hash_input_set");
12748 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12749 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12751 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12752 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12754 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12755 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12757 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12758 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12759 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12760 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12761 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12763 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12764 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12765 select, "select#add");
12767 cmdline_parse_inst_t cmd_set_hash_input_set = {
12768 .f = cmd_set_hash_input_set_parsed,
12770 .help_str = "set_hash_input_set <port_id> "
12771 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12772 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12773 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12774 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12775 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12776 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12777 "fld-7th|fld-8th|none select|add",
12779 (void *)&cmd_set_hash_input_set_cmd,
12780 (void *)&cmd_set_hash_input_set_port_id,
12781 (void *)&cmd_set_hash_input_set_flow_type,
12782 (void *)&cmd_set_hash_input_set_field,
12783 (void *)&cmd_set_hash_input_set_select,
12788 /* Set flow director input set */
12789 struct cmd_set_fdir_input_set_result {
12790 cmdline_fixed_string_t set_fdir_input_set;
12792 cmdline_fixed_string_t flow_type;
12793 cmdline_fixed_string_t inset_field;
12794 cmdline_fixed_string_t select;
12798 cmd_set_fdir_input_set_parsed(void *parsed_result,
12799 __rte_unused struct cmdline *cl,
12800 __rte_unused void *data)
12802 struct cmd_set_fdir_input_set_result *res = parsed_result;
12803 struct rte_eth_fdir_filter_info info;
12805 memset(&info, 0, sizeof(info));
12806 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12807 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12808 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12809 info.info.input_set_conf.inset_size = 1;
12810 if (!strcmp(res->select, "select"))
12811 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12812 else if (!strcmp(res->select, "add"))
12813 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12814 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12815 RTE_ETH_FILTER_SET, &info);
12818 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12819 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12820 set_fdir_input_set, "set_fdir_input_set");
12821 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12822 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12824 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12825 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12827 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12828 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12829 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12830 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12832 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12833 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12834 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12835 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12836 "sctp-veri-tag#none");
12837 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12838 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12839 select, "select#add");
12841 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12842 .f = cmd_set_fdir_input_set_parsed,
12844 .help_str = "set_fdir_input_set <port_id> "
12845 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12846 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12847 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12848 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12849 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12850 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12851 "sctp-veri-tag|none select|add",
12853 (void *)&cmd_set_fdir_input_set_cmd,
12854 (void *)&cmd_set_fdir_input_set_port_id,
12855 (void *)&cmd_set_fdir_input_set_flow_type,
12856 (void *)&cmd_set_fdir_input_set_field,
12857 (void *)&cmd_set_fdir_input_set_select,
12862 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12863 struct cmd_mcast_addr_result {
12864 cmdline_fixed_string_t mcast_addr_cmd;
12865 cmdline_fixed_string_t what;
12867 struct rte_ether_addr mc_addr;
12870 static void cmd_mcast_addr_parsed(void *parsed_result,
12871 __rte_unused struct cmdline *cl,
12872 __rte_unused void *data)
12874 struct cmd_mcast_addr_result *res = parsed_result;
12876 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12877 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12878 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12879 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12880 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12883 if (strcmp(res->what, "add") == 0)
12884 mcast_addr_add(res->port_num, &res->mc_addr);
12886 mcast_addr_remove(res->port_num, &res->mc_addr);
12889 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12890 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12891 mcast_addr_cmd, "mcast_addr");
12892 cmdline_parse_token_string_t cmd_mcast_addr_what =
12893 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12895 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12896 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12897 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12898 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12900 cmdline_parse_inst_t cmd_mcast_addr = {
12901 .f = cmd_mcast_addr_parsed,
12903 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12904 "Add/Remove multicast MAC address on port_id",
12906 (void *)&cmd_mcast_addr_cmd,
12907 (void *)&cmd_mcast_addr_what,
12908 (void *)&cmd_mcast_addr_portnum,
12909 (void *)&cmd_mcast_addr_addr,
12914 /* l2 tunnel config
12915 * only support E-tag now.
12918 /* Ether type config */
12919 struct cmd_config_l2_tunnel_eth_type_result {
12920 cmdline_fixed_string_t port;
12921 cmdline_fixed_string_t config;
12922 cmdline_fixed_string_t all;
12924 cmdline_fixed_string_t l2_tunnel;
12925 cmdline_fixed_string_t l2_tunnel_type;
12926 cmdline_fixed_string_t eth_type;
12927 uint16_t eth_type_val;
12930 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12931 TOKEN_STRING_INITIALIZER
12932 (struct cmd_config_l2_tunnel_eth_type_result,
12934 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12935 TOKEN_STRING_INITIALIZER
12936 (struct cmd_config_l2_tunnel_eth_type_result,
12938 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12939 TOKEN_STRING_INITIALIZER
12940 (struct cmd_config_l2_tunnel_eth_type_result,
12942 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12943 TOKEN_NUM_INITIALIZER
12944 (struct cmd_config_l2_tunnel_eth_type_result,
12946 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12947 TOKEN_STRING_INITIALIZER
12948 (struct cmd_config_l2_tunnel_eth_type_result,
12949 l2_tunnel, "l2-tunnel");
12950 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12951 TOKEN_STRING_INITIALIZER
12952 (struct cmd_config_l2_tunnel_eth_type_result,
12953 l2_tunnel_type, "E-tag");
12954 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12955 TOKEN_STRING_INITIALIZER
12956 (struct cmd_config_l2_tunnel_eth_type_result,
12957 eth_type, "ether-type");
12958 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12959 TOKEN_NUM_INITIALIZER
12960 (struct cmd_config_l2_tunnel_eth_type_result,
12961 eth_type_val, UINT16);
12963 static enum rte_eth_tunnel_type
12964 str2fdir_l2_tunnel_type(char *string)
12968 static const struct {
12970 enum rte_eth_tunnel_type type;
12971 } l2_tunnel_type_str[] = {
12972 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12975 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12976 if (!strcmp(l2_tunnel_type_str[i].str, string))
12977 return l2_tunnel_type_str[i].type;
12979 return RTE_TUNNEL_TYPE_NONE;
12982 /* ether type config for all ports */
12984 cmd_config_l2_tunnel_eth_type_all_parsed
12985 (void *parsed_result,
12986 __rte_unused struct cmdline *cl,
12987 __rte_unused void *data)
12989 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12990 struct rte_eth_l2_tunnel_conf entry;
12993 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12994 entry.ether_type = res->eth_type_val;
12996 RTE_ETH_FOREACH_DEV(pid) {
12997 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
13001 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
13002 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
13004 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
13006 (void *)&cmd_config_l2_tunnel_eth_type_port,
13007 (void *)&cmd_config_l2_tunnel_eth_type_config,
13008 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
13009 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
13010 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
13011 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
13012 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
13017 /* ether type config for a specific port */
13019 cmd_config_l2_tunnel_eth_type_specific_parsed(
13020 void *parsed_result,
13021 __rte_unused struct cmdline *cl,
13022 __rte_unused void *data)
13024 struct cmd_config_l2_tunnel_eth_type_result *res =
13026 struct rte_eth_l2_tunnel_conf entry;
13028 if (port_id_is_invalid(res->id, ENABLED_WARN))
13031 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13032 entry.ether_type = res->eth_type_val;
13034 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
13037 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
13038 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
13040 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
13042 (void *)&cmd_config_l2_tunnel_eth_type_port,
13043 (void *)&cmd_config_l2_tunnel_eth_type_config,
13044 (void *)&cmd_config_l2_tunnel_eth_type_id,
13045 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
13046 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
13047 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
13048 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
13053 /* Enable/disable l2 tunnel */
13054 struct cmd_config_l2_tunnel_en_dis_result {
13055 cmdline_fixed_string_t port;
13056 cmdline_fixed_string_t config;
13057 cmdline_fixed_string_t all;
13059 cmdline_fixed_string_t l2_tunnel;
13060 cmdline_fixed_string_t l2_tunnel_type;
13061 cmdline_fixed_string_t en_dis;
13064 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
13065 TOKEN_STRING_INITIALIZER
13066 (struct cmd_config_l2_tunnel_en_dis_result,
13068 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
13069 TOKEN_STRING_INITIALIZER
13070 (struct cmd_config_l2_tunnel_en_dis_result,
13072 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
13073 TOKEN_STRING_INITIALIZER
13074 (struct cmd_config_l2_tunnel_en_dis_result,
13076 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
13077 TOKEN_NUM_INITIALIZER
13078 (struct cmd_config_l2_tunnel_en_dis_result,
13080 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
13081 TOKEN_STRING_INITIALIZER
13082 (struct cmd_config_l2_tunnel_en_dis_result,
13083 l2_tunnel, "l2-tunnel");
13084 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
13085 TOKEN_STRING_INITIALIZER
13086 (struct cmd_config_l2_tunnel_en_dis_result,
13087 l2_tunnel_type, "E-tag");
13088 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
13089 TOKEN_STRING_INITIALIZER
13090 (struct cmd_config_l2_tunnel_en_dis_result,
13091 en_dis, "enable#disable");
13093 /* enable/disable l2 tunnel for all ports */
13095 cmd_config_l2_tunnel_en_dis_all_parsed(
13096 void *parsed_result,
13097 __rte_unused struct cmdline *cl,
13098 __rte_unused void *data)
13100 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
13101 struct rte_eth_l2_tunnel_conf entry;
13105 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13107 if (!strcmp("enable", res->en_dis))
13112 RTE_ETH_FOREACH_DEV(pid) {
13113 rte_eth_dev_l2_tunnel_offload_set(pid,
13115 ETH_L2_TUNNEL_ENABLE_MASK,
13120 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
13121 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
13123 .help_str = "port config all l2-tunnel E-tag enable|disable",
13125 (void *)&cmd_config_l2_tunnel_en_dis_port,
13126 (void *)&cmd_config_l2_tunnel_en_dis_config,
13127 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
13128 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13129 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13130 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13135 /* enable/disable l2 tunnel for a port */
13137 cmd_config_l2_tunnel_en_dis_specific_parsed(
13138 void *parsed_result,
13139 __rte_unused struct cmdline *cl,
13140 __rte_unused void *data)
13142 struct cmd_config_l2_tunnel_en_dis_result *res =
13144 struct rte_eth_l2_tunnel_conf entry;
13146 if (port_id_is_invalid(res->id, ENABLED_WARN))
13149 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13151 if (!strcmp("enable", res->en_dis))
13152 rte_eth_dev_l2_tunnel_offload_set(res->id,
13154 ETH_L2_TUNNEL_ENABLE_MASK,
13157 rte_eth_dev_l2_tunnel_offload_set(res->id,
13159 ETH_L2_TUNNEL_ENABLE_MASK,
13163 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
13164 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
13166 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
13168 (void *)&cmd_config_l2_tunnel_en_dis_port,
13169 (void *)&cmd_config_l2_tunnel_en_dis_config,
13170 (void *)&cmd_config_l2_tunnel_en_dis_id,
13171 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13172 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13173 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13178 /* E-tag configuration */
13180 /* Common result structure for all E-tag configuration */
13181 struct cmd_config_e_tag_result {
13182 cmdline_fixed_string_t e_tag;
13183 cmdline_fixed_string_t set;
13184 cmdline_fixed_string_t insertion;
13185 cmdline_fixed_string_t stripping;
13186 cmdline_fixed_string_t forwarding;
13187 cmdline_fixed_string_t filter;
13188 cmdline_fixed_string_t add;
13189 cmdline_fixed_string_t del;
13190 cmdline_fixed_string_t on;
13191 cmdline_fixed_string_t off;
13192 cmdline_fixed_string_t on_off;
13193 cmdline_fixed_string_t port_tag_id;
13194 uint32_t port_tag_id_val;
13195 cmdline_fixed_string_t e_tag_id;
13196 uint16_t e_tag_id_val;
13197 cmdline_fixed_string_t dst_pool;
13198 uint8_t dst_pool_val;
13199 cmdline_fixed_string_t port;
13201 cmdline_fixed_string_t vf;
13205 /* Common CLI fields for all E-tag configuration */
13206 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
13207 TOKEN_STRING_INITIALIZER
13208 (struct cmd_config_e_tag_result,
13210 cmdline_parse_token_string_t cmd_config_e_tag_set =
13211 TOKEN_STRING_INITIALIZER
13212 (struct cmd_config_e_tag_result,
13214 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
13215 TOKEN_STRING_INITIALIZER
13216 (struct cmd_config_e_tag_result,
13217 insertion, "insertion");
13218 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
13219 TOKEN_STRING_INITIALIZER
13220 (struct cmd_config_e_tag_result,
13221 stripping, "stripping");
13222 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
13223 TOKEN_STRING_INITIALIZER
13224 (struct cmd_config_e_tag_result,
13225 forwarding, "forwarding");
13226 cmdline_parse_token_string_t cmd_config_e_tag_filter =
13227 TOKEN_STRING_INITIALIZER
13228 (struct cmd_config_e_tag_result,
13230 cmdline_parse_token_string_t cmd_config_e_tag_add =
13231 TOKEN_STRING_INITIALIZER
13232 (struct cmd_config_e_tag_result,
13234 cmdline_parse_token_string_t cmd_config_e_tag_del =
13235 TOKEN_STRING_INITIALIZER
13236 (struct cmd_config_e_tag_result,
13238 cmdline_parse_token_string_t cmd_config_e_tag_on =
13239 TOKEN_STRING_INITIALIZER
13240 (struct cmd_config_e_tag_result,
13242 cmdline_parse_token_string_t cmd_config_e_tag_off =
13243 TOKEN_STRING_INITIALIZER
13244 (struct cmd_config_e_tag_result,
13246 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13247 TOKEN_STRING_INITIALIZER
13248 (struct cmd_config_e_tag_result,
13250 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13251 TOKEN_STRING_INITIALIZER
13252 (struct cmd_config_e_tag_result,
13253 port_tag_id, "port-tag-id");
13254 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13255 TOKEN_NUM_INITIALIZER
13256 (struct cmd_config_e_tag_result,
13257 port_tag_id_val, UINT32);
13258 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13259 TOKEN_STRING_INITIALIZER
13260 (struct cmd_config_e_tag_result,
13261 e_tag_id, "e-tag-id");
13262 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13263 TOKEN_NUM_INITIALIZER
13264 (struct cmd_config_e_tag_result,
13265 e_tag_id_val, UINT16);
13266 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13267 TOKEN_STRING_INITIALIZER
13268 (struct cmd_config_e_tag_result,
13269 dst_pool, "dst-pool");
13270 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13271 TOKEN_NUM_INITIALIZER
13272 (struct cmd_config_e_tag_result,
13273 dst_pool_val, UINT8);
13274 cmdline_parse_token_string_t cmd_config_e_tag_port =
13275 TOKEN_STRING_INITIALIZER
13276 (struct cmd_config_e_tag_result,
13278 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13279 TOKEN_NUM_INITIALIZER
13280 (struct cmd_config_e_tag_result,
13282 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13283 TOKEN_STRING_INITIALIZER
13284 (struct cmd_config_e_tag_result,
13286 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13287 TOKEN_NUM_INITIALIZER
13288 (struct cmd_config_e_tag_result,
13291 /* E-tag insertion configuration */
13293 cmd_config_e_tag_insertion_en_parsed(
13294 void *parsed_result,
13295 __rte_unused struct cmdline *cl,
13296 __rte_unused void *data)
13298 struct cmd_config_e_tag_result *res =
13300 struct rte_eth_l2_tunnel_conf entry;
13302 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13305 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13306 entry.tunnel_id = res->port_tag_id_val;
13307 entry.vf_id = res->vf_id;
13308 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13310 ETH_L2_TUNNEL_INSERTION_MASK,
13315 cmd_config_e_tag_insertion_dis_parsed(
13316 void *parsed_result,
13317 __rte_unused struct cmdline *cl,
13318 __rte_unused void *data)
13320 struct cmd_config_e_tag_result *res =
13322 struct rte_eth_l2_tunnel_conf entry;
13324 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13327 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13328 entry.vf_id = res->vf_id;
13330 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13332 ETH_L2_TUNNEL_INSERTION_MASK,
13336 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13337 .f = cmd_config_e_tag_insertion_en_parsed,
13339 .help_str = "E-tag ... : E-tag insertion enable",
13341 (void *)&cmd_config_e_tag_e_tag,
13342 (void *)&cmd_config_e_tag_set,
13343 (void *)&cmd_config_e_tag_insertion,
13344 (void *)&cmd_config_e_tag_on,
13345 (void *)&cmd_config_e_tag_port_tag_id,
13346 (void *)&cmd_config_e_tag_port_tag_id_val,
13347 (void *)&cmd_config_e_tag_port,
13348 (void *)&cmd_config_e_tag_port_id,
13349 (void *)&cmd_config_e_tag_vf,
13350 (void *)&cmd_config_e_tag_vf_id,
13355 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13356 .f = cmd_config_e_tag_insertion_dis_parsed,
13358 .help_str = "E-tag ... : E-tag insertion disable",
13360 (void *)&cmd_config_e_tag_e_tag,
13361 (void *)&cmd_config_e_tag_set,
13362 (void *)&cmd_config_e_tag_insertion,
13363 (void *)&cmd_config_e_tag_off,
13364 (void *)&cmd_config_e_tag_port,
13365 (void *)&cmd_config_e_tag_port_id,
13366 (void *)&cmd_config_e_tag_vf,
13367 (void *)&cmd_config_e_tag_vf_id,
13372 /* E-tag stripping configuration */
13374 cmd_config_e_tag_stripping_parsed(
13375 void *parsed_result,
13376 __rte_unused struct cmdline *cl,
13377 __rte_unused void *data)
13379 struct cmd_config_e_tag_result *res =
13381 struct rte_eth_l2_tunnel_conf entry;
13383 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13386 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13388 if (!strcmp(res->on_off, "on"))
13389 rte_eth_dev_l2_tunnel_offload_set
13392 ETH_L2_TUNNEL_STRIPPING_MASK,
13395 rte_eth_dev_l2_tunnel_offload_set
13398 ETH_L2_TUNNEL_STRIPPING_MASK,
13402 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13403 .f = cmd_config_e_tag_stripping_parsed,
13405 .help_str = "E-tag ... : E-tag stripping enable/disable",
13407 (void *)&cmd_config_e_tag_e_tag,
13408 (void *)&cmd_config_e_tag_set,
13409 (void *)&cmd_config_e_tag_stripping,
13410 (void *)&cmd_config_e_tag_on_off,
13411 (void *)&cmd_config_e_tag_port,
13412 (void *)&cmd_config_e_tag_port_id,
13417 /* E-tag forwarding configuration */
13419 cmd_config_e_tag_forwarding_parsed(
13420 void *parsed_result,
13421 __rte_unused struct cmdline *cl,
13422 __rte_unused void *data)
13424 struct cmd_config_e_tag_result *res = parsed_result;
13425 struct rte_eth_l2_tunnel_conf entry;
13427 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13430 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13432 if (!strcmp(res->on_off, "on"))
13433 rte_eth_dev_l2_tunnel_offload_set
13436 ETH_L2_TUNNEL_FORWARDING_MASK,
13439 rte_eth_dev_l2_tunnel_offload_set
13442 ETH_L2_TUNNEL_FORWARDING_MASK,
13446 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13447 .f = cmd_config_e_tag_forwarding_parsed,
13449 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13451 (void *)&cmd_config_e_tag_e_tag,
13452 (void *)&cmd_config_e_tag_set,
13453 (void *)&cmd_config_e_tag_forwarding,
13454 (void *)&cmd_config_e_tag_on_off,
13455 (void *)&cmd_config_e_tag_port,
13456 (void *)&cmd_config_e_tag_port_id,
13461 /* E-tag filter configuration */
13463 cmd_config_e_tag_filter_add_parsed(
13464 void *parsed_result,
13465 __rte_unused struct cmdline *cl,
13466 __rte_unused void *data)
13468 struct cmd_config_e_tag_result *res = parsed_result;
13469 struct rte_eth_l2_tunnel_conf entry;
13472 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13475 if (res->e_tag_id_val > 0x3fff) {
13476 printf("e-tag-id must be equal or less than 0x3fff.\n");
13480 ret = rte_eth_dev_filter_supported(res->port_id,
13481 RTE_ETH_FILTER_L2_TUNNEL);
13483 printf("E-tag filter is not supported on port %u.\n",
13488 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13489 entry.tunnel_id = res->e_tag_id_val;
13490 entry.pool = res->dst_pool_val;
13492 ret = rte_eth_dev_filter_ctrl(res->port_id,
13493 RTE_ETH_FILTER_L2_TUNNEL,
13494 RTE_ETH_FILTER_ADD,
13497 printf("E-tag filter programming error: (%s)\n",
13501 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13502 .f = cmd_config_e_tag_filter_add_parsed,
13504 .help_str = "E-tag ... : E-tag filter add",
13506 (void *)&cmd_config_e_tag_e_tag,
13507 (void *)&cmd_config_e_tag_set,
13508 (void *)&cmd_config_e_tag_filter,
13509 (void *)&cmd_config_e_tag_add,
13510 (void *)&cmd_config_e_tag_e_tag_id,
13511 (void *)&cmd_config_e_tag_e_tag_id_val,
13512 (void *)&cmd_config_e_tag_dst_pool,
13513 (void *)&cmd_config_e_tag_dst_pool_val,
13514 (void *)&cmd_config_e_tag_port,
13515 (void *)&cmd_config_e_tag_port_id,
13521 cmd_config_e_tag_filter_del_parsed(
13522 void *parsed_result,
13523 __rte_unused struct cmdline *cl,
13524 __rte_unused void *data)
13526 struct cmd_config_e_tag_result *res = parsed_result;
13527 struct rte_eth_l2_tunnel_conf entry;
13530 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13533 if (res->e_tag_id_val > 0x3fff) {
13534 printf("e-tag-id must be less than 0x3fff.\n");
13538 ret = rte_eth_dev_filter_supported(res->port_id,
13539 RTE_ETH_FILTER_L2_TUNNEL);
13541 printf("E-tag filter is not supported on port %u.\n",
13546 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13547 entry.tunnel_id = res->e_tag_id_val;
13549 ret = rte_eth_dev_filter_ctrl(res->port_id,
13550 RTE_ETH_FILTER_L2_TUNNEL,
13551 RTE_ETH_FILTER_DELETE,
13554 printf("E-tag filter programming error: (%s)\n",
13558 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13559 .f = cmd_config_e_tag_filter_del_parsed,
13561 .help_str = "E-tag ... : E-tag filter delete",
13563 (void *)&cmd_config_e_tag_e_tag,
13564 (void *)&cmd_config_e_tag_set,
13565 (void *)&cmd_config_e_tag_filter,
13566 (void *)&cmd_config_e_tag_del,
13567 (void *)&cmd_config_e_tag_e_tag_id,
13568 (void *)&cmd_config_e_tag_e_tag_id_val,
13569 (void *)&cmd_config_e_tag_port,
13570 (void *)&cmd_config_e_tag_port_id,
13575 /* vf vlan anti spoof configuration */
13577 /* Common result structure for vf vlan anti spoof */
13578 struct cmd_vf_vlan_anti_spoof_result {
13579 cmdline_fixed_string_t set;
13580 cmdline_fixed_string_t vf;
13581 cmdline_fixed_string_t vlan;
13582 cmdline_fixed_string_t antispoof;
13585 cmdline_fixed_string_t on_off;
13588 /* Common CLI fields for vf vlan anti spoof enable disable */
13589 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13590 TOKEN_STRING_INITIALIZER
13591 (struct cmd_vf_vlan_anti_spoof_result,
13593 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13594 TOKEN_STRING_INITIALIZER
13595 (struct cmd_vf_vlan_anti_spoof_result,
13597 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13598 TOKEN_STRING_INITIALIZER
13599 (struct cmd_vf_vlan_anti_spoof_result,
13601 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13602 TOKEN_STRING_INITIALIZER
13603 (struct cmd_vf_vlan_anti_spoof_result,
13604 antispoof, "antispoof");
13605 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13606 TOKEN_NUM_INITIALIZER
13607 (struct cmd_vf_vlan_anti_spoof_result,
13609 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13610 TOKEN_NUM_INITIALIZER
13611 (struct cmd_vf_vlan_anti_spoof_result,
13613 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13614 TOKEN_STRING_INITIALIZER
13615 (struct cmd_vf_vlan_anti_spoof_result,
13619 cmd_set_vf_vlan_anti_spoof_parsed(
13620 void *parsed_result,
13621 __rte_unused struct cmdline *cl,
13622 __rte_unused void *data)
13624 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13625 int ret = -ENOTSUP;
13627 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13629 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13632 #ifdef RTE_LIBRTE_IXGBE_PMD
13633 if (ret == -ENOTSUP)
13634 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13635 res->vf_id, is_on);
13637 #ifdef RTE_LIBRTE_I40E_PMD
13638 if (ret == -ENOTSUP)
13639 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13640 res->vf_id, is_on);
13642 #ifdef RTE_LIBRTE_BNXT_PMD
13643 if (ret == -ENOTSUP)
13644 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13645 res->vf_id, is_on);
13652 printf("invalid vf_id %d\n", res->vf_id);
13655 printf("invalid port_id %d\n", res->port_id);
13658 printf("function not implemented\n");
13661 printf("programming error: (%s)\n", strerror(-ret));
13665 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13666 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13668 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13670 (void *)&cmd_vf_vlan_anti_spoof_set,
13671 (void *)&cmd_vf_vlan_anti_spoof_vf,
13672 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13673 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13674 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13675 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13676 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13681 /* vf mac anti spoof configuration */
13683 /* Common result structure for vf mac anti spoof */
13684 struct cmd_vf_mac_anti_spoof_result {
13685 cmdline_fixed_string_t set;
13686 cmdline_fixed_string_t vf;
13687 cmdline_fixed_string_t mac;
13688 cmdline_fixed_string_t antispoof;
13691 cmdline_fixed_string_t on_off;
13694 /* Common CLI fields for vf mac anti spoof enable disable */
13695 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13696 TOKEN_STRING_INITIALIZER
13697 (struct cmd_vf_mac_anti_spoof_result,
13699 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13700 TOKEN_STRING_INITIALIZER
13701 (struct cmd_vf_mac_anti_spoof_result,
13703 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13704 TOKEN_STRING_INITIALIZER
13705 (struct cmd_vf_mac_anti_spoof_result,
13707 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13708 TOKEN_STRING_INITIALIZER
13709 (struct cmd_vf_mac_anti_spoof_result,
13710 antispoof, "antispoof");
13711 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13712 TOKEN_NUM_INITIALIZER
13713 (struct cmd_vf_mac_anti_spoof_result,
13715 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13716 TOKEN_NUM_INITIALIZER
13717 (struct cmd_vf_mac_anti_spoof_result,
13719 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13720 TOKEN_STRING_INITIALIZER
13721 (struct cmd_vf_mac_anti_spoof_result,
13725 cmd_set_vf_mac_anti_spoof_parsed(
13726 void *parsed_result,
13727 __rte_unused struct cmdline *cl,
13728 __rte_unused void *data)
13730 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13731 int ret = -ENOTSUP;
13733 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13735 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13738 #ifdef RTE_LIBRTE_IXGBE_PMD
13739 if (ret == -ENOTSUP)
13740 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13741 res->vf_id, is_on);
13743 #ifdef RTE_LIBRTE_I40E_PMD
13744 if (ret == -ENOTSUP)
13745 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13746 res->vf_id, is_on);
13748 #ifdef RTE_LIBRTE_BNXT_PMD
13749 if (ret == -ENOTSUP)
13750 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13751 res->vf_id, is_on);
13758 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13761 printf("invalid port_id %d\n", res->port_id);
13764 printf("function not implemented\n");
13767 printf("programming error: (%s)\n", strerror(-ret));
13771 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13772 .f = cmd_set_vf_mac_anti_spoof_parsed,
13774 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13776 (void *)&cmd_vf_mac_anti_spoof_set,
13777 (void *)&cmd_vf_mac_anti_spoof_vf,
13778 (void *)&cmd_vf_mac_anti_spoof_mac,
13779 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13780 (void *)&cmd_vf_mac_anti_spoof_port_id,
13781 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13782 (void *)&cmd_vf_mac_anti_spoof_on_off,
13787 /* vf vlan strip queue configuration */
13789 /* Common result structure for vf mac anti spoof */
13790 struct cmd_vf_vlan_stripq_result {
13791 cmdline_fixed_string_t set;
13792 cmdline_fixed_string_t vf;
13793 cmdline_fixed_string_t vlan;
13794 cmdline_fixed_string_t stripq;
13797 cmdline_fixed_string_t on_off;
13800 /* Common CLI fields for vf vlan strip enable disable */
13801 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13802 TOKEN_STRING_INITIALIZER
13803 (struct cmd_vf_vlan_stripq_result,
13805 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13806 TOKEN_STRING_INITIALIZER
13807 (struct cmd_vf_vlan_stripq_result,
13809 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13810 TOKEN_STRING_INITIALIZER
13811 (struct cmd_vf_vlan_stripq_result,
13813 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13814 TOKEN_STRING_INITIALIZER
13815 (struct cmd_vf_vlan_stripq_result,
13817 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13818 TOKEN_NUM_INITIALIZER
13819 (struct cmd_vf_vlan_stripq_result,
13821 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13822 TOKEN_NUM_INITIALIZER
13823 (struct cmd_vf_vlan_stripq_result,
13825 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13826 TOKEN_STRING_INITIALIZER
13827 (struct cmd_vf_vlan_stripq_result,
13831 cmd_set_vf_vlan_stripq_parsed(
13832 void *parsed_result,
13833 __rte_unused struct cmdline *cl,
13834 __rte_unused void *data)
13836 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13837 int ret = -ENOTSUP;
13839 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13841 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13844 #ifdef RTE_LIBRTE_IXGBE_PMD
13845 if (ret == -ENOTSUP)
13846 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13847 res->vf_id, is_on);
13849 #ifdef RTE_LIBRTE_I40E_PMD
13850 if (ret == -ENOTSUP)
13851 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13852 res->vf_id, is_on);
13854 #ifdef RTE_LIBRTE_BNXT_PMD
13855 if (ret == -ENOTSUP)
13856 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13857 res->vf_id, is_on);
13864 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13867 printf("invalid port_id %d\n", res->port_id);
13870 printf("function not implemented\n");
13873 printf("programming error: (%s)\n", strerror(-ret));
13877 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13878 .f = cmd_set_vf_vlan_stripq_parsed,
13880 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13882 (void *)&cmd_vf_vlan_stripq_set,
13883 (void *)&cmd_vf_vlan_stripq_vf,
13884 (void *)&cmd_vf_vlan_stripq_vlan,
13885 (void *)&cmd_vf_vlan_stripq_stripq,
13886 (void *)&cmd_vf_vlan_stripq_port_id,
13887 (void *)&cmd_vf_vlan_stripq_vf_id,
13888 (void *)&cmd_vf_vlan_stripq_on_off,
13893 /* vf vlan insert configuration */
13895 /* Common result structure for vf vlan insert */
13896 struct cmd_vf_vlan_insert_result {
13897 cmdline_fixed_string_t set;
13898 cmdline_fixed_string_t vf;
13899 cmdline_fixed_string_t vlan;
13900 cmdline_fixed_string_t insert;
13906 /* Common CLI fields for vf vlan insert enable disable */
13907 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13908 TOKEN_STRING_INITIALIZER
13909 (struct cmd_vf_vlan_insert_result,
13911 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13912 TOKEN_STRING_INITIALIZER
13913 (struct cmd_vf_vlan_insert_result,
13915 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13916 TOKEN_STRING_INITIALIZER
13917 (struct cmd_vf_vlan_insert_result,
13919 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13920 TOKEN_STRING_INITIALIZER
13921 (struct cmd_vf_vlan_insert_result,
13923 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13924 TOKEN_NUM_INITIALIZER
13925 (struct cmd_vf_vlan_insert_result,
13927 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13928 TOKEN_NUM_INITIALIZER
13929 (struct cmd_vf_vlan_insert_result,
13931 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13932 TOKEN_NUM_INITIALIZER
13933 (struct cmd_vf_vlan_insert_result,
13937 cmd_set_vf_vlan_insert_parsed(
13938 void *parsed_result,
13939 __rte_unused struct cmdline *cl,
13940 __rte_unused void *data)
13942 struct cmd_vf_vlan_insert_result *res = parsed_result;
13943 int ret = -ENOTSUP;
13945 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13948 #ifdef RTE_LIBRTE_IXGBE_PMD
13949 if (ret == -ENOTSUP)
13950 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13953 #ifdef RTE_LIBRTE_I40E_PMD
13954 if (ret == -ENOTSUP)
13955 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13958 #ifdef RTE_LIBRTE_BNXT_PMD
13959 if (ret == -ENOTSUP)
13960 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13968 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13971 printf("invalid port_id %d\n", res->port_id);
13974 printf("function not implemented\n");
13977 printf("programming error: (%s)\n", strerror(-ret));
13981 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13982 .f = cmd_set_vf_vlan_insert_parsed,
13984 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13986 (void *)&cmd_vf_vlan_insert_set,
13987 (void *)&cmd_vf_vlan_insert_vf,
13988 (void *)&cmd_vf_vlan_insert_vlan,
13989 (void *)&cmd_vf_vlan_insert_insert,
13990 (void *)&cmd_vf_vlan_insert_port_id,
13991 (void *)&cmd_vf_vlan_insert_vf_id,
13992 (void *)&cmd_vf_vlan_insert_vlan_id,
13997 /* tx loopback configuration */
13999 /* Common result structure for tx loopback */
14000 struct cmd_tx_loopback_result {
14001 cmdline_fixed_string_t set;
14002 cmdline_fixed_string_t tx;
14003 cmdline_fixed_string_t loopback;
14005 cmdline_fixed_string_t on_off;
14008 /* Common CLI fields for tx loopback enable disable */
14009 cmdline_parse_token_string_t cmd_tx_loopback_set =
14010 TOKEN_STRING_INITIALIZER
14011 (struct cmd_tx_loopback_result,
14013 cmdline_parse_token_string_t cmd_tx_loopback_tx =
14014 TOKEN_STRING_INITIALIZER
14015 (struct cmd_tx_loopback_result,
14017 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
14018 TOKEN_STRING_INITIALIZER
14019 (struct cmd_tx_loopback_result,
14020 loopback, "loopback");
14021 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
14022 TOKEN_NUM_INITIALIZER
14023 (struct cmd_tx_loopback_result,
14025 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
14026 TOKEN_STRING_INITIALIZER
14027 (struct cmd_tx_loopback_result,
14031 cmd_set_tx_loopback_parsed(
14032 void *parsed_result,
14033 __rte_unused struct cmdline *cl,
14034 __rte_unused void *data)
14036 struct cmd_tx_loopback_result *res = parsed_result;
14037 int ret = -ENOTSUP;
14039 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14041 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14044 #ifdef RTE_LIBRTE_IXGBE_PMD
14045 if (ret == -ENOTSUP)
14046 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
14048 #ifdef RTE_LIBRTE_I40E_PMD
14049 if (ret == -ENOTSUP)
14050 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
14052 #ifdef RTE_LIBRTE_BNXT_PMD
14053 if (ret == -ENOTSUP)
14054 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
14056 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
14057 if (ret == -ENOTSUP)
14058 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
14065 printf("invalid is_on %d\n", is_on);
14068 printf("invalid port_id %d\n", res->port_id);
14071 printf("function not implemented\n");
14074 printf("programming error: (%s)\n", strerror(-ret));
14078 cmdline_parse_inst_t cmd_set_tx_loopback = {
14079 .f = cmd_set_tx_loopback_parsed,
14081 .help_str = "set tx loopback <port_id> on|off",
14083 (void *)&cmd_tx_loopback_set,
14084 (void *)&cmd_tx_loopback_tx,
14085 (void *)&cmd_tx_loopback_loopback,
14086 (void *)&cmd_tx_loopback_port_id,
14087 (void *)&cmd_tx_loopback_on_off,
14092 /* all queues drop enable configuration */
14094 /* Common result structure for all queues drop enable */
14095 struct cmd_all_queues_drop_en_result {
14096 cmdline_fixed_string_t set;
14097 cmdline_fixed_string_t all;
14098 cmdline_fixed_string_t queues;
14099 cmdline_fixed_string_t drop;
14101 cmdline_fixed_string_t on_off;
14104 /* Common CLI fields for tx loopback enable disable */
14105 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
14106 TOKEN_STRING_INITIALIZER
14107 (struct cmd_all_queues_drop_en_result,
14109 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
14110 TOKEN_STRING_INITIALIZER
14111 (struct cmd_all_queues_drop_en_result,
14113 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
14114 TOKEN_STRING_INITIALIZER
14115 (struct cmd_all_queues_drop_en_result,
14117 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
14118 TOKEN_STRING_INITIALIZER
14119 (struct cmd_all_queues_drop_en_result,
14121 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
14122 TOKEN_NUM_INITIALIZER
14123 (struct cmd_all_queues_drop_en_result,
14125 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
14126 TOKEN_STRING_INITIALIZER
14127 (struct cmd_all_queues_drop_en_result,
14131 cmd_set_all_queues_drop_en_parsed(
14132 void *parsed_result,
14133 __rte_unused struct cmdline *cl,
14134 __rte_unused void *data)
14136 struct cmd_all_queues_drop_en_result *res = parsed_result;
14137 int ret = -ENOTSUP;
14138 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14140 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14143 #ifdef RTE_LIBRTE_IXGBE_PMD
14144 if (ret == -ENOTSUP)
14145 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
14147 #ifdef RTE_LIBRTE_BNXT_PMD
14148 if (ret == -ENOTSUP)
14149 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
14155 printf("invalid is_on %d\n", is_on);
14158 printf("invalid port_id %d\n", res->port_id);
14161 printf("function not implemented\n");
14164 printf("programming error: (%s)\n", strerror(-ret));
14168 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
14169 .f = cmd_set_all_queues_drop_en_parsed,
14171 .help_str = "set all queues drop <port_id> on|off",
14173 (void *)&cmd_all_queues_drop_en_set,
14174 (void *)&cmd_all_queues_drop_en_all,
14175 (void *)&cmd_all_queues_drop_en_queues,
14176 (void *)&cmd_all_queues_drop_en_drop,
14177 (void *)&cmd_all_queues_drop_en_port_id,
14178 (void *)&cmd_all_queues_drop_en_on_off,
14183 /* vf split drop enable configuration */
14185 /* Common result structure for vf split drop enable */
14186 struct cmd_vf_split_drop_en_result {
14187 cmdline_fixed_string_t set;
14188 cmdline_fixed_string_t vf;
14189 cmdline_fixed_string_t split;
14190 cmdline_fixed_string_t drop;
14193 cmdline_fixed_string_t on_off;
14196 /* Common CLI fields for vf split drop enable disable */
14197 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
14198 TOKEN_STRING_INITIALIZER
14199 (struct cmd_vf_split_drop_en_result,
14201 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
14202 TOKEN_STRING_INITIALIZER
14203 (struct cmd_vf_split_drop_en_result,
14205 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
14206 TOKEN_STRING_INITIALIZER
14207 (struct cmd_vf_split_drop_en_result,
14209 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
14210 TOKEN_STRING_INITIALIZER
14211 (struct cmd_vf_split_drop_en_result,
14213 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
14214 TOKEN_NUM_INITIALIZER
14215 (struct cmd_vf_split_drop_en_result,
14217 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
14218 TOKEN_NUM_INITIALIZER
14219 (struct cmd_vf_split_drop_en_result,
14221 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
14222 TOKEN_STRING_INITIALIZER
14223 (struct cmd_vf_split_drop_en_result,
14227 cmd_set_vf_split_drop_en_parsed(
14228 void *parsed_result,
14229 __rte_unused struct cmdline *cl,
14230 __rte_unused void *data)
14232 struct cmd_vf_split_drop_en_result *res = parsed_result;
14233 int ret = -ENOTSUP;
14234 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14236 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14239 #ifdef RTE_LIBRTE_IXGBE_PMD
14240 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14247 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14250 printf("invalid port_id %d\n", res->port_id);
14253 printf("not supported on port %d\n", res->port_id);
14256 printf("programming error: (%s)\n", strerror(-ret));
14260 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14261 .f = cmd_set_vf_split_drop_en_parsed,
14263 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14265 (void *)&cmd_vf_split_drop_en_set,
14266 (void *)&cmd_vf_split_drop_en_vf,
14267 (void *)&cmd_vf_split_drop_en_split,
14268 (void *)&cmd_vf_split_drop_en_drop,
14269 (void *)&cmd_vf_split_drop_en_port_id,
14270 (void *)&cmd_vf_split_drop_en_vf_id,
14271 (void *)&cmd_vf_split_drop_en_on_off,
14276 /* vf mac address configuration */
14278 /* Common result structure for vf mac address */
14279 struct cmd_set_vf_mac_addr_result {
14280 cmdline_fixed_string_t set;
14281 cmdline_fixed_string_t vf;
14282 cmdline_fixed_string_t mac;
14283 cmdline_fixed_string_t addr;
14286 struct rte_ether_addr mac_addr;
14290 /* Common CLI fields for vf split drop enable disable */
14291 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14292 TOKEN_STRING_INITIALIZER
14293 (struct cmd_set_vf_mac_addr_result,
14295 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14296 TOKEN_STRING_INITIALIZER
14297 (struct cmd_set_vf_mac_addr_result,
14299 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14300 TOKEN_STRING_INITIALIZER
14301 (struct cmd_set_vf_mac_addr_result,
14303 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14304 TOKEN_STRING_INITIALIZER
14305 (struct cmd_set_vf_mac_addr_result,
14307 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14308 TOKEN_NUM_INITIALIZER
14309 (struct cmd_set_vf_mac_addr_result,
14311 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14312 TOKEN_NUM_INITIALIZER
14313 (struct cmd_set_vf_mac_addr_result,
14315 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14316 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14320 cmd_set_vf_mac_addr_parsed(
14321 void *parsed_result,
14322 __rte_unused struct cmdline *cl,
14323 __rte_unused void *data)
14325 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14326 int ret = -ENOTSUP;
14328 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14331 #ifdef RTE_LIBRTE_IXGBE_PMD
14332 if (ret == -ENOTSUP)
14333 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14336 #ifdef RTE_LIBRTE_I40E_PMD
14337 if (ret == -ENOTSUP)
14338 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14341 #ifdef RTE_LIBRTE_BNXT_PMD
14342 if (ret == -ENOTSUP)
14343 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14351 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14354 printf("invalid port_id %d\n", res->port_id);
14357 printf("function not implemented\n");
14360 printf("programming error: (%s)\n", strerror(-ret));
14364 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14365 .f = cmd_set_vf_mac_addr_parsed,
14367 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14369 (void *)&cmd_set_vf_mac_addr_set,
14370 (void *)&cmd_set_vf_mac_addr_vf,
14371 (void *)&cmd_set_vf_mac_addr_mac,
14372 (void *)&cmd_set_vf_mac_addr_addr,
14373 (void *)&cmd_set_vf_mac_addr_port_id,
14374 (void *)&cmd_set_vf_mac_addr_vf_id,
14375 (void *)&cmd_set_vf_mac_addr_mac_addr,
14380 /* MACsec configuration */
14382 /* Common result structure for MACsec offload enable */
14383 struct cmd_macsec_offload_on_result {
14384 cmdline_fixed_string_t set;
14385 cmdline_fixed_string_t macsec;
14386 cmdline_fixed_string_t offload;
14388 cmdline_fixed_string_t on;
14389 cmdline_fixed_string_t encrypt;
14390 cmdline_fixed_string_t en_on_off;
14391 cmdline_fixed_string_t replay_protect;
14392 cmdline_fixed_string_t rp_on_off;
14395 /* Common CLI fields for MACsec offload disable */
14396 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14397 TOKEN_STRING_INITIALIZER
14398 (struct cmd_macsec_offload_on_result,
14400 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14401 TOKEN_STRING_INITIALIZER
14402 (struct cmd_macsec_offload_on_result,
14404 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14405 TOKEN_STRING_INITIALIZER
14406 (struct cmd_macsec_offload_on_result,
14407 offload, "offload");
14408 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14409 TOKEN_NUM_INITIALIZER
14410 (struct cmd_macsec_offload_on_result,
14412 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14413 TOKEN_STRING_INITIALIZER
14414 (struct cmd_macsec_offload_on_result,
14416 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14417 TOKEN_STRING_INITIALIZER
14418 (struct cmd_macsec_offload_on_result,
14419 encrypt, "encrypt");
14420 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14421 TOKEN_STRING_INITIALIZER
14422 (struct cmd_macsec_offload_on_result,
14423 en_on_off, "on#off");
14424 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14425 TOKEN_STRING_INITIALIZER
14426 (struct cmd_macsec_offload_on_result,
14427 replay_protect, "replay-protect");
14428 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14429 TOKEN_STRING_INITIALIZER
14430 (struct cmd_macsec_offload_on_result,
14431 rp_on_off, "on#off");
14434 cmd_set_macsec_offload_on_parsed(
14435 void *parsed_result,
14436 __rte_unused struct cmdline *cl,
14437 __rte_unused void *data)
14439 struct cmd_macsec_offload_on_result *res = parsed_result;
14440 int ret = -ENOTSUP;
14441 portid_t port_id = res->port_id;
14442 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14443 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14444 struct rte_eth_dev_info dev_info;
14446 if (port_id_is_invalid(port_id, ENABLED_WARN))
14448 if (!port_is_stopped(port_id)) {
14449 printf("Please stop port %d first\n", port_id);
14453 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14457 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14458 #ifdef RTE_LIBRTE_IXGBE_PMD
14459 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14467 ports[port_id].dev_conf.txmode.offloads |=
14468 DEV_TX_OFFLOAD_MACSEC_INSERT;
14469 cmd_reconfig_device_queue(port_id, 1, 1);
14472 printf("invalid port_id %d\n", port_id);
14475 printf("not supported on port %d\n", port_id);
14478 printf("programming error: (%s)\n", strerror(-ret));
14482 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14483 .f = cmd_set_macsec_offload_on_parsed,
14485 .help_str = "set macsec offload <port_id> on "
14486 "encrypt on|off replay-protect on|off",
14488 (void *)&cmd_macsec_offload_on_set,
14489 (void *)&cmd_macsec_offload_on_macsec,
14490 (void *)&cmd_macsec_offload_on_offload,
14491 (void *)&cmd_macsec_offload_on_port_id,
14492 (void *)&cmd_macsec_offload_on_on,
14493 (void *)&cmd_macsec_offload_on_encrypt,
14494 (void *)&cmd_macsec_offload_on_en_on_off,
14495 (void *)&cmd_macsec_offload_on_replay_protect,
14496 (void *)&cmd_macsec_offload_on_rp_on_off,
14501 /* Common result structure for MACsec offload disable */
14502 struct cmd_macsec_offload_off_result {
14503 cmdline_fixed_string_t set;
14504 cmdline_fixed_string_t macsec;
14505 cmdline_fixed_string_t offload;
14507 cmdline_fixed_string_t off;
14510 /* Common CLI fields for MACsec offload disable */
14511 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14512 TOKEN_STRING_INITIALIZER
14513 (struct cmd_macsec_offload_off_result,
14515 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14516 TOKEN_STRING_INITIALIZER
14517 (struct cmd_macsec_offload_off_result,
14519 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14520 TOKEN_STRING_INITIALIZER
14521 (struct cmd_macsec_offload_off_result,
14522 offload, "offload");
14523 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14524 TOKEN_NUM_INITIALIZER
14525 (struct cmd_macsec_offload_off_result,
14527 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14528 TOKEN_STRING_INITIALIZER
14529 (struct cmd_macsec_offload_off_result,
14533 cmd_set_macsec_offload_off_parsed(
14534 void *parsed_result,
14535 __rte_unused struct cmdline *cl,
14536 __rte_unused void *data)
14538 struct cmd_macsec_offload_off_result *res = parsed_result;
14539 int ret = -ENOTSUP;
14540 struct rte_eth_dev_info dev_info;
14541 portid_t port_id = res->port_id;
14543 if (port_id_is_invalid(port_id, ENABLED_WARN))
14545 if (!port_is_stopped(port_id)) {
14546 printf("Please stop port %d first\n", port_id);
14550 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14554 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14555 #ifdef RTE_LIBRTE_IXGBE_PMD
14556 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14561 ports[port_id].dev_conf.txmode.offloads &=
14562 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14563 cmd_reconfig_device_queue(port_id, 1, 1);
14566 printf("invalid port_id %d\n", port_id);
14569 printf("not supported on port %d\n", port_id);
14572 printf("programming error: (%s)\n", strerror(-ret));
14576 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14577 .f = cmd_set_macsec_offload_off_parsed,
14579 .help_str = "set macsec offload <port_id> off",
14581 (void *)&cmd_macsec_offload_off_set,
14582 (void *)&cmd_macsec_offload_off_macsec,
14583 (void *)&cmd_macsec_offload_off_offload,
14584 (void *)&cmd_macsec_offload_off_port_id,
14585 (void *)&cmd_macsec_offload_off_off,
14590 /* Common result structure for MACsec secure connection configure */
14591 struct cmd_macsec_sc_result {
14592 cmdline_fixed_string_t set;
14593 cmdline_fixed_string_t macsec;
14594 cmdline_fixed_string_t sc;
14595 cmdline_fixed_string_t tx_rx;
14597 struct rte_ether_addr mac;
14601 /* Common CLI fields for MACsec secure connection configure */
14602 cmdline_parse_token_string_t cmd_macsec_sc_set =
14603 TOKEN_STRING_INITIALIZER
14604 (struct cmd_macsec_sc_result,
14606 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14607 TOKEN_STRING_INITIALIZER
14608 (struct cmd_macsec_sc_result,
14610 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14611 TOKEN_STRING_INITIALIZER
14612 (struct cmd_macsec_sc_result,
14614 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14615 TOKEN_STRING_INITIALIZER
14616 (struct cmd_macsec_sc_result,
14618 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14619 TOKEN_NUM_INITIALIZER
14620 (struct cmd_macsec_sc_result,
14622 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14623 TOKEN_ETHERADDR_INITIALIZER
14624 (struct cmd_macsec_sc_result,
14626 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14627 TOKEN_NUM_INITIALIZER
14628 (struct cmd_macsec_sc_result,
14632 cmd_set_macsec_sc_parsed(
14633 void *parsed_result,
14634 __rte_unused struct cmdline *cl,
14635 __rte_unused void *data)
14637 struct cmd_macsec_sc_result *res = parsed_result;
14638 int ret = -ENOTSUP;
14639 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14641 #ifdef RTE_LIBRTE_IXGBE_PMD
14643 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14644 res->mac.addr_bytes) :
14645 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14646 res->mac.addr_bytes, res->pi);
14648 RTE_SET_USED(is_tx);
14654 printf("invalid port_id %d\n", res->port_id);
14657 printf("not supported on port %d\n", res->port_id);
14660 printf("programming error: (%s)\n", strerror(-ret));
14664 cmdline_parse_inst_t cmd_set_macsec_sc = {
14665 .f = cmd_set_macsec_sc_parsed,
14667 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14669 (void *)&cmd_macsec_sc_set,
14670 (void *)&cmd_macsec_sc_macsec,
14671 (void *)&cmd_macsec_sc_sc,
14672 (void *)&cmd_macsec_sc_tx_rx,
14673 (void *)&cmd_macsec_sc_port_id,
14674 (void *)&cmd_macsec_sc_mac,
14675 (void *)&cmd_macsec_sc_pi,
14680 /* Common result structure for MACsec secure connection configure */
14681 struct cmd_macsec_sa_result {
14682 cmdline_fixed_string_t set;
14683 cmdline_fixed_string_t macsec;
14684 cmdline_fixed_string_t sa;
14685 cmdline_fixed_string_t tx_rx;
14690 cmdline_fixed_string_t key;
14693 /* Common CLI fields for MACsec secure connection configure */
14694 cmdline_parse_token_string_t cmd_macsec_sa_set =
14695 TOKEN_STRING_INITIALIZER
14696 (struct cmd_macsec_sa_result,
14698 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14699 TOKEN_STRING_INITIALIZER
14700 (struct cmd_macsec_sa_result,
14702 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14703 TOKEN_STRING_INITIALIZER
14704 (struct cmd_macsec_sa_result,
14706 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14707 TOKEN_STRING_INITIALIZER
14708 (struct cmd_macsec_sa_result,
14710 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14711 TOKEN_NUM_INITIALIZER
14712 (struct cmd_macsec_sa_result,
14714 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14715 TOKEN_NUM_INITIALIZER
14716 (struct cmd_macsec_sa_result,
14718 cmdline_parse_token_num_t cmd_macsec_sa_an =
14719 TOKEN_NUM_INITIALIZER
14720 (struct cmd_macsec_sa_result,
14722 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14723 TOKEN_NUM_INITIALIZER
14724 (struct cmd_macsec_sa_result,
14726 cmdline_parse_token_string_t cmd_macsec_sa_key =
14727 TOKEN_STRING_INITIALIZER
14728 (struct cmd_macsec_sa_result,
14732 cmd_set_macsec_sa_parsed(
14733 void *parsed_result,
14734 __rte_unused struct cmdline *cl,
14735 __rte_unused void *data)
14737 struct cmd_macsec_sa_result *res = parsed_result;
14738 int ret = -ENOTSUP;
14739 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14740 uint8_t key[16] = { 0 };
14746 key_len = strlen(res->key) / 2;
14750 for (i = 0; i < key_len; i++) {
14751 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14754 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14757 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14760 #ifdef RTE_LIBRTE_IXGBE_PMD
14762 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14763 res->idx, res->an, res->pn, key) :
14764 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14765 res->idx, res->an, res->pn, key);
14767 RTE_SET_USED(is_tx);
14774 printf("invalid idx %d or an %d\n", res->idx, res->an);
14777 printf("invalid port_id %d\n", res->port_id);
14780 printf("not supported on port %d\n", res->port_id);
14783 printf("programming error: (%s)\n", strerror(-ret));
14787 cmdline_parse_inst_t cmd_set_macsec_sa = {
14788 .f = cmd_set_macsec_sa_parsed,
14790 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14792 (void *)&cmd_macsec_sa_set,
14793 (void *)&cmd_macsec_sa_macsec,
14794 (void *)&cmd_macsec_sa_sa,
14795 (void *)&cmd_macsec_sa_tx_rx,
14796 (void *)&cmd_macsec_sa_port_id,
14797 (void *)&cmd_macsec_sa_idx,
14798 (void *)&cmd_macsec_sa_an,
14799 (void *)&cmd_macsec_sa_pn,
14800 (void *)&cmd_macsec_sa_key,
14805 /* VF unicast promiscuous mode configuration */
14807 /* Common result structure for VF unicast promiscuous mode */
14808 struct cmd_vf_promisc_result {
14809 cmdline_fixed_string_t set;
14810 cmdline_fixed_string_t vf;
14811 cmdline_fixed_string_t promisc;
14814 cmdline_fixed_string_t on_off;
14817 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14818 cmdline_parse_token_string_t cmd_vf_promisc_set =
14819 TOKEN_STRING_INITIALIZER
14820 (struct cmd_vf_promisc_result,
14822 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14823 TOKEN_STRING_INITIALIZER
14824 (struct cmd_vf_promisc_result,
14826 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14827 TOKEN_STRING_INITIALIZER
14828 (struct cmd_vf_promisc_result,
14829 promisc, "promisc");
14830 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14831 TOKEN_NUM_INITIALIZER
14832 (struct cmd_vf_promisc_result,
14834 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14835 TOKEN_NUM_INITIALIZER
14836 (struct cmd_vf_promisc_result,
14838 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14839 TOKEN_STRING_INITIALIZER
14840 (struct cmd_vf_promisc_result,
14844 cmd_set_vf_promisc_parsed(
14845 void *parsed_result,
14846 __rte_unused struct cmdline *cl,
14847 __rte_unused void *data)
14849 struct cmd_vf_promisc_result *res = parsed_result;
14850 int ret = -ENOTSUP;
14852 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14854 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14857 #ifdef RTE_LIBRTE_I40E_PMD
14858 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14859 res->vf_id, is_on);
14866 printf("invalid vf_id %d\n", res->vf_id);
14869 printf("invalid port_id %d\n", res->port_id);
14872 printf("function not implemented\n");
14875 printf("programming error: (%s)\n", strerror(-ret));
14879 cmdline_parse_inst_t cmd_set_vf_promisc = {
14880 .f = cmd_set_vf_promisc_parsed,
14882 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14883 "Set unicast promiscuous mode for a VF from the PF",
14885 (void *)&cmd_vf_promisc_set,
14886 (void *)&cmd_vf_promisc_vf,
14887 (void *)&cmd_vf_promisc_promisc,
14888 (void *)&cmd_vf_promisc_port_id,
14889 (void *)&cmd_vf_promisc_vf_id,
14890 (void *)&cmd_vf_promisc_on_off,
14895 /* VF multicast promiscuous mode configuration */
14897 /* Common result structure for VF multicast promiscuous mode */
14898 struct cmd_vf_allmulti_result {
14899 cmdline_fixed_string_t set;
14900 cmdline_fixed_string_t vf;
14901 cmdline_fixed_string_t allmulti;
14904 cmdline_fixed_string_t on_off;
14907 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14908 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14909 TOKEN_STRING_INITIALIZER
14910 (struct cmd_vf_allmulti_result,
14912 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14913 TOKEN_STRING_INITIALIZER
14914 (struct cmd_vf_allmulti_result,
14916 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14917 TOKEN_STRING_INITIALIZER
14918 (struct cmd_vf_allmulti_result,
14919 allmulti, "allmulti");
14920 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14921 TOKEN_NUM_INITIALIZER
14922 (struct cmd_vf_allmulti_result,
14924 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14925 TOKEN_NUM_INITIALIZER
14926 (struct cmd_vf_allmulti_result,
14928 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14929 TOKEN_STRING_INITIALIZER
14930 (struct cmd_vf_allmulti_result,
14934 cmd_set_vf_allmulti_parsed(
14935 void *parsed_result,
14936 __rte_unused struct cmdline *cl,
14937 __rte_unused void *data)
14939 struct cmd_vf_allmulti_result *res = parsed_result;
14940 int ret = -ENOTSUP;
14942 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14944 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14947 #ifdef RTE_LIBRTE_I40E_PMD
14948 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14949 res->vf_id, is_on);
14956 printf("invalid vf_id %d\n", res->vf_id);
14959 printf("invalid port_id %d\n", res->port_id);
14962 printf("function not implemented\n");
14965 printf("programming error: (%s)\n", strerror(-ret));
14969 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14970 .f = cmd_set_vf_allmulti_parsed,
14972 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14973 "Set multicast promiscuous mode for a VF from the PF",
14975 (void *)&cmd_vf_allmulti_set,
14976 (void *)&cmd_vf_allmulti_vf,
14977 (void *)&cmd_vf_allmulti_allmulti,
14978 (void *)&cmd_vf_allmulti_port_id,
14979 (void *)&cmd_vf_allmulti_vf_id,
14980 (void *)&cmd_vf_allmulti_on_off,
14985 /* vf broadcast mode configuration */
14987 /* Common result structure for vf broadcast */
14988 struct cmd_set_vf_broadcast_result {
14989 cmdline_fixed_string_t set;
14990 cmdline_fixed_string_t vf;
14991 cmdline_fixed_string_t broadcast;
14994 cmdline_fixed_string_t on_off;
14997 /* Common CLI fields for vf broadcast enable disable */
14998 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14999 TOKEN_STRING_INITIALIZER
15000 (struct cmd_set_vf_broadcast_result,
15002 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
15003 TOKEN_STRING_INITIALIZER
15004 (struct cmd_set_vf_broadcast_result,
15006 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
15007 TOKEN_STRING_INITIALIZER
15008 (struct cmd_set_vf_broadcast_result,
15009 broadcast, "broadcast");
15010 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
15011 TOKEN_NUM_INITIALIZER
15012 (struct cmd_set_vf_broadcast_result,
15014 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
15015 TOKEN_NUM_INITIALIZER
15016 (struct cmd_set_vf_broadcast_result,
15018 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
15019 TOKEN_STRING_INITIALIZER
15020 (struct cmd_set_vf_broadcast_result,
15024 cmd_set_vf_broadcast_parsed(
15025 void *parsed_result,
15026 __rte_unused struct cmdline *cl,
15027 __rte_unused void *data)
15029 struct cmd_set_vf_broadcast_result *res = parsed_result;
15030 int ret = -ENOTSUP;
15032 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15034 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15037 #ifdef RTE_LIBRTE_I40E_PMD
15038 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
15039 res->vf_id, is_on);
15046 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15049 printf("invalid port_id %d\n", res->port_id);
15052 printf("function not implemented\n");
15055 printf("programming error: (%s)\n", strerror(-ret));
15059 cmdline_parse_inst_t cmd_set_vf_broadcast = {
15060 .f = cmd_set_vf_broadcast_parsed,
15062 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
15064 (void *)&cmd_set_vf_broadcast_set,
15065 (void *)&cmd_set_vf_broadcast_vf,
15066 (void *)&cmd_set_vf_broadcast_broadcast,
15067 (void *)&cmd_set_vf_broadcast_port_id,
15068 (void *)&cmd_set_vf_broadcast_vf_id,
15069 (void *)&cmd_set_vf_broadcast_on_off,
15074 /* vf vlan tag configuration */
15076 /* Common result structure for vf vlan tag */
15077 struct cmd_set_vf_vlan_tag_result {
15078 cmdline_fixed_string_t set;
15079 cmdline_fixed_string_t vf;
15080 cmdline_fixed_string_t vlan;
15081 cmdline_fixed_string_t tag;
15084 cmdline_fixed_string_t on_off;
15087 /* Common CLI fields for vf vlan tag enable disable */
15088 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
15089 TOKEN_STRING_INITIALIZER
15090 (struct cmd_set_vf_vlan_tag_result,
15092 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
15093 TOKEN_STRING_INITIALIZER
15094 (struct cmd_set_vf_vlan_tag_result,
15096 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
15097 TOKEN_STRING_INITIALIZER
15098 (struct cmd_set_vf_vlan_tag_result,
15100 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
15101 TOKEN_STRING_INITIALIZER
15102 (struct cmd_set_vf_vlan_tag_result,
15104 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
15105 TOKEN_NUM_INITIALIZER
15106 (struct cmd_set_vf_vlan_tag_result,
15108 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
15109 TOKEN_NUM_INITIALIZER
15110 (struct cmd_set_vf_vlan_tag_result,
15112 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
15113 TOKEN_STRING_INITIALIZER
15114 (struct cmd_set_vf_vlan_tag_result,
15118 cmd_set_vf_vlan_tag_parsed(
15119 void *parsed_result,
15120 __rte_unused struct cmdline *cl,
15121 __rte_unused void *data)
15123 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
15124 int ret = -ENOTSUP;
15126 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15128 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15131 #ifdef RTE_LIBRTE_I40E_PMD
15132 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
15133 res->vf_id, is_on);
15140 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15143 printf("invalid port_id %d\n", res->port_id);
15146 printf("function not implemented\n");
15149 printf("programming error: (%s)\n", strerror(-ret));
15153 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
15154 .f = cmd_set_vf_vlan_tag_parsed,
15156 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
15158 (void *)&cmd_set_vf_vlan_tag_set,
15159 (void *)&cmd_set_vf_vlan_tag_vf,
15160 (void *)&cmd_set_vf_vlan_tag_vlan,
15161 (void *)&cmd_set_vf_vlan_tag_tag,
15162 (void *)&cmd_set_vf_vlan_tag_port_id,
15163 (void *)&cmd_set_vf_vlan_tag_vf_id,
15164 (void *)&cmd_set_vf_vlan_tag_on_off,
15169 /* Common definition of VF and TC TX bandwidth configuration */
15170 struct cmd_vf_tc_bw_result {
15171 cmdline_fixed_string_t set;
15172 cmdline_fixed_string_t vf;
15173 cmdline_fixed_string_t tc;
15174 cmdline_fixed_string_t tx;
15175 cmdline_fixed_string_t min_bw;
15176 cmdline_fixed_string_t max_bw;
15177 cmdline_fixed_string_t strict_link_prio;
15182 cmdline_fixed_string_t bw_list;
15186 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
15187 TOKEN_STRING_INITIALIZER
15188 (struct cmd_vf_tc_bw_result,
15190 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
15191 TOKEN_STRING_INITIALIZER
15192 (struct cmd_vf_tc_bw_result,
15194 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
15195 TOKEN_STRING_INITIALIZER
15196 (struct cmd_vf_tc_bw_result,
15198 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
15199 TOKEN_STRING_INITIALIZER
15200 (struct cmd_vf_tc_bw_result,
15202 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
15203 TOKEN_STRING_INITIALIZER
15204 (struct cmd_vf_tc_bw_result,
15205 strict_link_prio, "strict-link-priority");
15206 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
15207 TOKEN_STRING_INITIALIZER
15208 (struct cmd_vf_tc_bw_result,
15209 min_bw, "min-bandwidth");
15210 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
15211 TOKEN_STRING_INITIALIZER
15212 (struct cmd_vf_tc_bw_result,
15213 max_bw, "max-bandwidth");
15214 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
15215 TOKEN_NUM_INITIALIZER
15216 (struct cmd_vf_tc_bw_result,
15218 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
15219 TOKEN_NUM_INITIALIZER
15220 (struct cmd_vf_tc_bw_result,
15222 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
15223 TOKEN_NUM_INITIALIZER
15224 (struct cmd_vf_tc_bw_result,
15226 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
15227 TOKEN_NUM_INITIALIZER
15228 (struct cmd_vf_tc_bw_result,
15230 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
15231 TOKEN_STRING_INITIALIZER
15232 (struct cmd_vf_tc_bw_result,
15234 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
15235 TOKEN_NUM_INITIALIZER
15236 (struct cmd_vf_tc_bw_result,
15239 /* VF max bandwidth setting */
15241 cmd_vf_max_bw_parsed(
15242 void *parsed_result,
15243 __rte_unused struct cmdline *cl,
15244 __rte_unused void *data)
15246 struct cmd_vf_tc_bw_result *res = parsed_result;
15247 int ret = -ENOTSUP;
15249 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15252 #ifdef RTE_LIBRTE_I40E_PMD
15253 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15254 res->vf_id, res->bw);
15261 printf("invalid vf_id %d or bandwidth %d\n",
15262 res->vf_id, res->bw);
15265 printf("invalid port_id %d\n", res->port_id);
15268 printf("function not implemented\n");
15271 printf("programming error: (%s)\n", strerror(-ret));
15275 cmdline_parse_inst_t cmd_vf_max_bw = {
15276 .f = cmd_vf_max_bw_parsed,
15278 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15280 (void *)&cmd_vf_tc_bw_set,
15281 (void *)&cmd_vf_tc_bw_vf,
15282 (void *)&cmd_vf_tc_bw_tx,
15283 (void *)&cmd_vf_tc_bw_max_bw,
15284 (void *)&cmd_vf_tc_bw_port_id,
15285 (void *)&cmd_vf_tc_bw_vf_id,
15286 (void *)&cmd_vf_tc_bw_bw,
15292 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15297 const char *p, *p0 = str;
15304 p = strchr(p0, '(');
15306 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15310 p0 = strchr(p, ')');
15312 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15316 if (size >= sizeof(s)) {
15317 printf("The string size exceeds the internal buffer size\n");
15320 snprintf(s, sizeof(s), "%.*s", size, p);
15321 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15323 printf("Failed to get the bandwidth list. ");
15327 for (i = 0; i < ret; i++)
15328 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15333 /* TC min bandwidth setting */
15335 cmd_vf_tc_min_bw_parsed(
15336 void *parsed_result,
15337 __rte_unused struct cmdline *cl,
15338 __rte_unused void *data)
15340 struct cmd_vf_tc_bw_result *res = parsed_result;
15343 int ret = -ENOTSUP;
15345 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15348 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15352 #ifdef RTE_LIBRTE_I40E_PMD
15353 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15361 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15364 printf("invalid port_id %d\n", res->port_id);
15367 printf("function not implemented\n");
15370 printf("programming error: (%s)\n", strerror(-ret));
15374 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15375 .f = cmd_vf_tc_min_bw_parsed,
15377 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15378 " <bw1, bw2, ...>",
15380 (void *)&cmd_vf_tc_bw_set,
15381 (void *)&cmd_vf_tc_bw_vf,
15382 (void *)&cmd_vf_tc_bw_tc,
15383 (void *)&cmd_vf_tc_bw_tx,
15384 (void *)&cmd_vf_tc_bw_min_bw,
15385 (void *)&cmd_vf_tc_bw_port_id,
15386 (void *)&cmd_vf_tc_bw_vf_id,
15387 (void *)&cmd_vf_tc_bw_bw_list,
15393 cmd_tc_min_bw_parsed(
15394 void *parsed_result,
15395 __rte_unused struct cmdline *cl,
15396 __rte_unused void *data)
15398 struct cmd_vf_tc_bw_result *res = parsed_result;
15399 struct rte_port *port;
15402 int ret = -ENOTSUP;
15404 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15407 port = &ports[res->port_id];
15408 /** Check if the port is not started **/
15409 if (port->port_status != RTE_PORT_STOPPED) {
15410 printf("Please stop port %d first\n", res->port_id);
15414 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15418 #ifdef RTE_LIBRTE_IXGBE_PMD
15419 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15426 printf("invalid bandwidth\n");
15429 printf("invalid port_id %d\n", res->port_id);
15432 printf("function not implemented\n");
15435 printf("programming error: (%s)\n", strerror(-ret));
15439 cmdline_parse_inst_t cmd_tc_min_bw = {
15440 .f = cmd_tc_min_bw_parsed,
15442 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15444 (void *)&cmd_vf_tc_bw_set,
15445 (void *)&cmd_vf_tc_bw_tc,
15446 (void *)&cmd_vf_tc_bw_tx,
15447 (void *)&cmd_vf_tc_bw_min_bw,
15448 (void *)&cmd_vf_tc_bw_port_id,
15449 (void *)&cmd_vf_tc_bw_bw_list,
15454 /* TC max bandwidth setting */
15456 cmd_vf_tc_max_bw_parsed(
15457 void *parsed_result,
15458 __rte_unused struct cmdline *cl,
15459 __rte_unused void *data)
15461 struct cmd_vf_tc_bw_result *res = parsed_result;
15462 int ret = -ENOTSUP;
15464 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15467 #ifdef RTE_LIBRTE_I40E_PMD
15468 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15469 res->tc_no, res->bw);
15476 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15477 res->vf_id, res->tc_no, res->bw);
15480 printf("invalid port_id %d\n", res->port_id);
15483 printf("function not implemented\n");
15486 printf("programming error: (%s)\n", strerror(-ret));
15490 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15491 .f = cmd_vf_tc_max_bw_parsed,
15493 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15496 (void *)&cmd_vf_tc_bw_set,
15497 (void *)&cmd_vf_tc_bw_vf,
15498 (void *)&cmd_vf_tc_bw_tc,
15499 (void *)&cmd_vf_tc_bw_tx,
15500 (void *)&cmd_vf_tc_bw_max_bw,
15501 (void *)&cmd_vf_tc_bw_port_id,
15502 (void *)&cmd_vf_tc_bw_vf_id,
15503 (void *)&cmd_vf_tc_bw_tc_no,
15504 (void *)&cmd_vf_tc_bw_bw,
15509 /** Set VXLAN encapsulation details */
15510 struct cmd_set_vxlan_result {
15511 cmdline_fixed_string_t set;
15512 cmdline_fixed_string_t vxlan;
15513 cmdline_fixed_string_t pos_token;
15514 cmdline_fixed_string_t ip_version;
15515 uint32_t vlan_present:1;
15519 cmdline_ipaddr_t ip_src;
15520 cmdline_ipaddr_t ip_dst;
15524 struct rte_ether_addr eth_src;
15525 struct rte_ether_addr eth_dst;
15528 cmdline_parse_token_string_t cmd_set_vxlan_set =
15529 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15530 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15531 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15532 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15533 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15535 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15536 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15537 "vxlan-with-vlan");
15538 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15539 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15541 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15542 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15544 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15545 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15547 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15548 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15549 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15550 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15552 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15553 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15554 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15555 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15557 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15558 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15559 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15560 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15562 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15563 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15564 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15565 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15567 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15568 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15569 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15570 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15572 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15573 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15574 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15575 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15577 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15578 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15579 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15580 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15582 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15583 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15584 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15585 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15587 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15588 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15589 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15590 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15592 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15593 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15595 static void cmd_set_vxlan_parsed(void *parsed_result,
15596 __rte_unused struct cmdline *cl,
15597 __rte_unused void *data)
15599 struct cmd_set_vxlan_result *res = parsed_result;
15604 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15607 vxlan_encap_conf.select_tos_ttl = 0;
15608 if (strcmp(res->vxlan, "vxlan") == 0)
15609 vxlan_encap_conf.select_vlan = 0;
15610 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15611 vxlan_encap_conf.select_vlan = 1;
15612 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15613 vxlan_encap_conf.select_vlan = 0;
15614 vxlan_encap_conf.select_tos_ttl = 1;
15616 if (strcmp(res->ip_version, "ipv4") == 0)
15617 vxlan_encap_conf.select_ipv4 = 1;
15618 else if (strcmp(res->ip_version, "ipv6") == 0)
15619 vxlan_encap_conf.select_ipv4 = 0;
15622 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15623 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15624 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15625 vxlan_encap_conf.ip_tos = res->tos;
15626 vxlan_encap_conf.ip_ttl = res->ttl;
15627 if (vxlan_encap_conf.select_ipv4) {
15628 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15629 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15631 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15632 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15634 if (vxlan_encap_conf.select_vlan)
15635 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15636 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15637 RTE_ETHER_ADDR_LEN);
15638 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15639 RTE_ETHER_ADDR_LEN);
15642 cmdline_parse_inst_t cmd_set_vxlan = {
15643 .f = cmd_set_vxlan_parsed,
15645 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15646 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15647 " eth-src <eth-src> eth-dst <eth-dst>",
15649 (void *)&cmd_set_vxlan_set,
15650 (void *)&cmd_set_vxlan_vxlan,
15651 (void *)&cmd_set_vxlan_ip_version,
15652 (void *)&cmd_set_vxlan_ip_version_value,
15653 (void *)&cmd_set_vxlan_vni,
15654 (void *)&cmd_set_vxlan_vni_value,
15655 (void *)&cmd_set_vxlan_udp_src,
15656 (void *)&cmd_set_vxlan_udp_src_value,
15657 (void *)&cmd_set_vxlan_udp_dst,
15658 (void *)&cmd_set_vxlan_udp_dst_value,
15659 (void *)&cmd_set_vxlan_ip_src,
15660 (void *)&cmd_set_vxlan_ip_src_value,
15661 (void *)&cmd_set_vxlan_ip_dst,
15662 (void *)&cmd_set_vxlan_ip_dst_value,
15663 (void *)&cmd_set_vxlan_eth_src,
15664 (void *)&cmd_set_vxlan_eth_src_value,
15665 (void *)&cmd_set_vxlan_eth_dst,
15666 (void *)&cmd_set_vxlan_eth_dst_value,
15671 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15672 .f = cmd_set_vxlan_parsed,
15674 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15675 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15676 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15677 " eth-dst <eth-dst>",
15679 (void *)&cmd_set_vxlan_set,
15680 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15681 (void *)&cmd_set_vxlan_ip_version,
15682 (void *)&cmd_set_vxlan_ip_version_value,
15683 (void *)&cmd_set_vxlan_vni,
15684 (void *)&cmd_set_vxlan_vni_value,
15685 (void *)&cmd_set_vxlan_udp_src,
15686 (void *)&cmd_set_vxlan_udp_src_value,
15687 (void *)&cmd_set_vxlan_udp_dst,
15688 (void *)&cmd_set_vxlan_udp_dst_value,
15689 (void *)&cmd_set_vxlan_ip_tos,
15690 (void *)&cmd_set_vxlan_ip_tos_value,
15691 (void *)&cmd_set_vxlan_ip_ttl,
15692 (void *)&cmd_set_vxlan_ip_ttl_value,
15693 (void *)&cmd_set_vxlan_ip_src,
15694 (void *)&cmd_set_vxlan_ip_src_value,
15695 (void *)&cmd_set_vxlan_ip_dst,
15696 (void *)&cmd_set_vxlan_ip_dst_value,
15697 (void *)&cmd_set_vxlan_eth_src,
15698 (void *)&cmd_set_vxlan_eth_src_value,
15699 (void *)&cmd_set_vxlan_eth_dst,
15700 (void *)&cmd_set_vxlan_eth_dst_value,
15705 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15706 .f = cmd_set_vxlan_parsed,
15708 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15709 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15710 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15713 (void *)&cmd_set_vxlan_set,
15714 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15715 (void *)&cmd_set_vxlan_ip_version,
15716 (void *)&cmd_set_vxlan_ip_version_value,
15717 (void *)&cmd_set_vxlan_vni,
15718 (void *)&cmd_set_vxlan_vni_value,
15719 (void *)&cmd_set_vxlan_udp_src,
15720 (void *)&cmd_set_vxlan_udp_src_value,
15721 (void *)&cmd_set_vxlan_udp_dst,
15722 (void *)&cmd_set_vxlan_udp_dst_value,
15723 (void *)&cmd_set_vxlan_ip_src,
15724 (void *)&cmd_set_vxlan_ip_src_value,
15725 (void *)&cmd_set_vxlan_ip_dst,
15726 (void *)&cmd_set_vxlan_ip_dst_value,
15727 (void *)&cmd_set_vxlan_vlan,
15728 (void *)&cmd_set_vxlan_vlan_value,
15729 (void *)&cmd_set_vxlan_eth_src,
15730 (void *)&cmd_set_vxlan_eth_src_value,
15731 (void *)&cmd_set_vxlan_eth_dst,
15732 (void *)&cmd_set_vxlan_eth_dst_value,
15737 /** Set NVGRE encapsulation details */
15738 struct cmd_set_nvgre_result {
15739 cmdline_fixed_string_t set;
15740 cmdline_fixed_string_t nvgre;
15741 cmdline_fixed_string_t pos_token;
15742 cmdline_fixed_string_t ip_version;
15744 cmdline_ipaddr_t ip_src;
15745 cmdline_ipaddr_t ip_dst;
15747 struct rte_ether_addr eth_src;
15748 struct rte_ether_addr eth_dst;
15751 cmdline_parse_token_string_t cmd_set_nvgre_set =
15752 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15753 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15754 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15755 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15756 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15757 "nvgre-with-vlan");
15758 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15759 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15761 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15762 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15764 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15765 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15767 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15768 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15769 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15770 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15772 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15773 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15774 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15775 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15777 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15778 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15779 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15780 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15782 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15783 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15784 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15785 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15787 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15788 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15789 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15790 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15792 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15793 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15795 static void cmd_set_nvgre_parsed(void *parsed_result,
15796 __rte_unused struct cmdline *cl,
15797 __rte_unused void *data)
15799 struct cmd_set_nvgre_result *res = parsed_result;
15801 uint32_t nvgre_tni;
15804 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15807 if (strcmp(res->nvgre, "nvgre") == 0)
15808 nvgre_encap_conf.select_vlan = 0;
15809 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15810 nvgre_encap_conf.select_vlan = 1;
15811 if (strcmp(res->ip_version, "ipv4") == 0)
15812 nvgre_encap_conf.select_ipv4 = 1;
15813 else if (strcmp(res->ip_version, "ipv6") == 0)
15814 nvgre_encap_conf.select_ipv4 = 0;
15817 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15818 if (nvgre_encap_conf.select_ipv4) {
15819 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15820 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15822 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15823 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15825 if (nvgre_encap_conf.select_vlan)
15826 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15827 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15828 RTE_ETHER_ADDR_LEN);
15829 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15830 RTE_ETHER_ADDR_LEN);
15833 cmdline_parse_inst_t cmd_set_nvgre = {
15834 .f = cmd_set_nvgre_parsed,
15836 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15837 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15838 " eth-dst <eth-dst>",
15840 (void *)&cmd_set_nvgre_set,
15841 (void *)&cmd_set_nvgre_nvgre,
15842 (void *)&cmd_set_nvgre_ip_version,
15843 (void *)&cmd_set_nvgre_ip_version_value,
15844 (void *)&cmd_set_nvgre_tni,
15845 (void *)&cmd_set_nvgre_tni_value,
15846 (void *)&cmd_set_nvgre_ip_src,
15847 (void *)&cmd_set_nvgre_ip_src_value,
15848 (void *)&cmd_set_nvgre_ip_dst,
15849 (void *)&cmd_set_nvgre_ip_dst_value,
15850 (void *)&cmd_set_nvgre_eth_src,
15851 (void *)&cmd_set_nvgre_eth_src_value,
15852 (void *)&cmd_set_nvgre_eth_dst,
15853 (void *)&cmd_set_nvgre_eth_dst_value,
15858 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15859 .f = cmd_set_nvgre_parsed,
15861 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15862 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15863 " eth-src <eth-src> eth-dst <eth-dst>",
15865 (void *)&cmd_set_nvgre_set,
15866 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15867 (void *)&cmd_set_nvgre_ip_version,
15868 (void *)&cmd_set_nvgre_ip_version_value,
15869 (void *)&cmd_set_nvgre_tni,
15870 (void *)&cmd_set_nvgre_tni_value,
15871 (void *)&cmd_set_nvgre_ip_src,
15872 (void *)&cmd_set_nvgre_ip_src_value,
15873 (void *)&cmd_set_nvgre_ip_dst,
15874 (void *)&cmd_set_nvgre_ip_dst_value,
15875 (void *)&cmd_set_nvgre_vlan,
15876 (void *)&cmd_set_nvgre_vlan_value,
15877 (void *)&cmd_set_nvgre_eth_src,
15878 (void *)&cmd_set_nvgre_eth_src_value,
15879 (void *)&cmd_set_nvgre_eth_dst,
15880 (void *)&cmd_set_nvgre_eth_dst_value,
15885 /** Set L2 encapsulation details */
15886 struct cmd_set_l2_encap_result {
15887 cmdline_fixed_string_t set;
15888 cmdline_fixed_string_t l2_encap;
15889 cmdline_fixed_string_t pos_token;
15890 cmdline_fixed_string_t ip_version;
15891 uint32_t vlan_present:1;
15893 struct rte_ether_addr eth_src;
15894 struct rte_ether_addr eth_dst;
15897 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15898 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15899 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15900 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15901 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15902 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15903 "l2_encap-with-vlan");
15904 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15905 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15907 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15908 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15910 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15911 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15913 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15914 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15915 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15916 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15918 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15919 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15920 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15921 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15923 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15924 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15926 static void cmd_set_l2_encap_parsed(void *parsed_result,
15927 __rte_unused struct cmdline *cl,
15928 __rte_unused void *data)
15930 struct cmd_set_l2_encap_result *res = parsed_result;
15932 if (strcmp(res->l2_encap, "l2_encap") == 0)
15933 l2_encap_conf.select_vlan = 0;
15934 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15935 l2_encap_conf.select_vlan = 1;
15936 if (strcmp(res->ip_version, "ipv4") == 0)
15937 l2_encap_conf.select_ipv4 = 1;
15938 else if (strcmp(res->ip_version, "ipv6") == 0)
15939 l2_encap_conf.select_ipv4 = 0;
15942 if (l2_encap_conf.select_vlan)
15943 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15944 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15945 RTE_ETHER_ADDR_LEN);
15946 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15947 RTE_ETHER_ADDR_LEN);
15950 cmdline_parse_inst_t cmd_set_l2_encap = {
15951 .f = cmd_set_l2_encap_parsed,
15953 .help_str = "set l2_encap ip-version ipv4|ipv6"
15954 " eth-src <eth-src> eth-dst <eth-dst>",
15956 (void *)&cmd_set_l2_encap_set,
15957 (void *)&cmd_set_l2_encap_l2_encap,
15958 (void *)&cmd_set_l2_encap_ip_version,
15959 (void *)&cmd_set_l2_encap_ip_version_value,
15960 (void *)&cmd_set_l2_encap_eth_src,
15961 (void *)&cmd_set_l2_encap_eth_src_value,
15962 (void *)&cmd_set_l2_encap_eth_dst,
15963 (void *)&cmd_set_l2_encap_eth_dst_value,
15968 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15969 .f = cmd_set_l2_encap_parsed,
15971 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15972 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15974 (void *)&cmd_set_l2_encap_set,
15975 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15976 (void *)&cmd_set_l2_encap_ip_version,
15977 (void *)&cmd_set_l2_encap_ip_version_value,
15978 (void *)&cmd_set_l2_encap_vlan,
15979 (void *)&cmd_set_l2_encap_vlan_value,
15980 (void *)&cmd_set_l2_encap_eth_src,
15981 (void *)&cmd_set_l2_encap_eth_src_value,
15982 (void *)&cmd_set_l2_encap_eth_dst,
15983 (void *)&cmd_set_l2_encap_eth_dst_value,
15988 /** Set L2 decapsulation details */
15989 struct cmd_set_l2_decap_result {
15990 cmdline_fixed_string_t set;
15991 cmdline_fixed_string_t l2_decap;
15992 cmdline_fixed_string_t pos_token;
15993 uint32_t vlan_present:1;
15996 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15997 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15998 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15999 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
16001 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
16002 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
16003 "l2_decap-with-vlan");
16005 static void cmd_set_l2_decap_parsed(void *parsed_result,
16006 __rte_unused struct cmdline *cl,
16007 __rte_unused void *data)
16009 struct cmd_set_l2_decap_result *res = parsed_result;
16011 if (strcmp(res->l2_decap, "l2_decap") == 0)
16012 l2_decap_conf.select_vlan = 0;
16013 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
16014 l2_decap_conf.select_vlan = 1;
16017 cmdline_parse_inst_t cmd_set_l2_decap = {
16018 .f = cmd_set_l2_decap_parsed,
16020 .help_str = "set l2_decap",
16022 (void *)&cmd_set_l2_decap_set,
16023 (void *)&cmd_set_l2_decap_l2_decap,
16028 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
16029 .f = cmd_set_l2_decap_parsed,
16031 .help_str = "set l2_decap-with-vlan",
16033 (void *)&cmd_set_l2_decap_set,
16034 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
16039 /** Set MPLSoGRE encapsulation details */
16040 struct cmd_set_mplsogre_encap_result {
16041 cmdline_fixed_string_t set;
16042 cmdline_fixed_string_t mplsogre;
16043 cmdline_fixed_string_t pos_token;
16044 cmdline_fixed_string_t ip_version;
16045 uint32_t vlan_present:1;
16047 cmdline_ipaddr_t ip_src;
16048 cmdline_ipaddr_t ip_dst;
16050 struct rte_ether_addr eth_src;
16051 struct rte_ether_addr eth_dst;
16054 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
16055 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
16057 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
16058 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
16060 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
16061 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16062 mplsogre, "mplsogre_encap-with-vlan");
16063 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
16064 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16065 pos_token, "ip-version");
16066 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
16067 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16068 ip_version, "ipv4#ipv6");
16069 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
16070 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16071 pos_token, "label");
16072 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
16073 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
16075 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
16076 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16077 pos_token, "ip-src");
16078 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
16079 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
16080 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
16081 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16082 pos_token, "ip-dst");
16083 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
16084 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
16085 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
16086 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16087 pos_token, "vlan-tci");
16088 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
16089 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
16091 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
16092 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16093 pos_token, "eth-src");
16094 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
16095 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16097 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
16098 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16099 pos_token, "eth-dst");
16100 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
16101 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16104 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
16105 __rte_unused struct cmdline *cl,
16106 __rte_unused void *data)
16108 struct cmd_set_mplsogre_encap_result *res = parsed_result;
16110 uint32_t mplsogre_label;
16113 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
16116 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
16117 mplsogre_encap_conf.select_vlan = 0;
16118 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
16119 mplsogre_encap_conf.select_vlan = 1;
16120 if (strcmp(res->ip_version, "ipv4") == 0)
16121 mplsogre_encap_conf.select_ipv4 = 1;
16122 else if (strcmp(res->ip_version, "ipv6") == 0)
16123 mplsogre_encap_conf.select_ipv4 = 0;
16126 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
16127 if (mplsogre_encap_conf.select_ipv4) {
16128 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
16129 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
16131 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
16132 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
16134 if (mplsogre_encap_conf.select_vlan)
16135 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16136 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
16137 RTE_ETHER_ADDR_LEN);
16138 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16139 RTE_ETHER_ADDR_LEN);
16142 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
16143 .f = cmd_set_mplsogre_encap_parsed,
16145 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
16146 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
16147 " eth-dst <eth-dst>",
16149 (void *)&cmd_set_mplsogre_encap_set,
16150 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
16151 (void *)&cmd_set_mplsogre_encap_ip_version,
16152 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16153 (void *)&cmd_set_mplsogre_encap_label,
16154 (void *)&cmd_set_mplsogre_encap_label_value,
16155 (void *)&cmd_set_mplsogre_encap_ip_src,
16156 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16157 (void *)&cmd_set_mplsogre_encap_ip_dst,
16158 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16159 (void *)&cmd_set_mplsogre_encap_eth_src,
16160 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16161 (void *)&cmd_set_mplsogre_encap_eth_dst,
16162 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16167 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16168 .f = cmd_set_mplsogre_encap_parsed,
16170 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16171 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16172 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16174 (void *)&cmd_set_mplsogre_encap_set,
16175 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16176 (void *)&cmd_set_mplsogre_encap_ip_version,
16177 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16178 (void *)&cmd_set_mplsogre_encap_label,
16179 (void *)&cmd_set_mplsogre_encap_label_value,
16180 (void *)&cmd_set_mplsogre_encap_ip_src,
16181 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16182 (void *)&cmd_set_mplsogre_encap_ip_dst,
16183 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16184 (void *)&cmd_set_mplsogre_encap_vlan,
16185 (void *)&cmd_set_mplsogre_encap_vlan_value,
16186 (void *)&cmd_set_mplsogre_encap_eth_src,
16187 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16188 (void *)&cmd_set_mplsogre_encap_eth_dst,
16189 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16194 /** Set MPLSoGRE decapsulation details */
16195 struct cmd_set_mplsogre_decap_result {
16196 cmdline_fixed_string_t set;
16197 cmdline_fixed_string_t mplsogre;
16198 cmdline_fixed_string_t pos_token;
16199 cmdline_fixed_string_t ip_version;
16200 uint32_t vlan_present:1;
16203 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16204 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16206 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16207 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16209 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16210 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16211 mplsogre, "mplsogre_decap-with-vlan");
16212 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16213 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16214 pos_token, "ip-version");
16215 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16216 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16217 ip_version, "ipv4#ipv6");
16219 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16220 __rte_unused struct cmdline *cl,
16221 __rte_unused void *data)
16223 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16225 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16226 mplsogre_decap_conf.select_vlan = 0;
16227 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16228 mplsogre_decap_conf.select_vlan = 1;
16229 if (strcmp(res->ip_version, "ipv4") == 0)
16230 mplsogre_decap_conf.select_ipv4 = 1;
16231 else if (strcmp(res->ip_version, "ipv6") == 0)
16232 mplsogre_decap_conf.select_ipv4 = 0;
16235 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16236 .f = cmd_set_mplsogre_decap_parsed,
16238 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16240 (void *)&cmd_set_mplsogre_decap_set,
16241 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16242 (void *)&cmd_set_mplsogre_decap_ip_version,
16243 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16248 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16249 .f = cmd_set_mplsogre_decap_parsed,
16251 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16253 (void *)&cmd_set_mplsogre_decap_set,
16254 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16255 (void *)&cmd_set_mplsogre_decap_ip_version,
16256 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16261 /** Set MPLSoUDP encapsulation details */
16262 struct cmd_set_mplsoudp_encap_result {
16263 cmdline_fixed_string_t set;
16264 cmdline_fixed_string_t mplsoudp;
16265 cmdline_fixed_string_t pos_token;
16266 cmdline_fixed_string_t ip_version;
16267 uint32_t vlan_present:1;
16271 cmdline_ipaddr_t ip_src;
16272 cmdline_ipaddr_t ip_dst;
16274 struct rte_ether_addr eth_src;
16275 struct rte_ether_addr eth_dst;
16278 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16279 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16281 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16282 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16284 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16285 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16286 mplsoudp, "mplsoudp_encap-with-vlan");
16287 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16288 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16289 pos_token, "ip-version");
16290 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16291 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16292 ip_version, "ipv4#ipv6");
16293 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16294 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16295 pos_token, "label");
16296 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16297 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16299 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16300 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16301 pos_token, "udp-src");
16302 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16303 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16305 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16306 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16307 pos_token, "udp-dst");
16308 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16309 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16311 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16312 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16313 pos_token, "ip-src");
16314 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16315 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16316 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16317 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16318 pos_token, "ip-dst");
16319 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16320 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16321 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16322 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16323 pos_token, "vlan-tci");
16324 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16325 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16327 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16328 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16329 pos_token, "eth-src");
16330 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16331 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16333 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16334 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16335 pos_token, "eth-dst");
16336 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16337 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16340 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16341 __rte_unused struct cmdline *cl,
16342 __rte_unused void *data)
16344 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16346 uint32_t mplsoudp_label;
16349 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16352 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16353 mplsoudp_encap_conf.select_vlan = 0;
16354 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16355 mplsoudp_encap_conf.select_vlan = 1;
16356 if (strcmp(res->ip_version, "ipv4") == 0)
16357 mplsoudp_encap_conf.select_ipv4 = 1;
16358 else if (strcmp(res->ip_version, "ipv6") == 0)
16359 mplsoudp_encap_conf.select_ipv4 = 0;
16362 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16363 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16364 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16365 if (mplsoudp_encap_conf.select_ipv4) {
16366 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16367 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16369 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16370 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16372 if (mplsoudp_encap_conf.select_vlan)
16373 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16374 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16375 RTE_ETHER_ADDR_LEN);
16376 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16377 RTE_ETHER_ADDR_LEN);
16380 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16381 .f = cmd_set_mplsoudp_encap_parsed,
16383 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16384 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16385 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16387 (void *)&cmd_set_mplsoudp_encap_set,
16388 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16389 (void *)&cmd_set_mplsoudp_encap_ip_version,
16390 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16391 (void *)&cmd_set_mplsoudp_encap_label,
16392 (void *)&cmd_set_mplsoudp_encap_label_value,
16393 (void *)&cmd_set_mplsoudp_encap_udp_src,
16394 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16395 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16396 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16397 (void *)&cmd_set_mplsoudp_encap_ip_src,
16398 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16399 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16400 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16401 (void *)&cmd_set_mplsoudp_encap_eth_src,
16402 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16403 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16404 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16409 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16410 .f = cmd_set_mplsoudp_encap_parsed,
16412 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16413 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16414 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16415 " eth-src <eth-src> eth-dst <eth-dst>",
16417 (void *)&cmd_set_mplsoudp_encap_set,
16418 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16419 (void *)&cmd_set_mplsoudp_encap_ip_version,
16420 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16421 (void *)&cmd_set_mplsoudp_encap_label,
16422 (void *)&cmd_set_mplsoudp_encap_label_value,
16423 (void *)&cmd_set_mplsoudp_encap_udp_src,
16424 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16425 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16426 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16427 (void *)&cmd_set_mplsoudp_encap_ip_src,
16428 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16429 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16430 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16431 (void *)&cmd_set_mplsoudp_encap_vlan,
16432 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16433 (void *)&cmd_set_mplsoudp_encap_eth_src,
16434 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16435 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16436 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16441 /** Set MPLSoUDP decapsulation details */
16442 struct cmd_set_mplsoudp_decap_result {
16443 cmdline_fixed_string_t set;
16444 cmdline_fixed_string_t mplsoudp;
16445 cmdline_fixed_string_t pos_token;
16446 cmdline_fixed_string_t ip_version;
16447 uint32_t vlan_present:1;
16450 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16451 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16453 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16454 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16456 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16457 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16458 mplsoudp, "mplsoudp_decap-with-vlan");
16459 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16460 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16461 pos_token, "ip-version");
16462 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16463 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16464 ip_version, "ipv4#ipv6");
16466 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16467 __rte_unused struct cmdline *cl,
16468 __rte_unused void *data)
16470 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16472 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16473 mplsoudp_decap_conf.select_vlan = 0;
16474 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16475 mplsoudp_decap_conf.select_vlan = 1;
16476 if (strcmp(res->ip_version, "ipv4") == 0)
16477 mplsoudp_decap_conf.select_ipv4 = 1;
16478 else if (strcmp(res->ip_version, "ipv6") == 0)
16479 mplsoudp_decap_conf.select_ipv4 = 0;
16482 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16483 .f = cmd_set_mplsoudp_decap_parsed,
16485 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16487 (void *)&cmd_set_mplsoudp_decap_set,
16488 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16489 (void *)&cmd_set_mplsoudp_decap_ip_version,
16490 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16495 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16496 .f = cmd_set_mplsoudp_decap_parsed,
16498 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16500 (void *)&cmd_set_mplsoudp_decap_set,
16501 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16502 (void *)&cmd_set_mplsoudp_decap_ip_version,
16503 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16508 /* Strict link priority scheduling mode setting */
16510 cmd_strict_link_prio_parsed(
16511 void *parsed_result,
16512 __rte_unused struct cmdline *cl,
16513 __rte_unused void *data)
16515 struct cmd_vf_tc_bw_result *res = parsed_result;
16516 int ret = -ENOTSUP;
16518 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16521 #ifdef RTE_LIBRTE_I40E_PMD
16522 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16529 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16532 printf("invalid port_id %d\n", res->port_id);
16535 printf("function not implemented\n");
16538 printf("programming error: (%s)\n", strerror(-ret));
16542 cmdline_parse_inst_t cmd_strict_link_prio = {
16543 .f = cmd_strict_link_prio_parsed,
16545 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16547 (void *)&cmd_vf_tc_bw_set,
16548 (void *)&cmd_vf_tc_bw_tx,
16549 (void *)&cmd_vf_tc_bw_strict_link_prio,
16550 (void *)&cmd_vf_tc_bw_port_id,
16551 (void *)&cmd_vf_tc_bw_tc_map,
16556 /* Load dynamic device personalization*/
16557 struct cmd_ddp_add_result {
16558 cmdline_fixed_string_t ddp;
16559 cmdline_fixed_string_t add;
16564 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16565 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16566 cmdline_parse_token_string_t cmd_ddp_add_add =
16567 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16568 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16569 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16570 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16571 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16574 cmd_ddp_add_parsed(
16575 void *parsed_result,
16576 __rte_unused struct cmdline *cl,
16577 __rte_unused void *data)
16579 struct cmd_ddp_add_result *res = parsed_result;
16585 int ret = -ENOTSUP;
16587 if (!all_ports_stopped()) {
16588 printf("Please stop all ports first\n");
16592 filepath = strdup(res->filepath);
16593 if (filepath == NULL) {
16594 printf("Failed to allocate memory\n");
16597 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16599 buff = open_file(file_fld[0], &size);
16601 free((void *)filepath);
16605 #ifdef RTE_LIBRTE_I40E_PMD
16606 if (ret == -ENOTSUP)
16607 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16609 RTE_PMD_I40E_PKG_OP_WR_ADD);
16612 if (ret == -EEXIST)
16613 printf("Profile has already existed.\n");
16615 printf("Failed to load profile.\n");
16616 else if (file_num == 2)
16617 save_file(file_fld[1], buff, size);
16620 free((void *)filepath);
16623 cmdline_parse_inst_t cmd_ddp_add = {
16624 .f = cmd_ddp_add_parsed,
16626 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16628 (void *)&cmd_ddp_add_ddp,
16629 (void *)&cmd_ddp_add_add,
16630 (void *)&cmd_ddp_add_port_id,
16631 (void *)&cmd_ddp_add_filepath,
16636 /* Delete dynamic device personalization*/
16637 struct cmd_ddp_del_result {
16638 cmdline_fixed_string_t ddp;
16639 cmdline_fixed_string_t del;
16644 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16645 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16646 cmdline_parse_token_string_t cmd_ddp_del_del =
16647 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16648 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16649 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16650 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16651 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16654 cmd_ddp_del_parsed(
16655 void *parsed_result,
16656 __rte_unused struct cmdline *cl,
16657 __rte_unused void *data)
16659 struct cmd_ddp_del_result *res = parsed_result;
16662 int ret = -ENOTSUP;
16664 if (!all_ports_stopped()) {
16665 printf("Please stop all ports first\n");
16669 buff = open_file(res->filepath, &size);
16673 #ifdef RTE_LIBRTE_I40E_PMD
16674 if (ret == -ENOTSUP)
16675 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16677 RTE_PMD_I40E_PKG_OP_WR_DEL);
16680 if (ret == -EACCES)
16681 printf("Profile does not exist.\n");
16683 printf("Failed to delete profile.\n");
16688 cmdline_parse_inst_t cmd_ddp_del = {
16689 .f = cmd_ddp_del_parsed,
16691 .help_str = "ddp del <port_id> <backup_profile_path>",
16693 (void *)&cmd_ddp_del_ddp,
16694 (void *)&cmd_ddp_del_del,
16695 (void *)&cmd_ddp_del_port_id,
16696 (void *)&cmd_ddp_del_filepath,
16701 /* Get dynamic device personalization profile info */
16702 struct cmd_ddp_info_result {
16703 cmdline_fixed_string_t ddp;
16704 cmdline_fixed_string_t get;
16705 cmdline_fixed_string_t info;
16709 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16710 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16711 cmdline_parse_token_string_t cmd_ddp_info_get =
16712 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16713 cmdline_parse_token_string_t cmd_ddp_info_info =
16714 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16715 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16716 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16719 cmd_ddp_info_parsed(
16720 void *parsed_result,
16721 __rte_unused struct cmdline *cl,
16722 __rte_unused void *data)
16724 struct cmd_ddp_info_result *res = parsed_result;
16727 int ret = -ENOTSUP;
16728 #ifdef RTE_LIBRTE_I40E_PMD
16731 uint32_t buff_size = 0;
16732 struct rte_pmd_i40e_profile_info info;
16733 uint32_t dev_num = 0;
16734 struct rte_pmd_i40e_ddp_device_id *devs;
16735 uint32_t proto_num = 0;
16736 struct rte_pmd_i40e_proto_info *proto = NULL;
16737 uint32_t pctype_num = 0;
16738 struct rte_pmd_i40e_ptype_info *pctype;
16739 uint32_t ptype_num = 0;
16740 struct rte_pmd_i40e_ptype_info *ptype;
16745 pkg = open_file(res->filepath, &pkg_size);
16749 #ifdef RTE_LIBRTE_I40E_PMD
16750 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16751 (uint8_t *)&info, sizeof(info),
16752 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16754 printf("Global Track id: 0x%x\n", info.track_id);
16755 printf("Global Version: %d.%d.%d.%d\n",
16756 info.version.major,
16757 info.version.minor,
16758 info.version.update,
16759 info.version.draft);
16760 printf("Global Package name: %s\n\n", info.name);
16763 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16764 (uint8_t *)&info, sizeof(info),
16765 RTE_PMD_I40E_PKG_INFO_HEADER);
16767 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16768 printf("i40e Profile Version: %d.%d.%d.%d\n",
16769 info.version.major,
16770 info.version.minor,
16771 info.version.update,
16772 info.version.draft);
16773 printf("i40e Profile name: %s\n\n", info.name);
16776 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16777 (uint8_t *)&buff_size, sizeof(buff_size),
16778 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16779 if (!ret && buff_size) {
16780 buff = (uint8_t *)malloc(buff_size);
16782 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16784 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16786 printf("Package Notes:\n%s\n\n", buff);
16791 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16792 (uint8_t *)&dev_num, sizeof(dev_num),
16793 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16794 if (!ret && dev_num) {
16795 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16796 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16798 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16799 (uint8_t *)devs, buff_size,
16800 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16802 printf("List of supported devices:\n");
16803 for (i = 0; i < dev_num; i++) {
16804 printf(" %04X:%04X %04X:%04X\n",
16805 devs[i].vendor_dev_id >> 16,
16806 devs[i].vendor_dev_id & 0xFFFF,
16807 devs[i].sub_vendor_dev_id >> 16,
16808 devs[i].sub_vendor_dev_id & 0xFFFF);
16816 /* get information about protocols and packet types */
16817 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16818 (uint8_t *)&proto_num, sizeof(proto_num),
16819 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16820 if (ret || !proto_num)
16821 goto no_print_return;
16823 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16824 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16826 goto no_print_return;
16828 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16830 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16832 printf("List of used protocols:\n");
16833 for (i = 0; i < proto_num; i++)
16834 printf(" %2u: %s\n", proto[i].proto_id,
16838 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16839 (uint8_t *)&pctype_num, sizeof(pctype_num),
16840 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16841 if (ret || !pctype_num)
16842 goto no_print_pctypes;
16844 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16845 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16847 goto no_print_pctypes;
16849 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16851 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16854 goto no_print_pctypes;
16857 printf("List of defined packet classification types:\n");
16858 for (i = 0; i < pctype_num; i++) {
16859 printf(" %2u:", pctype[i].ptype_id);
16860 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16861 proto_id = pctype[i].protocols[j];
16862 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16863 for (n = 0; n < proto_num; n++) {
16864 if (proto[n].proto_id == proto_id) {
16865 printf(" %s", proto[n].name);
16878 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16880 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16881 if (ret || !ptype_num)
16882 goto no_print_return;
16884 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16885 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16887 goto no_print_return;
16889 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16891 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16894 goto no_print_return;
16896 printf("List of defined packet types:\n");
16897 for (i = 0; i < ptype_num; i++) {
16898 printf(" %2u:", ptype[i].ptype_id);
16899 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16900 proto_id = ptype[i].protocols[j];
16901 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16902 for (n = 0; n < proto_num; n++) {
16903 if (proto[n].proto_id == proto_id) {
16904 printf(" %s", proto[n].name);
16920 if (ret == -ENOTSUP)
16921 printf("Function not supported in PMD driver\n");
16925 cmdline_parse_inst_t cmd_ddp_get_info = {
16926 .f = cmd_ddp_info_parsed,
16928 .help_str = "ddp get info <profile_path>",
16930 (void *)&cmd_ddp_info_ddp,
16931 (void *)&cmd_ddp_info_get,
16932 (void *)&cmd_ddp_info_info,
16933 (void *)&cmd_ddp_info_filepath,
16938 /* Get dynamic device personalization profile info list*/
16939 #define PROFILE_INFO_SIZE 48
16940 #define MAX_PROFILE_NUM 16
16942 struct cmd_ddp_get_list_result {
16943 cmdline_fixed_string_t ddp;
16944 cmdline_fixed_string_t get;
16945 cmdline_fixed_string_t list;
16949 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16950 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16951 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16952 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16953 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16954 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16955 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16956 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16959 cmd_ddp_get_list_parsed(
16960 __rte_unused void *parsed_result,
16961 __rte_unused struct cmdline *cl,
16962 __rte_unused void *data)
16964 #ifdef RTE_LIBRTE_I40E_PMD
16965 struct cmd_ddp_get_list_result *res = parsed_result;
16966 struct rte_pmd_i40e_profile_list *p_list;
16967 struct rte_pmd_i40e_profile_info *p_info;
16972 int ret = -ENOTSUP;
16974 #ifdef RTE_LIBRTE_I40E_PMD
16975 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16976 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16978 printf("%s: Failed to malloc buffer\n", __func__);
16982 if (ret == -ENOTSUP)
16983 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16984 (uint8_t *)p_list, size);
16987 p_num = p_list->p_count;
16988 printf("Profile number is: %d\n\n", p_num);
16990 for (i = 0; i < p_num; i++) {
16991 p_info = &p_list->p_info[i];
16992 printf("Profile %d:\n", i);
16993 printf("Track id: 0x%x\n", p_info->track_id);
16994 printf("Version: %d.%d.%d.%d\n",
16995 p_info->version.major,
16996 p_info->version.minor,
16997 p_info->version.update,
16998 p_info->version.draft);
16999 printf("Profile name: %s\n\n", p_info->name);
17007 printf("Failed to get ddp list\n");
17010 cmdline_parse_inst_t cmd_ddp_get_list = {
17011 .f = cmd_ddp_get_list_parsed,
17013 .help_str = "ddp get list <port_id>",
17015 (void *)&cmd_ddp_get_list_ddp,
17016 (void *)&cmd_ddp_get_list_get,
17017 (void *)&cmd_ddp_get_list_list,
17018 (void *)&cmd_ddp_get_list_port_id,
17023 /* Configure input set */
17024 struct cmd_cfg_input_set_result {
17025 cmdline_fixed_string_t port;
17026 cmdline_fixed_string_t cfg;
17028 cmdline_fixed_string_t pctype;
17030 cmdline_fixed_string_t inset_type;
17031 cmdline_fixed_string_t opt;
17032 cmdline_fixed_string_t field;
17037 cmd_cfg_input_set_parsed(
17038 __rte_unused void *parsed_result,
17039 __rte_unused struct cmdline *cl,
17040 __rte_unused void *data)
17042 #ifdef RTE_LIBRTE_I40E_PMD
17043 struct cmd_cfg_input_set_result *res = parsed_result;
17044 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17045 struct rte_pmd_i40e_inset inset;
17047 int ret = -ENOTSUP;
17049 if (!all_ports_stopped()) {
17050 printf("Please stop all ports first\n");
17054 #ifdef RTE_LIBRTE_I40E_PMD
17055 if (!strcmp(res->inset_type, "hash_inset"))
17056 inset_type = INSET_HASH;
17057 else if (!strcmp(res->inset_type, "fdir_inset"))
17058 inset_type = INSET_FDIR;
17059 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17060 inset_type = INSET_FDIR_FLX;
17061 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
17062 &inset, inset_type);
17064 printf("Failed to get input set.\n");
17068 if (!strcmp(res->opt, "get")) {
17069 ret = rte_pmd_i40e_inset_field_get(inset.inset,
17072 printf("Field index %d is enabled.\n", res->field_idx);
17074 printf("Field index %d is disabled.\n", res->field_idx);
17076 } else if (!strcmp(res->opt, "set"))
17077 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
17079 else if (!strcmp(res->opt, "clear"))
17080 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
17083 printf("Failed to configure input set field.\n");
17087 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17088 &inset, inset_type);
17090 printf("Failed to set input set.\n");
17095 if (ret == -ENOTSUP)
17096 printf("Function not supported\n");
17099 cmdline_parse_token_string_t cmd_cfg_input_set_port =
17100 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17102 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
17103 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17105 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
17106 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17108 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
17109 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17111 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
17112 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17114 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
17115 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17117 "hash_inset#fdir_inset#fdir_flx_inset");
17118 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
17119 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17120 opt, "get#set#clear");
17121 cmdline_parse_token_string_t cmd_cfg_input_set_field =
17122 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17124 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
17125 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17128 cmdline_parse_inst_t cmd_cfg_input_set = {
17129 .f = cmd_cfg_input_set_parsed,
17131 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17132 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
17134 (void *)&cmd_cfg_input_set_port,
17135 (void *)&cmd_cfg_input_set_cfg,
17136 (void *)&cmd_cfg_input_set_port_id,
17137 (void *)&cmd_cfg_input_set_pctype,
17138 (void *)&cmd_cfg_input_set_pctype_id,
17139 (void *)&cmd_cfg_input_set_inset_type,
17140 (void *)&cmd_cfg_input_set_opt,
17141 (void *)&cmd_cfg_input_set_field,
17142 (void *)&cmd_cfg_input_set_field_idx,
17147 /* Clear input set */
17148 struct cmd_clear_input_set_result {
17149 cmdline_fixed_string_t port;
17150 cmdline_fixed_string_t cfg;
17152 cmdline_fixed_string_t pctype;
17154 cmdline_fixed_string_t inset_type;
17155 cmdline_fixed_string_t clear;
17156 cmdline_fixed_string_t all;
17160 cmd_clear_input_set_parsed(
17161 __rte_unused void *parsed_result,
17162 __rte_unused struct cmdline *cl,
17163 __rte_unused void *data)
17165 #ifdef RTE_LIBRTE_I40E_PMD
17166 struct cmd_clear_input_set_result *res = parsed_result;
17167 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17168 struct rte_pmd_i40e_inset inset;
17170 int ret = -ENOTSUP;
17172 if (!all_ports_stopped()) {
17173 printf("Please stop all ports first\n");
17177 #ifdef RTE_LIBRTE_I40E_PMD
17178 if (!strcmp(res->inset_type, "hash_inset"))
17179 inset_type = INSET_HASH;
17180 else if (!strcmp(res->inset_type, "fdir_inset"))
17181 inset_type = INSET_FDIR;
17182 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17183 inset_type = INSET_FDIR_FLX;
17185 memset(&inset, 0, sizeof(inset));
17187 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17188 &inset, inset_type);
17190 printf("Failed to clear input set.\n");
17196 if (ret == -ENOTSUP)
17197 printf("Function not supported\n");
17200 cmdline_parse_token_string_t cmd_clear_input_set_port =
17201 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17203 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17204 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17206 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17207 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17209 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17210 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17212 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17213 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17215 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17216 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17218 "hash_inset#fdir_inset#fdir_flx_inset");
17219 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17220 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17222 cmdline_parse_token_string_t cmd_clear_input_set_all =
17223 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17226 cmdline_parse_inst_t cmd_clear_input_set = {
17227 .f = cmd_clear_input_set_parsed,
17229 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17230 "fdir_inset|fdir_flx_inset clear all",
17232 (void *)&cmd_clear_input_set_port,
17233 (void *)&cmd_clear_input_set_cfg,
17234 (void *)&cmd_clear_input_set_port_id,
17235 (void *)&cmd_clear_input_set_pctype,
17236 (void *)&cmd_clear_input_set_pctype_id,
17237 (void *)&cmd_clear_input_set_inset_type,
17238 (void *)&cmd_clear_input_set_clear,
17239 (void *)&cmd_clear_input_set_all,
17244 /* show vf stats */
17246 /* Common result structure for show vf stats */
17247 struct cmd_show_vf_stats_result {
17248 cmdline_fixed_string_t show;
17249 cmdline_fixed_string_t vf;
17250 cmdline_fixed_string_t stats;
17255 /* Common CLI fields show vf stats*/
17256 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17257 TOKEN_STRING_INITIALIZER
17258 (struct cmd_show_vf_stats_result,
17260 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17261 TOKEN_STRING_INITIALIZER
17262 (struct cmd_show_vf_stats_result,
17264 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17265 TOKEN_STRING_INITIALIZER
17266 (struct cmd_show_vf_stats_result,
17268 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17269 TOKEN_NUM_INITIALIZER
17270 (struct cmd_show_vf_stats_result,
17272 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17273 TOKEN_NUM_INITIALIZER
17274 (struct cmd_show_vf_stats_result,
17278 cmd_show_vf_stats_parsed(
17279 void *parsed_result,
17280 __rte_unused struct cmdline *cl,
17281 __rte_unused void *data)
17283 struct cmd_show_vf_stats_result *res = parsed_result;
17284 struct rte_eth_stats stats;
17285 int ret = -ENOTSUP;
17286 static const char *nic_stats_border = "########################";
17288 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17291 memset(&stats, 0, sizeof(stats));
17293 #ifdef RTE_LIBRTE_I40E_PMD
17294 if (ret == -ENOTSUP)
17295 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17299 #ifdef RTE_LIBRTE_BNXT_PMD
17300 if (ret == -ENOTSUP)
17301 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17310 printf("invalid vf_id %d\n", res->vf_id);
17313 printf("invalid port_id %d\n", res->port_id);
17316 printf("function not implemented\n");
17319 printf("programming error: (%s)\n", strerror(-ret));
17322 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17323 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17325 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17327 stats.ipackets, stats.imissed, stats.ibytes);
17328 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17329 printf(" RX-nombuf: %-10"PRIu64"\n",
17331 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17333 stats.opackets, stats.oerrors, stats.obytes);
17335 printf(" %s############################%s\n",
17336 nic_stats_border, nic_stats_border);
17339 cmdline_parse_inst_t cmd_show_vf_stats = {
17340 .f = cmd_show_vf_stats_parsed,
17342 .help_str = "show vf stats <port_id> <vf_id>",
17344 (void *)&cmd_show_vf_stats_show,
17345 (void *)&cmd_show_vf_stats_vf,
17346 (void *)&cmd_show_vf_stats_stats,
17347 (void *)&cmd_show_vf_stats_port_id,
17348 (void *)&cmd_show_vf_stats_vf_id,
17353 /* clear vf stats */
17355 /* Common result structure for clear vf stats */
17356 struct cmd_clear_vf_stats_result {
17357 cmdline_fixed_string_t clear;
17358 cmdline_fixed_string_t vf;
17359 cmdline_fixed_string_t stats;
17364 /* Common CLI fields clear vf stats*/
17365 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17366 TOKEN_STRING_INITIALIZER
17367 (struct cmd_clear_vf_stats_result,
17369 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17370 TOKEN_STRING_INITIALIZER
17371 (struct cmd_clear_vf_stats_result,
17373 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17374 TOKEN_STRING_INITIALIZER
17375 (struct cmd_clear_vf_stats_result,
17377 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17378 TOKEN_NUM_INITIALIZER
17379 (struct cmd_clear_vf_stats_result,
17381 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17382 TOKEN_NUM_INITIALIZER
17383 (struct cmd_clear_vf_stats_result,
17387 cmd_clear_vf_stats_parsed(
17388 void *parsed_result,
17389 __rte_unused struct cmdline *cl,
17390 __rte_unused void *data)
17392 struct cmd_clear_vf_stats_result *res = parsed_result;
17393 int ret = -ENOTSUP;
17395 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17398 #ifdef RTE_LIBRTE_I40E_PMD
17399 if (ret == -ENOTSUP)
17400 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17403 #ifdef RTE_LIBRTE_BNXT_PMD
17404 if (ret == -ENOTSUP)
17405 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17413 printf("invalid vf_id %d\n", res->vf_id);
17416 printf("invalid port_id %d\n", res->port_id);
17419 printf("function not implemented\n");
17422 printf("programming error: (%s)\n", strerror(-ret));
17426 cmdline_parse_inst_t cmd_clear_vf_stats = {
17427 .f = cmd_clear_vf_stats_parsed,
17429 .help_str = "clear vf stats <port_id> <vf_id>",
17431 (void *)&cmd_clear_vf_stats_clear,
17432 (void *)&cmd_clear_vf_stats_vf,
17433 (void *)&cmd_clear_vf_stats_stats,
17434 (void *)&cmd_clear_vf_stats_port_id,
17435 (void *)&cmd_clear_vf_stats_vf_id,
17440 /* port config pctype mapping reset */
17442 /* Common result structure for port config pctype mapping reset */
17443 struct cmd_pctype_mapping_reset_result {
17444 cmdline_fixed_string_t port;
17445 cmdline_fixed_string_t config;
17447 cmdline_fixed_string_t pctype;
17448 cmdline_fixed_string_t mapping;
17449 cmdline_fixed_string_t reset;
17452 /* Common CLI fields for port config pctype mapping reset*/
17453 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17454 TOKEN_STRING_INITIALIZER
17455 (struct cmd_pctype_mapping_reset_result,
17457 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17458 TOKEN_STRING_INITIALIZER
17459 (struct cmd_pctype_mapping_reset_result,
17461 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17462 TOKEN_NUM_INITIALIZER
17463 (struct cmd_pctype_mapping_reset_result,
17465 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17466 TOKEN_STRING_INITIALIZER
17467 (struct cmd_pctype_mapping_reset_result,
17469 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17470 TOKEN_STRING_INITIALIZER
17471 (struct cmd_pctype_mapping_reset_result,
17472 mapping, "mapping");
17473 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17474 TOKEN_STRING_INITIALIZER
17475 (struct cmd_pctype_mapping_reset_result,
17479 cmd_pctype_mapping_reset_parsed(
17480 void *parsed_result,
17481 __rte_unused struct cmdline *cl,
17482 __rte_unused void *data)
17484 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17485 int ret = -ENOTSUP;
17487 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17490 #ifdef RTE_LIBRTE_I40E_PMD
17491 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17498 printf("invalid port_id %d\n", res->port_id);
17501 printf("function not implemented\n");
17504 printf("programming error: (%s)\n", strerror(-ret));
17508 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17509 .f = cmd_pctype_mapping_reset_parsed,
17511 .help_str = "port config <port_id> pctype mapping reset",
17513 (void *)&cmd_pctype_mapping_reset_port,
17514 (void *)&cmd_pctype_mapping_reset_config,
17515 (void *)&cmd_pctype_mapping_reset_port_id,
17516 (void *)&cmd_pctype_mapping_reset_pctype,
17517 (void *)&cmd_pctype_mapping_reset_mapping,
17518 (void *)&cmd_pctype_mapping_reset_reset,
17523 /* show port pctype mapping */
17525 /* Common result structure for show port pctype mapping */
17526 struct cmd_pctype_mapping_get_result {
17527 cmdline_fixed_string_t show;
17528 cmdline_fixed_string_t port;
17530 cmdline_fixed_string_t pctype;
17531 cmdline_fixed_string_t mapping;
17534 /* Common CLI fields for pctype mapping get */
17535 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17536 TOKEN_STRING_INITIALIZER
17537 (struct cmd_pctype_mapping_get_result,
17539 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17540 TOKEN_STRING_INITIALIZER
17541 (struct cmd_pctype_mapping_get_result,
17543 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17544 TOKEN_NUM_INITIALIZER
17545 (struct cmd_pctype_mapping_get_result,
17547 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17548 TOKEN_STRING_INITIALIZER
17549 (struct cmd_pctype_mapping_get_result,
17551 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17552 TOKEN_STRING_INITIALIZER
17553 (struct cmd_pctype_mapping_get_result,
17554 mapping, "mapping");
17557 cmd_pctype_mapping_get_parsed(
17558 void *parsed_result,
17559 __rte_unused struct cmdline *cl,
17560 __rte_unused void *data)
17562 struct cmd_pctype_mapping_get_result *res = parsed_result;
17563 int ret = -ENOTSUP;
17564 #ifdef RTE_LIBRTE_I40E_PMD
17565 struct rte_pmd_i40e_flow_type_mapping
17566 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17567 int i, j, first_pctype;
17570 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17573 #ifdef RTE_LIBRTE_I40E_PMD
17574 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17581 printf("invalid port_id %d\n", res->port_id);
17584 printf("function not implemented\n");
17587 printf("programming error: (%s)\n", strerror(-ret));
17591 #ifdef RTE_LIBRTE_I40E_PMD
17592 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17593 if (mapping[i].pctype != 0ULL) {
17596 printf("pctype: ");
17597 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17598 if (mapping[i].pctype & (1ULL << j)) {
17599 printf(first_pctype ?
17600 "%02d" : ",%02d", j);
17604 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17610 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17611 .f = cmd_pctype_mapping_get_parsed,
17613 .help_str = "show port <port_id> pctype mapping",
17615 (void *)&cmd_pctype_mapping_get_show,
17616 (void *)&cmd_pctype_mapping_get_port,
17617 (void *)&cmd_pctype_mapping_get_port_id,
17618 (void *)&cmd_pctype_mapping_get_pctype,
17619 (void *)&cmd_pctype_mapping_get_mapping,
17624 /* port config pctype mapping update */
17626 /* Common result structure for port config pctype mapping update */
17627 struct cmd_pctype_mapping_update_result {
17628 cmdline_fixed_string_t port;
17629 cmdline_fixed_string_t config;
17631 cmdline_fixed_string_t pctype;
17632 cmdline_fixed_string_t mapping;
17633 cmdline_fixed_string_t update;
17634 cmdline_fixed_string_t pctype_list;
17635 uint16_t flow_type;
17638 /* Common CLI fields for pctype mapping update*/
17639 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17640 TOKEN_STRING_INITIALIZER
17641 (struct cmd_pctype_mapping_update_result,
17643 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17644 TOKEN_STRING_INITIALIZER
17645 (struct cmd_pctype_mapping_update_result,
17647 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17648 TOKEN_NUM_INITIALIZER
17649 (struct cmd_pctype_mapping_update_result,
17651 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17652 TOKEN_STRING_INITIALIZER
17653 (struct cmd_pctype_mapping_update_result,
17655 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17656 TOKEN_STRING_INITIALIZER
17657 (struct cmd_pctype_mapping_update_result,
17658 mapping, "mapping");
17659 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17660 TOKEN_STRING_INITIALIZER
17661 (struct cmd_pctype_mapping_update_result,
17663 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17664 TOKEN_STRING_INITIALIZER
17665 (struct cmd_pctype_mapping_update_result,
17666 pctype_list, NULL);
17667 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17668 TOKEN_NUM_INITIALIZER
17669 (struct cmd_pctype_mapping_update_result,
17670 flow_type, UINT16);
17673 cmd_pctype_mapping_update_parsed(
17674 void *parsed_result,
17675 __rte_unused struct cmdline *cl,
17676 __rte_unused void *data)
17678 struct cmd_pctype_mapping_update_result *res = parsed_result;
17679 int ret = -ENOTSUP;
17680 #ifdef RTE_LIBRTE_I40E_PMD
17681 struct rte_pmd_i40e_flow_type_mapping mapping;
17683 unsigned int nb_item;
17684 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17687 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17690 #ifdef RTE_LIBRTE_I40E_PMD
17691 nb_item = parse_item_list(res->pctype_list, "pctypes",
17692 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17693 mapping.flow_type = res->flow_type;
17694 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17695 mapping.pctype |= (1ULL << pctype_list[i]);
17696 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17706 printf("invalid pctype or flow type\n");
17709 printf("invalid port_id %d\n", res->port_id);
17712 printf("function not implemented\n");
17715 printf("programming error: (%s)\n", strerror(-ret));
17719 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17720 .f = cmd_pctype_mapping_update_parsed,
17722 .help_str = "port config <port_id> pctype mapping update"
17723 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17725 (void *)&cmd_pctype_mapping_update_port,
17726 (void *)&cmd_pctype_mapping_update_config,
17727 (void *)&cmd_pctype_mapping_update_port_id,
17728 (void *)&cmd_pctype_mapping_update_pctype,
17729 (void *)&cmd_pctype_mapping_update_mapping,
17730 (void *)&cmd_pctype_mapping_update_update,
17731 (void *)&cmd_pctype_mapping_update_pc_type,
17732 (void *)&cmd_pctype_mapping_update_flow_type,
17737 /* ptype mapping get */
17739 /* Common result structure for ptype mapping get */
17740 struct cmd_ptype_mapping_get_result {
17741 cmdline_fixed_string_t ptype;
17742 cmdline_fixed_string_t mapping;
17743 cmdline_fixed_string_t get;
17745 uint8_t valid_only;
17748 /* Common CLI fields for ptype mapping get */
17749 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17750 TOKEN_STRING_INITIALIZER
17751 (struct cmd_ptype_mapping_get_result,
17753 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17754 TOKEN_STRING_INITIALIZER
17755 (struct cmd_ptype_mapping_get_result,
17756 mapping, "mapping");
17757 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17758 TOKEN_STRING_INITIALIZER
17759 (struct cmd_ptype_mapping_get_result,
17761 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17762 TOKEN_NUM_INITIALIZER
17763 (struct cmd_ptype_mapping_get_result,
17765 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17766 TOKEN_NUM_INITIALIZER
17767 (struct cmd_ptype_mapping_get_result,
17768 valid_only, UINT8);
17771 cmd_ptype_mapping_get_parsed(
17772 void *parsed_result,
17773 __rte_unused struct cmdline *cl,
17774 __rte_unused void *data)
17776 struct cmd_ptype_mapping_get_result *res = parsed_result;
17777 int ret = -ENOTSUP;
17778 #ifdef RTE_LIBRTE_I40E_PMD
17779 int max_ptype_num = 256;
17780 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17785 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17788 #ifdef RTE_LIBRTE_I40E_PMD
17789 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17800 printf("invalid port_id %d\n", res->port_id);
17803 printf("function not implemented\n");
17806 printf("programming error: (%s)\n", strerror(-ret));
17809 #ifdef RTE_LIBRTE_I40E_PMD
17811 for (i = 0; i < count; i++)
17812 printf("%3d\t0x%08x\n",
17813 mapping[i].hw_ptype, mapping[i].sw_ptype);
17818 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17819 .f = cmd_ptype_mapping_get_parsed,
17821 .help_str = "ptype mapping get <port_id> <valid_only>",
17823 (void *)&cmd_ptype_mapping_get_ptype,
17824 (void *)&cmd_ptype_mapping_get_mapping,
17825 (void *)&cmd_ptype_mapping_get_get,
17826 (void *)&cmd_ptype_mapping_get_port_id,
17827 (void *)&cmd_ptype_mapping_get_valid_only,
17832 /* ptype mapping replace */
17834 /* Common result structure for ptype mapping replace */
17835 struct cmd_ptype_mapping_replace_result {
17836 cmdline_fixed_string_t ptype;
17837 cmdline_fixed_string_t mapping;
17838 cmdline_fixed_string_t replace;
17845 /* Common CLI fields for ptype mapping replace */
17846 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17847 TOKEN_STRING_INITIALIZER
17848 (struct cmd_ptype_mapping_replace_result,
17850 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17851 TOKEN_STRING_INITIALIZER
17852 (struct cmd_ptype_mapping_replace_result,
17853 mapping, "mapping");
17854 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17855 TOKEN_STRING_INITIALIZER
17856 (struct cmd_ptype_mapping_replace_result,
17857 replace, "replace");
17858 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17859 TOKEN_NUM_INITIALIZER
17860 (struct cmd_ptype_mapping_replace_result,
17862 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17863 TOKEN_NUM_INITIALIZER
17864 (struct cmd_ptype_mapping_replace_result,
17866 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17867 TOKEN_NUM_INITIALIZER
17868 (struct cmd_ptype_mapping_replace_result,
17870 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17871 TOKEN_NUM_INITIALIZER
17872 (struct cmd_ptype_mapping_replace_result,
17876 cmd_ptype_mapping_replace_parsed(
17877 void *parsed_result,
17878 __rte_unused struct cmdline *cl,
17879 __rte_unused void *data)
17881 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17882 int ret = -ENOTSUP;
17884 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17887 #ifdef RTE_LIBRTE_I40E_PMD
17888 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17898 printf("invalid ptype 0x%8x or 0x%8x\n",
17899 res->target, res->pkt_type);
17902 printf("invalid port_id %d\n", res->port_id);
17905 printf("function not implemented\n");
17908 printf("programming error: (%s)\n", strerror(-ret));
17912 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17913 .f = cmd_ptype_mapping_replace_parsed,
17916 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17918 (void *)&cmd_ptype_mapping_replace_ptype,
17919 (void *)&cmd_ptype_mapping_replace_mapping,
17920 (void *)&cmd_ptype_mapping_replace_replace,
17921 (void *)&cmd_ptype_mapping_replace_port_id,
17922 (void *)&cmd_ptype_mapping_replace_target,
17923 (void *)&cmd_ptype_mapping_replace_mask,
17924 (void *)&cmd_ptype_mapping_replace_pkt_type,
17929 /* ptype mapping reset */
17931 /* Common result structure for ptype mapping reset */
17932 struct cmd_ptype_mapping_reset_result {
17933 cmdline_fixed_string_t ptype;
17934 cmdline_fixed_string_t mapping;
17935 cmdline_fixed_string_t reset;
17939 /* Common CLI fields for ptype mapping reset*/
17940 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17941 TOKEN_STRING_INITIALIZER
17942 (struct cmd_ptype_mapping_reset_result,
17944 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17945 TOKEN_STRING_INITIALIZER
17946 (struct cmd_ptype_mapping_reset_result,
17947 mapping, "mapping");
17948 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17949 TOKEN_STRING_INITIALIZER
17950 (struct cmd_ptype_mapping_reset_result,
17952 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17953 TOKEN_NUM_INITIALIZER
17954 (struct cmd_ptype_mapping_reset_result,
17958 cmd_ptype_mapping_reset_parsed(
17959 void *parsed_result,
17960 __rte_unused struct cmdline *cl,
17961 __rte_unused void *data)
17963 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17964 int ret = -ENOTSUP;
17966 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17969 #ifdef RTE_LIBRTE_I40E_PMD
17970 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17977 printf("invalid port_id %d\n", res->port_id);
17980 printf("function not implemented\n");
17983 printf("programming error: (%s)\n", strerror(-ret));
17987 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17988 .f = cmd_ptype_mapping_reset_parsed,
17990 .help_str = "ptype mapping reset <port_id>",
17992 (void *)&cmd_ptype_mapping_reset_ptype,
17993 (void *)&cmd_ptype_mapping_reset_mapping,
17994 (void *)&cmd_ptype_mapping_reset_reset,
17995 (void *)&cmd_ptype_mapping_reset_port_id,
18000 /* ptype mapping update */
18002 /* Common result structure for ptype mapping update */
18003 struct cmd_ptype_mapping_update_result {
18004 cmdline_fixed_string_t ptype;
18005 cmdline_fixed_string_t mapping;
18006 cmdline_fixed_string_t reset;
18012 /* Common CLI fields for ptype mapping update*/
18013 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
18014 TOKEN_STRING_INITIALIZER
18015 (struct cmd_ptype_mapping_update_result,
18017 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
18018 TOKEN_STRING_INITIALIZER
18019 (struct cmd_ptype_mapping_update_result,
18020 mapping, "mapping");
18021 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
18022 TOKEN_STRING_INITIALIZER
18023 (struct cmd_ptype_mapping_update_result,
18025 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
18026 TOKEN_NUM_INITIALIZER
18027 (struct cmd_ptype_mapping_update_result,
18029 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
18030 TOKEN_NUM_INITIALIZER
18031 (struct cmd_ptype_mapping_update_result,
18033 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
18034 TOKEN_NUM_INITIALIZER
18035 (struct cmd_ptype_mapping_update_result,
18039 cmd_ptype_mapping_update_parsed(
18040 void *parsed_result,
18041 __rte_unused struct cmdline *cl,
18042 __rte_unused void *data)
18044 struct cmd_ptype_mapping_update_result *res = parsed_result;
18045 int ret = -ENOTSUP;
18046 #ifdef RTE_LIBRTE_I40E_PMD
18047 struct rte_pmd_i40e_ptype_mapping mapping;
18049 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18052 #ifdef RTE_LIBRTE_I40E_PMD
18053 mapping.hw_ptype = res->hw_ptype;
18054 mapping.sw_ptype = res->sw_ptype;
18055 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
18065 printf("invalid ptype 0x%8x\n", res->sw_ptype);
18068 printf("invalid port_id %d\n", res->port_id);
18071 printf("function not implemented\n");
18074 printf("programming error: (%s)\n", strerror(-ret));
18078 cmdline_parse_inst_t cmd_ptype_mapping_update = {
18079 .f = cmd_ptype_mapping_update_parsed,
18081 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
18083 (void *)&cmd_ptype_mapping_update_ptype,
18084 (void *)&cmd_ptype_mapping_update_mapping,
18085 (void *)&cmd_ptype_mapping_update_update,
18086 (void *)&cmd_ptype_mapping_update_port_id,
18087 (void *)&cmd_ptype_mapping_update_hw_ptype,
18088 (void *)&cmd_ptype_mapping_update_sw_ptype,
18093 /* Common result structure for file commands */
18094 struct cmd_cmdfile_result {
18095 cmdline_fixed_string_t load;
18096 cmdline_fixed_string_t filename;
18099 /* Common CLI fields for file commands */
18100 cmdline_parse_token_string_t cmd_load_cmdfile =
18101 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
18102 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
18103 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
18106 cmd_load_from_file_parsed(
18107 void *parsed_result,
18108 __rte_unused struct cmdline *cl,
18109 __rte_unused void *data)
18111 struct cmd_cmdfile_result *res = parsed_result;
18113 cmdline_read_from_file(res->filename);
18116 cmdline_parse_inst_t cmd_load_from_file = {
18117 .f = cmd_load_from_file_parsed,
18119 .help_str = "load <filename>",
18121 (void *)&cmd_load_cmdfile,
18122 (void *)&cmd_load_cmdfile_filename,
18127 /* Get Rx offloads capabilities */
18128 struct cmd_rx_offload_get_capa_result {
18129 cmdline_fixed_string_t show;
18130 cmdline_fixed_string_t port;
18132 cmdline_fixed_string_t rx_offload;
18133 cmdline_fixed_string_t capabilities;
18136 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
18137 TOKEN_STRING_INITIALIZER
18138 (struct cmd_rx_offload_get_capa_result,
18140 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
18141 TOKEN_STRING_INITIALIZER
18142 (struct cmd_rx_offload_get_capa_result,
18144 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
18145 TOKEN_NUM_INITIALIZER
18146 (struct cmd_rx_offload_get_capa_result,
18148 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
18149 TOKEN_STRING_INITIALIZER
18150 (struct cmd_rx_offload_get_capa_result,
18151 rx_offload, "rx_offload");
18152 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
18153 TOKEN_STRING_INITIALIZER
18154 (struct cmd_rx_offload_get_capa_result,
18155 capabilities, "capabilities");
18158 print_rx_offloads(uint64_t offloads)
18160 uint64_t single_offload;
18168 begin = __builtin_ctzll(offloads);
18169 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18171 single_offload = 1ULL << begin;
18172 for (bit = begin; bit < end; bit++) {
18173 if (offloads & single_offload)
18175 rte_eth_dev_rx_offload_name(single_offload));
18176 single_offload <<= 1;
18181 cmd_rx_offload_get_capa_parsed(
18182 void *parsed_result,
18183 __rte_unused struct cmdline *cl,
18184 __rte_unused void *data)
18186 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18187 struct rte_eth_dev_info dev_info;
18188 portid_t port_id = res->port_id;
18189 uint64_t queue_offloads;
18190 uint64_t port_offloads;
18193 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18197 queue_offloads = dev_info.rx_queue_offload_capa;
18198 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18200 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18201 printf(" Per Queue :");
18202 print_rx_offloads(queue_offloads);
18205 printf(" Per Port :");
18206 print_rx_offloads(port_offloads);
18210 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18211 .f = cmd_rx_offload_get_capa_parsed,
18213 .help_str = "show port <port_id> rx_offload capabilities",
18215 (void *)&cmd_rx_offload_get_capa_show,
18216 (void *)&cmd_rx_offload_get_capa_port,
18217 (void *)&cmd_rx_offload_get_capa_port_id,
18218 (void *)&cmd_rx_offload_get_capa_rx_offload,
18219 (void *)&cmd_rx_offload_get_capa_capabilities,
18224 /* Get Rx offloads configuration */
18225 struct cmd_rx_offload_get_configuration_result {
18226 cmdline_fixed_string_t show;
18227 cmdline_fixed_string_t port;
18229 cmdline_fixed_string_t rx_offload;
18230 cmdline_fixed_string_t configuration;
18233 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18234 TOKEN_STRING_INITIALIZER
18235 (struct cmd_rx_offload_get_configuration_result,
18237 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18238 TOKEN_STRING_INITIALIZER
18239 (struct cmd_rx_offload_get_configuration_result,
18241 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18242 TOKEN_NUM_INITIALIZER
18243 (struct cmd_rx_offload_get_configuration_result,
18245 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18246 TOKEN_STRING_INITIALIZER
18247 (struct cmd_rx_offload_get_configuration_result,
18248 rx_offload, "rx_offload");
18249 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18250 TOKEN_STRING_INITIALIZER
18251 (struct cmd_rx_offload_get_configuration_result,
18252 configuration, "configuration");
18255 cmd_rx_offload_get_configuration_parsed(
18256 void *parsed_result,
18257 __rte_unused struct cmdline *cl,
18258 __rte_unused void *data)
18260 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18261 struct rte_eth_dev_info dev_info;
18262 portid_t port_id = res->port_id;
18263 struct rte_port *port = &ports[port_id];
18264 uint64_t port_offloads;
18265 uint64_t queue_offloads;
18266 uint16_t nb_rx_queues;
18270 printf("Rx Offloading Configuration of port %d :\n", port_id);
18272 port_offloads = port->dev_conf.rxmode.offloads;
18274 print_rx_offloads(port_offloads);
18277 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18281 nb_rx_queues = dev_info.nb_rx_queues;
18282 for (q = 0; q < nb_rx_queues; q++) {
18283 queue_offloads = port->rx_conf[q].offloads;
18284 printf(" Queue[%2d] :", q);
18285 print_rx_offloads(queue_offloads);
18291 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18292 .f = cmd_rx_offload_get_configuration_parsed,
18294 .help_str = "show port <port_id> rx_offload configuration",
18296 (void *)&cmd_rx_offload_get_configuration_show,
18297 (void *)&cmd_rx_offload_get_configuration_port,
18298 (void *)&cmd_rx_offload_get_configuration_port_id,
18299 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18300 (void *)&cmd_rx_offload_get_configuration_configuration,
18305 /* Enable/Disable a per port offloading */
18306 struct cmd_config_per_port_rx_offload_result {
18307 cmdline_fixed_string_t port;
18308 cmdline_fixed_string_t config;
18310 cmdline_fixed_string_t rx_offload;
18311 cmdline_fixed_string_t offload;
18312 cmdline_fixed_string_t on_off;
18315 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18316 TOKEN_STRING_INITIALIZER
18317 (struct cmd_config_per_port_rx_offload_result,
18319 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18320 TOKEN_STRING_INITIALIZER
18321 (struct cmd_config_per_port_rx_offload_result,
18323 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18324 TOKEN_NUM_INITIALIZER
18325 (struct cmd_config_per_port_rx_offload_result,
18327 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18328 TOKEN_STRING_INITIALIZER
18329 (struct cmd_config_per_port_rx_offload_result,
18330 rx_offload, "rx_offload");
18331 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18332 TOKEN_STRING_INITIALIZER
18333 (struct cmd_config_per_port_rx_offload_result,
18334 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18335 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18336 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18337 "scatter#timestamp#security#keep_crc#rss_hash");
18338 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18339 TOKEN_STRING_INITIALIZER
18340 (struct cmd_config_per_port_rx_offload_result,
18344 search_rx_offload(const char *name)
18346 uint64_t single_offload;
18347 const char *single_name;
18351 single_offload = 1;
18352 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18353 single_name = rte_eth_dev_rx_offload_name(single_offload);
18354 if (!strcasecmp(single_name, name)) {
18358 single_offload <<= 1;
18362 return single_offload;
18368 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18369 __rte_unused struct cmdline *cl,
18370 __rte_unused void *data)
18372 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18373 portid_t port_id = res->port_id;
18374 struct rte_eth_dev_info dev_info;
18375 struct rte_port *port = &ports[port_id];
18376 uint64_t single_offload;
18377 uint16_t nb_rx_queues;
18381 if (port->port_status != RTE_PORT_STOPPED) {
18382 printf("Error: Can't config offload when Port %d "
18383 "is not stopped\n", port_id);
18387 single_offload = search_rx_offload(res->offload);
18388 if (single_offload == 0) {
18389 printf("Unknown offload name: %s\n", res->offload);
18393 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18397 nb_rx_queues = dev_info.nb_rx_queues;
18398 if (!strcmp(res->on_off, "on")) {
18399 port->dev_conf.rxmode.offloads |= single_offload;
18400 for (q = 0; q < nb_rx_queues; q++)
18401 port->rx_conf[q].offloads |= single_offload;
18403 port->dev_conf.rxmode.offloads &= ~single_offload;
18404 for (q = 0; q < nb_rx_queues; q++)
18405 port->rx_conf[q].offloads &= ~single_offload;
18408 cmd_reconfig_device_queue(port_id, 1, 1);
18411 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18412 .f = cmd_config_per_port_rx_offload_parsed,
18414 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18415 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18416 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18417 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18420 (void *)&cmd_config_per_port_rx_offload_result_port,
18421 (void *)&cmd_config_per_port_rx_offload_result_config,
18422 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18423 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18424 (void *)&cmd_config_per_port_rx_offload_result_offload,
18425 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18430 /* Enable/Disable a per queue offloading */
18431 struct cmd_config_per_queue_rx_offload_result {
18432 cmdline_fixed_string_t port;
18434 cmdline_fixed_string_t rxq;
18436 cmdline_fixed_string_t rx_offload;
18437 cmdline_fixed_string_t offload;
18438 cmdline_fixed_string_t on_off;
18441 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18442 TOKEN_STRING_INITIALIZER
18443 (struct cmd_config_per_queue_rx_offload_result,
18445 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18446 TOKEN_NUM_INITIALIZER
18447 (struct cmd_config_per_queue_rx_offload_result,
18449 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18450 TOKEN_STRING_INITIALIZER
18451 (struct cmd_config_per_queue_rx_offload_result,
18453 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18454 TOKEN_NUM_INITIALIZER
18455 (struct cmd_config_per_queue_rx_offload_result,
18457 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18458 TOKEN_STRING_INITIALIZER
18459 (struct cmd_config_per_queue_rx_offload_result,
18460 rx_offload, "rx_offload");
18461 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18462 TOKEN_STRING_INITIALIZER
18463 (struct cmd_config_per_queue_rx_offload_result,
18464 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18465 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18466 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18467 "scatter#timestamp#security#keep_crc");
18468 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18469 TOKEN_STRING_INITIALIZER
18470 (struct cmd_config_per_queue_rx_offload_result,
18474 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18475 __rte_unused struct cmdline *cl,
18476 __rte_unused void *data)
18478 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18479 struct rte_eth_dev_info dev_info;
18480 portid_t port_id = res->port_id;
18481 uint16_t queue_id = res->queue_id;
18482 struct rte_port *port = &ports[port_id];
18483 uint64_t single_offload;
18486 if (port->port_status != RTE_PORT_STOPPED) {
18487 printf("Error: Can't config offload when Port %d "
18488 "is not stopped\n", port_id);
18492 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18496 if (queue_id >= dev_info.nb_rx_queues) {
18497 printf("Error: input queue_id should be 0 ... "
18498 "%d\n", dev_info.nb_rx_queues - 1);
18502 single_offload = search_rx_offload(res->offload);
18503 if (single_offload == 0) {
18504 printf("Unknown offload name: %s\n", res->offload);
18508 if (!strcmp(res->on_off, "on"))
18509 port->rx_conf[queue_id].offloads |= single_offload;
18511 port->rx_conf[queue_id].offloads &= ~single_offload;
18513 cmd_reconfig_device_queue(port_id, 1, 1);
18516 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18517 .f = cmd_config_per_queue_rx_offload_parsed,
18519 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18520 "vlan_strip|ipv4_cksum|"
18521 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18522 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18523 "jumbo_frame|scatter|timestamp|security|keep_crc "
18526 (void *)&cmd_config_per_queue_rx_offload_result_port,
18527 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18528 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18529 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18530 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18531 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18532 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18537 /* Get Tx offloads capabilities */
18538 struct cmd_tx_offload_get_capa_result {
18539 cmdline_fixed_string_t show;
18540 cmdline_fixed_string_t port;
18542 cmdline_fixed_string_t tx_offload;
18543 cmdline_fixed_string_t capabilities;
18546 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18547 TOKEN_STRING_INITIALIZER
18548 (struct cmd_tx_offload_get_capa_result,
18550 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18551 TOKEN_STRING_INITIALIZER
18552 (struct cmd_tx_offload_get_capa_result,
18554 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18555 TOKEN_NUM_INITIALIZER
18556 (struct cmd_tx_offload_get_capa_result,
18558 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18559 TOKEN_STRING_INITIALIZER
18560 (struct cmd_tx_offload_get_capa_result,
18561 tx_offload, "tx_offload");
18562 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18563 TOKEN_STRING_INITIALIZER
18564 (struct cmd_tx_offload_get_capa_result,
18565 capabilities, "capabilities");
18568 print_tx_offloads(uint64_t offloads)
18570 uint64_t single_offload;
18578 begin = __builtin_ctzll(offloads);
18579 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18581 single_offload = 1ULL << begin;
18582 for (bit = begin; bit < end; bit++) {
18583 if (offloads & single_offload)
18585 rte_eth_dev_tx_offload_name(single_offload));
18586 single_offload <<= 1;
18591 cmd_tx_offload_get_capa_parsed(
18592 void *parsed_result,
18593 __rte_unused struct cmdline *cl,
18594 __rte_unused void *data)
18596 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18597 struct rte_eth_dev_info dev_info;
18598 portid_t port_id = res->port_id;
18599 uint64_t queue_offloads;
18600 uint64_t port_offloads;
18603 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18607 queue_offloads = dev_info.tx_queue_offload_capa;
18608 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18610 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18611 printf(" Per Queue :");
18612 print_tx_offloads(queue_offloads);
18615 printf(" Per Port :");
18616 print_tx_offloads(port_offloads);
18620 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18621 .f = cmd_tx_offload_get_capa_parsed,
18623 .help_str = "show port <port_id> tx_offload capabilities",
18625 (void *)&cmd_tx_offload_get_capa_show,
18626 (void *)&cmd_tx_offload_get_capa_port,
18627 (void *)&cmd_tx_offload_get_capa_port_id,
18628 (void *)&cmd_tx_offload_get_capa_tx_offload,
18629 (void *)&cmd_tx_offload_get_capa_capabilities,
18634 /* Get Tx offloads configuration */
18635 struct cmd_tx_offload_get_configuration_result {
18636 cmdline_fixed_string_t show;
18637 cmdline_fixed_string_t port;
18639 cmdline_fixed_string_t tx_offload;
18640 cmdline_fixed_string_t configuration;
18643 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18644 TOKEN_STRING_INITIALIZER
18645 (struct cmd_tx_offload_get_configuration_result,
18647 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18648 TOKEN_STRING_INITIALIZER
18649 (struct cmd_tx_offload_get_configuration_result,
18651 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18652 TOKEN_NUM_INITIALIZER
18653 (struct cmd_tx_offload_get_configuration_result,
18655 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18656 TOKEN_STRING_INITIALIZER
18657 (struct cmd_tx_offload_get_configuration_result,
18658 tx_offload, "tx_offload");
18659 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18660 TOKEN_STRING_INITIALIZER
18661 (struct cmd_tx_offload_get_configuration_result,
18662 configuration, "configuration");
18665 cmd_tx_offload_get_configuration_parsed(
18666 void *parsed_result,
18667 __rte_unused struct cmdline *cl,
18668 __rte_unused void *data)
18670 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18671 struct rte_eth_dev_info dev_info;
18672 portid_t port_id = res->port_id;
18673 struct rte_port *port = &ports[port_id];
18674 uint64_t port_offloads;
18675 uint64_t queue_offloads;
18676 uint16_t nb_tx_queues;
18680 printf("Tx Offloading Configuration of port %d :\n", port_id);
18682 port_offloads = port->dev_conf.txmode.offloads;
18684 print_tx_offloads(port_offloads);
18687 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18691 nb_tx_queues = dev_info.nb_tx_queues;
18692 for (q = 0; q < nb_tx_queues; q++) {
18693 queue_offloads = port->tx_conf[q].offloads;
18694 printf(" Queue[%2d] :", q);
18695 print_tx_offloads(queue_offloads);
18701 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18702 .f = cmd_tx_offload_get_configuration_parsed,
18704 .help_str = "show port <port_id> tx_offload configuration",
18706 (void *)&cmd_tx_offload_get_configuration_show,
18707 (void *)&cmd_tx_offload_get_configuration_port,
18708 (void *)&cmd_tx_offload_get_configuration_port_id,
18709 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18710 (void *)&cmd_tx_offload_get_configuration_configuration,
18715 /* Enable/Disable a per port offloading */
18716 struct cmd_config_per_port_tx_offload_result {
18717 cmdline_fixed_string_t port;
18718 cmdline_fixed_string_t config;
18720 cmdline_fixed_string_t tx_offload;
18721 cmdline_fixed_string_t offload;
18722 cmdline_fixed_string_t on_off;
18725 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18726 TOKEN_STRING_INITIALIZER
18727 (struct cmd_config_per_port_tx_offload_result,
18729 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18730 TOKEN_STRING_INITIALIZER
18731 (struct cmd_config_per_port_tx_offload_result,
18733 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18734 TOKEN_NUM_INITIALIZER
18735 (struct cmd_config_per_port_tx_offload_result,
18737 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18738 TOKEN_STRING_INITIALIZER
18739 (struct cmd_config_per_port_tx_offload_result,
18740 tx_offload, "tx_offload");
18741 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18742 TOKEN_STRING_INITIALIZER
18743 (struct cmd_config_per_port_tx_offload_result,
18744 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18745 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18746 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18747 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18748 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18749 "send_on_timestamp");
18750 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18751 TOKEN_STRING_INITIALIZER
18752 (struct cmd_config_per_port_tx_offload_result,
18756 search_tx_offload(const char *name)
18758 uint64_t single_offload;
18759 const char *single_name;
18763 single_offload = 1;
18764 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18765 single_name = rte_eth_dev_tx_offload_name(single_offload);
18766 if (single_name == NULL)
18768 if (!strcasecmp(single_name, name)) {
18771 } else if (!strcasecmp(single_name, "UNKNOWN"))
18773 single_offload <<= 1;
18777 return single_offload;
18783 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18784 __rte_unused struct cmdline *cl,
18785 __rte_unused void *data)
18787 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18788 portid_t port_id = res->port_id;
18789 struct rte_eth_dev_info dev_info;
18790 struct rte_port *port = &ports[port_id];
18791 uint64_t single_offload;
18792 uint16_t nb_tx_queues;
18796 if (port->port_status != RTE_PORT_STOPPED) {
18797 printf("Error: Can't config offload when Port %d "
18798 "is not stopped\n", port_id);
18802 single_offload = search_tx_offload(res->offload);
18803 if (single_offload == 0) {
18804 printf("Unknown offload name: %s\n", res->offload);
18808 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18812 nb_tx_queues = dev_info.nb_tx_queues;
18813 if (!strcmp(res->on_off, "on")) {
18814 port->dev_conf.txmode.offloads |= single_offload;
18815 for (q = 0; q < nb_tx_queues; q++)
18816 port->tx_conf[q].offloads |= single_offload;
18818 port->dev_conf.txmode.offloads &= ~single_offload;
18819 for (q = 0; q < nb_tx_queues; q++)
18820 port->tx_conf[q].offloads &= ~single_offload;
18823 cmd_reconfig_device_queue(port_id, 1, 1);
18826 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18827 .f = cmd_config_per_port_tx_offload_parsed,
18829 .help_str = "port config <port_id> tx_offload "
18830 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18831 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18832 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18833 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18834 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18835 "send_on_timestamp on|off",
18837 (void *)&cmd_config_per_port_tx_offload_result_port,
18838 (void *)&cmd_config_per_port_tx_offload_result_config,
18839 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18840 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18841 (void *)&cmd_config_per_port_tx_offload_result_offload,
18842 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18847 /* Enable/Disable a per queue offloading */
18848 struct cmd_config_per_queue_tx_offload_result {
18849 cmdline_fixed_string_t port;
18851 cmdline_fixed_string_t txq;
18853 cmdline_fixed_string_t tx_offload;
18854 cmdline_fixed_string_t offload;
18855 cmdline_fixed_string_t on_off;
18858 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18859 TOKEN_STRING_INITIALIZER
18860 (struct cmd_config_per_queue_tx_offload_result,
18862 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18863 TOKEN_NUM_INITIALIZER
18864 (struct cmd_config_per_queue_tx_offload_result,
18866 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18867 TOKEN_STRING_INITIALIZER
18868 (struct cmd_config_per_queue_tx_offload_result,
18870 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18871 TOKEN_NUM_INITIALIZER
18872 (struct cmd_config_per_queue_tx_offload_result,
18874 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18875 TOKEN_STRING_INITIALIZER
18876 (struct cmd_config_per_queue_tx_offload_result,
18877 tx_offload, "tx_offload");
18878 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18879 TOKEN_STRING_INITIALIZER
18880 (struct cmd_config_per_queue_tx_offload_result,
18881 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18882 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18883 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18884 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18885 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18886 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18887 TOKEN_STRING_INITIALIZER
18888 (struct cmd_config_per_queue_tx_offload_result,
18892 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18893 __rte_unused struct cmdline *cl,
18894 __rte_unused void *data)
18896 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18897 struct rte_eth_dev_info dev_info;
18898 portid_t port_id = res->port_id;
18899 uint16_t queue_id = res->queue_id;
18900 struct rte_port *port = &ports[port_id];
18901 uint64_t single_offload;
18904 if (port->port_status != RTE_PORT_STOPPED) {
18905 printf("Error: Can't config offload when Port %d "
18906 "is not stopped\n", port_id);
18910 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18914 if (queue_id >= dev_info.nb_tx_queues) {
18915 printf("Error: input queue_id should be 0 ... "
18916 "%d\n", dev_info.nb_tx_queues - 1);
18920 single_offload = search_tx_offload(res->offload);
18921 if (single_offload == 0) {
18922 printf("Unknown offload name: %s\n", res->offload);
18926 if (!strcmp(res->on_off, "on"))
18927 port->tx_conf[queue_id].offloads |= single_offload;
18929 port->tx_conf[queue_id].offloads &= ~single_offload;
18931 cmd_reconfig_device_queue(port_id, 1, 1);
18934 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18935 .f = cmd_config_per_queue_tx_offload_parsed,
18937 .help_str = "port <port_id> txq <queue_id> tx_offload "
18938 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18939 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18940 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18941 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18942 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18945 (void *)&cmd_config_per_queue_tx_offload_result_port,
18946 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18947 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18948 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18949 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18950 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18951 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18956 /* *** configure tx_metadata for specific port *** */
18957 struct cmd_config_tx_metadata_specific_result {
18958 cmdline_fixed_string_t port;
18959 cmdline_fixed_string_t keyword;
18961 cmdline_fixed_string_t item;
18966 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18967 __rte_unused struct cmdline *cl,
18968 __rte_unused void *data)
18970 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18972 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18974 ports[res->port_id].tx_metadata = res->value;
18975 /* Add/remove callback to insert valid metadata in every Tx packet. */
18976 if (ports[res->port_id].tx_metadata)
18977 add_tx_md_callback(res->port_id);
18979 remove_tx_md_callback(res->port_id);
18980 rte_flow_dynf_metadata_register();
18983 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18984 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18986 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18987 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18988 keyword, "config");
18989 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18990 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18992 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18993 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18994 item, "tx_metadata");
18995 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18996 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18999 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
19000 .f = cmd_config_tx_metadata_specific_parsed,
19002 .help_str = "port config <port_id> tx_metadata <value>",
19004 (void *)&cmd_config_tx_metadata_specific_port,
19005 (void *)&cmd_config_tx_metadata_specific_keyword,
19006 (void *)&cmd_config_tx_metadata_specific_id,
19007 (void *)&cmd_config_tx_metadata_specific_item,
19008 (void *)&cmd_config_tx_metadata_specific_value,
19013 /* *** set dynf *** */
19014 struct cmd_config_tx_dynf_specific_result {
19015 cmdline_fixed_string_t port;
19016 cmdline_fixed_string_t keyword;
19018 cmdline_fixed_string_t item;
19019 cmdline_fixed_string_t name;
19020 cmdline_fixed_string_t value;
19024 cmd_config_dynf_specific_parsed(void *parsed_result,
19025 __rte_unused struct cmdline *cl,
19026 __rte_unused void *data)
19028 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
19029 struct rte_mbuf_dynflag desc_flag;
19031 uint64_t old_port_flags;
19033 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
19035 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
19037 if (strlcpy(desc_flag.name, res->name,
19038 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
19039 printf("Flag name too long\n");
19042 desc_flag.flags = 0;
19043 flag = rte_mbuf_dynflag_register(&desc_flag);
19045 printf("Can't register flag\n");
19048 strcpy(dynf_names[flag], desc_flag.name);
19050 old_port_flags = ports[res->port_id].mbuf_dynf;
19051 if (!strcmp(res->value, "set")) {
19052 ports[res->port_id].mbuf_dynf |= 1UL << flag;
19053 if (old_port_flags == 0)
19054 add_tx_dynf_callback(res->port_id);
19056 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
19057 if (ports[res->port_id].mbuf_dynf == 0)
19058 remove_tx_dynf_callback(res->port_id);
19062 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
19063 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19065 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
19066 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19067 keyword, "config");
19068 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
19069 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19071 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
19072 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19074 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
19075 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19077 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
19078 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19079 value, "set#clear");
19081 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
19082 .f = cmd_config_dynf_specific_parsed,
19084 .help_str = "port config <port id> dynf <name> set|clear",
19086 (void *)&cmd_config_tx_dynf_specific_port,
19087 (void *)&cmd_config_tx_dynf_specific_keyword,
19088 (void *)&cmd_config_tx_dynf_specific_port_id,
19089 (void *)&cmd_config_tx_dynf_specific_item,
19090 (void *)&cmd_config_tx_dynf_specific_name,
19091 (void *)&cmd_config_tx_dynf_specific_value,
19096 /* *** display tx_metadata per port configuration *** */
19097 struct cmd_show_tx_metadata_result {
19098 cmdline_fixed_string_t cmd_show;
19099 cmdline_fixed_string_t cmd_port;
19100 cmdline_fixed_string_t cmd_keyword;
19105 cmd_show_tx_metadata_parsed(void *parsed_result,
19106 __rte_unused struct cmdline *cl,
19107 __rte_unused void *data)
19109 struct cmd_show_tx_metadata_result *res = parsed_result;
19111 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19112 printf("invalid port id %u\n", res->cmd_pid);
19115 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
19116 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
19117 ports[res->cmd_pid].tx_metadata);
19121 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
19122 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19124 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
19125 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19127 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
19128 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
19130 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
19131 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19132 cmd_keyword, "tx_metadata");
19134 cmdline_parse_inst_t cmd_show_tx_metadata = {
19135 .f = cmd_show_tx_metadata_parsed,
19137 .help_str = "show port <port_id> tx_metadata",
19139 (void *)&cmd_show_tx_metadata_show,
19140 (void *)&cmd_show_tx_metadata_port,
19141 (void *)&cmd_show_tx_metadata_pid,
19142 (void *)&cmd_show_tx_metadata_keyword,
19147 /* show port supported ptypes */
19149 /* Common result structure for show port ptypes */
19150 struct cmd_show_port_supported_ptypes_result {
19151 cmdline_fixed_string_t show;
19152 cmdline_fixed_string_t port;
19154 cmdline_fixed_string_t ptypes;
19157 /* Common CLI fields for show port ptypes */
19158 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
19159 TOKEN_STRING_INITIALIZER
19160 (struct cmd_show_port_supported_ptypes_result,
19162 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
19163 TOKEN_STRING_INITIALIZER
19164 (struct cmd_show_port_supported_ptypes_result,
19166 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19167 TOKEN_NUM_INITIALIZER
19168 (struct cmd_show_port_supported_ptypes_result,
19170 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19171 TOKEN_STRING_INITIALIZER
19172 (struct cmd_show_port_supported_ptypes_result,
19176 cmd_show_port_supported_ptypes_parsed(
19177 void *parsed_result,
19178 __rte_unused struct cmdline *cl,
19179 __rte_unused void *data)
19181 #define RSVD_PTYPE_MASK 0xf0000000
19182 #define MAX_PTYPES_PER_LAYER 16
19183 #define LTYPE_NAMESIZE 32
19184 #define PTYPE_NAMESIZE 256
19185 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19186 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19187 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19188 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19189 uint16_t port_id = res->port_id;
19192 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19196 while (ptype_mask != RSVD_PTYPE_MASK) {
19198 switch (ptype_mask) {
19199 case RTE_PTYPE_L2_MASK:
19200 strlcpy(ltype, "L2", sizeof(ltype));
19202 case RTE_PTYPE_L3_MASK:
19203 strlcpy(ltype, "L3", sizeof(ltype));
19205 case RTE_PTYPE_L4_MASK:
19206 strlcpy(ltype, "L4", sizeof(ltype));
19208 case RTE_PTYPE_TUNNEL_MASK:
19209 strlcpy(ltype, "Tunnel", sizeof(ltype));
19211 case RTE_PTYPE_INNER_L2_MASK:
19212 strlcpy(ltype, "Inner L2", sizeof(ltype));
19214 case RTE_PTYPE_INNER_L3_MASK:
19215 strlcpy(ltype, "Inner L3", sizeof(ltype));
19217 case RTE_PTYPE_INNER_L4_MASK:
19218 strlcpy(ltype, "Inner L4", sizeof(ltype));
19224 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19225 ptype_mask, ptypes,
19226 MAX_PTYPES_PER_LAYER);
19229 printf("Supported %s ptypes:\n", ltype);
19231 printf("%s ptypes unsupported\n", ltype);
19233 for (i = 0; i < ret; ++i) {
19234 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19235 printf("%s\n", buf);
19242 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19243 .f = cmd_show_port_supported_ptypes_parsed,
19245 .help_str = "show port <port_id> ptypes",
19247 (void *)&cmd_show_port_supported_ptypes_show,
19248 (void *)&cmd_show_port_supported_ptypes_port,
19249 (void *)&cmd_show_port_supported_ptypes_port_id,
19250 (void *)&cmd_show_port_supported_ptypes_ptypes,
19255 /* *** display rx/tx descriptor status *** */
19256 struct cmd_show_rx_tx_desc_status_result {
19257 cmdline_fixed_string_t cmd_show;
19258 cmdline_fixed_string_t cmd_port;
19259 cmdline_fixed_string_t cmd_keyword;
19260 cmdline_fixed_string_t cmd_desc;
19261 cmdline_fixed_string_t cmd_status;
19268 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19269 __rte_unused struct cmdline *cl,
19270 __rte_unused void *data)
19272 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19275 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19276 printf("invalid port id %u\n", res->cmd_pid);
19280 if (!strcmp(res->cmd_keyword, "rxq")) {
19281 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19284 printf("Invalid queueid = %d\n", res->cmd_qid);
19287 if (rc == RTE_ETH_RX_DESC_AVAIL)
19288 printf("Desc status = AVAILABLE\n");
19289 else if (rc == RTE_ETH_RX_DESC_DONE)
19290 printf("Desc status = DONE\n");
19292 printf("Desc status = UNAVAILABLE\n");
19293 } else if (!strcmp(res->cmd_keyword, "txq")) {
19294 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19297 printf("Invalid queueid = %d\n", res->cmd_qid);
19300 if (rc == RTE_ETH_TX_DESC_FULL)
19301 printf("Desc status = FULL\n");
19302 else if (rc == RTE_ETH_TX_DESC_DONE)
19303 printf("Desc status = DONE\n");
19305 printf("Desc status = UNAVAILABLE\n");
19309 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19310 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19312 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19313 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19315 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19316 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19318 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19319 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19320 cmd_keyword, "rxq#txq");
19321 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19322 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19324 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19325 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19327 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19328 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19330 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19331 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19332 cmd_status, "status");
19333 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19334 .f = cmd_show_rx_tx_desc_status_parsed,
19336 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19339 (void *)&cmd_show_rx_tx_desc_status_show,
19340 (void *)&cmd_show_rx_tx_desc_status_port,
19341 (void *)&cmd_show_rx_tx_desc_status_pid,
19342 (void *)&cmd_show_rx_tx_desc_status_keyword,
19343 (void *)&cmd_show_rx_tx_desc_status_qid,
19344 (void *)&cmd_show_rx_tx_desc_status_desc,
19345 (void *)&cmd_show_rx_tx_desc_status_did,
19346 (void *)&cmd_show_rx_tx_desc_status_status,
19351 /* Common result structure for set port ptypes */
19352 struct cmd_set_port_ptypes_result {
19353 cmdline_fixed_string_t set;
19354 cmdline_fixed_string_t port;
19356 cmdline_fixed_string_t ptype_mask;
19360 /* Common CLI fields for set port ptypes */
19361 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19362 TOKEN_STRING_INITIALIZER
19363 (struct cmd_set_port_ptypes_result,
19365 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19366 TOKEN_STRING_INITIALIZER
19367 (struct cmd_set_port_ptypes_result,
19369 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19370 TOKEN_NUM_INITIALIZER
19371 (struct cmd_set_port_ptypes_result,
19373 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19374 TOKEN_STRING_INITIALIZER
19375 (struct cmd_set_port_ptypes_result,
19376 ptype_mask, "ptype_mask");
19377 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19378 TOKEN_NUM_INITIALIZER
19379 (struct cmd_set_port_ptypes_result,
19383 cmd_set_port_ptypes_parsed(
19384 void *parsed_result,
19385 __rte_unused struct cmdline *cl,
19386 __rte_unused void *data)
19388 struct cmd_set_port_ptypes_result *res = parsed_result;
19389 #define PTYPE_NAMESIZE 256
19390 char ptype_name[PTYPE_NAMESIZE];
19391 uint16_t port_id = res->port_id;
19392 uint32_t ptype_mask = res->mask;
19395 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19398 printf("Port %d doesn't support any ptypes.\n", port_id);
19402 uint32_t ptypes[ret];
19404 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19406 printf("Unable to set requested ptypes for Port %d\n", port_id);
19410 printf("Successfully set following ptypes for Port %d\n", port_id);
19411 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19412 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19413 printf("%s\n", ptype_name);
19416 clear_ptypes = false;
19419 cmdline_parse_inst_t cmd_set_port_ptypes = {
19420 .f = cmd_set_port_ptypes_parsed,
19422 .help_str = "set port <port_id> ptype_mask <mask>",
19424 (void *)&cmd_set_port_ptypes_set,
19425 (void *)&cmd_set_port_ptypes_port,
19426 (void *)&cmd_set_port_ptypes_port_id,
19427 (void *)&cmd_set_port_ptypes_mask_str,
19428 (void *)&cmd_set_port_ptypes_mask_u32,
19433 /* *** display mac addresses added to a port *** */
19434 struct cmd_showport_macs_result {
19435 cmdline_fixed_string_t cmd_show;
19436 cmdline_fixed_string_t cmd_port;
19437 cmdline_fixed_string_t cmd_keyword;
19442 cmd_showport_macs_parsed(void *parsed_result,
19443 __rte_unused struct cmdline *cl,
19444 __rte_unused void *data)
19446 struct cmd_showport_macs_result *res = parsed_result;
19448 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19451 if (!strcmp(res->cmd_keyword, "macs"))
19452 show_macs(res->cmd_pid);
19453 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19454 show_mcast_macs(res->cmd_pid);
19457 cmdline_parse_token_string_t cmd_showport_macs_show =
19458 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19460 cmdline_parse_token_string_t cmd_showport_macs_port =
19461 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19463 cmdline_parse_token_num_t cmd_showport_macs_pid =
19464 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19466 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19467 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19468 cmd_keyword, "macs#mcast_macs");
19470 cmdline_parse_inst_t cmd_showport_macs = {
19471 .f = cmd_showport_macs_parsed,
19473 .help_str = "show port <port_id> macs|mcast_macs",
19475 (void *)&cmd_showport_macs_show,
19476 (void *)&cmd_showport_macs_port,
19477 (void *)&cmd_showport_macs_pid,
19478 (void *)&cmd_showport_macs_keyword,
19483 /* ******************************************************************************** */
19485 /* list of instructions */
19486 cmdline_parse_ctx_t main_ctx[] = {
19487 (cmdline_parse_inst_t *)&cmd_help_brief,
19488 (cmdline_parse_inst_t *)&cmd_help_long,
19489 (cmdline_parse_inst_t *)&cmd_quit,
19490 (cmdline_parse_inst_t *)&cmd_load_from_file,
19491 (cmdline_parse_inst_t *)&cmd_showport,
19492 (cmdline_parse_inst_t *)&cmd_showqueue,
19493 (cmdline_parse_inst_t *)&cmd_showportall,
19494 (cmdline_parse_inst_t *)&cmd_showdevice,
19495 (cmdline_parse_inst_t *)&cmd_showcfg,
19496 (cmdline_parse_inst_t *)&cmd_showfwdall,
19497 (cmdline_parse_inst_t *)&cmd_start,
19498 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19499 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19500 (cmdline_parse_inst_t *)&cmd_set_link_up,
19501 (cmdline_parse_inst_t *)&cmd_set_link_down,
19502 (cmdline_parse_inst_t *)&cmd_reset,
19503 (cmdline_parse_inst_t *)&cmd_set_numbers,
19504 (cmdline_parse_inst_t *)&cmd_set_log,
19505 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19506 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19507 (cmdline_parse_inst_t *)&cmd_set_txtimes,
19508 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19509 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19510 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19511 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19512 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19513 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19514 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19515 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19516 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19517 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19518 (cmdline_parse_inst_t *)&cmd_set_link_check,
19519 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19520 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19521 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19522 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19523 #ifdef RTE_LIBRTE_PMD_BOND
19524 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19525 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19526 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19527 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19528 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19529 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19530 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19531 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19532 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19533 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19534 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19536 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19537 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19538 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19539 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19540 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19541 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19542 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19543 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19544 (cmdline_parse_inst_t *)&cmd_csum_set,
19545 (cmdline_parse_inst_t *)&cmd_csum_show,
19546 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19547 (cmdline_parse_inst_t *)&cmd_tso_set,
19548 (cmdline_parse_inst_t *)&cmd_tso_show,
19549 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19550 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19551 (cmdline_parse_inst_t *)&cmd_gro_enable,
19552 (cmdline_parse_inst_t *)&cmd_gro_flush,
19553 (cmdline_parse_inst_t *)&cmd_gro_show,
19554 (cmdline_parse_inst_t *)&cmd_gso_enable,
19555 (cmdline_parse_inst_t *)&cmd_gso_size,
19556 (cmdline_parse_inst_t *)&cmd_gso_show,
19557 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19558 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19559 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19560 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19561 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19562 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19563 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19564 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19565 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19566 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19567 (cmdline_parse_inst_t *)&cmd_config_dcb,
19568 (cmdline_parse_inst_t *)&cmd_read_reg,
19569 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19570 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19571 (cmdline_parse_inst_t *)&cmd_write_reg,
19572 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19573 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19574 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19575 (cmdline_parse_inst_t *)&cmd_stop,
19576 (cmdline_parse_inst_t *)&cmd_mac_addr,
19577 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19578 (cmdline_parse_inst_t *)&cmd_set_qmap,
19579 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19580 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
19581 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
19582 (cmdline_parse_inst_t *)&cmd_operate_port,
19583 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19584 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19585 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19586 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19587 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19588 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19589 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19590 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19591 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19592 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19593 (cmdline_parse_inst_t *)&cmd_config_mtu,
19594 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19595 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19596 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19597 (cmdline_parse_inst_t *)&cmd_config_rss,
19598 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19599 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19600 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19601 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19602 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19603 (cmdline_parse_inst_t *)&cmd_showport_reta,
19604 (cmdline_parse_inst_t *)&cmd_showport_macs,
19605 (cmdline_parse_inst_t *)&cmd_config_burst,
19606 (cmdline_parse_inst_t *)&cmd_config_thresh,
19607 (cmdline_parse_inst_t *)&cmd_config_threshold,
19608 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19609 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19610 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19611 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19612 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19613 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19614 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19615 (cmdline_parse_inst_t *)&cmd_global_config,
19616 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19617 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19618 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19619 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19620 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19621 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19622 (cmdline_parse_inst_t *)&cmd_dump,
19623 (cmdline_parse_inst_t *)&cmd_dump_one,
19624 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19625 (cmdline_parse_inst_t *)&cmd_syn_filter,
19626 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19627 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19628 (cmdline_parse_inst_t *)&cmd_flex_filter,
19629 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19630 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19631 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19632 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19633 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19634 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19635 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19636 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19637 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19638 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19639 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19640 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19641 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19642 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19643 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19644 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19645 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19646 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19647 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19648 (cmdline_parse_inst_t *)&cmd_flow,
19649 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19650 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19651 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19652 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19653 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19654 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19655 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19656 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19657 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19658 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19659 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19660 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19661 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19662 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19663 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19664 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19665 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19666 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19667 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19668 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19669 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19670 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19671 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19672 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19673 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19674 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19675 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19676 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19677 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19678 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19679 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19680 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19681 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19682 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19683 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19684 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19685 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19686 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19687 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19688 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19689 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19690 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19691 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19692 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19693 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19694 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19695 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19696 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19697 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19698 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19699 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19700 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19701 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19702 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19703 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19704 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19705 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19706 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19707 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19708 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19709 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19710 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19711 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19712 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19713 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19714 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19715 (cmdline_parse_inst_t *)&cmd_ddp_add,
19716 (cmdline_parse_inst_t *)&cmd_ddp_del,
19717 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19718 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19719 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19720 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19721 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19722 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19723 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19724 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19725 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19726 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19727 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19728 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19730 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19731 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19732 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19733 (cmdline_parse_inst_t *)&cmd_queue_region,
19734 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19735 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19736 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19737 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19738 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19739 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19740 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19741 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19742 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19743 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19744 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19745 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19746 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19747 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19748 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19749 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19750 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19751 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19752 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19753 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19754 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19755 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19756 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19757 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19758 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19759 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19760 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19761 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19762 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19763 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19764 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19765 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19766 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19767 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19768 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19769 #ifdef RTE_LIBRTE_BPF
19770 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19771 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19773 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19774 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19775 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19776 (cmdline_parse_inst_t *)&cmd_set_raw,
19777 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19778 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19779 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
19783 /* read cmdline commands from file */
19785 cmdline_read_from_file(const char *filename)
19787 struct cmdline *cl;
19789 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19791 printf("Failed to create file based cmdline context: %s\n",
19796 cmdline_interact(cl);
19801 printf("Read CLI commands from %s\n", filename);
19804 /* prompt function, called from main on MASTER lcore */
19808 /* initialize non-constant commands */
19809 cmd_set_fwd_mode_init();
19810 cmd_set_fwd_retry_mode_init();
19812 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19813 if (testpmd_cl == NULL)
19815 cmdline_interact(testpmd_cl);
19816 cmdline_stdin_exit(testpmd_cl);
19822 if (testpmd_cl != NULL)
19823 cmdline_quit(testpmd_cl);
19827 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19829 if (id == (portid_t)RTE_PORT_ALL) {
19832 RTE_ETH_FOREACH_DEV(pid) {
19833 /* check if need_reconfig has been set to 1 */
19834 if (ports[pid].need_reconfig == 0)
19835 ports[pid].need_reconfig = dev;
19836 /* check if need_reconfig_queues has been set to 1 */
19837 if (ports[pid].need_reconfig_queues == 0)
19838 ports[pid].need_reconfig_queues = queue;
19840 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19841 /* check if need_reconfig has been set to 1 */
19842 if (ports[id].need_reconfig == 0)
19843 ports[id].need_reconfig = dev;
19844 /* check if need_reconfig_queues has been set to 1 */
19845 if (ports[id].need_reconfig_queues == 0)
19846 ports[id].need_reconfig_queues = queue;