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 port_id (module_eeprom|eeprom)\n"
170 " Display the module EEPROM or EEPROM information for port_id.\n\n"
172 "show port X rss reta (size) (mask0,mask1,...)\n"
173 " Display the rss redirection table entry indicated"
174 " by masks on port X. size is used to indicate the"
175 " hardware supported reta size\n\n"
177 "show port (port_id) rss-hash [key]\n"
178 " Display the RSS hash functions and RSS hash key of port\n\n"
180 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
181 " Clear information for port_id, or all.\n\n"
183 "show (rxq|txq) info (port_id) (queue_id)\n"
184 " Display information for configured RX/TX queue.\n\n"
186 "show config (rxtx|cores|fwd|txpkts)\n"
187 " Display the given configuration.\n\n"
189 "read rxd (port_id) (queue_id) (rxd_id)\n"
190 " Display an RX descriptor of a port RX queue.\n\n"
192 "read txd (port_id) (queue_id) (txd_id)\n"
193 " Display a TX descriptor of a port TX queue.\n\n"
195 "ddp get list (port_id)\n"
196 " Get ddp profile info list\n\n"
198 "ddp get info (profile_path)\n"
199 " Get ddp profile information.\n\n"
201 "show vf stats (port_id) (vf_id)\n"
202 " Display a VF's statistics.\n\n"
204 "clear vf stats (port_id) (vf_id)\n"
205 " Reset a VF's statistics.\n\n"
207 "show port (port_id) pctype mapping\n"
208 " Get flow ptype to pctype mapping on a port\n\n"
210 "show port meter stats (port_id) (meter_id) (clear)\n"
211 " Get meter stats on a port\n\n"
213 "show fwd stats all\n"
214 " Display statistics for all fwd engines.\n\n"
216 "clear fwd stats all\n"
217 " Clear statistics for all fwd engines.\n\n"
219 "show port (port_id) rx_offload capabilities\n"
220 " List all per queue and per port Rx offloading"
221 " capabilities of a port\n\n"
223 "show port (port_id) rx_offload configuration\n"
224 " List port level and all queue level"
225 " Rx offloading configuration\n\n"
227 "show port (port_id) tx_offload capabilities\n"
228 " List all per queue and per port"
229 " Tx offloading capabilities of a port\n\n"
231 "show port (port_id) tx_offload configuration\n"
232 " List port level and all queue level"
233 " Tx offloading configuration\n\n"
235 "show port (port_id) tx_metadata\n"
236 " Show Tx metadata value set"
237 " for a specific port\n\n"
239 "show port (port_id) ptypes\n"
240 " Show port supported ptypes"
241 " for a specific port\n\n"
243 "show device info (<identifier>|all)"
244 " Show general information about devices probed.\n\n"
246 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
247 " Show status of rx|tx descriptor.\n\n"
249 "show port (port_id) macs|mcast_macs"
250 " Display list of mac addresses added to port.\n\n"
254 if (show_all || !strcmp(res->section, "config")) {
260 "Configuration changes only become active when"
261 " forwarding is started/restarted.\n\n"
264 " Reset forwarding to the default configuration.\n\n"
266 "set verbose (level)\n"
267 " Set the debug verbosity level X.\n\n"
269 "set log global|(type) (level)\n"
270 " Set the log level.\n\n"
273 " Set number of ports.\n\n"
276 " Set number of cores.\n\n"
278 "set coremask (mask)\n"
279 " Set the forwarding cores hexadecimal mask.\n\n"
281 "set portmask (mask)\n"
282 " Set the forwarding ports hexadecimal mask.\n\n"
285 " Set number of packets per burst.\n\n"
287 "set burst tx delay (microseconds) retry (num)\n"
288 " Set the transmit delay time and number of retries,"
289 " effective when retry is enabled.\n\n"
291 "set txpkts (x[,y]*)\n"
292 " Set the length of each segment of TXONLY"
293 " and optionally CSUM packets.\n\n"
295 "set txsplit (off|on|rand)\n"
296 " Set the split policy for the TX packets."
297 " Right now only applicable for CSUM and TXONLY"
300 "set txtimes (x, y)\n"
301 " Set the scheduling on timestamps"
302 " timings for the TXONLY mode\n\n"
304 "set corelist (x[,y]*)\n"
305 " Set the list of forwarding cores.\n\n"
307 "set portlist (x[,y]*)\n"
308 " Set the list of forwarding ports.\n\n"
310 "set port setup on (iterator|event)\n"
311 " Select how attached port is retrieved for setup.\n\n"
313 "set tx loopback (port_id) (on|off)\n"
314 " Enable or disable tx loopback.\n\n"
316 "set all queues drop (port_id) (on|off)\n"
317 " Set drop enable bit for all queues.\n\n"
319 "set vf split drop (port_id) (vf_id) (on|off)\n"
320 " Set split drop enable bit for a VF from the PF.\n\n"
322 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
323 " Set MAC antispoof for a VF from the PF.\n\n"
325 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
326 " Enable MACsec offload.\n\n"
328 "set macsec offload (port_id) off\n"
329 " Disable MACsec offload.\n\n"
331 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
332 " Configure MACsec secure connection (SC).\n\n"
334 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
335 " Configure MACsec secure association (SA).\n\n"
337 "set vf broadcast (port_id) (vf_id) (on|off)\n"
338 " Set VF broadcast for a VF from the PF.\n\n"
340 "vlan set stripq (on|off) (port_id,queue_id)\n"
341 " Set the VLAN strip for a queue on a port.\n\n"
343 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
344 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
346 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
347 " Set VLAN insert for a VF from the PF.\n\n"
349 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
350 " Set VLAN antispoof for a VF from the PF.\n\n"
352 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
353 " Set VLAN tag for a VF from the PF.\n\n"
355 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
356 " Set a VF's max bandwidth(Mbps).\n\n"
358 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
359 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
361 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
362 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
364 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
365 " Set some TCs' strict link priority mode on a physical port.\n\n"
367 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
368 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
370 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
371 " Set the VLAN strip or filter or qinq strip or extend\n\n"
373 "vlan set (inner|outer) tpid (value) (port_id)\n"
374 " Set the VLAN TPID for Packet Filtering on"
377 "rx_vlan add (vlan_id|all) (port_id)\n"
378 " Add a vlan_id, or all identifiers, to the set"
379 " of VLAN identifiers filtered by port_id.\n\n"
381 "rx_vlan rm (vlan_id|all) (port_id)\n"
382 " Remove a vlan_id, or all identifiers, from the set"
383 " of VLAN identifiers filtered by port_id.\n\n"
385 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
386 " Add a vlan_id, to the set of VLAN identifiers"
387 "filtered for VF(s) from port_id.\n\n"
389 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
390 " Remove a vlan_id, to the set of VLAN identifiers"
391 "filtered for VF(s) from port_id.\n\n"
393 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
394 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
395 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
396 " add a tunnel filter of a port.\n\n"
398 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
399 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
400 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
401 " remove a tunnel filter of a port.\n\n"
403 "rx_vxlan_port add (udp_port) (port_id)\n"
404 " Add an UDP port for VXLAN packet filter on a port\n\n"
406 "rx_vxlan_port rm (udp_port) (port_id)\n"
407 " Remove an UDP port for VXLAN packet filter on a port\n\n"
409 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
410 " Set hardware insertion of VLAN IDs (single or double VLAN "
411 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
413 "tx_vlan set pvid port_id vlan_id (on|off)\n"
414 " Set port based TX VLAN insertion.\n\n"
416 "tx_vlan reset (port_id)\n"
417 " Disable hardware insertion of a VLAN header in"
418 " packets sent on a port.\n\n"
420 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
421 " Select hardware or software calculation of the"
422 " checksum when transmitting a packet using the"
423 " csum forward engine.\n"
424 " ip|udp|tcp|sctp always concern the inner layer.\n"
425 " outer-ip concerns the outer IP layer in"
426 " outer-udp concerns the outer UDP layer in"
427 " case the packet is recognized as a tunnel packet by"
428 " the forward engine (vxlan, gre and ipip are supported)\n"
429 " Please check the NIC datasheet for HW limits.\n\n"
431 "csum parse-tunnel (on|off) (tx_port_id)\n"
432 " If disabled, treat tunnel packets as non-tunneled"
433 " packets (treat inner headers as payload). The port\n"
434 " argument is the port used for TX in csum forward"
437 "csum show (port_id)\n"
438 " Display tx checksum offload configuration\n\n"
440 "tso set (segsize) (portid)\n"
441 " Enable TCP Segmentation Offload in csum forward"
443 " Please check the NIC datasheet for HW limits.\n\n"
446 " Display the status of TCP Segmentation Offload.\n\n"
448 "set port (port_id) gro on|off\n"
449 " Enable or disable Generic Receive Offload in"
450 " csum forwarding engine.\n\n"
452 "show port (port_id) gro\n"
453 " Display GRO configuration.\n\n"
455 "set gro flush (cycles)\n"
456 " Set the cycle to flush GROed packets from"
457 " reassembly tables.\n\n"
459 "set port (port_id) gso (on|off)"
460 " Enable or disable Generic Segmentation Offload in"
461 " csum forwarding engine.\n\n"
463 "set gso segsz (length)\n"
464 " Set max packet length for output GSO segments,"
465 " including packet header and payload.\n\n"
467 "show port (port_id) gso\n"
468 " Show GSO configuration.\n\n"
471 " Set packet forwarding mode.\n\n"
473 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
474 " Add a MAC address on port_id.\n\n"
476 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
477 " Remove a MAC address from port_id.\n\n"
479 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
480 " Set the default MAC address for port_id.\n\n"
482 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
483 " Add a MAC address for a VF on the port.\n\n"
485 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
486 " Set the MAC address for a VF from the PF.\n\n"
488 "set eth-peer (port_id) (peer_addr)\n"
489 " set the peer address for certain port.\n\n"
491 "set port (port_id) uta (mac_address|all) (on|off)\n"
492 " Add/Remove a or all unicast hash filter(s)"
495 "set promisc (port_id|all) (on|off)\n"
496 " Set the promiscuous mode on port_id, or all.\n\n"
498 "set allmulti (port_id|all) (on|off)\n"
499 " Set the allmulti mode on port_id, or all.\n\n"
501 "set vf promisc (port_id) (vf_id) (on|off)\n"
502 " Set unicast promiscuous mode for a VF from the PF.\n\n"
504 "set vf allmulti (port_id) (vf_id) (on|off)\n"
505 " Set multicast promiscuous mode for a VF from the PF.\n\n"
507 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
508 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
509 " (on|off) autoneg (on|off) (port_id)\n"
510 "set flow_ctrl rx (on|off) (portid)\n"
511 "set flow_ctrl tx (on|off) (portid)\n"
512 "set flow_ctrl high_water (high_water) (portid)\n"
513 "set flow_ctrl low_water (low_water) (portid)\n"
514 "set flow_ctrl pause_time (pause_time) (portid)\n"
515 "set flow_ctrl send_xon (send_xon) (portid)\n"
516 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
517 "set flow_ctrl autoneg (on|off) (port_id)\n"
518 " Set the link flow control parameter on a port.\n\n"
520 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
521 " (low_water) (pause_time) (priority) (port_id)\n"
522 " Set the priority flow control parameter on a"
525 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
526 " Set statistics mapping (qmapping 0..15) for RX/TX"
528 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
529 " on port 0 to mapping 5.\n\n"
531 "set xstats-hide-zero on|off\n"
532 " Set the option to hide the zero values"
533 " for xstats display.\n"
535 "set record-core-cycles on|off\n"
536 " Set the option to enable measurement of CPU cycles.\n"
538 "set record-burst-stats on|off\n"
539 " Set the option to enable display of RX and TX bursts.\n"
541 "set port (port_id) vf (vf_id) rx|tx on|off\n"
542 " Enable/Disable a VF receive/tranmit from a port\n\n"
544 "set port (port_id) vf (vf_id) (mac_addr)"
545 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
546 " Add/Remove unicast or multicast MAC addr filter"
549 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
551 " AUPE:accepts untagged VLAN;"
552 "ROPE:accept unicast hash\n\n"
553 " BAM:accepts broadcast packets;"
554 "MPE:accepts all multicast packets\n\n"
555 " Enable/Disable a VF receive mode of a port\n\n"
557 "set port (port_id) queue (queue_id) rate (rate_num)\n"
558 " Set rate limit for a queue of a port\n\n"
560 "set port (port_id) vf (vf_id) rate (rate_num) "
561 "queue_mask (queue_mask_value)\n"
562 " Set rate limit for queues in VF of a port\n\n"
564 "set port (port_id) mirror-rule (rule_id)"
565 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
566 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
567 " Set pool or vlan type mirror rule on a port.\n"
568 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
569 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
572 "set port (port_id) mirror-rule (rule_id)"
573 " (uplink-mirror|downlink-mirror) dst-pool"
574 " (pool_id) (on|off)\n"
575 " Set uplink or downlink type mirror rule on a port.\n"
576 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
577 " 0 on' enable mirror income traffic to pool 0.\n\n"
579 "reset port (port_id) mirror-rule (rule_id)\n"
580 " Reset a mirror rule.\n\n"
582 "set flush_rx (on|off)\n"
583 " Flush (default) or don't flush RX streams before"
584 " forwarding. Mainly used with PCAP drivers.\n\n"
586 "set bypass mode (normal|bypass|isolate) (port_id)\n"
587 " Set the bypass mode for the lowest port on bypass enabled"
590 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
591 "mode (normal|bypass|isolate) (port_id)\n"
592 " Set the event required to initiate specified bypass mode for"
593 " the lowest port on a bypass enabled NIC where:\n"
594 " timeout = enable bypass after watchdog timeout.\n"
595 " os_on = enable bypass when OS/board is powered on.\n"
596 " os_off = enable bypass when OS/board is powered off.\n"
597 " power_on = enable bypass when power supply is turned on.\n"
598 " power_off = enable bypass when power supply is turned off."
601 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
602 " Set the bypass watchdog timeout to 'n' seconds"
603 " where 0 = instant.\n\n"
605 "show bypass config (port_id)\n"
606 " Show the bypass configuration for a bypass enabled NIC"
607 " using the lowest port on the NIC.\n\n"
609 #ifdef RTE_LIBRTE_PMD_BOND
610 "create bonded device (mode) (socket)\n"
611 " Create a new bonded device with specific bonding mode and socket.\n\n"
613 "add bonding slave (slave_id) (port_id)\n"
614 " Add a slave device to a bonded device.\n\n"
616 "remove bonding slave (slave_id) (port_id)\n"
617 " Remove a slave device from a bonded device.\n\n"
619 "set bonding mode (value) (port_id)\n"
620 " Set the bonding mode on a bonded device.\n\n"
622 "set bonding primary (slave_id) (port_id)\n"
623 " Set the primary slave for a bonded device.\n\n"
625 "show bonding config (port_id)\n"
626 " Show the bonding config for port_id.\n\n"
628 "set bonding mac_addr (port_id) (address)\n"
629 " Set the MAC address of a bonded device.\n\n"
631 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
632 " Set Aggregation mode for IEEE802.3AD (mode 4)"
634 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
635 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
637 "set bonding mon_period (port_id) (value)\n"
638 " Set the bonding link status monitoring polling period in ms.\n\n"
640 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
641 " Enable/disable dedicated queues for LACP control traffic.\n\n"
644 "set link-up port (port_id)\n"
645 " Set link up for a port.\n\n"
647 "set link-down port (port_id)\n"
648 " Set link down for a port.\n\n"
650 "E-tag set insertion on port-tag-id (value)"
651 " port (port_id) vf (vf_id)\n"
652 " Enable E-tag insertion for a VF on a port\n\n"
654 "E-tag set insertion off port (port_id) vf (vf_id)\n"
655 " Disable E-tag insertion for a VF on a port\n\n"
657 "E-tag set stripping (on|off) port (port_id)\n"
658 " Enable/disable E-tag stripping on a port\n\n"
660 "E-tag set forwarding (on|off) port (port_id)\n"
661 " Enable/disable E-tag based forwarding"
664 "E-tag set filter add e-tag-id (value) dst-pool"
665 " (pool_id) port (port_id)\n"
666 " Add an E-tag forwarding filter on a port\n\n"
668 "E-tag set filter del e-tag-id (value) port (port_id)\n"
669 " Delete an E-tag forwarding filter on a port\n\n"
671 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
672 " Load a profile package on a port\n\n"
674 "ddp del (port_id) (backup_profile_path)\n"
675 " Delete a profile package from a port\n\n"
677 "ptype mapping get (port_id) (valid_only)\n"
678 " Get ptype mapping on a port\n\n"
680 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
681 " Replace target with the pkt_type in ptype mapping\n\n"
683 "ptype mapping reset (port_id)\n"
684 " Reset ptype mapping on a port\n\n"
686 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
687 " Update a ptype mapping item on a port\n\n"
689 "set port (port_id) ptype_mask (ptype_mask)\n"
690 " set packet types classification for a specific port\n\n"
692 "set port (port_id) queue-region region_id (value) "
693 "queue_start_index (value) queue_num (value)\n"
694 " Set a queue region on a port\n\n"
696 "set port (port_id) queue-region region_id (value) "
698 " Set a flowtype region index on a port\n\n"
700 "set port (port_id) queue-region UP (value) region_id (value)\n"
701 " Set the mapping of User Priority to "
702 "queue region on a port\n\n"
704 "set port (port_id) queue-region flush (on|off)\n"
705 " flush all queue region related configuration\n\n"
707 "show port meter cap (port_id)\n"
708 " Show port meter capability information\n\n"
710 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
711 " meter profile add - srtcm rfc 2697\n\n"
713 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
714 " meter profile add - trtcm rfc 2698\n\n"
716 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
717 " meter profile add - trtcm rfc 4115\n\n"
719 "del port meter profile (port_id) (profile_id)\n"
720 " meter profile delete\n\n"
722 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
723 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
724 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
725 "(dscp_tbl_entry63)]\n"
728 "enable port meter (port_id) (mtr_id)\n"
731 "disable port meter (port_id) (mtr_id)\n"
734 "del port meter (port_id) (mtr_id)\n"
737 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
738 " meter update meter profile\n\n"
740 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
741 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
742 " update meter dscp table entries\n\n"
744 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
745 "(action0) [(action1) (action2)]\n"
746 " meter update policer action\n\n"
748 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
749 " meter update stats\n\n"
751 "show port (port_id) queue-region\n"
752 " show all queue region related configuration info\n\n"
754 , list_pkt_forwarding_modes()
758 if (show_all || !strcmp(res->section, "ports")) {
764 "----------------\n\n"
766 "port start (port_id|all)\n"
767 " Start all ports or port_id.\n\n"
769 "port stop (port_id|all)\n"
770 " Stop all ports or port_id.\n\n"
772 "port close (port_id|all)\n"
773 " Close all ports or port_id.\n\n"
775 "port reset (port_id|all)\n"
776 " Reset all ports or port_id.\n\n"
778 "port attach (ident)\n"
779 " Attach physical or virtual dev by pci address or virtual device name\n\n"
781 "port detach (port_id)\n"
782 " Detach physical or virtual dev by port_id\n\n"
784 "port config (port_id|all)"
785 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
786 " duplex (half|full|auto)\n"
787 " Set speed and duplex for all ports or port_id\n\n"
789 "port config (port_id|all) loopback (mode)\n"
790 " Set loopback mode for all ports or port_id\n\n"
792 "port config all (rxq|txq|rxd|txd) (value)\n"
793 " Set number for rxq/txq/rxd/txd.\n\n"
795 "port config all max-pkt-len (value)\n"
796 " Set the max packet length.\n\n"
798 "port config all max-lro-pkt-size (value)\n"
799 " Set the max LRO aggregated packet size.\n\n"
801 "port config all drop-en (on|off)\n"
802 " Enable or disable packet drop on all RX queues of all ports when no "
803 "receive buffers available.\n\n"
805 "port config all rss (all|default|ip|tcp|udp|sctp|"
806 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|level-default|"
807 "level-outer|level-inner|<flowtype_id>)\n"
808 " Set the RSS mode.\n\n"
810 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
811 " Set the RSS redirection table.\n\n"
813 "port config (port_id) dcb vt (on|off) (traffic_class)"
815 " Set the DCB mode.\n\n"
817 "port config all burst (value)\n"
818 " Set the number of packets per burst.\n\n"
820 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
822 " Set the ring prefetch/host/writeback threshold"
823 " for tx/rx queue.\n\n"
825 "port config all (txfreet|txrst|rxfreet) (value)\n"
826 " Set free threshold for rx/tx, or set"
827 " tx rs bit threshold.\n\n"
828 "port config mtu X value\n"
829 " Set the MTU of port X to a given value\n\n"
831 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
832 " Set a rx/tx queue's ring size configuration, the new"
833 " value will take effect after command that (re-)start the port"
834 " or command that setup the specific queue\n\n"
836 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
837 " Start/stop a rx/tx queue of port X. Only take effect"
838 " when port X is started\n\n"
840 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
841 " Switch on/off a deferred start of port X rx/tx queue. Only"
842 " take effect when port X is stopped.\n\n"
844 "port (port_id) (rxq|txq) (queue_id) setup\n"
845 " Setup a rx/tx queue of port X.\n\n"
847 "port config (port_id|all) l2-tunnel E-tag ether-type"
849 " Set the value of E-tag ether-type.\n\n"
851 "port config (port_id|all) l2-tunnel E-tag"
852 " (enable|disable)\n"
853 " Enable/disable the E-tag support.\n\n"
855 "port config (port_id) pctype mapping reset\n"
856 " Reset flow type to pctype mapping on a port\n\n"
858 "port config (port_id) pctype mapping update"
859 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
860 " Update a flow type to pctype mapping item on a port\n\n"
862 "port config (port_id) pctype (pctype_id) hash_inset|"
863 "fdir_inset|fdir_flx_inset get|set|clear field\n"
865 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
867 "port config (port_id) pctype (pctype_id) hash_inset|"
868 "fdir_inset|fdir_flx_inset clear all"
869 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
871 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
872 " Add/remove UDP tunnel port for tunneling offload\n\n"
874 "port config <port_id> rx_offload vlan_strip|"
875 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
876 "outer_ipv4_cksum|macsec_strip|header_split|"
877 "vlan_filter|vlan_extend|jumbo_frame|"
878 "scatter|timestamp|security|keep_crc on|off\n"
879 " Enable or disable a per port Rx offloading"
880 " on all Rx queues of a port\n\n"
882 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
883 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
884 "outer_ipv4_cksum|macsec_strip|header_split|"
885 "vlan_filter|vlan_extend|jumbo_frame|"
886 "scatter|timestamp|security|keep_crc on|off\n"
887 " Enable or disable a per queue Rx offloading"
888 " only on a specific Rx queue\n\n"
890 "port config (port_id) tx_offload vlan_insert|"
891 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
892 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
893 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
894 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
896 " Enable or disable a per port Tx offloading"
897 " on all Tx queues of a port\n\n"
899 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
900 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
901 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
902 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
903 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
905 " Enable or disable a per queue Tx offloading"
906 " only on a specific Tx queue\n\n"
908 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
909 " Load an eBPF program as a callback"
910 " for particular RX/TX queue\n\n"
912 "bpf-unload rx|tx (port) (queue)\n"
913 " Unload previously loaded eBPF program"
914 " for particular RX/TX queue\n\n"
916 "port config (port_id) tx_metadata (value)\n"
917 " Set Tx metadata value per port. Testpmd will add this value"
918 " to any Tx packet sent from this port\n\n"
920 "port config (port_id) dynf (name) set|clear\n"
921 " Register a dynf and Set/clear this flag on Tx. "
922 "Testpmd will set this value to any Tx packet "
923 "sent from this port\n\n"
927 if (show_all || !strcmp(res->section, "registers")) {
935 "read reg (port_id) (address)\n"
936 " Display value of a port register.\n\n"
938 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
939 " Display a port register bit field.\n\n"
941 "read regbit (port_id) (address) (bit_x)\n"
942 " Display a single port register bit.\n\n"
944 "write reg (port_id) (address) (value)\n"
945 " Set value of a port register.\n\n"
947 "write regfield (port_id) (address) (bit_x) (bit_y)"
949 " Set bit field of a port register.\n\n"
951 "write regbit (port_id) (address) (bit_x) (value)\n"
952 " Set single bit value of a port register.\n\n"
955 if (show_all || !strcmp(res->section, "filters")) {
963 "ethertype_filter (port_id) (add|del)"
964 " (mac_addr|mac_ignr) (mac_address) ethertype"
965 " (ether_type) (drop|fwd) queue (queue_id)\n"
966 " Add/Del an ethertype filter.\n\n"
968 "2tuple_filter (port_id) (add|del)"
969 " dst_port (dst_port_value) protocol (protocol_value)"
970 " mask (mask_value) tcp_flags (tcp_flags_value)"
971 " priority (prio_value) queue (queue_id)\n"
972 " Add/Del a 2tuple filter.\n\n"
974 "5tuple_filter (port_id) (add|del)"
975 " dst_ip (dst_address) src_ip (src_address)"
976 " dst_port (dst_port_value) src_port (src_port_value)"
977 " protocol (protocol_value)"
978 " mask (mask_value) tcp_flags (tcp_flags_value)"
979 " priority (prio_value) queue (queue_id)\n"
980 " Add/Del a 5tuple filter.\n\n"
982 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
983 " Add/Del syn filter.\n\n"
985 "flex_filter (port_id) (add|del) len (len_value)"
986 " bytes (bytes_value) mask (mask_value)"
987 " priority (prio_value) queue (queue_id)\n"
988 " Add/Del a flex filter.\n\n"
990 "flow_director_filter (port_id) mode IP (add|del|update)"
991 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
992 " src (src_ip_address) dst (dst_ip_address)"
993 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
994 " vlan (vlan_value) flexbytes (flexbytes_value)"
995 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
996 " fd_id (fd_id_value)\n"
997 " Add/Del an IP type flow director filter.\n\n"
999 "flow_director_filter (port_id) mode IP (add|del|update)"
1000 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
1001 " src (src_ip_address) (src_port)"
1002 " dst (dst_ip_address) (dst_port)"
1003 " tos (tos_value) ttl (ttl_value)"
1004 " vlan (vlan_value) flexbytes (flexbytes_value)"
1005 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1006 " fd_id (fd_id_value)\n"
1007 " Add/Del an UDP/TCP type flow director filter.\n\n"
1009 "flow_director_filter (port_id) mode IP (add|del|update)"
1010 " flow (ipv4-sctp|ipv6-sctp)"
1011 " src (src_ip_address) (src_port)"
1012 " dst (dst_ip_address) (dst_port)"
1013 " tag (verification_tag) "
1014 " tos (tos_value) ttl (ttl_value)"
1015 " vlan (vlan_value)"
1016 " flexbytes (flexbytes_value) (drop|fwd)"
1017 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1018 " Add/Del a SCTP type flow director filter.\n\n"
1020 "flow_director_filter (port_id) mode IP (add|del|update)"
1021 " flow l2_payload ether (ethertype)"
1022 " flexbytes (flexbytes_value) (drop|fwd)"
1023 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1024 " Add/Del a l2 payload type flow director filter.\n\n"
1026 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1027 " mac (mac_address) vlan (vlan_value)"
1028 " flexbytes (flexbytes_value) (drop|fwd)"
1029 " queue (queue_id) fd_id (fd_id_value)\n"
1030 " Add/Del a MAC-VLAN flow director filter.\n\n"
1032 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1033 " mac (mac_address) vlan (vlan_value)"
1034 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1035 " flexbytes (flexbytes_value) (drop|fwd)"
1036 " queue (queue_id) fd_id (fd_id_value)\n"
1037 " Add/Del a Tunnel flow director filter.\n\n"
1039 "flow_director_filter (port_id) mode raw (add|del|update)"
1040 " flow (flow_id) (drop|fwd) queue (queue_id)"
1041 " fd_id (fd_id_value) packet (packet file name)\n"
1042 " Add/Del a raw type flow director filter.\n\n"
1044 "flush_flow_director (port_id)\n"
1045 " Flush all flow director entries of a device.\n\n"
1047 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1048 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1049 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1050 " Set flow director IP mask.\n\n"
1052 "flow_director_mask (port_id) mode MAC-VLAN"
1053 " vlan (vlan_value)\n"
1054 " Set flow director MAC-VLAN mask.\n\n"
1056 "flow_director_mask (port_id) mode Tunnel"
1057 " vlan (vlan_value) mac (mac_value)"
1058 " tunnel-type (tunnel_type_value)"
1059 " tunnel-id (tunnel_id_value)\n"
1060 " Set flow director Tunnel mask.\n\n"
1062 "flow_director_flex_mask (port_id)"
1063 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1064 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1066 " Configure mask of flex payload.\n\n"
1068 "flow_director_flex_payload (port_id)"
1069 " (raw|l2|l3|l4) (config)\n"
1070 " Configure flex payload selection.\n\n"
1072 "get_sym_hash_ena_per_port (port_id)\n"
1073 " get symmetric hash enable configuration per port.\n\n"
1075 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1076 " set symmetric hash enable configuration per port"
1077 " to enable or disable.\n\n"
1079 "get_hash_global_config (port_id)\n"
1080 " Get the global configurations of hash filters.\n\n"
1082 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1083 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1084 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1085 " (enable|disable)\n"
1086 " Set the global configurations of hash filters.\n\n"
1088 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1089 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1090 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1091 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1092 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1093 "ipv6-next-header|udp-src-port|udp-dst-port|"
1094 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1095 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1096 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1097 "fld-8th|none) (select|add)\n"
1098 " Set the input set for hash.\n\n"
1100 "set_fdir_input_set (port_id) "
1101 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1102 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1103 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1104 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1105 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1106 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1107 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1109 " Set the input set for FDir.\n\n"
1111 "flow validate {port_id}"
1112 " [group {group_id}] [priority {level}]"
1113 " [ingress] [egress]"
1114 " pattern {item} [/ {item} [...]] / end"
1115 " actions {action} [/ {action} [...]] / end\n"
1116 " Check whether a flow rule can be created.\n\n"
1118 "flow create {port_id}"
1119 " [group {group_id}] [priority {level}]"
1120 " [ingress] [egress]"
1121 " pattern {item} [/ {item} [...]] / end"
1122 " actions {action} [/ {action} [...]] / end\n"
1123 " Create a flow rule.\n\n"
1125 "flow destroy {port_id} rule {rule_id} [...]\n"
1126 " Destroy specific flow rules.\n\n"
1128 "flow flush {port_id}\n"
1129 " Destroy all flow rules.\n\n"
1131 "flow query {port_id} {rule_id} {action}\n"
1132 " Query an existing flow rule.\n\n"
1134 "flow list {port_id} [group {group_id}] [...]\n"
1135 " List existing flow rules sorted by priority,"
1136 " filtered by group identifiers.\n\n"
1138 "flow isolate {port_id} {boolean}\n"
1139 " Restrict ingress traffic to the defined"
1142 "flow aged {port_id} [destroy]\n"
1143 " List and destroy aged flows"
1146 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1147 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1148 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1149 " Configure the VXLAN encapsulation for flows.\n\n"
1151 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1152 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1153 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1154 " eth-dst (eth-dst)\n"
1155 " Configure the VXLAN encapsulation for flows.\n\n"
1157 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1158 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1159 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1160 " eth-dst (eth-dst)\n"
1161 " Configure the VXLAN encapsulation for flows.\n\n"
1163 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1164 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1166 " Configure the NVGRE encapsulation for flows.\n\n"
1168 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1169 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1170 " eth-src (eth-src) eth-dst (eth-dst)\n"
1171 " Configure the NVGRE encapsulation for flows.\n\n"
1173 "set raw_encap {flow items}\n"
1174 " Configure the encapsulation with raw data.\n\n"
1176 "set raw_decap {flow items}\n"
1177 " Configure the decapsulation with raw data.\n\n"
1182 if (show_all || !strcmp(res->section, "traffic_management")) {
1186 "Traffic Management:\n"
1188 "show port tm cap (port_id)\n"
1189 " Display the port TM capability.\n\n"
1191 "show port tm level cap (port_id) (level_id)\n"
1192 " Display the port TM hierarchical level capability.\n\n"
1194 "show port tm node cap (port_id) (node_id)\n"
1195 " Display the port TM node capability.\n\n"
1197 "show port tm node type (port_id) (node_id)\n"
1198 " Display the port TM node type.\n\n"
1200 "show port tm node stats (port_id) (node_id) (clear)\n"
1201 " Display the port TM node stats.\n\n"
1203 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1204 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1205 " (packet_length_adjust) (packet_mode)\n"
1206 " Add port tm node private shaper profile.\n\n"
1208 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1209 " Delete port tm node private shaper profile.\n\n"
1211 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1212 " (shaper_profile_id)\n"
1213 " Add/update port tm node shared shaper.\n\n"
1215 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1216 " Delete port tm node shared shaper.\n\n"
1218 "set port tm node shaper profile (port_id) (node_id)"
1219 " (shaper_profile_id)\n"
1220 " Set port tm node shaper profile.\n\n"
1222 "add port tm node wred profile (port_id) (wred_profile_id)"
1223 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1224 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1225 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1226 " Add port tm node wred profile.\n\n"
1228 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1229 " Delete port tm node wred profile.\n\n"
1231 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1232 " (priority) (weight) (level_id) (shaper_profile_id)"
1233 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1234 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1235 " Add port tm nonleaf node.\n\n"
1237 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1238 " (priority) (weight) (level_id) (shaper_profile_id)"
1239 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1240 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1241 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1243 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1244 " (priority) (weight) (level_id) (shaper_profile_id)"
1245 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1246 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1247 " Add port tm leaf node.\n\n"
1249 "del port tm node (port_id) (node_id)\n"
1250 " Delete port tm node.\n\n"
1252 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1253 " (priority) (weight)\n"
1254 " Set port tm node parent.\n\n"
1256 "suspend port tm node (port_id) (node_id)"
1257 " Suspend tm node.\n\n"
1259 "resume port tm node (port_id) (node_id)"
1260 " Resume tm node.\n\n"
1262 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1263 " Commit tm hierarchy.\n\n"
1265 "set port tm mark ip_ecn (port) (green) (yellow)"
1267 " Enables/Disables the traffic management marking"
1268 " for IP ECN (Explicit Congestion Notification)"
1269 " packets on a given port\n\n"
1271 "set port tm mark ip_dscp (port) (green) (yellow)"
1273 " Enables/Disables the traffic management marking"
1274 " on the port for IP dscp packets\n\n"
1276 "set port tm mark vlan_dei (port) (green) (yellow)"
1278 " Enables/Disables the traffic management marking"
1279 " on the port for VLAN packets with DEI enabled\n\n"
1283 if (show_all || !strcmp(res->section, "devices")) {
1287 "Device Operations:\n"
1289 "device detach (identifier)\n"
1290 " Detach device by identifier.\n\n"
1296 cmdline_parse_token_string_t cmd_help_long_help =
1297 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1299 cmdline_parse_token_string_t cmd_help_long_section =
1300 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1301 "all#control#display#config#"
1302 "ports#registers#filters#traffic_management#devices");
1304 cmdline_parse_inst_t cmd_help_long = {
1305 .f = cmd_help_long_parsed,
1307 .help_str = "help all|control|display|config|ports|register|"
1308 "filters|traffic_management|devices: "
1311 (void *)&cmd_help_long_help,
1312 (void *)&cmd_help_long_section,
1318 /* *** start/stop/close all ports *** */
1319 struct cmd_operate_port_result {
1320 cmdline_fixed_string_t keyword;
1321 cmdline_fixed_string_t name;
1322 cmdline_fixed_string_t value;
1325 static void cmd_operate_port_parsed(void *parsed_result,
1326 __rte_unused struct cmdline *cl,
1327 __rte_unused void *data)
1329 struct cmd_operate_port_result *res = parsed_result;
1331 if (!strcmp(res->name, "start"))
1332 start_port(RTE_PORT_ALL);
1333 else if (!strcmp(res->name, "stop"))
1334 stop_port(RTE_PORT_ALL);
1335 else if (!strcmp(res->name, "close"))
1336 close_port(RTE_PORT_ALL);
1337 else if (!strcmp(res->name, "reset"))
1338 reset_port(RTE_PORT_ALL);
1340 printf("Unknown parameter\n");
1343 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1344 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1346 cmdline_parse_token_string_t cmd_operate_port_all_port =
1347 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1348 "start#stop#close#reset");
1349 cmdline_parse_token_string_t cmd_operate_port_all_all =
1350 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1352 cmdline_parse_inst_t cmd_operate_port = {
1353 .f = cmd_operate_port_parsed,
1355 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1357 (void *)&cmd_operate_port_all_cmd,
1358 (void *)&cmd_operate_port_all_port,
1359 (void *)&cmd_operate_port_all_all,
1364 /* *** start/stop/close specific port *** */
1365 struct cmd_operate_specific_port_result {
1366 cmdline_fixed_string_t keyword;
1367 cmdline_fixed_string_t name;
1371 static void cmd_operate_specific_port_parsed(void *parsed_result,
1372 __rte_unused struct cmdline *cl,
1373 __rte_unused void *data)
1375 struct cmd_operate_specific_port_result *res = parsed_result;
1377 if (!strcmp(res->name, "start"))
1378 start_port(res->value);
1379 else if (!strcmp(res->name, "stop"))
1380 stop_port(res->value);
1381 else if (!strcmp(res->name, "close"))
1382 close_port(res->value);
1383 else if (!strcmp(res->name, "reset"))
1384 reset_port(res->value);
1386 printf("Unknown parameter\n");
1389 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1390 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1392 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1393 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1394 name, "start#stop#close#reset");
1395 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1396 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1399 cmdline_parse_inst_t cmd_operate_specific_port = {
1400 .f = cmd_operate_specific_port_parsed,
1402 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1404 (void *)&cmd_operate_specific_port_cmd,
1405 (void *)&cmd_operate_specific_port_port,
1406 (void *)&cmd_operate_specific_port_id,
1411 /* *** enable port setup (after attach) via iterator or event *** */
1412 struct cmd_set_port_setup_on_result {
1413 cmdline_fixed_string_t set;
1414 cmdline_fixed_string_t port;
1415 cmdline_fixed_string_t setup;
1416 cmdline_fixed_string_t on;
1417 cmdline_fixed_string_t mode;
1420 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1421 __rte_unused struct cmdline *cl,
1422 __rte_unused void *data)
1424 struct cmd_set_port_setup_on_result *res = parsed_result;
1426 if (strcmp(res->mode, "event") == 0)
1427 setup_on_probe_event = true;
1428 else if (strcmp(res->mode, "iterator") == 0)
1429 setup_on_probe_event = false;
1431 printf("Unknown mode\n");
1434 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1435 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1437 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1438 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1440 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1441 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1443 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1444 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1446 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1447 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1448 mode, "iterator#event");
1450 cmdline_parse_inst_t cmd_set_port_setup_on = {
1451 .f = cmd_set_port_setup_on_parsed,
1453 .help_str = "set port setup on iterator|event",
1455 (void *)&cmd_set_port_setup_on_set,
1456 (void *)&cmd_set_port_setup_on_port,
1457 (void *)&cmd_set_port_setup_on_setup,
1458 (void *)&cmd_set_port_setup_on_on,
1459 (void *)&cmd_set_port_setup_on_mode,
1464 /* *** attach a specified port *** */
1465 struct cmd_operate_attach_port_result {
1466 cmdline_fixed_string_t port;
1467 cmdline_fixed_string_t keyword;
1468 cmdline_multi_string_t identifier;
1471 static void cmd_operate_attach_port_parsed(void *parsed_result,
1472 __rte_unused struct cmdline *cl,
1473 __rte_unused void *data)
1475 struct cmd_operate_attach_port_result *res = parsed_result;
1477 if (!strcmp(res->keyword, "attach"))
1478 attach_port(res->identifier);
1480 printf("Unknown parameter\n");
1483 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1484 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1486 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1487 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1489 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1490 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1491 identifier, TOKEN_STRING_MULTI);
1493 cmdline_parse_inst_t cmd_operate_attach_port = {
1494 .f = cmd_operate_attach_port_parsed,
1496 .help_str = "port attach <identifier>: "
1497 "(identifier: pci address or virtual dev name)",
1499 (void *)&cmd_operate_attach_port_port,
1500 (void *)&cmd_operate_attach_port_keyword,
1501 (void *)&cmd_operate_attach_port_identifier,
1506 /* *** detach a specified port *** */
1507 struct cmd_operate_detach_port_result {
1508 cmdline_fixed_string_t port;
1509 cmdline_fixed_string_t keyword;
1513 static void cmd_operate_detach_port_parsed(void *parsed_result,
1514 __rte_unused struct cmdline *cl,
1515 __rte_unused void *data)
1517 struct cmd_operate_detach_port_result *res = parsed_result;
1519 if (!strcmp(res->keyword, "detach")) {
1520 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1521 detach_port_device(res->port_id);
1523 printf("Unknown parameter\n");
1527 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1528 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1530 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1531 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1533 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1534 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1537 cmdline_parse_inst_t cmd_operate_detach_port = {
1538 .f = cmd_operate_detach_port_parsed,
1540 .help_str = "port detach <port_id>",
1542 (void *)&cmd_operate_detach_port_port,
1543 (void *)&cmd_operate_detach_port_keyword,
1544 (void *)&cmd_operate_detach_port_port_id,
1549 /* *** detach device by identifier *** */
1550 struct cmd_operate_detach_device_result {
1551 cmdline_fixed_string_t device;
1552 cmdline_fixed_string_t keyword;
1553 cmdline_fixed_string_t identifier;
1556 static void cmd_operate_detach_device_parsed(void *parsed_result,
1557 __rte_unused struct cmdline *cl,
1558 __rte_unused void *data)
1560 struct cmd_operate_detach_device_result *res = parsed_result;
1562 if (!strcmp(res->keyword, "detach"))
1563 detach_devargs(res->identifier);
1565 printf("Unknown parameter\n");
1568 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1569 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1571 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1572 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1574 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1575 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1578 cmdline_parse_inst_t cmd_operate_detach_device = {
1579 .f = cmd_operate_detach_device_parsed,
1581 .help_str = "device detach <identifier>:"
1582 "(identifier: pci address or virtual dev name)",
1584 (void *)&cmd_operate_detach_device_device,
1585 (void *)&cmd_operate_detach_device_keyword,
1586 (void *)&cmd_operate_detach_device_identifier,
1590 /* *** configure speed for all ports *** */
1591 struct cmd_config_speed_all {
1592 cmdline_fixed_string_t port;
1593 cmdline_fixed_string_t keyword;
1594 cmdline_fixed_string_t all;
1595 cmdline_fixed_string_t item1;
1596 cmdline_fixed_string_t item2;
1597 cmdline_fixed_string_t value1;
1598 cmdline_fixed_string_t value2;
1602 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1607 if (!strcmp(duplexstr, "half")) {
1608 duplex = ETH_LINK_HALF_DUPLEX;
1609 } else if (!strcmp(duplexstr, "full")) {
1610 duplex = ETH_LINK_FULL_DUPLEX;
1611 } else if (!strcmp(duplexstr, "auto")) {
1612 duplex = ETH_LINK_FULL_DUPLEX;
1614 printf("Unknown duplex parameter\n");
1618 if (!strcmp(speedstr, "10")) {
1619 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1620 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1621 } else if (!strcmp(speedstr, "100")) {
1622 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1623 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1625 if (duplex != ETH_LINK_FULL_DUPLEX) {
1626 printf("Invalid speed/duplex parameters\n");
1629 if (!strcmp(speedstr, "1000")) {
1630 *speed = ETH_LINK_SPEED_1G;
1631 } else if (!strcmp(speedstr, "10000")) {
1632 *speed = ETH_LINK_SPEED_10G;
1633 } else if (!strcmp(speedstr, "25000")) {
1634 *speed = ETH_LINK_SPEED_25G;
1635 } else if (!strcmp(speedstr, "40000")) {
1636 *speed = ETH_LINK_SPEED_40G;
1637 } else if (!strcmp(speedstr, "50000")) {
1638 *speed = ETH_LINK_SPEED_50G;
1639 } else if (!strcmp(speedstr, "100000")) {
1640 *speed = ETH_LINK_SPEED_100G;
1641 } else if (!strcmp(speedstr, "200000")) {
1642 *speed = ETH_LINK_SPEED_200G;
1643 } else if (!strcmp(speedstr, "auto")) {
1644 *speed = ETH_LINK_SPEED_AUTONEG;
1646 printf("Unknown speed parameter\n");
1655 cmd_config_speed_all_parsed(void *parsed_result,
1656 __rte_unused struct cmdline *cl,
1657 __rte_unused void *data)
1659 struct cmd_config_speed_all *res = parsed_result;
1660 uint32_t link_speed;
1663 if (!all_ports_stopped()) {
1664 printf("Please stop all ports first\n");
1668 if (parse_and_check_speed_duplex(res->value1, res->value2,
1672 RTE_ETH_FOREACH_DEV(pid) {
1673 ports[pid].dev_conf.link_speeds = link_speed;
1676 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1679 cmdline_parse_token_string_t cmd_config_speed_all_port =
1680 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1681 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1682 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1684 cmdline_parse_token_string_t cmd_config_speed_all_all =
1685 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1686 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1687 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1688 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1689 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1690 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1691 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1692 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1693 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1694 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1697 cmdline_parse_inst_t cmd_config_speed_all = {
1698 .f = cmd_config_speed_all_parsed,
1700 .help_str = "port config all speed "
1701 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1704 (void *)&cmd_config_speed_all_port,
1705 (void *)&cmd_config_speed_all_keyword,
1706 (void *)&cmd_config_speed_all_all,
1707 (void *)&cmd_config_speed_all_item1,
1708 (void *)&cmd_config_speed_all_value1,
1709 (void *)&cmd_config_speed_all_item2,
1710 (void *)&cmd_config_speed_all_value2,
1715 /* *** configure speed for specific port *** */
1716 struct cmd_config_speed_specific {
1717 cmdline_fixed_string_t port;
1718 cmdline_fixed_string_t keyword;
1720 cmdline_fixed_string_t item1;
1721 cmdline_fixed_string_t item2;
1722 cmdline_fixed_string_t value1;
1723 cmdline_fixed_string_t value2;
1727 cmd_config_speed_specific_parsed(void *parsed_result,
1728 __rte_unused struct cmdline *cl,
1729 __rte_unused void *data)
1731 struct cmd_config_speed_specific *res = parsed_result;
1732 uint32_t link_speed;
1734 if (!all_ports_stopped()) {
1735 printf("Please stop all ports first\n");
1739 if (port_id_is_invalid(res->id, ENABLED_WARN))
1742 if (parse_and_check_speed_duplex(res->value1, res->value2,
1746 ports[res->id].dev_conf.link_speeds = link_speed;
1748 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1752 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1753 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1755 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1756 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1758 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1759 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1760 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1761 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1763 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1764 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1765 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1766 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1767 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1769 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1770 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1773 cmdline_parse_inst_t cmd_config_speed_specific = {
1774 .f = cmd_config_speed_specific_parsed,
1776 .help_str = "port config <port_id> speed "
1777 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1780 (void *)&cmd_config_speed_specific_port,
1781 (void *)&cmd_config_speed_specific_keyword,
1782 (void *)&cmd_config_speed_specific_id,
1783 (void *)&cmd_config_speed_specific_item1,
1784 (void *)&cmd_config_speed_specific_value1,
1785 (void *)&cmd_config_speed_specific_item2,
1786 (void *)&cmd_config_speed_specific_value2,
1791 /* *** configure loopback for all ports *** */
1792 struct cmd_config_loopback_all {
1793 cmdline_fixed_string_t port;
1794 cmdline_fixed_string_t keyword;
1795 cmdline_fixed_string_t all;
1796 cmdline_fixed_string_t item;
1801 cmd_config_loopback_all_parsed(void *parsed_result,
1802 __rte_unused struct cmdline *cl,
1803 __rte_unused void *data)
1805 struct cmd_config_loopback_all *res = parsed_result;
1808 if (!all_ports_stopped()) {
1809 printf("Please stop all ports first\n");
1813 RTE_ETH_FOREACH_DEV(pid) {
1814 ports[pid].dev_conf.lpbk_mode = res->mode;
1817 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1820 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1821 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1822 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1823 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1825 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1826 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1827 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1828 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1830 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1831 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1833 cmdline_parse_inst_t cmd_config_loopback_all = {
1834 .f = cmd_config_loopback_all_parsed,
1836 .help_str = "port config all loopback <mode>",
1838 (void *)&cmd_config_loopback_all_port,
1839 (void *)&cmd_config_loopback_all_keyword,
1840 (void *)&cmd_config_loopback_all_all,
1841 (void *)&cmd_config_loopback_all_item,
1842 (void *)&cmd_config_loopback_all_mode,
1847 /* *** configure loopback for specific port *** */
1848 struct cmd_config_loopback_specific {
1849 cmdline_fixed_string_t port;
1850 cmdline_fixed_string_t keyword;
1852 cmdline_fixed_string_t item;
1857 cmd_config_loopback_specific_parsed(void *parsed_result,
1858 __rte_unused struct cmdline *cl,
1859 __rte_unused void *data)
1861 struct cmd_config_loopback_specific *res = parsed_result;
1863 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1866 if (!port_is_stopped(res->port_id)) {
1867 printf("Please stop port %u first\n", res->port_id);
1871 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1873 cmd_reconfig_device_queue(res->port_id, 1, 1);
1877 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1878 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1880 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1881 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1883 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1884 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1886 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1887 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1889 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1890 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1893 cmdline_parse_inst_t cmd_config_loopback_specific = {
1894 .f = cmd_config_loopback_specific_parsed,
1896 .help_str = "port config <port_id> loopback <mode>",
1898 (void *)&cmd_config_loopback_specific_port,
1899 (void *)&cmd_config_loopback_specific_keyword,
1900 (void *)&cmd_config_loopback_specific_id,
1901 (void *)&cmd_config_loopback_specific_item,
1902 (void *)&cmd_config_loopback_specific_mode,
1907 /* *** configure txq/rxq, txd/rxd *** */
1908 struct cmd_config_rx_tx {
1909 cmdline_fixed_string_t port;
1910 cmdline_fixed_string_t keyword;
1911 cmdline_fixed_string_t all;
1912 cmdline_fixed_string_t name;
1917 cmd_config_rx_tx_parsed(void *parsed_result,
1918 __rte_unused struct cmdline *cl,
1919 __rte_unused void *data)
1921 struct cmd_config_rx_tx *res = parsed_result;
1923 if (!all_ports_stopped()) {
1924 printf("Please stop all ports first\n");
1927 if (!strcmp(res->name, "rxq")) {
1928 if (!res->value && !nb_txq) {
1929 printf("Warning: Either rx or tx queues should be non zero\n");
1932 if (check_nb_rxq(res->value) != 0)
1934 nb_rxq = res->value;
1936 else if (!strcmp(res->name, "txq")) {
1937 if (!res->value && !nb_rxq) {
1938 printf("Warning: Either rx or tx queues should be non zero\n");
1941 if (check_nb_txq(res->value) != 0)
1943 nb_txq = res->value;
1945 else if (!strcmp(res->name, "rxd")) {
1946 if (check_nb_rxd(res->value) != 0)
1948 nb_rxd = res->value;
1949 } else if (!strcmp(res->name, "txd")) {
1950 if (check_nb_txd(res->value) != 0)
1953 nb_txd = res->value;
1955 printf("Unknown parameter\n");
1963 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1966 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1967 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1968 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1969 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1970 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1971 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1972 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1973 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1975 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1976 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1978 cmdline_parse_inst_t cmd_config_rx_tx = {
1979 .f = cmd_config_rx_tx_parsed,
1981 .help_str = "port config all rxq|txq|rxd|txd <value>",
1983 (void *)&cmd_config_rx_tx_port,
1984 (void *)&cmd_config_rx_tx_keyword,
1985 (void *)&cmd_config_rx_tx_all,
1986 (void *)&cmd_config_rx_tx_name,
1987 (void *)&cmd_config_rx_tx_value,
1992 /* *** config max packet length *** */
1993 struct cmd_config_max_pkt_len_result {
1994 cmdline_fixed_string_t port;
1995 cmdline_fixed_string_t keyword;
1996 cmdline_fixed_string_t all;
1997 cmdline_fixed_string_t name;
2002 cmd_config_max_pkt_len_parsed(void *parsed_result,
2003 __rte_unused struct cmdline *cl,
2004 __rte_unused void *data)
2006 struct cmd_config_max_pkt_len_result *res = parsed_result;
2009 if (!all_ports_stopped()) {
2010 printf("Please stop all ports first\n");
2014 RTE_ETH_FOREACH_DEV(pid) {
2015 struct rte_port *port = &ports[pid];
2016 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
2018 if (!strcmp(res->name, "max-pkt-len")) {
2019 if (res->value < RTE_ETHER_MIN_LEN) {
2020 printf("max-pkt-len can not be less than %d\n",
2024 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2027 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2028 if (res->value > RTE_ETHER_MAX_LEN)
2029 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2031 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2032 port->dev_conf.rxmode.offloads = rx_offloads;
2034 printf("Unknown parameter\n");
2041 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2044 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2045 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2047 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2048 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2050 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2051 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2053 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2054 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2056 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2057 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2060 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2061 .f = cmd_config_max_pkt_len_parsed,
2063 .help_str = "port config all max-pkt-len <value>",
2065 (void *)&cmd_config_max_pkt_len_port,
2066 (void *)&cmd_config_max_pkt_len_keyword,
2067 (void *)&cmd_config_max_pkt_len_all,
2068 (void *)&cmd_config_max_pkt_len_name,
2069 (void *)&cmd_config_max_pkt_len_value,
2074 /* *** config max LRO aggregated packet size *** */
2075 struct cmd_config_max_lro_pkt_size_result {
2076 cmdline_fixed_string_t port;
2077 cmdline_fixed_string_t keyword;
2078 cmdline_fixed_string_t all;
2079 cmdline_fixed_string_t name;
2084 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2085 __rte_unused struct cmdline *cl,
2086 __rte_unused void *data)
2088 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2091 if (!all_ports_stopped()) {
2092 printf("Please stop all ports first\n");
2096 RTE_ETH_FOREACH_DEV(pid) {
2097 struct rte_port *port = &ports[pid];
2099 if (!strcmp(res->name, "max-lro-pkt-size")) {
2101 port->dev_conf.rxmode.max_lro_pkt_size)
2104 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2106 printf("Unknown parameter\n");
2113 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2116 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2117 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2119 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2120 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2122 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2123 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2125 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2126 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2127 name, "max-lro-pkt-size");
2128 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2129 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2132 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2133 .f = cmd_config_max_lro_pkt_size_parsed,
2135 .help_str = "port config all max-lro-pkt-size <value>",
2137 (void *)&cmd_config_max_lro_pkt_size_port,
2138 (void *)&cmd_config_max_lro_pkt_size_keyword,
2139 (void *)&cmd_config_max_lro_pkt_size_all,
2140 (void *)&cmd_config_max_lro_pkt_size_name,
2141 (void *)&cmd_config_max_lro_pkt_size_value,
2146 /* *** configure port MTU *** */
2147 struct cmd_config_mtu_result {
2148 cmdline_fixed_string_t port;
2149 cmdline_fixed_string_t keyword;
2150 cmdline_fixed_string_t mtu;
2156 cmd_config_mtu_parsed(void *parsed_result,
2157 __rte_unused struct cmdline *cl,
2158 __rte_unused void *data)
2160 struct cmd_config_mtu_result *res = parsed_result;
2162 if (res->value < RTE_ETHER_MIN_LEN) {
2163 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2166 port_mtu_set(res->port_id, res->value);
2169 cmdline_parse_token_string_t cmd_config_mtu_port =
2170 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2172 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2173 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2175 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2176 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2178 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2179 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2180 cmdline_parse_token_num_t cmd_config_mtu_value =
2181 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2183 cmdline_parse_inst_t cmd_config_mtu = {
2184 .f = cmd_config_mtu_parsed,
2186 .help_str = "port config mtu <port_id> <value>",
2188 (void *)&cmd_config_mtu_port,
2189 (void *)&cmd_config_mtu_keyword,
2190 (void *)&cmd_config_mtu_mtu,
2191 (void *)&cmd_config_mtu_port_id,
2192 (void *)&cmd_config_mtu_value,
2197 /* *** configure rx mode *** */
2198 struct cmd_config_rx_mode_flag {
2199 cmdline_fixed_string_t port;
2200 cmdline_fixed_string_t keyword;
2201 cmdline_fixed_string_t all;
2202 cmdline_fixed_string_t name;
2203 cmdline_fixed_string_t value;
2207 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2208 __rte_unused struct cmdline *cl,
2209 __rte_unused void *data)
2211 struct cmd_config_rx_mode_flag *res = parsed_result;
2213 if (!all_ports_stopped()) {
2214 printf("Please stop all ports first\n");
2218 if (!strcmp(res->name, "drop-en")) {
2219 if (!strcmp(res->value, "on"))
2221 else if (!strcmp(res->value, "off"))
2224 printf("Unknown parameter\n");
2228 printf("Unknown parameter\n");
2234 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2237 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2238 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2239 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2240 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2242 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2243 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2244 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2245 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2247 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2248 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2251 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2252 .f = cmd_config_rx_mode_flag_parsed,
2254 .help_str = "port config all drop-en on|off",
2256 (void *)&cmd_config_rx_mode_flag_port,
2257 (void *)&cmd_config_rx_mode_flag_keyword,
2258 (void *)&cmd_config_rx_mode_flag_all,
2259 (void *)&cmd_config_rx_mode_flag_name,
2260 (void *)&cmd_config_rx_mode_flag_value,
2265 /* *** configure rss *** */
2266 struct cmd_config_rss {
2267 cmdline_fixed_string_t port;
2268 cmdline_fixed_string_t keyword;
2269 cmdline_fixed_string_t all;
2270 cmdline_fixed_string_t name;
2271 cmdline_fixed_string_t value;
2275 cmd_config_rss_parsed(void *parsed_result,
2276 __rte_unused struct cmdline *cl,
2277 __rte_unused void *data)
2279 struct cmd_config_rss *res = parsed_result;
2280 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2281 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2282 int use_default = 0;
2283 int all_updated = 1;
2288 if (!strcmp(res->value, "all"))
2289 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2290 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2291 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2292 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU;
2293 else if (!strcmp(res->value, "eth"))
2294 rss_conf.rss_hf = ETH_RSS_ETH;
2295 else if (!strcmp(res->value, "vlan"))
2296 rss_conf.rss_hf = ETH_RSS_VLAN;
2297 else if (!strcmp(res->value, "ip"))
2298 rss_conf.rss_hf = ETH_RSS_IP;
2299 else if (!strcmp(res->value, "udp"))
2300 rss_conf.rss_hf = ETH_RSS_UDP;
2301 else if (!strcmp(res->value, "tcp"))
2302 rss_conf.rss_hf = ETH_RSS_TCP;
2303 else if (!strcmp(res->value, "sctp"))
2304 rss_conf.rss_hf = ETH_RSS_SCTP;
2305 else if (!strcmp(res->value, "ether"))
2306 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2307 else if (!strcmp(res->value, "port"))
2308 rss_conf.rss_hf = ETH_RSS_PORT;
2309 else if (!strcmp(res->value, "vxlan"))
2310 rss_conf.rss_hf = ETH_RSS_VXLAN;
2311 else if (!strcmp(res->value, "geneve"))
2312 rss_conf.rss_hf = ETH_RSS_GENEVE;
2313 else if (!strcmp(res->value, "nvgre"))
2314 rss_conf.rss_hf = ETH_RSS_NVGRE;
2315 else if (!strcmp(res->value, "l3-pre32"))
2316 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2317 else if (!strcmp(res->value, "l3-pre40"))
2318 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2319 else if (!strcmp(res->value, "l3-pre48"))
2320 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2321 else if (!strcmp(res->value, "l3-pre56"))
2322 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2323 else if (!strcmp(res->value, "l3-pre64"))
2324 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2325 else if (!strcmp(res->value, "l3-pre96"))
2326 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2327 else if (!strcmp(res->value, "l3-src-only"))
2328 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2329 else if (!strcmp(res->value, "l3-dst-only"))
2330 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2331 else if (!strcmp(res->value, "l4-src-only"))
2332 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2333 else if (!strcmp(res->value, "l4-dst-only"))
2334 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2335 else if (!strcmp(res->value, "l2-src-only"))
2336 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2337 else if (!strcmp(res->value, "l2-dst-only"))
2338 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2339 else if (!strcmp(res->value, "l2tpv3"))
2340 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2341 else if (!strcmp(res->value, "esp"))
2342 rss_conf.rss_hf = ETH_RSS_ESP;
2343 else if (!strcmp(res->value, "ah"))
2344 rss_conf.rss_hf = ETH_RSS_AH;
2345 else if (!strcmp(res->value, "pfcp"))
2346 rss_conf.rss_hf = ETH_RSS_PFCP;
2347 else if (!strcmp(res->value, "pppoe"))
2348 rss_conf.rss_hf = ETH_RSS_PPPOE;
2349 else if (!strcmp(res->value, "gtpu"))
2350 rss_conf.rss_hf = ETH_RSS_GTPU;
2351 else if (!strcmp(res->value, "none"))
2352 rss_conf.rss_hf = 0;
2353 else if (!strcmp(res->value, "level-default")) {
2354 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2355 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2356 } else if (!strcmp(res->value, "level-outer")) {
2357 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2358 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2359 } else if (!strcmp(res->value, "level-inner")) {
2360 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2361 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2362 } else if (!strcmp(res->value, "default"))
2364 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2365 atoi(res->value) < 64)
2366 rss_conf.rss_hf = 1ULL << atoi(res->value);
2368 printf("Unknown parameter\n");
2371 rss_conf.rss_key = NULL;
2372 /* Update global configuration for RSS types. */
2373 RTE_ETH_FOREACH_DEV(i) {
2374 struct rte_eth_rss_conf local_rss_conf;
2376 ret = eth_dev_info_get_print_err(i, &dev_info);
2381 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2383 local_rss_conf = rss_conf;
2384 local_rss_conf.rss_hf = rss_conf.rss_hf &
2385 dev_info.flow_type_rss_offloads;
2386 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2387 printf("Port %u modified RSS hash function based on hardware support,"
2388 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2389 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2391 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2394 printf("Configuration of RSS hash at ethernet port %d "
2395 "failed with error (%d): %s.\n",
2396 i, -diag, strerror(-diag));
2399 if (all_updated && !use_default) {
2400 rss_hf = rss_conf.rss_hf;
2401 printf("rss_hf %#"PRIx64"\n", rss_hf);
2405 cmdline_parse_token_string_t cmd_config_rss_port =
2406 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2407 cmdline_parse_token_string_t cmd_config_rss_keyword =
2408 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2409 cmdline_parse_token_string_t cmd_config_rss_all =
2410 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2411 cmdline_parse_token_string_t cmd_config_rss_name =
2412 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2413 cmdline_parse_token_string_t cmd_config_rss_value =
2414 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2416 cmdline_parse_inst_t cmd_config_rss = {
2417 .f = cmd_config_rss_parsed,
2419 .help_str = "port config all rss "
2420 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2421 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|level-default|"
2422 "level-outer|level-inner|<flowtype_id>",
2424 (void *)&cmd_config_rss_port,
2425 (void *)&cmd_config_rss_keyword,
2426 (void *)&cmd_config_rss_all,
2427 (void *)&cmd_config_rss_name,
2428 (void *)&cmd_config_rss_value,
2433 /* *** configure rss hash key *** */
2434 struct cmd_config_rss_hash_key {
2435 cmdline_fixed_string_t port;
2436 cmdline_fixed_string_t config;
2438 cmdline_fixed_string_t rss_hash_key;
2439 cmdline_fixed_string_t rss_type;
2440 cmdline_fixed_string_t key;
2444 hexa_digit_to_value(char hexa_digit)
2446 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2447 return (uint8_t) (hexa_digit - '0');
2448 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2449 return (uint8_t) ((hexa_digit - 'a') + 10);
2450 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2451 return (uint8_t) ((hexa_digit - 'A') + 10);
2452 /* Invalid hexa digit */
2457 parse_and_check_key_hexa_digit(char *key, int idx)
2461 hexa_v = hexa_digit_to_value(key[idx]);
2463 printf("invalid key: character %c at position %d is not a "
2464 "valid hexa digit\n", key[idx], idx);
2469 cmd_config_rss_hash_key_parsed(void *parsed_result,
2470 __rte_unused struct cmdline *cl,
2471 __rte_unused void *data)
2473 struct cmd_config_rss_hash_key *res = parsed_result;
2474 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2478 struct rte_eth_dev_info dev_info;
2479 uint8_t hash_key_size;
2483 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2487 if (dev_info.hash_key_size > 0 &&
2488 dev_info.hash_key_size <= sizeof(hash_key))
2489 hash_key_size = dev_info.hash_key_size;
2491 printf("dev_info did not provide a valid hash key size\n");
2494 /* Check the length of the RSS hash key */
2495 key_len = strlen(res->key);
2496 if (key_len != (hash_key_size * 2)) {
2497 printf("key length: %d invalid - key must be a string of %d"
2498 " hexa-decimal numbers\n",
2499 (int) key_len, hash_key_size * 2);
2502 /* Translate RSS hash key into binary representation */
2503 for (i = 0; i < hash_key_size; i++) {
2504 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2507 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2510 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2512 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2516 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2517 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2518 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2519 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2521 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2522 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2523 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2524 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2525 rss_hash_key, "rss-hash-key");
2526 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2527 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2528 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2529 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2530 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2531 "ipv6-tcp-ex#ipv6-udp-ex#"
2532 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2533 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2534 "l2tpv3#esp#ah#pfcp#pppoe#gtpu");
2535 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2536 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2538 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2539 .f = cmd_config_rss_hash_key_parsed,
2541 .help_str = "port config <port_id> rss-hash-key "
2542 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2543 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2544 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2545 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2546 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2547 "l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2548 "<string of hex digits (variable length, NIC dependent)>",
2550 (void *)&cmd_config_rss_hash_key_port,
2551 (void *)&cmd_config_rss_hash_key_config,
2552 (void *)&cmd_config_rss_hash_key_port_id,
2553 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2554 (void *)&cmd_config_rss_hash_key_rss_type,
2555 (void *)&cmd_config_rss_hash_key_value,
2560 /* *** configure port rxq/txq ring size *** */
2561 struct cmd_config_rxtx_ring_size {
2562 cmdline_fixed_string_t port;
2563 cmdline_fixed_string_t config;
2565 cmdline_fixed_string_t rxtxq;
2567 cmdline_fixed_string_t rsize;
2572 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2573 __rte_unused struct cmdline *cl,
2574 __rte_unused void *data)
2576 struct cmd_config_rxtx_ring_size *res = parsed_result;
2577 struct rte_port *port;
2580 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2583 if (res->portid == (portid_t)RTE_PORT_ALL) {
2584 printf("Invalid port id\n");
2588 port = &ports[res->portid];
2590 if (!strcmp(res->rxtxq, "rxq"))
2592 else if (!strcmp(res->rxtxq, "txq"))
2595 printf("Unknown parameter\n");
2599 if (isrx && rx_queue_id_is_invalid(res->qid))
2601 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2604 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2605 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2611 port->nb_rx_desc[res->qid] = res->size;
2613 port->nb_tx_desc[res->qid] = res->size;
2615 cmd_reconfig_device_queue(res->portid, 0, 1);
2618 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2619 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2621 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2622 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2624 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2625 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2627 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2628 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2630 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2631 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2633 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2634 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2635 rsize, "ring_size");
2636 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2637 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2640 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2641 .f = cmd_config_rxtx_ring_size_parsed,
2643 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2645 (void *)&cmd_config_rxtx_ring_size_port,
2646 (void *)&cmd_config_rxtx_ring_size_config,
2647 (void *)&cmd_config_rxtx_ring_size_portid,
2648 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2649 (void *)&cmd_config_rxtx_ring_size_qid,
2650 (void *)&cmd_config_rxtx_ring_size_rsize,
2651 (void *)&cmd_config_rxtx_ring_size_size,
2656 /* *** configure port rxq/txq start/stop *** */
2657 struct cmd_config_rxtx_queue {
2658 cmdline_fixed_string_t port;
2660 cmdline_fixed_string_t rxtxq;
2662 cmdline_fixed_string_t opname;
2666 cmd_config_rxtx_queue_parsed(void *parsed_result,
2667 __rte_unused struct cmdline *cl,
2668 __rte_unused void *data)
2670 struct cmd_config_rxtx_queue *res = parsed_result;
2675 if (test_done == 0) {
2676 printf("Please stop forwarding first\n");
2680 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2683 if (port_is_started(res->portid) != 1) {
2684 printf("Please start port %u first\n", res->portid);
2688 if (!strcmp(res->rxtxq, "rxq"))
2690 else if (!strcmp(res->rxtxq, "txq"))
2693 printf("Unknown parameter\n");
2697 if (isrx && rx_queue_id_is_invalid(res->qid))
2699 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2702 if (!strcmp(res->opname, "start"))
2704 else if (!strcmp(res->opname, "stop"))
2707 printf("Unknown parameter\n");
2711 if (isstart && isrx)
2712 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2713 else if (!isstart && isrx)
2714 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2715 else if (isstart && !isrx)
2716 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2718 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2720 if (ret == -ENOTSUP)
2721 printf("Function not supported in PMD driver\n");
2724 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2725 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2726 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2727 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2728 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2729 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2730 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2731 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2732 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2733 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2736 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2737 .f = cmd_config_rxtx_queue_parsed,
2739 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2741 (void *)&cmd_config_rxtx_queue_port,
2742 (void *)&cmd_config_rxtx_queue_portid,
2743 (void *)&cmd_config_rxtx_queue_rxtxq,
2744 (void *)&cmd_config_rxtx_queue_qid,
2745 (void *)&cmd_config_rxtx_queue_opname,
2750 /* *** configure port rxq/txq deferred start on/off *** */
2751 struct cmd_config_deferred_start_rxtx_queue {
2752 cmdline_fixed_string_t port;
2754 cmdline_fixed_string_t rxtxq;
2756 cmdline_fixed_string_t opname;
2757 cmdline_fixed_string_t state;
2761 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2762 __rte_unused struct cmdline *cl,
2763 __rte_unused void *data)
2765 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2766 struct rte_port *port;
2769 uint8_t needreconfig = 0;
2771 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2774 if (port_is_started(res->port_id) != 0) {
2775 printf("Please stop port %u first\n", res->port_id);
2779 port = &ports[res->port_id];
2781 isrx = !strcmp(res->rxtxq, "rxq");
2783 if (isrx && rx_queue_id_is_invalid(res->qid))
2785 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2788 ison = !strcmp(res->state, "on");
2790 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2791 port->rx_conf[res->qid].rx_deferred_start = ison;
2793 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2794 port->tx_conf[res->qid].tx_deferred_start = ison;
2799 cmd_reconfig_device_queue(res->port_id, 0, 1);
2802 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2803 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2805 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2806 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2808 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2809 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2811 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2812 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2814 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2815 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2816 opname, "deferred_start");
2817 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2818 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2821 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2822 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2824 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2826 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2827 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2828 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2829 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2830 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2831 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2836 /* *** configure port rxq/txq setup *** */
2837 struct cmd_setup_rxtx_queue {
2838 cmdline_fixed_string_t port;
2840 cmdline_fixed_string_t rxtxq;
2842 cmdline_fixed_string_t setup;
2845 /* Common CLI fields for queue setup */
2846 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2847 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2848 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2849 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2850 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2851 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2852 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2853 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2854 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2855 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2858 cmd_setup_rxtx_queue_parsed(
2859 void *parsed_result,
2860 __rte_unused struct cmdline *cl,
2861 __rte_unused void *data)
2863 struct cmd_setup_rxtx_queue *res = parsed_result;
2864 struct rte_port *port;
2865 struct rte_mempool *mp;
2866 unsigned int socket_id;
2870 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2873 if (res->portid == (portid_t)RTE_PORT_ALL) {
2874 printf("Invalid port id\n");
2878 if (!strcmp(res->rxtxq, "rxq"))
2880 else if (!strcmp(res->rxtxq, "txq"))
2883 printf("Unknown parameter\n");
2887 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2888 printf("Invalid rx queue\n");
2890 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2891 printf("Invalid tx queue\n");
2895 port = &ports[res->portid];
2897 socket_id = rxring_numa[res->portid];
2898 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2899 socket_id = port->socket_id;
2901 mp = mbuf_pool_find(socket_id);
2903 printf("Failed to setup RX queue: "
2904 "No mempool allocation"
2905 " on the socket %d\n",
2906 rxring_numa[res->portid]);
2909 ret = rte_eth_rx_queue_setup(res->portid,
2911 port->nb_rx_desc[res->qid],
2913 &port->rx_conf[res->qid],
2916 printf("Failed to setup RX queue\n");
2918 socket_id = txring_numa[res->portid];
2919 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2920 socket_id = port->socket_id;
2922 ret = rte_eth_tx_queue_setup(res->portid,
2924 port->nb_tx_desc[res->qid],
2926 &port->tx_conf[res->qid]);
2928 printf("Failed to setup TX queue\n");
2932 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2933 .f = cmd_setup_rxtx_queue_parsed,
2935 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2937 (void *)&cmd_setup_rxtx_queue_port,
2938 (void *)&cmd_setup_rxtx_queue_portid,
2939 (void *)&cmd_setup_rxtx_queue_rxtxq,
2940 (void *)&cmd_setup_rxtx_queue_qid,
2941 (void *)&cmd_setup_rxtx_queue_setup,
2947 /* *** Configure RSS RETA *** */
2948 struct cmd_config_rss_reta {
2949 cmdline_fixed_string_t port;
2950 cmdline_fixed_string_t keyword;
2952 cmdline_fixed_string_t name;
2953 cmdline_fixed_string_t list_name;
2954 cmdline_fixed_string_t list_of_items;
2958 parse_reta_config(const char *str,
2959 struct rte_eth_rss_reta_entry64 *reta_conf,
2960 uint16_t nb_entries)
2964 uint16_t hash_index, idx, shift;
2967 const char *p, *p0 = str;
2974 unsigned long int_fld[_NUM_FLD];
2975 char *str_fld[_NUM_FLD];
2977 while ((p = strchr(p0,'(')) != NULL) {
2979 if((p0 = strchr(p,')')) == NULL)
2983 if(size >= sizeof(s))
2986 snprintf(s, sizeof(s), "%.*s", size, p);
2987 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2989 for (i = 0; i < _NUM_FLD; i++) {
2991 int_fld[i] = strtoul(str_fld[i], &end, 0);
2992 if (errno != 0 || end == str_fld[i] ||
2997 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2998 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
3000 if (hash_index >= nb_entries) {
3001 printf("Invalid RETA hash index=%d\n", hash_index);
3005 idx = hash_index / RTE_RETA_GROUP_SIZE;
3006 shift = hash_index % RTE_RETA_GROUP_SIZE;
3007 reta_conf[idx].mask |= (1ULL << shift);
3008 reta_conf[idx].reta[shift] = nb_queue;
3015 cmd_set_rss_reta_parsed(void *parsed_result,
3016 __rte_unused struct cmdline *cl,
3017 __rte_unused void *data)
3020 struct rte_eth_dev_info dev_info;
3021 struct rte_eth_rss_reta_entry64 reta_conf[8];
3022 struct cmd_config_rss_reta *res = parsed_result;
3024 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3028 if (dev_info.reta_size == 0) {
3029 printf("Redirection table size is 0 which is "
3030 "invalid for RSS\n");
3033 printf("The reta size of port %d is %u\n",
3034 res->port_id, dev_info.reta_size);
3035 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3036 printf("Currently do not support more than %u entries of "
3037 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3041 memset(reta_conf, 0, sizeof(reta_conf));
3042 if (!strcmp(res->list_name, "reta")) {
3043 if (parse_reta_config(res->list_of_items, reta_conf,
3044 dev_info.reta_size)) {
3045 printf("Invalid RSS Redirection Table "
3046 "config entered\n");
3049 ret = rte_eth_dev_rss_reta_update(res->port_id,
3050 reta_conf, dev_info.reta_size);
3052 printf("Bad redirection table parameter, "
3053 "return code = %d \n", ret);
3057 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3058 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3059 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3060 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3061 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3062 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3063 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3064 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3065 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3066 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3067 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3068 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3070 cmdline_parse_inst_t cmd_config_rss_reta = {
3071 .f = cmd_set_rss_reta_parsed,
3073 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3075 (void *)&cmd_config_rss_reta_port,
3076 (void *)&cmd_config_rss_reta_keyword,
3077 (void *)&cmd_config_rss_reta_port_id,
3078 (void *)&cmd_config_rss_reta_name,
3079 (void *)&cmd_config_rss_reta_list_name,
3080 (void *)&cmd_config_rss_reta_list_of_items,
3085 /* *** SHOW PORT RETA INFO *** */
3086 struct cmd_showport_reta {
3087 cmdline_fixed_string_t show;
3088 cmdline_fixed_string_t port;
3090 cmdline_fixed_string_t rss;
3091 cmdline_fixed_string_t reta;
3093 cmdline_fixed_string_t list_of_items;
3097 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3098 uint16_t nb_entries,
3102 const char *p, *p0 = str;
3107 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3108 RTE_RETA_GROUP_SIZE;
3111 p = strchr(p0, '(');
3115 p0 = strchr(p, ')');
3119 if (size >= sizeof(s)) {
3120 printf("The string size exceeds the internal buffer size\n");
3123 snprintf(s, sizeof(s), "%.*s", size, p);
3124 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3125 if (ret <= 0 || ret != num) {
3126 printf("The bits of masks do not match the number of "
3127 "reta entries: %u\n", num);
3130 for (i = 0; i < ret; i++)
3131 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3137 cmd_showport_reta_parsed(void *parsed_result,
3138 __rte_unused struct cmdline *cl,
3139 __rte_unused void *data)
3141 struct cmd_showport_reta *res = parsed_result;
3142 struct rte_eth_rss_reta_entry64 reta_conf[8];
3143 struct rte_eth_dev_info dev_info;
3144 uint16_t max_reta_size;
3147 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3151 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3152 if (res->size == 0 || res->size > max_reta_size) {
3153 printf("Invalid redirection table size: %u (1-%u)\n",
3154 res->size, max_reta_size);
3158 memset(reta_conf, 0, sizeof(reta_conf));
3159 if (showport_parse_reta_config(reta_conf, res->size,
3160 res->list_of_items) < 0) {
3161 printf("Invalid string: %s for reta masks\n",
3162 res->list_of_items);
3165 port_rss_reta_info(res->port_id, reta_conf, res->size);
3168 cmdline_parse_token_string_t cmd_showport_reta_show =
3169 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3170 cmdline_parse_token_string_t cmd_showport_reta_port =
3171 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3172 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3173 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3174 cmdline_parse_token_string_t cmd_showport_reta_rss =
3175 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3176 cmdline_parse_token_string_t cmd_showport_reta_reta =
3177 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3178 cmdline_parse_token_num_t cmd_showport_reta_size =
3179 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3180 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3181 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3182 list_of_items, NULL);
3184 cmdline_parse_inst_t cmd_showport_reta = {
3185 .f = cmd_showport_reta_parsed,
3187 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3189 (void *)&cmd_showport_reta_show,
3190 (void *)&cmd_showport_reta_port,
3191 (void *)&cmd_showport_reta_port_id,
3192 (void *)&cmd_showport_reta_rss,
3193 (void *)&cmd_showport_reta_reta,
3194 (void *)&cmd_showport_reta_size,
3195 (void *)&cmd_showport_reta_list_of_items,
3200 /* *** Show RSS hash configuration *** */
3201 struct cmd_showport_rss_hash {
3202 cmdline_fixed_string_t show;
3203 cmdline_fixed_string_t port;
3205 cmdline_fixed_string_t rss_hash;
3206 cmdline_fixed_string_t rss_type;
3207 cmdline_fixed_string_t key; /* optional argument */
3210 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3211 __rte_unused struct cmdline *cl,
3214 struct cmd_showport_rss_hash *res = parsed_result;
3216 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3219 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3220 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3221 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3222 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3223 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3224 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3225 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3226 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3228 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3229 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3231 cmdline_parse_inst_t cmd_showport_rss_hash = {
3232 .f = cmd_showport_rss_hash_parsed,
3234 .help_str = "show port <port_id> rss-hash",
3236 (void *)&cmd_showport_rss_hash_show,
3237 (void *)&cmd_showport_rss_hash_port,
3238 (void *)&cmd_showport_rss_hash_port_id,
3239 (void *)&cmd_showport_rss_hash_rss_hash,
3244 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3245 .f = cmd_showport_rss_hash_parsed,
3247 .help_str = "show port <port_id> rss-hash key",
3249 (void *)&cmd_showport_rss_hash_show,
3250 (void *)&cmd_showport_rss_hash_port,
3251 (void *)&cmd_showport_rss_hash_port_id,
3252 (void *)&cmd_showport_rss_hash_rss_hash,
3253 (void *)&cmd_showport_rss_hash_rss_key,
3258 /* *** Configure DCB *** */
3259 struct cmd_config_dcb {
3260 cmdline_fixed_string_t port;
3261 cmdline_fixed_string_t config;
3263 cmdline_fixed_string_t dcb;
3264 cmdline_fixed_string_t vt;
3265 cmdline_fixed_string_t vt_en;
3267 cmdline_fixed_string_t pfc;
3268 cmdline_fixed_string_t pfc_en;
3272 cmd_config_dcb_parsed(void *parsed_result,
3273 __rte_unused struct cmdline *cl,
3274 __rte_unused void *data)
3276 struct cmd_config_dcb *res = parsed_result;
3277 portid_t port_id = res->port_id;
3278 struct rte_port *port;
3282 port = &ports[port_id];
3283 /** Check if the port is not started **/
3284 if (port->port_status != RTE_PORT_STOPPED) {
3285 printf("Please stop port %d first\n", port_id);
3289 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3290 printf("The invalid number of traffic class,"
3291 " only 4 or 8 allowed.\n");
3295 if (nb_fwd_lcores < res->num_tcs) {
3296 printf("nb_cores shouldn't be less than number of TCs.\n");
3299 if (!strncmp(res->pfc_en, "on", 2))
3304 /* DCB in VT mode */
3305 if (!strncmp(res->vt_en, "on", 2))
3306 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3307 (enum rte_eth_nb_tcs)res->num_tcs,
3310 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3311 (enum rte_eth_nb_tcs)res->num_tcs,
3316 printf("Cannot initialize network ports.\n");
3320 cmd_reconfig_device_queue(port_id, 1, 1);
3323 cmdline_parse_token_string_t cmd_config_dcb_port =
3324 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3325 cmdline_parse_token_string_t cmd_config_dcb_config =
3326 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3327 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3328 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3329 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3330 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3331 cmdline_parse_token_string_t cmd_config_dcb_vt =
3332 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3333 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3334 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3335 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3336 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3337 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3338 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3339 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3340 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3342 cmdline_parse_inst_t cmd_config_dcb = {
3343 .f = cmd_config_dcb_parsed,
3345 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3347 (void *)&cmd_config_dcb_port,
3348 (void *)&cmd_config_dcb_config,
3349 (void *)&cmd_config_dcb_port_id,
3350 (void *)&cmd_config_dcb_dcb,
3351 (void *)&cmd_config_dcb_vt,
3352 (void *)&cmd_config_dcb_vt_en,
3353 (void *)&cmd_config_dcb_num_tcs,
3354 (void *)&cmd_config_dcb_pfc,
3355 (void *)&cmd_config_dcb_pfc_en,
3360 /* *** configure number of packets per burst *** */
3361 struct cmd_config_burst {
3362 cmdline_fixed_string_t port;
3363 cmdline_fixed_string_t keyword;
3364 cmdline_fixed_string_t all;
3365 cmdline_fixed_string_t name;
3370 cmd_config_burst_parsed(void *parsed_result,
3371 __rte_unused struct cmdline *cl,
3372 __rte_unused void *data)
3374 struct cmd_config_burst *res = parsed_result;
3375 struct rte_eth_dev_info dev_info;
3376 uint16_t rec_nb_pkts;
3379 if (!all_ports_stopped()) {
3380 printf("Please stop all ports first\n");
3384 if (!strcmp(res->name, "burst")) {
3385 if (res->value == 0) {
3386 /* If user gives a value of zero, query the PMD for
3387 * its recommended Rx burst size. Testpmd uses a single
3388 * size for all ports, so assume all ports are the same
3389 * NIC model and use the values from Port 0.
3391 ret = eth_dev_info_get_print_err(0, &dev_info);
3395 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3397 if (rec_nb_pkts == 0) {
3398 printf("PMD does not recommend a burst size.\n"
3399 "User provided value must be between"
3400 " 1 and %d\n", MAX_PKT_BURST);
3402 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3403 printf("PMD recommended burst size of %d"
3404 " exceeds maximum value of %d\n",
3405 rec_nb_pkts, MAX_PKT_BURST);
3408 printf("Using PMD-provided burst value of %d\n",
3410 nb_pkt_per_burst = rec_nb_pkts;
3411 } else if (res->value > MAX_PKT_BURST) {
3412 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3415 nb_pkt_per_burst = res->value;
3417 printf("Unknown parameter\n");
3423 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3426 cmdline_parse_token_string_t cmd_config_burst_port =
3427 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3428 cmdline_parse_token_string_t cmd_config_burst_keyword =
3429 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3430 cmdline_parse_token_string_t cmd_config_burst_all =
3431 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3432 cmdline_parse_token_string_t cmd_config_burst_name =
3433 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3434 cmdline_parse_token_num_t cmd_config_burst_value =
3435 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3437 cmdline_parse_inst_t cmd_config_burst = {
3438 .f = cmd_config_burst_parsed,
3440 .help_str = "port config all burst <value>",
3442 (void *)&cmd_config_burst_port,
3443 (void *)&cmd_config_burst_keyword,
3444 (void *)&cmd_config_burst_all,
3445 (void *)&cmd_config_burst_name,
3446 (void *)&cmd_config_burst_value,
3451 /* *** configure rx/tx queues *** */
3452 struct cmd_config_thresh {
3453 cmdline_fixed_string_t port;
3454 cmdline_fixed_string_t keyword;
3455 cmdline_fixed_string_t all;
3456 cmdline_fixed_string_t name;
3461 cmd_config_thresh_parsed(void *parsed_result,
3462 __rte_unused struct cmdline *cl,
3463 __rte_unused void *data)
3465 struct cmd_config_thresh *res = parsed_result;
3467 if (!all_ports_stopped()) {
3468 printf("Please stop all ports first\n");
3472 if (!strcmp(res->name, "txpt"))
3473 tx_pthresh = res->value;
3474 else if(!strcmp(res->name, "txht"))
3475 tx_hthresh = res->value;
3476 else if(!strcmp(res->name, "txwt"))
3477 tx_wthresh = res->value;
3478 else if(!strcmp(res->name, "rxpt"))
3479 rx_pthresh = res->value;
3480 else if(!strcmp(res->name, "rxht"))
3481 rx_hthresh = res->value;
3482 else if(!strcmp(res->name, "rxwt"))
3483 rx_wthresh = res->value;
3485 printf("Unknown parameter\n");
3491 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3494 cmdline_parse_token_string_t cmd_config_thresh_port =
3495 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3496 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3497 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3498 cmdline_parse_token_string_t cmd_config_thresh_all =
3499 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3500 cmdline_parse_token_string_t cmd_config_thresh_name =
3501 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3502 "txpt#txht#txwt#rxpt#rxht#rxwt");
3503 cmdline_parse_token_num_t cmd_config_thresh_value =
3504 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3506 cmdline_parse_inst_t cmd_config_thresh = {
3507 .f = cmd_config_thresh_parsed,
3509 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3511 (void *)&cmd_config_thresh_port,
3512 (void *)&cmd_config_thresh_keyword,
3513 (void *)&cmd_config_thresh_all,
3514 (void *)&cmd_config_thresh_name,
3515 (void *)&cmd_config_thresh_value,
3520 /* *** configure free/rs threshold *** */
3521 struct cmd_config_threshold {
3522 cmdline_fixed_string_t port;
3523 cmdline_fixed_string_t keyword;
3524 cmdline_fixed_string_t all;
3525 cmdline_fixed_string_t name;
3530 cmd_config_threshold_parsed(void *parsed_result,
3531 __rte_unused struct cmdline *cl,
3532 __rte_unused void *data)
3534 struct cmd_config_threshold *res = parsed_result;
3536 if (!all_ports_stopped()) {
3537 printf("Please stop all ports first\n");
3541 if (!strcmp(res->name, "txfreet"))
3542 tx_free_thresh = res->value;
3543 else if (!strcmp(res->name, "txrst"))
3544 tx_rs_thresh = res->value;
3545 else if (!strcmp(res->name, "rxfreet"))
3546 rx_free_thresh = res->value;
3548 printf("Unknown parameter\n");
3554 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3557 cmdline_parse_token_string_t cmd_config_threshold_port =
3558 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3559 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3560 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3562 cmdline_parse_token_string_t cmd_config_threshold_all =
3563 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3564 cmdline_parse_token_string_t cmd_config_threshold_name =
3565 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3566 "txfreet#txrst#rxfreet");
3567 cmdline_parse_token_num_t cmd_config_threshold_value =
3568 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3570 cmdline_parse_inst_t cmd_config_threshold = {
3571 .f = cmd_config_threshold_parsed,
3573 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3575 (void *)&cmd_config_threshold_port,
3576 (void *)&cmd_config_threshold_keyword,
3577 (void *)&cmd_config_threshold_all,
3578 (void *)&cmd_config_threshold_name,
3579 (void *)&cmd_config_threshold_value,
3585 struct cmd_stop_result {
3586 cmdline_fixed_string_t stop;
3589 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3590 __rte_unused struct cmdline *cl,
3591 __rte_unused void *data)
3593 stop_packet_forwarding();
3596 cmdline_parse_token_string_t cmd_stop_stop =
3597 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3599 cmdline_parse_inst_t cmd_stop = {
3600 .f = cmd_stop_parsed,
3602 .help_str = "stop: Stop packet forwarding",
3604 (void *)&cmd_stop_stop,
3609 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3612 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3613 unsigned int *parsed_items, int check_unique_values)
3615 unsigned int nb_item;
3623 * First parse all items in the list and store their value.
3628 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3630 if ((c >= '0') && (c <= '9')) {
3631 value = (unsigned int) (value * 10 + (c - '0'));
3636 printf("character %c is not a decimal digit\n", c);
3640 printf("No valid value before comma\n");
3643 if (nb_item < max_items) {
3644 parsed_items[nb_item] = value;
3650 if (nb_item >= max_items) {
3651 printf("Number of %s = %u > %u (maximum items)\n",
3652 item_name, nb_item + 1, max_items);
3655 parsed_items[nb_item++] = value;
3656 if (! check_unique_values)
3660 * Then, check that all values in the list are differents.
3661 * No optimization here...
3663 for (i = 0; i < nb_item; i++) {
3664 for (j = i + 1; j < nb_item; j++) {
3665 if (parsed_items[j] == parsed_items[i]) {
3666 printf("duplicated %s %u at index %u and %u\n",
3667 item_name, parsed_items[i], i, j);
3675 struct cmd_set_list_result {
3676 cmdline_fixed_string_t cmd_keyword;
3677 cmdline_fixed_string_t list_name;
3678 cmdline_fixed_string_t list_of_items;
3681 static void cmd_set_list_parsed(void *parsed_result,
3682 __rte_unused struct cmdline *cl,
3683 __rte_unused void *data)
3685 struct cmd_set_list_result *res;
3687 unsigned int lcorelist[RTE_MAX_LCORE];
3688 unsigned int portlist[RTE_MAX_ETHPORTS];
3690 unsigned int nb_item;
3692 if (test_done == 0) {
3693 printf("Please stop forwarding first\n");
3697 res = parsed_result;
3698 if (!strcmp(res->list_name, "corelist")) {
3699 nb_item = parse_item_list(res->list_of_items, "core",
3701 parsed_items.lcorelist, 1);
3703 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3708 if (!strcmp(res->list_name, "portlist")) {
3709 nb_item = parse_item_list(res->list_of_items, "port",
3711 parsed_items.portlist, 1);
3713 set_fwd_ports_list(parsed_items.portlist, nb_item);
3719 cmdline_parse_token_string_t cmd_set_list_keyword =
3720 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3722 cmdline_parse_token_string_t cmd_set_list_name =
3723 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3724 "corelist#portlist");
3725 cmdline_parse_token_string_t cmd_set_list_of_items =
3726 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3729 cmdline_parse_inst_t cmd_set_fwd_list = {
3730 .f = cmd_set_list_parsed,
3732 .help_str = "set corelist|portlist <list0[,list1]*>",
3734 (void *)&cmd_set_list_keyword,
3735 (void *)&cmd_set_list_name,
3736 (void *)&cmd_set_list_of_items,
3741 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3743 struct cmd_setmask_result {
3744 cmdline_fixed_string_t set;
3745 cmdline_fixed_string_t mask;
3749 static void cmd_set_mask_parsed(void *parsed_result,
3750 __rte_unused struct cmdline *cl,
3751 __rte_unused void *data)
3753 struct cmd_setmask_result *res = parsed_result;
3755 if (test_done == 0) {
3756 printf("Please stop forwarding first\n");
3759 if (!strcmp(res->mask, "coremask")) {
3760 set_fwd_lcores_mask(res->hexavalue);
3762 } else if (!strcmp(res->mask, "portmask")) {
3763 set_fwd_ports_mask(res->hexavalue);
3768 cmdline_parse_token_string_t cmd_setmask_set =
3769 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3770 cmdline_parse_token_string_t cmd_setmask_mask =
3771 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3772 "coremask#portmask");
3773 cmdline_parse_token_num_t cmd_setmask_value =
3774 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3776 cmdline_parse_inst_t cmd_set_fwd_mask = {
3777 .f = cmd_set_mask_parsed,
3779 .help_str = "set coremask|portmask <hexadecimal value>",
3781 (void *)&cmd_setmask_set,
3782 (void *)&cmd_setmask_mask,
3783 (void *)&cmd_setmask_value,
3789 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3791 struct cmd_set_result {
3792 cmdline_fixed_string_t set;
3793 cmdline_fixed_string_t what;
3797 static void cmd_set_parsed(void *parsed_result,
3798 __rte_unused struct cmdline *cl,
3799 __rte_unused void *data)
3801 struct cmd_set_result *res = parsed_result;
3802 if (!strcmp(res->what, "nbport")) {
3803 set_fwd_ports_number(res->value);
3805 } else if (!strcmp(res->what, "nbcore")) {
3806 set_fwd_lcores_number(res->value);
3808 } else if (!strcmp(res->what, "burst"))
3809 set_nb_pkt_per_burst(res->value);
3810 else if (!strcmp(res->what, "verbose"))
3811 set_verbose_level(res->value);
3814 cmdline_parse_token_string_t cmd_set_set =
3815 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3816 cmdline_parse_token_string_t cmd_set_what =
3817 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3818 "nbport#nbcore#burst#verbose");
3819 cmdline_parse_token_num_t cmd_set_value =
3820 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3822 cmdline_parse_inst_t cmd_set_numbers = {
3823 .f = cmd_set_parsed,
3825 .help_str = "set nbport|nbcore|burst|verbose <value>",
3827 (void *)&cmd_set_set,
3828 (void *)&cmd_set_what,
3829 (void *)&cmd_set_value,
3834 /* *** SET LOG LEVEL CONFIGURATION *** */
3836 struct cmd_set_log_result {
3837 cmdline_fixed_string_t set;
3838 cmdline_fixed_string_t log;
3839 cmdline_fixed_string_t type;
3844 cmd_set_log_parsed(void *parsed_result,
3845 __rte_unused struct cmdline *cl,
3846 __rte_unused void *data)
3848 struct cmd_set_log_result *res;
3851 res = parsed_result;
3852 if (!strcmp(res->type, "global"))
3853 rte_log_set_global_level(res->level);
3855 ret = rte_log_set_level_regexp(res->type, res->level);
3857 printf("Unable to set log level\n");
3861 cmdline_parse_token_string_t cmd_set_log_set =
3862 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3863 cmdline_parse_token_string_t cmd_set_log_log =
3864 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3865 cmdline_parse_token_string_t cmd_set_log_type =
3866 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3867 cmdline_parse_token_num_t cmd_set_log_level =
3868 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3870 cmdline_parse_inst_t cmd_set_log = {
3871 .f = cmd_set_log_parsed,
3873 .help_str = "set log global|<type> <level>",
3875 (void *)&cmd_set_log_set,
3876 (void *)&cmd_set_log_log,
3877 (void *)&cmd_set_log_type,
3878 (void *)&cmd_set_log_level,
3883 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3885 struct cmd_set_txpkts_result {
3886 cmdline_fixed_string_t cmd_keyword;
3887 cmdline_fixed_string_t txpkts;
3888 cmdline_fixed_string_t seg_lengths;
3892 cmd_set_txpkts_parsed(void *parsed_result,
3893 __rte_unused struct cmdline *cl,
3894 __rte_unused void *data)
3896 struct cmd_set_txpkts_result *res;
3897 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3898 unsigned int nb_segs;
3900 res = parsed_result;
3901 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3902 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3904 set_tx_pkt_segments(seg_lengths, nb_segs);
3907 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3908 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3909 cmd_keyword, "set");
3910 cmdline_parse_token_string_t cmd_set_txpkts_name =
3911 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3913 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3914 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3917 cmdline_parse_inst_t cmd_set_txpkts = {
3918 .f = cmd_set_txpkts_parsed,
3920 .help_str = "set txpkts <len0[,len1]*>",
3922 (void *)&cmd_set_txpkts_keyword,
3923 (void *)&cmd_set_txpkts_name,
3924 (void *)&cmd_set_txpkts_lengths,
3929 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3931 struct cmd_set_txsplit_result {
3932 cmdline_fixed_string_t cmd_keyword;
3933 cmdline_fixed_string_t txsplit;
3934 cmdline_fixed_string_t mode;
3938 cmd_set_txsplit_parsed(void *parsed_result,
3939 __rte_unused struct cmdline *cl,
3940 __rte_unused void *data)
3942 struct cmd_set_txsplit_result *res;
3944 res = parsed_result;
3945 set_tx_pkt_split(res->mode);
3948 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3949 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3950 cmd_keyword, "set");
3951 cmdline_parse_token_string_t cmd_set_txsplit_name =
3952 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3953 txsplit, "txsplit");
3954 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3955 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3958 cmdline_parse_inst_t cmd_set_txsplit = {
3959 .f = cmd_set_txsplit_parsed,
3961 .help_str = "set txsplit on|off|rand",
3963 (void *)&cmd_set_txsplit_keyword,
3964 (void *)&cmd_set_txsplit_name,
3965 (void *)&cmd_set_txsplit_mode,
3970 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
3972 struct cmd_set_txtimes_result {
3973 cmdline_fixed_string_t cmd_keyword;
3974 cmdline_fixed_string_t txtimes;
3975 cmdline_fixed_string_t tx_times;
3979 cmd_set_txtimes_parsed(void *parsed_result,
3980 __rte_unused struct cmdline *cl,
3981 __rte_unused void *data)
3983 struct cmd_set_txtimes_result *res;
3984 unsigned int tx_times[2] = {0, 0};
3985 unsigned int n_times;
3987 res = parsed_result;
3988 n_times = parse_item_list(res->tx_times, "tx times",
3991 set_tx_pkt_times(tx_times);
3994 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
3995 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3996 cmd_keyword, "set");
3997 cmdline_parse_token_string_t cmd_set_txtimes_name =
3998 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3999 txtimes, "txtimes");
4000 cmdline_parse_token_string_t cmd_set_txtimes_value =
4001 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4004 cmdline_parse_inst_t cmd_set_txtimes = {
4005 .f = cmd_set_txtimes_parsed,
4007 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4009 (void *)&cmd_set_txtimes_keyword,
4010 (void *)&cmd_set_txtimes_name,
4011 (void *)&cmd_set_txtimes_value,
4016 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4017 struct cmd_rx_vlan_filter_all_result {
4018 cmdline_fixed_string_t rx_vlan;
4019 cmdline_fixed_string_t what;
4020 cmdline_fixed_string_t all;
4025 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4026 __rte_unused struct cmdline *cl,
4027 __rte_unused void *data)
4029 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4031 if (!strcmp(res->what, "add"))
4032 rx_vlan_all_filter_set(res->port_id, 1);
4034 rx_vlan_all_filter_set(res->port_id, 0);
4037 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4038 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4039 rx_vlan, "rx_vlan");
4040 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4041 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4043 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4044 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4046 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4047 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4050 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4051 .f = cmd_rx_vlan_filter_all_parsed,
4053 .help_str = "rx_vlan add|rm all <port_id>: "
4054 "Add/Remove all identifiers to/from the set of VLAN "
4055 "identifiers filtered by a port",
4057 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4058 (void *)&cmd_rx_vlan_filter_all_what,
4059 (void *)&cmd_rx_vlan_filter_all_all,
4060 (void *)&cmd_rx_vlan_filter_all_portid,
4065 /* *** VLAN OFFLOAD SET ON A PORT *** */
4066 struct cmd_vlan_offload_result {
4067 cmdline_fixed_string_t vlan;
4068 cmdline_fixed_string_t set;
4069 cmdline_fixed_string_t vlan_type;
4070 cmdline_fixed_string_t what;
4071 cmdline_fixed_string_t on;
4072 cmdline_fixed_string_t port_id;
4076 cmd_vlan_offload_parsed(void *parsed_result,
4077 __rte_unused struct cmdline *cl,
4078 __rte_unused void *data)
4081 struct cmd_vlan_offload_result *res = parsed_result;
4084 portid_t port_id = 0;
4088 len = strnlen(str, STR_TOKEN_SIZE);
4090 /* Get port_id first */
4098 tmp = strtoul(str, NULL, 0);
4099 /* If port_id greater that what portid_t can represent, return */
4100 if(tmp >= RTE_MAX_ETHPORTS)
4102 port_id = (portid_t)tmp;
4104 if (!strcmp(res->on, "on"))
4109 if (!strcmp(res->what, "strip"))
4110 rx_vlan_strip_set(port_id, on);
4111 else if(!strcmp(res->what, "stripq")){
4112 uint16_t queue_id = 0;
4114 /* No queue_id, return */
4116 printf("must specify (port,queue_id)\n");
4119 tmp = strtoul(str + i + 1, NULL, 0);
4120 /* If queue_id greater that what 16-bits can represent, return */
4124 queue_id = (uint16_t)tmp;
4125 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4127 else if (!strcmp(res->what, "filter"))
4128 rx_vlan_filter_set(port_id, on);
4129 else if (!strcmp(res->what, "qinq_strip"))
4130 rx_vlan_qinq_strip_set(port_id, on);
4132 vlan_extend_set(port_id, on);
4137 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4138 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4140 cmdline_parse_token_string_t cmd_vlan_offload_set =
4141 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4143 cmdline_parse_token_string_t cmd_vlan_offload_what =
4144 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4145 what, "strip#filter#qinq_strip#extend#stripq");
4146 cmdline_parse_token_string_t cmd_vlan_offload_on =
4147 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4149 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4150 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4153 cmdline_parse_inst_t cmd_vlan_offload = {
4154 .f = cmd_vlan_offload_parsed,
4156 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4157 "<port_id[,queue_id]>: "
4158 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4160 (void *)&cmd_vlan_offload_vlan,
4161 (void *)&cmd_vlan_offload_set,
4162 (void *)&cmd_vlan_offload_what,
4163 (void *)&cmd_vlan_offload_on,
4164 (void *)&cmd_vlan_offload_portid,
4169 /* *** VLAN TPID SET ON A PORT *** */
4170 struct cmd_vlan_tpid_result {
4171 cmdline_fixed_string_t vlan;
4172 cmdline_fixed_string_t set;
4173 cmdline_fixed_string_t vlan_type;
4174 cmdline_fixed_string_t what;
4180 cmd_vlan_tpid_parsed(void *parsed_result,
4181 __rte_unused struct cmdline *cl,
4182 __rte_unused void *data)
4184 struct cmd_vlan_tpid_result *res = parsed_result;
4185 enum rte_vlan_type vlan_type;
4187 if (!strcmp(res->vlan_type, "inner"))
4188 vlan_type = ETH_VLAN_TYPE_INNER;
4189 else if (!strcmp(res->vlan_type, "outer"))
4190 vlan_type = ETH_VLAN_TYPE_OUTER;
4192 printf("Unknown vlan type\n");
4195 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4198 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4199 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4201 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4202 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4204 cmdline_parse_token_string_t cmd_vlan_type =
4205 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4206 vlan_type, "inner#outer");
4207 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4208 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4210 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4211 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4213 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4214 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4217 cmdline_parse_inst_t cmd_vlan_tpid = {
4218 .f = cmd_vlan_tpid_parsed,
4220 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4221 "Set the VLAN Ether type",
4223 (void *)&cmd_vlan_tpid_vlan,
4224 (void *)&cmd_vlan_tpid_set,
4225 (void *)&cmd_vlan_type,
4226 (void *)&cmd_vlan_tpid_what,
4227 (void *)&cmd_vlan_tpid_tpid,
4228 (void *)&cmd_vlan_tpid_portid,
4233 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4234 struct cmd_rx_vlan_filter_result {
4235 cmdline_fixed_string_t rx_vlan;
4236 cmdline_fixed_string_t what;
4242 cmd_rx_vlan_filter_parsed(void *parsed_result,
4243 __rte_unused struct cmdline *cl,
4244 __rte_unused void *data)
4246 struct cmd_rx_vlan_filter_result *res = parsed_result;
4248 if (!strcmp(res->what, "add"))
4249 rx_vft_set(res->port_id, res->vlan_id, 1);
4251 rx_vft_set(res->port_id, res->vlan_id, 0);
4254 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4255 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4256 rx_vlan, "rx_vlan");
4257 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4258 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4260 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4261 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4263 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4264 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4267 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4268 .f = cmd_rx_vlan_filter_parsed,
4270 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4271 "Add/Remove a VLAN identifier to/from the set of VLAN "
4272 "identifiers filtered by a port",
4274 (void *)&cmd_rx_vlan_filter_rx_vlan,
4275 (void *)&cmd_rx_vlan_filter_what,
4276 (void *)&cmd_rx_vlan_filter_vlanid,
4277 (void *)&cmd_rx_vlan_filter_portid,
4282 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4283 struct cmd_tx_vlan_set_result {
4284 cmdline_fixed_string_t tx_vlan;
4285 cmdline_fixed_string_t set;
4291 cmd_tx_vlan_set_parsed(void *parsed_result,
4292 __rte_unused struct cmdline *cl,
4293 __rte_unused void *data)
4295 struct cmd_tx_vlan_set_result *res = parsed_result;
4297 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4300 if (!port_is_stopped(res->port_id)) {
4301 printf("Please stop port %d first\n", res->port_id);
4305 tx_vlan_set(res->port_id, res->vlan_id);
4307 cmd_reconfig_device_queue(res->port_id, 1, 1);
4310 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4311 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4312 tx_vlan, "tx_vlan");
4313 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4314 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4316 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4317 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4319 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4320 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4323 cmdline_parse_inst_t cmd_tx_vlan_set = {
4324 .f = cmd_tx_vlan_set_parsed,
4326 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4327 "Enable hardware insertion of a single VLAN header "
4328 "with a given TAG Identifier in packets sent on a port",
4330 (void *)&cmd_tx_vlan_set_tx_vlan,
4331 (void *)&cmd_tx_vlan_set_set,
4332 (void *)&cmd_tx_vlan_set_portid,
4333 (void *)&cmd_tx_vlan_set_vlanid,
4338 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4339 struct cmd_tx_vlan_set_qinq_result {
4340 cmdline_fixed_string_t tx_vlan;
4341 cmdline_fixed_string_t set;
4344 uint16_t vlan_id_outer;
4348 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4349 __rte_unused struct cmdline *cl,
4350 __rte_unused void *data)
4352 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4354 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4357 if (!port_is_stopped(res->port_id)) {
4358 printf("Please stop port %d first\n", res->port_id);
4362 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4364 cmd_reconfig_device_queue(res->port_id, 1, 1);
4367 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4368 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4369 tx_vlan, "tx_vlan");
4370 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4371 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4373 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4374 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4376 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4377 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4379 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4380 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4381 vlan_id_outer, UINT16);
4383 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4384 .f = cmd_tx_vlan_set_qinq_parsed,
4386 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4387 "Enable hardware insertion of double VLAN header "
4388 "with given TAG Identifiers in packets sent on a port",
4390 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4391 (void *)&cmd_tx_vlan_set_qinq_set,
4392 (void *)&cmd_tx_vlan_set_qinq_portid,
4393 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4394 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4399 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4400 struct cmd_tx_vlan_set_pvid_result {
4401 cmdline_fixed_string_t tx_vlan;
4402 cmdline_fixed_string_t set;
4403 cmdline_fixed_string_t pvid;
4406 cmdline_fixed_string_t mode;
4410 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4411 __rte_unused struct cmdline *cl,
4412 __rte_unused void *data)
4414 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4416 if (strcmp(res->mode, "on") == 0)
4417 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4419 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4422 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4423 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4424 tx_vlan, "tx_vlan");
4425 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4426 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4428 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4429 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4431 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4432 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4434 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4435 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4437 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4438 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4441 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4442 .f = cmd_tx_vlan_set_pvid_parsed,
4444 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4446 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4447 (void *)&cmd_tx_vlan_set_pvid_set,
4448 (void *)&cmd_tx_vlan_set_pvid_pvid,
4449 (void *)&cmd_tx_vlan_set_pvid_port_id,
4450 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4451 (void *)&cmd_tx_vlan_set_pvid_mode,
4456 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4457 struct cmd_tx_vlan_reset_result {
4458 cmdline_fixed_string_t tx_vlan;
4459 cmdline_fixed_string_t reset;
4464 cmd_tx_vlan_reset_parsed(void *parsed_result,
4465 __rte_unused struct cmdline *cl,
4466 __rte_unused void *data)
4468 struct cmd_tx_vlan_reset_result *res = parsed_result;
4470 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4473 if (!port_is_stopped(res->port_id)) {
4474 printf("Please stop port %d first\n", res->port_id);
4478 tx_vlan_reset(res->port_id);
4480 cmd_reconfig_device_queue(res->port_id, 1, 1);
4483 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4484 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4485 tx_vlan, "tx_vlan");
4486 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4487 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4489 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4490 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4493 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4494 .f = cmd_tx_vlan_reset_parsed,
4496 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4497 "VLAN header in packets sent on a port",
4499 (void *)&cmd_tx_vlan_reset_tx_vlan,
4500 (void *)&cmd_tx_vlan_reset_reset,
4501 (void *)&cmd_tx_vlan_reset_portid,
4507 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4508 struct cmd_csum_result {
4509 cmdline_fixed_string_t csum;
4510 cmdline_fixed_string_t mode;
4511 cmdline_fixed_string_t proto;
4512 cmdline_fixed_string_t hwsw;
4517 csum_show(int port_id)
4519 struct rte_eth_dev_info dev_info;
4520 uint64_t tx_offloads;
4523 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4524 printf("Parse tunnel is %s\n",
4525 (ports[port_id].parse_tunnel) ? "on" : "off");
4526 printf("IP checksum offload is %s\n",
4527 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4528 printf("UDP checksum offload is %s\n",
4529 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4530 printf("TCP checksum offload is %s\n",
4531 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4532 printf("SCTP checksum offload is %s\n",
4533 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4534 printf("Outer-Ip checksum offload is %s\n",
4535 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4536 printf("Outer-Udp checksum offload is %s\n",
4537 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4539 /* display warnings if configuration is not supported by the NIC */
4540 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4544 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4545 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4546 printf("Warning: hardware IP checksum enabled but not "
4547 "supported by port %d\n", port_id);
4549 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4550 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4551 printf("Warning: hardware UDP checksum enabled but not "
4552 "supported by port %d\n", port_id);
4554 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4555 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4556 printf("Warning: hardware TCP checksum enabled but not "
4557 "supported by port %d\n", port_id);
4559 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4560 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4561 printf("Warning: hardware SCTP checksum enabled but not "
4562 "supported by port %d\n", port_id);
4564 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4565 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4566 printf("Warning: hardware outer IP checksum enabled but not "
4567 "supported by port %d\n", port_id);
4569 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4570 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4572 printf("Warning: hardware outer UDP checksum enabled but not "
4573 "supported by port %d\n", port_id);
4578 cmd_config_queue_tx_offloads(struct rte_port *port)
4582 /* Apply queue tx offloads configuration */
4583 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4584 port->tx_conf[k].offloads =
4585 port->dev_conf.txmode.offloads;
4589 cmd_csum_parsed(void *parsed_result,
4590 __rte_unused struct cmdline *cl,
4591 __rte_unused void *data)
4593 struct cmd_csum_result *res = parsed_result;
4595 uint64_t csum_offloads = 0;
4596 struct rte_eth_dev_info dev_info;
4599 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4600 printf("invalid port %d\n", res->port_id);
4603 if (!port_is_stopped(res->port_id)) {
4604 printf("Please stop port %d first\n", res->port_id);
4608 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4612 if (!strcmp(res->mode, "set")) {
4614 if (!strcmp(res->hwsw, "hw"))
4617 if (!strcmp(res->proto, "ip")) {
4618 if (hw == 0 || (dev_info.tx_offload_capa &
4619 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4620 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4622 printf("IP checksum offload is not supported "
4623 "by port %u\n", res->port_id);
4625 } else if (!strcmp(res->proto, "udp")) {
4626 if (hw == 0 || (dev_info.tx_offload_capa &
4627 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4628 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4630 printf("UDP checksum offload is not supported "
4631 "by port %u\n", res->port_id);
4633 } else if (!strcmp(res->proto, "tcp")) {
4634 if (hw == 0 || (dev_info.tx_offload_capa &
4635 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4636 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4638 printf("TCP checksum offload is not supported "
4639 "by port %u\n", res->port_id);
4641 } else if (!strcmp(res->proto, "sctp")) {
4642 if (hw == 0 || (dev_info.tx_offload_capa &
4643 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4644 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4646 printf("SCTP checksum offload is not supported "
4647 "by port %u\n", res->port_id);
4649 } else if (!strcmp(res->proto, "outer-ip")) {
4650 if (hw == 0 || (dev_info.tx_offload_capa &
4651 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4653 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4655 printf("Outer IP checksum offload is not "
4656 "supported by port %u\n", res->port_id);
4658 } else if (!strcmp(res->proto, "outer-udp")) {
4659 if (hw == 0 || (dev_info.tx_offload_capa &
4660 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4662 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4664 printf("Outer UDP checksum offload is not "
4665 "supported by port %u\n", res->port_id);
4670 ports[res->port_id].dev_conf.txmode.offloads |=
4673 ports[res->port_id].dev_conf.txmode.offloads &=
4676 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4678 csum_show(res->port_id);
4680 cmd_reconfig_device_queue(res->port_id, 1, 1);
4683 cmdline_parse_token_string_t cmd_csum_csum =
4684 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4686 cmdline_parse_token_string_t cmd_csum_mode =
4687 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4689 cmdline_parse_token_string_t cmd_csum_proto =
4690 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4691 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4692 cmdline_parse_token_string_t cmd_csum_hwsw =
4693 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4695 cmdline_parse_token_num_t cmd_csum_portid =
4696 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4699 cmdline_parse_inst_t cmd_csum_set = {
4700 .f = cmd_csum_parsed,
4702 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4703 "Enable/Disable hardware calculation of L3/L4 checksum when "
4704 "using csum forward engine",
4706 (void *)&cmd_csum_csum,
4707 (void *)&cmd_csum_mode,
4708 (void *)&cmd_csum_proto,
4709 (void *)&cmd_csum_hwsw,
4710 (void *)&cmd_csum_portid,
4715 cmdline_parse_token_string_t cmd_csum_mode_show =
4716 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4719 cmdline_parse_inst_t cmd_csum_show = {
4720 .f = cmd_csum_parsed,
4722 .help_str = "csum show <port_id>: Show checksum offload configuration",
4724 (void *)&cmd_csum_csum,
4725 (void *)&cmd_csum_mode_show,
4726 (void *)&cmd_csum_portid,
4731 /* Enable/disable tunnel parsing */
4732 struct cmd_csum_tunnel_result {
4733 cmdline_fixed_string_t csum;
4734 cmdline_fixed_string_t parse;
4735 cmdline_fixed_string_t onoff;
4740 cmd_csum_tunnel_parsed(void *parsed_result,
4741 __rte_unused struct cmdline *cl,
4742 __rte_unused void *data)
4744 struct cmd_csum_tunnel_result *res = parsed_result;
4746 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4749 if (!strcmp(res->onoff, "on"))
4750 ports[res->port_id].parse_tunnel = 1;
4752 ports[res->port_id].parse_tunnel = 0;
4754 csum_show(res->port_id);
4757 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4758 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4760 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4761 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4762 parse, "parse-tunnel");
4763 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4764 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4766 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4767 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4770 cmdline_parse_inst_t cmd_csum_tunnel = {
4771 .f = cmd_csum_tunnel_parsed,
4773 .help_str = "csum parse-tunnel on|off <port_id>: "
4774 "Enable/Disable parsing of tunnels for csum engine",
4776 (void *)&cmd_csum_tunnel_csum,
4777 (void *)&cmd_csum_tunnel_parse,
4778 (void *)&cmd_csum_tunnel_onoff,
4779 (void *)&cmd_csum_tunnel_portid,
4784 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4785 struct cmd_tso_set_result {
4786 cmdline_fixed_string_t tso;
4787 cmdline_fixed_string_t mode;
4793 cmd_tso_set_parsed(void *parsed_result,
4794 __rte_unused struct cmdline *cl,
4795 __rte_unused void *data)
4797 struct cmd_tso_set_result *res = parsed_result;
4798 struct rte_eth_dev_info dev_info;
4801 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4803 if (!port_is_stopped(res->port_id)) {
4804 printf("Please stop port %d first\n", res->port_id);
4808 if (!strcmp(res->mode, "set"))
4809 ports[res->port_id].tso_segsz = res->tso_segsz;
4811 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4815 if ((ports[res->port_id].tso_segsz != 0) &&
4816 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4817 printf("Error: TSO is not supported by port %d\n",
4822 if (ports[res->port_id].tso_segsz == 0) {
4823 ports[res->port_id].dev_conf.txmode.offloads &=
4824 ~DEV_TX_OFFLOAD_TCP_TSO;
4825 printf("TSO for non-tunneled packets is disabled\n");
4827 ports[res->port_id].dev_conf.txmode.offloads |=
4828 DEV_TX_OFFLOAD_TCP_TSO;
4829 printf("TSO segment size for non-tunneled packets is %d\n",
4830 ports[res->port_id].tso_segsz);
4832 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4834 /* display warnings if configuration is not supported by the NIC */
4835 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4839 if ((ports[res->port_id].tso_segsz != 0) &&
4840 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4841 printf("Warning: TSO enabled but not "
4842 "supported by port %d\n", res->port_id);
4845 cmd_reconfig_device_queue(res->port_id, 1, 1);
4848 cmdline_parse_token_string_t cmd_tso_set_tso =
4849 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4851 cmdline_parse_token_string_t cmd_tso_set_mode =
4852 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4854 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4855 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4857 cmdline_parse_token_num_t cmd_tso_set_portid =
4858 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4861 cmdline_parse_inst_t cmd_tso_set = {
4862 .f = cmd_tso_set_parsed,
4864 .help_str = "tso set <tso_segsz> <port_id>: "
4865 "Set TSO segment size of non-tunneled packets for csum engine "
4868 (void *)&cmd_tso_set_tso,
4869 (void *)&cmd_tso_set_mode,
4870 (void *)&cmd_tso_set_tso_segsz,
4871 (void *)&cmd_tso_set_portid,
4876 cmdline_parse_token_string_t cmd_tso_show_mode =
4877 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4881 cmdline_parse_inst_t cmd_tso_show = {
4882 .f = cmd_tso_set_parsed,
4884 .help_str = "tso show <port_id>: "
4885 "Show TSO segment size of non-tunneled packets for csum engine",
4887 (void *)&cmd_tso_set_tso,
4888 (void *)&cmd_tso_show_mode,
4889 (void *)&cmd_tso_set_portid,
4894 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4895 struct cmd_tunnel_tso_set_result {
4896 cmdline_fixed_string_t tso;
4897 cmdline_fixed_string_t mode;
4902 static struct rte_eth_dev_info
4903 check_tunnel_tso_nic_support(portid_t port_id)
4905 struct rte_eth_dev_info dev_info;
4907 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4910 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4911 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4912 "not enabled for port %d\n", port_id);
4913 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4914 printf("Warning: GRE TUNNEL TSO not supported therefore "
4915 "not enabled for port %d\n", port_id);
4916 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4917 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4918 "not enabled for port %d\n", port_id);
4919 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4920 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4921 "not enabled for port %d\n", port_id);
4922 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4923 printf("Warning: IP TUNNEL TSO not supported therefore "
4924 "not enabled for port %d\n", port_id);
4925 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4926 printf("Warning: UDP TUNNEL TSO not supported therefore "
4927 "not enabled for port %d\n", port_id);
4932 cmd_tunnel_tso_set_parsed(void *parsed_result,
4933 __rte_unused struct cmdline *cl,
4934 __rte_unused void *data)
4936 struct cmd_tunnel_tso_set_result *res = parsed_result;
4937 struct rte_eth_dev_info dev_info;
4939 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4941 if (!port_is_stopped(res->port_id)) {
4942 printf("Please stop port %d first\n", res->port_id);
4946 if (!strcmp(res->mode, "set"))
4947 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4949 dev_info = check_tunnel_tso_nic_support(res->port_id);
4950 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4951 ports[res->port_id].dev_conf.txmode.offloads &=
4952 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4953 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4954 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4955 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4956 DEV_TX_OFFLOAD_IP_TNL_TSO |
4957 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4958 printf("TSO for tunneled packets is disabled\n");
4960 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4961 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4962 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4963 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4964 DEV_TX_OFFLOAD_IP_TNL_TSO |
4965 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4967 ports[res->port_id].dev_conf.txmode.offloads |=
4968 (tso_offloads & dev_info.tx_offload_capa);
4969 printf("TSO segment size for tunneled packets is %d\n",
4970 ports[res->port_id].tunnel_tso_segsz);
4972 /* Below conditions are needed to make it work:
4973 * (1) tunnel TSO is supported by the NIC;
4974 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4976 * (3) for tunneled pkts with outer L3 of IPv4,
4977 * "csum set outer-ip" must be set to hw, because after tso,
4978 * total_len of outer IP header is changed, and the checksum
4979 * of outer IP header calculated by sw should be wrong; that
4980 * is not necessary for IPv6 tunneled pkts because there's no
4981 * checksum in IP header anymore.
4984 if (!ports[res->port_id].parse_tunnel)
4985 printf("Warning: csum parse_tunnel must be set "
4986 "so that tunneled packets are recognized\n");
4987 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4988 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4989 printf("Warning: csum set outer-ip must be set to hw "
4990 "if outer L3 is IPv4; not necessary for IPv6\n");
4993 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4994 cmd_reconfig_device_queue(res->port_id, 1, 1);
4997 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4998 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5000 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5001 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5003 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5004 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5006 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5007 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5010 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5011 .f = cmd_tunnel_tso_set_parsed,
5013 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5014 "Set TSO segment size of tunneled packets for csum engine "
5017 (void *)&cmd_tunnel_tso_set_tso,
5018 (void *)&cmd_tunnel_tso_set_mode,
5019 (void *)&cmd_tunnel_tso_set_tso_segsz,
5020 (void *)&cmd_tunnel_tso_set_portid,
5025 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5026 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5030 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5031 .f = cmd_tunnel_tso_set_parsed,
5033 .help_str = "tunnel_tso show <port_id> "
5034 "Show TSO segment size of tunneled packets for csum engine",
5036 (void *)&cmd_tunnel_tso_set_tso,
5037 (void *)&cmd_tunnel_tso_show_mode,
5038 (void *)&cmd_tunnel_tso_set_portid,
5043 /* *** SET GRO FOR A PORT *** */
5044 struct cmd_gro_enable_result {
5045 cmdline_fixed_string_t cmd_set;
5046 cmdline_fixed_string_t cmd_port;
5047 cmdline_fixed_string_t cmd_keyword;
5048 cmdline_fixed_string_t cmd_onoff;
5053 cmd_gro_enable_parsed(void *parsed_result,
5054 __rte_unused struct cmdline *cl,
5055 __rte_unused void *data)
5057 struct cmd_gro_enable_result *res;
5059 res = parsed_result;
5060 if (!strcmp(res->cmd_keyword, "gro"))
5061 setup_gro(res->cmd_onoff, res->cmd_pid);
5064 cmdline_parse_token_string_t cmd_gro_enable_set =
5065 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5067 cmdline_parse_token_string_t cmd_gro_enable_port =
5068 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5069 cmd_keyword, "port");
5070 cmdline_parse_token_num_t cmd_gro_enable_pid =
5071 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5073 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5074 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5075 cmd_keyword, "gro");
5076 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5077 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5078 cmd_onoff, "on#off");
5080 cmdline_parse_inst_t cmd_gro_enable = {
5081 .f = cmd_gro_enable_parsed,
5083 .help_str = "set port <port_id> gro on|off",
5085 (void *)&cmd_gro_enable_set,
5086 (void *)&cmd_gro_enable_port,
5087 (void *)&cmd_gro_enable_pid,
5088 (void *)&cmd_gro_enable_keyword,
5089 (void *)&cmd_gro_enable_onoff,
5094 /* *** DISPLAY GRO CONFIGURATION *** */
5095 struct cmd_gro_show_result {
5096 cmdline_fixed_string_t cmd_show;
5097 cmdline_fixed_string_t cmd_port;
5098 cmdline_fixed_string_t cmd_keyword;
5103 cmd_gro_show_parsed(void *parsed_result,
5104 __rte_unused struct cmdline *cl,
5105 __rte_unused void *data)
5107 struct cmd_gro_show_result *res;
5109 res = parsed_result;
5110 if (!strcmp(res->cmd_keyword, "gro"))
5111 show_gro(res->cmd_pid);
5114 cmdline_parse_token_string_t cmd_gro_show_show =
5115 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5117 cmdline_parse_token_string_t cmd_gro_show_port =
5118 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5120 cmdline_parse_token_num_t cmd_gro_show_pid =
5121 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5123 cmdline_parse_token_string_t cmd_gro_show_keyword =
5124 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5125 cmd_keyword, "gro");
5127 cmdline_parse_inst_t cmd_gro_show = {
5128 .f = cmd_gro_show_parsed,
5130 .help_str = "show port <port_id> gro",
5132 (void *)&cmd_gro_show_show,
5133 (void *)&cmd_gro_show_port,
5134 (void *)&cmd_gro_show_pid,
5135 (void *)&cmd_gro_show_keyword,
5140 /* *** SET FLUSH CYCLES FOR GRO *** */
5141 struct cmd_gro_flush_result {
5142 cmdline_fixed_string_t cmd_set;
5143 cmdline_fixed_string_t cmd_keyword;
5144 cmdline_fixed_string_t cmd_flush;
5149 cmd_gro_flush_parsed(void *parsed_result,
5150 __rte_unused struct cmdline *cl,
5151 __rte_unused void *data)
5153 struct cmd_gro_flush_result *res;
5155 res = parsed_result;
5156 if ((!strcmp(res->cmd_keyword, "gro")) &&
5157 (!strcmp(res->cmd_flush, "flush")))
5158 setup_gro_flush_cycles(res->cmd_cycles);
5161 cmdline_parse_token_string_t cmd_gro_flush_set =
5162 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5164 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5165 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5166 cmd_keyword, "gro");
5167 cmdline_parse_token_string_t cmd_gro_flush_flush =
5168 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5169 cmd_flush, "flush");
5170 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5171 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5174 cmdline_parse_inst_t cmd_gro_flush = {
5175 .f = cmd_gro_flush_parsed,
5177 .help_str = "set gro flush <cycles>",
5179 (void *)&cmd_gro_flush_set,
5180 (void *)&cmd_gro_flush_keyword,
5181 (void *)&cmd_gro_flush_flush,
5182 (void *)&cmd_gro_flush_cycles,
5187 /* *** ENABLE/DISABLE GSO *** */
5188 struct cmd_gso_enable_result {
5189 cmdline_fixed_string_t cmd_set;
5190 cmdline_fixed_string_t cmd_port;
5191 cmdline_fixed_string_t cmd_keyword;
5192 cmdline_fixed_string_t cmd_mode;
5197 cmd_gso_enable_parsed(void *parsed_result,
5198 __rte_unused struct cmdline *cl,
5199 __rte_unused void *data)
5201 struct cmd_gso_enable_result *res;
5203 res = parsed_result;
5204 if (!strcmp(res->cmd_keyword, "gso"))
5205 setup_gso(res->cmd_mode, res->cmd_pid);
5208 cmdline_parse_token_string_t cmd_gso_enable_set =
5209 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5211 cmdline_parse_token_string_t cmd_gso_enable_port =
5212 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5214 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5215 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5216 cmd_keyword, "gso");
5217 cmdline_parse_token_string_t cmd_gso_enable_mode =
5218 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5219 cmd_mode, "on#off");
5220 cmdline_parse_token_num_t cmd_gso_enable_pid =
5221 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5224 cmdline_parse_inst_t cmd_gso_enable = {
5225 .f = cmd_gso_enable_parsed,
5227 .help_str = "set port <port_id> gso on|off",
5229 (void *)&cmd_gso_enable_set,
5230 (void *)&cmd_gso_enable_port,
5231 (void *)&cmd_gso_enable_pid,
5232 (void *)&cmd_gso_enable_keyword,
5233 (void *)&cmd_gso_enable_mode,
5238 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5239 struct cmd_gso_size_result {
5240 cmdline_fixed_string_t cmd_set;
5241 cmdline_fixed_string_t cmd_keyword;
5242 cmdline_fixed_string_t cmd_segsz;
5247 cmd_gso_size_parsed(void *parsed_result,
5248 __rte_unused struct cmdline *cl,
5249 __rte_unused void *data)
5251 struct cmd_gso_size_result *res = parsed_result;
5253 if (test_done == 0) {
5254 printf("Before setting GSO segsz, please first"
5255 " stop forwarding\n");
5259 if (!strcmp(res->cmd_keyword, "gso") &&
5260 !strcmp(res->cmd_segsz, "segsz")) {
5261 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5262 printf("gso_size should be larger than %zu."
5263 " Please input a legal value\n",
5264 RTE_GSO_SEG_SIZE_MIN);
5266 gso_max_segment_size = res->cmd_size;
5270 cmdline_parse_token_string_t cmd_gso_size_set =
5271 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5273 cmdline_parse_token_string_t cmd_gso_size_keyword =
5274 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5275 cmd_keyword, "gso");
5276 cmdline_parse_token_string_t cmd_gso_size_segsz =
5277 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5278 cmd_segsz, "segsz");
5279 cmdline_parse_token_num_t cmd_gso_size_size =
5280 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5283 cmdline_parse_inst_t cmd_gso_size = {
5284 .f = cmd_gso_size_parsed,
5286 .help_str = "set gso segsz <length>",
5288 (void *)&cmd_gso_size_set,
5289 (void *)&cmd_gso_size_keyword,
5290 (void *)&cmd_gso_size_segsz,
5291 (void *)&cmd_gso_size_size,
5296 /* *** SHOW GSO CONFIGURATION *** */
5297 struct cmd_gso_show_result {
5298 cmdline_fixed_string_t cmd_show;
5299 cmdline_fixed_string_t cmd_port;
5300 cmdline_fixed_string_t cmd_keyword;
5305 cmd_gso_show_parsed(void *parsed_result,
5306 __rte_unused struct cmdline *cl,
5307 __rte_unused void *data)
5309 struct cmd_gso_show_result *res = parsed_result;
5311 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5312 printf("invalid port id %u\n", res->cmd_pid);
5315 if (!strcmp(res->cmd_keyword, "gso")) {
5316 if (gso_ports[res->cmd_pid].enable) {
5317 printf("Max GSO'd packet size: %uB\n"
5318 "Supported GSO types: TCP/IPv4, "
5319 "UDP/IPv4, VxLAN with inner "
5320 "TCP/IPv4 packet, GRE with inner "
5321 "TCP/IPv4 packet\n",
5322 gso_max_segment_size);
5324 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5328 cmdline_parse_token_string_t cmd_gso_show_show =
5329 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5331 cmdline_parse_token_string_t cmd_gso_show_port =
5332 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5334 cmdline_parse_token_string_t cmd_gso_show_keyword =
5335 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5336 cmd_keyword, "gso");
5337 cmdline_parse_token_num_t cmd_gso_show_pid =
5338 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5341 cmdline_parse_inst_t cmd_gso_show = {
5342 .f = cmd_gso_show_parsed,
5344 .help_str = "show port <port_id> gso",
5346 (void *)&cmd_gso_show_show,
5347 (void *)&cmd_gso_show_port,
5348 (void *)&cmd_gso_show_pid,
5349 (void *)&cmd_gso_show_keyword,
5354 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5355 struct cmd_set_flush_rx {
5356 cmdline_fixed_string_t set;
5357 cmdline_fixed_string_t flush_rx;
5358 cmdline_fixed_string_t mode;
5362 cmd_set_flush_rx_parsed(void *parsed_result,
5363 __rte_unused struct cmdline *cl,
5364 __rte_unused void *data)
5366 struct cmd_set_flush_rx *res = parsed_result;
5367 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5370 cmdline_parse_token_string_t cmd_setflushrx_set =
5371 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5373 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5374 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5375 flush_rx, "flush_rx");
5376 cmdline_parse_token_string_t cmd_setflushrx_mode =
5377 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5381 cmdline_parse_inst_t cmd_set_flush_rx = {
5382 .f = cmd_set_flush_rx_parsed,
5383 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5386 (void *)&cmd_setflushrx_set,
5387 (void *)&cmd_setflushrx_flush_rx,
5388 (void *)&cmd_setflushrx_mode,
5393 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5394 struct cmd_set_link_check {
5395 cmdline_fixed_string_t set;
5396 cmdline_fixed_string_t link_check;
5397 cmdline_fixed_string_t mode;
5401 cmd_set_link_check_parsed(void *parsed_result,
5402 __rte_unused struct cmdline *cl,
5403 __rte_unused void *data)
5405 struct cmd_set_link_check *res = parsed_result;
5406 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5409 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5410 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5412 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5413 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5414 link_check, "link_check");
5415 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5416 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5420 cmdline_parse_inst_t cmd_set_link_check = {
5421 .f = cmd_set_link_check_parsed,
5422 .help_str = "set link_check on|off: Enable/Disable link status check "
5423 "when starting/stopping a port",
5426 (void *)&cmd_setlinkcheck_set,
5427 (void *)&cmd_setlinkcheck_link_check,
5428 (void *)&cmd_setlinkcheck_mode,
5433 /* *** SET NIC BYPASS MODE *** */
5434 struct cmd_set_bypass_mode_result {
5435 cmdline_fixed_string_t set;
5436 cmdline_fixed_string_t bypass;
5437 cmdline_fixed_string_t mode;
5438 cmdline_fixed_string_t value;
5443 cmd_set_bypass_mode_parsed(void *parsed_result,
5444 __rte_unused struct cmdline *cl,
5445 __rte_unused void *data)
5447 struct cmd_set_bypass_mode_result *res = parsed_result;
5448 portid_t port_id = res->port_id;
5449 int32_t rc = -EINVAL;
5451 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5452 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5454 if (!strcmp(res->value, "bypass"))
5455 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5456 else if (!strcmp(res->value, "isolate"))
5457 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5459 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5461 /* Set the bypass mode for the relevant port. */
5462 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5465 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5468 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5469 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5471 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5472 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5474 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5475 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5477 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5478 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5479 value, "normal#bypass#isolate");
5480 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5481 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5484 cmdline_parse_inst_t cmd_set_bypass_mode = {
5485 .f = cmd_set_bypass_mode_parsed,
5486 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5487 "Set the NIC bypass mode for port_id",
5490 (void *)&cmd_setbypass_mode_set,
5491 (void *)&cmd_setbypass_mode_bypass,
5492 (void *)&cmd_setbypass_mode_mode,
5493 (void *)&cmd_setbypass_mode_value,
5494 (void *)&cmd_setbypass_mode_port,
5499 /* *** SET NIC BYPASS EVENT *** */
5500 struct cmd_set_bypass_event_result {
5501 cmdline_fixed_string_t set;
5502 cmdline_fixed_string_t bypass;
5503 cmdline_fixed_string_t event;
5504 cmdline_fixed_string_t event_value;
5505 cmdline_fixed_string_t mode;
5506 cmdline_fixed_string_t mode_value;
5511 cmd_set_bypass_event_parsed(void *parsed_result,
5512 __rte_unused struct cmdline *cl,
5513 __rte_unused void *data)
5515 int32_t rc = -EINVAL;
5516 struct cmd_set_bypass_event_result *res = parsed_result;
5517 portid_t port_id = res->port_id;
5519 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5520 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5521 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5523 if (!strcmp(res->event_value, "timeout"))
5524 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5525 else if (!strcmp(res->event_value, "os_on"))
5526 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5527 else if (!strcmp(res->event_value, "os_off"))
5528 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5529 else if (!strcmp(res->event_value, "power_on"))
5530 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5531 else if (!strcmp(res->event_value, "power_off"))
5532 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5534 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5536 if (!strcmp(res->mode_value, "bypass"))
5537 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5538 else if (!strcmp(res->mode_value, "isolate"))
5539 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5541 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5543 /* Set the watchdog timeout. */
5544 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5547 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5548 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5552 printf("Failed to set timeout value %u "
5553 "for port %d, errto code: %d.\n",
5554 bypass_timeout, port_id, rc);
5558 /* Set the bypass event to transition to bypass mode. */
5559 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5564 printf("\t Failed to set bypass event for port = %d.\n",
5568 cmdline_parse_token_string_t cmd_setbypass_event_set =
5569 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5571 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5572 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5574 cmdline_parse_token_string_t cmd_setbypass_event_event =
5575 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5577 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5578 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5579 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5580 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5581 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5583 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5584 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5585 mode_value, "normal#bypass#isolate");
5586 cmdline_parse_token_num_t cmd_setbypass_event_port =
5587 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5590 cmdline_parse_inst_t cmd_set_bypass_event = {
5591 .f = cmd_set_bypass_event_parsed,
5592 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5593 "power_off mode normal|bypass|isolate <port_id>: "
5594 "Set the NIC bypass event mode for port_id",
5597 (void *)&cmd_setbypass_event_set,
5598 (void *)&cmd_setbypass_event_bypass,
5599 (void *)&cmd_setbypass_event_event,
5600 (void *)&cmd_setbypass_event_event_value,
5601 (void *)&cmd_setbypass_event_mode,
5602 (void *)&cmd_setbypass_event_mode_value,
5603 (void *)&cmd_setbypass_event_port,
5609 /* *** SET NIC BYPASS TIMEOUT *** */
5610 struct cmd_set_bypass_timeout_result {
5611 cmdline_fixed_string_t set;
5612 cmdline_fixed_string_t bypass;
5613 cmdline_fixed_string_t timeout;
5614 cmdline_fixed_string_t value;
5618 cmd_set_bypass_timeout_parsed(void *parsed_result,
5619 __rte_unused struct cmdline *cl,
5620 __rte_unused void *data)
5622 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5624 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5625 if (!strcmp(res->value, "1.5"))
5626 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5627 else if (!strcmp(res->value, "2"))
5628 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5629 else if (!strcmp(res->value, "3"))
5630 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5631 else if (!strcmp(res->value, "4"))
5632 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5633 else if (!strcmp(res->value, "8"))
5634 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5635 else if (!strcmp(res->value, "16"))
5636 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5637 else if (!strcmp(res->value, "32"))
5638 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5640 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5644 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5645 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5647 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5648 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5650 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5651 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5652 timeout, "timeout");
5653 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5654 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5655 value, "0#1.5#2#3#4#8#16#32");
5657 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5658 .f = cmd_set_bypass_timeout_parsed,
5659 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5660 "Set the NIC bypass watchdog timeout in seconds",
5663 (void *)&cmd_setbypass_timeout_set,
5664 (void *)&cmd_setbypass_timeout_bypass,
5665 (void *)&cmd_setbypass_timeout_timeout,
5666 (void *)&cmd_setbypass_timeout_value,
5671 /* *** SHOW NIC BYPASS MODE *** */
5672 struct cmd_show_bypass_config_result {
5673 cmdline_fixed_string_t show;
5674 cmdline_fixed_string_t bypass;
5675 cmdline_fixed_string_t config;
5680 cmd_show_bypass_config_parsed(void *parsed_result,
5681 __rte_unused struct cmdline *cl,
5682 __rte_unused void *data)
5684 struct cmd_show_bypass_config_result *res = parsed_result;
5685 portid_t port_id = res->port_id;
5687 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5688 uint32_t event_mode;
5689 uint32_t bypass_mode;
5690 uint32_t timeout = bypass_timeout;
5693 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5694 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5695 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5696 {"UNKNOWN", "normal", "bypass", "isolate"};
5697 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5705 /* Display the bypass mode.*/
5706 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5707 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5711 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5712 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5714 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5717 /* Display the bypass timeout.*/
5718 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5719 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5721 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5723 /* Display the bypass events and associated modes. */
5724 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5726 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5727 printf("\tFailed to get bypass mode for event = %s\n",
5730 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5731 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5733 printf("\tbypass event: %-16s = %s\n", events[i],
5739 printf("\tFailed to get bypass configuration for port = %d\n",
5743 cmdline_parse_token_string_t cmd_showbypass_config_show =
5744 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5746 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5747 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5749 cmdline_parse_token_string_t cmd_showbypass_config_config =
5750 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5752 cmdline_parse_token_num_t cmd_showbypass_config_port =
5753 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5756 cmdline_parse_inst_t cmd_show_bypass_config = {
5757 .f = cmd_show_bypass_config_parsed,
5758 .help_str = "show bypass config <port_id>: "
5759 "Show the NIC bypass config for port_id",
5762 (void *)&cmd_showbypass_config_show,
5763 (void *)&cmd_showbypass_config_bypass,
5764 (void *)&cmd_showbypass_config_config,
5765 (void *)&cmd_showbypass_config_port,
5770 #ifdef RTE_LIBRTE_PMD_BOND
5771 /* *** SET BONDING MODE *** */
5772 struct cmd_set_bonding_mode_result {
5773 cmdline_fixed_string_t set;
5774 cmdline_fixed_string_t bonding;
5775 cmdline_fixed_string_t mode;
5780 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5781 __rte_unused struct cmdline *cl,
5782 __rte_unused void *data)
5784 struct cmd_set_bonding_mode_result *res = parsed_result;
5785 portid_t port_id = res->port_id;
5787 /* Set the bonding mode for the relevant port. */
5788 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5789 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5792 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5793 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5795 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5796 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5797 bonding, "bonding");
5798 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5799 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5801 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5802 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5804 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5805 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5808 cmdline_parse_inst_t cmd_set_bonding_mode = {
5809 .f = cmd_set_bonding_mode_parsed,
5810 .help_str = "set bonding mode <mode_value> <port_id>: "
5811 "Set the bonding mode for port_id",
5814 (void *) &cmd_setbonding_mode_set,
5815 (void *) &cmd_setbonding_mode_bonding,
5816 (void *) &cmd_setbonding_mode_mode,
5817 (void *) &cmd_setbonding_mode_value,
5818 (void *) &cmd_setbonding_mode_port,
5823 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5824 struct cmd_set_bonding_lacp_dedicated_queues_result {
5825 cmdline_fixed_string_t set;
5826 cmdline_fixed_string_t bonding;
5827 cmdline_fixed_string_t lacp;
5828 cmdline_fixed_string_t dedicated_queues;
5830 cmdline_fixed_string_t mode;
5833 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5834 __rte_unused struct cmdline *cl,
5835 __rte_unused void *data)
5837 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5838 portid_t port_id = res->port_id;
5839 struct rte_port *port;
5841 port = &ports[port_id];
5843 /** Check if the port is not started **/
5844 if (port->port_status != RTE_PORT_STOPPED) {
5845 printf("Please stop port %d first\n", port_id);
5849 if (!strcmp(res->mode, "enable")) {
5850 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5851 printf("Dedicate queues for LACP control packets"
5854 printf("Enabling dedicate queues for LACP control "
5855 "packets on port %d failed\n", port_id);
5856 } else if (!strcmp(res->mode, "disable")) {
5857 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5858 printf("Dedicated queues for LACP control packets "
5861 printf("Disabling dedicated queues for LACP control "
5862 "traffic on port %d failed\n", port_id);
5866 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5867 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5869 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5870 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5871 bonding, "bonding");
5872 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5873 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5875 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5876 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5877 dedicated_queues, "dedicated_queues");
5878 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5879 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5881 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5882 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5883 mode, "enable#disable");
5885 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5886 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5887 .help_str = "set bonding lacp dedicated_queues <port_id> "
5889 "Enable/disable dedicated queues for LACP control traffic for port_id",
5892 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5893 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5894 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5895 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5896 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5897 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5902 /* *** SET BALANCE XMIT POLICY *** */
5903 struct cmd_set_bonding_balance_xmit_policy_result {
5904 cmdline_fixed_string_t set;
5905 cmdline_fixed_string_t bonding;
5906 cmdline_fixed_string_t balance_xmit_policy;
5908 cmdline_fixed_string_t policy;
5911 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5912 __rte_unused struct cmdline *cl,
5913 __rte_unused void *data)
5915 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5916 portid_t port_id = res->port_id;
5919 if (!strcmp(res->policy, "l2")) {
5920 policy = BALANCE_XMIT_POLICY_LAYER2;
5921 } else if (!strcmp(res->policy, "l23")) {
5922 policy = BALANCE_XMIT_POLICY_LAYER23;
5923 } else if (!strcmp(res->policy, "l34")) {
5924 policy = BALANCE_XMIT_POLICY_LAYER34;
5926 printf("\t Invalid xmit policy selection");
5930 /* Set the bonding mode for the relevant port. */
5931 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5932 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5937 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5938 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5940 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5941 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5942 bonding, "bonding");
5943 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5944 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5945 balance_xmit_policy, "balance_xmit_policy");
5946 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5947 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5949 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5950 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5951 policy, "l2#l23#l34");
5953 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5954 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5955 .help_str = "set bonding balance_xmit_policy <port_id> "
5957 "Set the bonding balance_xmit_policy for port_id",
5960 (void *)&cmd_setbonding_balance_xmit_policy_set,
5961 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5962 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5963 (void *)&cmd_setbonding_balance_xmit_policy_port,
5964 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5969 /* *** SHOW NIC BONDING CONFIGURATION *** */
5970 struct cmd_show_bonding_config_result {
5971 cmdline_fixed_string_t show;
5972 cmdline_fixed_string_t bonding;
5973 cmdline_fixed_string_t config;
5977 static void cmd_show_bonding_config_parsed(void *parsed_result,
5978 __rte_unused struct cmdline *cl,
5979 __rte_unused void *data)
5981 struct cmd_show_bonding_config_result *res = parsed_result;
5982 int bonding_mode, agg_mode;
5983 portid_t slaves[RTE_MAX_ETHPORTS];
5984 int num_slaves, num_active_slaves;
5987 portid_t port_id = res->port_id;
5989 /* Display the bonding mode.*/
5990 bonding_mode = rte_eth_bond_mode_get(port_id);
5991 if (bonding_mode < 0) {
5992 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5995 printf("\tBonding mode: %d\n", bonding_mode);
5997 if (bonding_mode == BONDING_MODE_BALANCE) {
5998 int balance_xmit_policy;
6000 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6001 if (balance_xmit_policy < 0) {
6002 printf("\tFailed to get balance xmit policy for port = %d\n",
6006 printf("\tBalance Xmit Policy: ");
6008 switch (balance_xmit_policy) {
6009 case BALANCE_XMIT_POLICY_LAYER2:
6010 printf("BALANCE_XMIT_POLICY_LAYER2");
6012 case BALANCE_XMIT_POLICY_LAYER23:
6013 printf("BALANCE_XMIT_POLICY_LAYER23");
6015 case BALANCE_XMIT_POLICY_LAYER34:
6016 printf("BALANCE_XMIT_POLICY_LAYER34");
6023 if (bonding_mode == BONDING_MODE_8023AD) {
6024 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6025 printf("\tIEEE802.3AD Aggregator Mode: ");
6028 printf("bandwidth");
6040 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6042 if (num_slaves < 0) {
6043 printf("\tFailed to get slave list for port = %d\n", port_id);
6046 if (num_slaves > 0) {
6047 printf("\tSlaves (%d): [", num_slaves);
6048 for (i = 0; i < num_slaves - 1; i++)
6049 printf("%d ", slaves[i]);
6051 printf("%d]\n", slaves[num_slaves - 1]);
6053 printf("\tSlaves: []\n");
6057 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6060 if (num_active_slaves < 0) {
6061 printf("\tFailed to get active slave list for port = %d\n", port_id);
6064 if (num_active_slaves > 0) {
6065 printf("\tActive Slaves (%d): [", num_active_slaves);
6066 for (i = 0; i < num_active_slaves - 1; i++)
6067 printf("%d ", slaves[i]);
6069 printf("%d]\n", slaves[num_active_slaves - 1]);
6072 printf("\tActive Slaves: []\n");
6076 primary_id = rte_eth_bond_primary_get(port_id);
6077 if (primary_id < 0) {
6078 printf("\tFailed to get primary slave for port = %d\n", port_id);
6081 printf("\tPrimary: [%d]\n", primary_id);
6085 cmdline_parse_token_string_t cmd_showbonding_config_show =
6086 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6088 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6089 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6090 bonding, "bonding");
6091 cmdline_parse_token_string_t cmd_showbonding_config_config =
6092 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6094 cmdline_parse_token_num_t cmd_showbonding_config_port =
6095 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6098 cmdline_parse_inst_t cmd_show_bonding_config = {
6099 .f = cmd_show_bonding_config_parsed,
6100 .help_str = "show bonding config <port_id>: "
6101 "Show the bonding config for port_id",
6104 (void *)&cmd_showbonding_config_show,
6105 (void *)&cmd_showbonding_config_bonding,
6106 (void *)&cmd_showbonding_config_config,
6107 (void *)&cmd_showbonding_config_port,
6112 /* *** SET BONDING PRIMARY *** */
6113 struct cmd_set_bonding_primary_result {
6114 cmdline_fixed_string_t set;
6115 cmdline_fixed_string_t bonding;
6116 cmdline_fixed_string_t primary;
6121 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6122 __rte_unused struct cmdline *cl,
6123 __rte_unused void *data)
6125 struct cmd_set_bonding_primary_result *res = parsed_result;
6126 portid_t master_port_id = res->port_id;
6127 portid_t slave_port_id = res->slave_id;
6129 /* Set the primary slave for a bonded device. */
6130 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6131 printf("\t Failed to set primary slave for port = %d.\n",
6138 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6139 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6141 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6142 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6143 bonding, "bonding");
6144 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6145 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6146 primary, "primary");
6147 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6148 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6150 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6151 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6154 cmdline_parse_inst_t cmd_set_bonding_primary = {
6155 .f = cmd_set_bonding_primary_parsed,
6156 .help_str = "set bonding primary <slave_id> <port_id>: "
6157 "Set the primary slave for port_id",
6160 (void *)&cmd_setbonding_primary_set,
6161 (void *)&cmd_setbonding_primary_bonding,
6162 (void *)&cmd_setbonding_primary_primary,
6163 (void *)&cmd_setbonding_primary_slave,
6164 (void *)&cmd_setbonding_primary_port,
6169 /* *** ADD SLAVE *** */
6170 struct cmd_add_bonding_slave_result {
6171 cmdline_fixed_string_t add;
6172 cmdline_fixed_string_t bonding;
6173 cmdline_fixed_string_t slave;
6178 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6179 __rte_unused struct cmdline *cl,
6180 __rte_unused void *data)
6182 struct cmd_add_bonding_slave_result *res = parsed_result;
6183 portid_t master_port_id = res->port_id;
6184 portid_t slave_port_id = res->slave_id;
6186 /* add the slave for a bonded device. */
6187 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6188 printf("\t Failed to add slave %d to master port = %d.\n",
6189 slave_port_id, master_port_id);
6193 set_port_slave_flag(slave_port_id);
6196 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6197 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6199 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6200 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6201 bonding, "bonding");
6202 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6203 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6205 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6206 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6208 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6209 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6212 cmdline_parse_inst_t cmd_add_bonding_slave = {
6213 .f = cmd_add_bonding_slave_parsed,
6214 .help_str = "add bonding slave <slave_id> <port_id>: "
6215 "Add a slave device to a bonded device",
6218 (void *)&cmd_addbonding_slave_add,
6219 (void *)&cmd_addbonding_slave_bonding,
6220 (void *)&cmd_addbonding_slave_slave,
6221 (void *)&cmd_addbonding_slave_slaveid,
6222 (void *)&cmd_addbonding_slave_port,
6227 /* *** REMOVE SLAVE *** */
6228 struct cmd_remove_bonding_slave_result {
6229 cmdline_fixed_string_t remove;
6230 cmdline_fixed_string_t bonding;
6231 cmdline_fixed_string_t slave;
6236 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6237 __rte_unused struct cmdline *cl,
6238 __rte_unused void *data)
6240 struct cmd_remove_bonding_slave_result *res = parsed_result;
6241 portid_t master_port_id = res->port_id;
6242 portid_t slave_port_id = res->slave_id;
6244 /* remove the slave from a bonded device. */
6245 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6246 printf("\t Failed to remove slave %d from master port = %d.\n",
6247 slave_port_id, master_port_id);
6251 clear_port_slave_flag(slave_port_id);
6254 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6255 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6257 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6258 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6259 bonding, "bonding");
6260 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6261 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6263 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6264 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6266 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6267 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6270 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6271 .f = cmd_remove_bonding_slave_parsed,
6272 .help_str = "remove bonding slave <slave_id> <port_id>: "
6273 "Remove a slave device from a bonded device",
6276 (void *)&cmd_removebonding_slave_remove,
6277 (void *)&cmd_removebonding_slave_bonding,
6278 (void *)&cmd_removebonding_slave_slave,
6279 (void *)&cmd_removebonding_slave_slaveid,
6280 (void *)&cmd_removebonding_slave_port,
6285 /* *** CREATE BONDED DEVICE *** */
6286 struct cmd_create_bonded_device_result {
6287 cmdline_fixed_string_t create;
6288 cmdline_fixed_string_t bonded;
6289 cmdline_fixed_string_t device;
6294 static int bond_dev_num = 0;
6296 static void cmd_create_bonded_device_parsed(void *parsed_result,
6297 __rte_unused struct cmdline *cl,
6298 __rte_unused void *data)
6300 struct cmd_create_bonded_device_result *res = parsed_result;
6301 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6305 if (test_done == 0) {
6306 printf("Please stop forwarding first\n");
6310 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6313 /* Create a new bonded device. */
6314 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6316 printf("\t Failed to create bonded device.\n");
6319 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6322 /* Update number of ports */
6323 nb_ports = rte_eth_dev_count_avail();
6324 reconfig(port_id, res->socket);
6325 ret = rte_eth_promiscuous_enable(port_id);
6327 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6328 port_id, rte_strerror(-ret));
6330 ports[port_id].need_setup = 0;
6331 ports[port_id].port_status = RTE_PORT_STOPPED;
6336 cmdline_parse_token_string_t cmd_createbonded_device_create =
6337 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6339 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6340 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6342 cmdline_parse_token_string_t cmd_createbonded_device_device =
6343 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6345 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6346 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6348 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6349 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6352 cmdline_parse_inst_t cmd_create_bonded_device = {
6353 .f = cmd_create_bonded_device_parsed,
6354 .help_str = "create bonded device <mode> <socket>: "
6355 "Create a new bonded device with specific bonding mode and socket",
6358 (void *)&cmd_createbonded_device_create,
6359 (void *)&cmd_createbonded_device_bonded,
6360 (void *)&cmd_createbonded_device_device,
6361 (void *)&cmd_createbonded_device_mode,
6362 (void *)&cmd_createbonded_device_socket,
6367 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6368 struct cmd_set_bond_mac_addr_result {
6369 cmdline_fixed_string_t set;
6370 cmdline_fixed_string_t bonding;
6371 cmdline_fixed_string_t mac_addr;
6373 struct rte_ether_addr address;
6376 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6377 __rte_unused struct cmdline *cl,
6378 __rte_unused void *data)
6380 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6383 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6386 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6388 /* check the return value and print it if is < 0 */
6390 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6393 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6394 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6395 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6396 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6398 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6399 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6401 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6402 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6404 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6405 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6407 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6408 .f = cmd_set_bond_mac_addr_parsed,
6410 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6412 (void *)&cmd_set_bond_mac_addr_set,
6413 (void *)&cmd_set_bond_mac_addr_bonding,
6414 (void *)&cmd_set_bond_mac_addr_mac,
6415 (void *)&cmd_set_bond_mac_addr_portnum,
6416 (void *)&cmd_set_bond_mac_addr_addr,
6422 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6423 struct cmd_set_bond_mon_period_result {
6424 cmdline_fixed_string_t set;
6425 cmdline_fixed_string_t bonding;
6426 cmdline_fixed_string_t mon_period;
6431 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6432 __rte_unused struct cmdline *cl,
6433 __rte_unused void *data)
6435 struct cmd_set_bond_mon_period_result *res = parsed_result;
6438 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6440 /* check the return value and print it if is < 0 */
6442 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6445 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6446 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6448 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6449 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6450 bonding, "bonding");
6451 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6452 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6453 mon_period, "mon_period");
6454 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6455 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6457 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6458 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6461 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6462 .f = cmd_set_bond_mon_period_parsed,
6464 .help_str = "set bonding mon_period <port_id> <period_ms>",
6466 (void *)&cmd_set_bond_mon_period_set,
6467 (void *)&cmd_set_bond_mon_period_bonding,
6468 (void *)&cmd_set_bond_mon_period_mon_period,
6469 (void *)&cmd_set_bond_mon_period_portnum,
6470 (void *)&cmd_set_bond_mon_period_period_ms,
6477 struct cmd_set_bonding_agg_mode_policy_result {
6478 cmdline_fixed_string_t set;
6479 cmdline_fixed_string_t bonding;
6480 cmdline_fixed_string_t agg_mode;
6482 cmdline_fixed_string_t policy;
6487 cmd_set_bonding_agg_mode(void *parsed_result,
6488 __rte_unused struct cmdline *cl,
6489 __rte_unused void *data)
6491 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6492 uint8_t policy = AGG_BANDWIDTH;
6494 if (!strcmp(res->policy, "bandwidth"))
6495 policy = AGG_BANDWIDTH;
6496 else if (!strcmp(res->policy, "stable"))
6497 policy = AGG_STABLE;
6498 else if (!strcmp(res->policy, "count"))
6501 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6505 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6506 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6508 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6509 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6510 bonding, "bonding");
6512 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6513 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6514 agg_mode, "agg_mode");
6516 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6517 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6520 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6521 TOKEN_STRING_INITIALIZER(
6522 struct cmd_set_bonding_balance_xmit_policy_result,
6523 policy, "stable#bandwidth#count");
6525 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6526 .f = cmd_set_bonding_agg_mode,
6528 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6530 (void *)&cmd_set_bonding_agg_mode_set,
6531 (void *)&cmd_set_bonding_agg_mode_bonding,
6532 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6533 (void *)&cmd_set_bonding_agg_mode_portnum,
6534 (void *)&cmd_set_bonding_agg_mode_policy_string,
6540 #endif /* RTE_LIBRTE_PMD_BOND */
6542 /* *** SET FORWARDING MODE *** */
6543 struct cmd_set_fwd_mode_result {
6544 cmdline_fixed_string_t set;
6545 cmdline_fixed_string_t fwd;
6546 cmdline_fixed_string_t mode;
6549 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6550 __rte_unused struct cmdline *cl,
6551 __rte_unused void *data)
6553 struct cmd_set_fwd_mode_result *res = parsed_result;
6556 set_pkt_forwarding_mode(res->mode);
6559 cmdline_parse_token_string_t cmd_setfwd_set =
6560 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6561 cmdline_parse_token_string_t cmd_setfwd_fwd =
6562 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6563 cmdline_parse_token_string_t cmd_setfwd_mode =
6564 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6565 "" /* defined at init */);
6567 cmdline_parse_inst_t cmd_set_fwd_mode = {
6568 .f = cmd_set_fwd_mode_parsed,
6570 .help_str = NULL, /* defined at init */
6572 (void *)&cmd_setfwd_set,
6573 (void *)&cmd_setfwd_fwd,
6574 (void *)&cmd_setfwd_mode,
6579 static void cmd_set_fwd_mode_init(void)
6582 static char token[128];
6583 static char help[256];
6584 cmdline_parse_token_string_t *token_struct;
6586 modes = list_pkt_forwarding_modes();
6587 snprintf(help, sizeof(help), "set fwd %s: "
6588 "Set packet forwarding mode", modes);
6589 cmd_set_fwd_mode.help_str = help;
6591 /* string token separator is # */
6592 for (c = token; *modes != '\0'; modes++)
6597 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6598 token_struct->string_data.str = token;
6601 /* *** SET RETRY FORWARDING MODE *** */
6602 struct cmd_set_fwd_retry_mode_result {
6603 cmdline_fixed_string_t set;
6604 cmdline_fixed_string_t fwd;
6605 cmdline_fixed_string_t mode;
6606 cmdline_fixed_string_t retry;
6609 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6610 __rte_unused struct cmdline *cl,
6611 __rte_unused void *data)
6613 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6616 set_pkt_forwarding_mode(res->mode);
6619 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6620 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6622 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6623 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6625 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6626 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6628 "" /* defined at init */);
6629 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6630 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6633 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6634 .f = cmd_set_fwd_retry_mode_parsed,
6636 .help_str = NULL, /* defined at init */
6638 (void *)&cmd_setfwd_retry_set,
6639 (void *)&cmd_setfwd_retry_fwd,
6640 (void *)&cmd_setfwd_retry_mode,
6641 (void *)&cmd_setfwd_retry_retry,
6646 static void cmd_set_fwd_retry_mode_init(void)
6649 static char token[128];
6650 static char help[256];
6651 cmdline_parse_token_string_t *token_struct;
6653 modes = list_pkt_forwarding_retry_modes();
6654 snprintf(help, sizeof(help), "set fwd %s retry: "
6655 "Set packet forwarding mode with retry", modes);
6656 cmd_set_fwd_retry_mode.help_str = help;
6658 /* string token separator is # */
6659 for (c = token; *modes != '\0'; modes++)
6664 token_struct = (cmdline_parse_token_string_t *)
6665 cmd_set_fwd_retry_mode.tokens[2];
6666 token_struct->string_data.str = token;
6669 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6670 struct cmd_set_burst_tx_retry_result {
6671 cmdline_fixed_string_t set;
6672 cmdline_fixed_string_t burst;
6673 cmdline_fixed_string_t tx;
6674 cmdline_fixed_string_t delay;
6676 cmdline_fixed_string_t retry;
6680 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6681 __rte_unused struct cmdline *cl,
6682 __rte_unused void *data)
6684 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6686 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6687 && !strcmp(res->tx, "tx")) {
6688 if (!strcmp(res->delay, "delay"))
6689 burst_tx_delay_time = res->time;
6690 if (!strcmp(res->retry, "retry"))
6691 burst_tx_retry_num = res->retry_num;
6696 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6697 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6698 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6699 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6701 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6702 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6703 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6704 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6705 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6706 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6707 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6708 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6709 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6710 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6712 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6713 .f = cmd_set_burst_tx_retry_parsed,
6714 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6716 (void *)&cmd_set_burst_tx_retry_set,
6717 (void *)&cmd_set_burst_tx_retry_burst,
6718 (void *)&cmd_set_burst_tx_retry_tx,
6719 (void *)&cmd_set_burst_tx_retry_delay,
6720 (void *)&cmd_set_burst_tx_retry_time,
6721 (void *)&cmd_set_burst_tx_retry_retry,
6722 (void *)&cmd_set_burst_tx_retry_retry_num,
6727 /* *** SET PROMISC MODE *** */
6728 struct cmd_set_promisc_mode_result {
6729 cmdline_fixed_string_t set;
6730 cmdline_fixed_string_t promisc;
6731 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6732 uint16_t port_num; /* valid if "allports" argument == 0 */
6733 cmdline_fixed_string_t mode;
6736 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6737 __rte_unused struct cmdline *cl,
6740 struct cmd_set_promisc_mode_result *res = parsed_result;
6744 if (!strcmp(res->mode, "on"))
6751 RTE_ETH_FOREACH_DEV(i)
6752 eth_set_promisc_mode(i, enable);
6754 eth_set_promisc_mode(res->port_num, enable);
6758 cmdline_parse_token_string_t cmd_setpromisc_set =
6759 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6760 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6761 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6763 cmdline_parse_token_string_t cmd_setpromisc_portall =
6764 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6766 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6767 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6769 cmdline_parse_token_string_t cmd_setpromisc_mode =
6770 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6773 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6774 .f = cmd_set_promisc_mode_parsed,
6776 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6778 (void *)&cmd_setpromisc_set,
6779 (void *)&cmd_setpromisc_promisc,
6780 (void *)&cmd_setpromisc_portall,
6781 (void *)&cmd_setpromisc_mode,
6786 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6787 .f = cmd_set_promisc_mode_parsed,
6789 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6791 (void *)&cmd_setpromisc_set,
6792 (void *)&cmd_setpromisc_promisc,
6793 (void *)&cmd_setpromisc_portnum,
6794 (void *)&cmd_setpromisc_mode,
6799 /* *** SET ALLMULTI MODE *** */
6800 struct cmd_set_allmulti_mode_result {
6801 cmdline_fixed_string_t set;
6802 cmdline_fixed_string_t allmulti;
6803 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6804 uint16_t port_num; /* valid if "allports" argument == 0 */
6805 cmdline_fixed_string_t mode;
6808 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6809 __rte_unused struct cmdline *cl,
6812 struct cmd_set_allmulti_mode_result *res = parsed_result;
6816 if (!strcmp(res->mode, "on"))
6823 RTE_ETH_FOREACH_DEV(i) {
6824 eth_set_allmulticast_mode(i, enable);
6828 eth_set_allmulticast_mode(res->port_num, enable);
6832 cmdline_parse_token_string_t cmd_setallmulti_set =
6833 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6834 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6835 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6837 cmdline_parse_token_string_t cmd_setallmulti_portall =
6838 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6840 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6841 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6843 cmdline_parse_token_string_t cmd_setallmulti_mode =
6844 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6847 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6848 .f = cmd_set_allmulti_mode_parsed,
6850 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6852 (void *)&cmd_setallmulti_set,
6853 (void *)&cmd_setallmulti_allmulti,
6854 (void *)&cmd_setallmulti_portall,
6855 (void *)&cmd_setallmulti_mode,
6860 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6861 .f = cmd_set_allmulti_mode_parsed,
6863 .help_str = "set allmulti <port_id> on|off: "
6864 "Set allmulti mode on port_id",
6866 (void *)&cmd_setallmulti_set,
6867 (void *)&cmd_setallmulti_allmulti,
6868 (void *)&cmd_setallmulti_portnum,
6869 (void *)&cmd_setallmulti_mode,
6874 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6875 struct cmd_link_flow_ctrl_set_result {
6876 cmdline_fixed_string_t set;
6877 cmdline_fixed_string_t flow_ctrl;
6878 cmdline_fixed_string_t rx;
6879 cmdline_fixed_string_t rx_lfc_mode;
6880 cmdline_fixed_string_t tx;
6881 cmdline_fixed_string_t tx_lfc_mode;
6882 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6883 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6884 cmdline_fixed_string_t autoneg_str;
6885 cmdline_fixed_string_t autoneg;
6886 cmdline_fixed_string_t hw_str;
6887 uint32_t high_water;
6888 cmdline_fixed_string_t lw_str;
6890 cmdline_fixed_string_t pt_str;
6891 uint16_t pause_time;
6892 cmdline_fixed_string_t xon_str;
6897 cmdline_parse_token_string_t cmd_lfc_set_set =
6898 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6900 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6901 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6902 flow_ctrl, "flow_ctrl");
6903 cmdline_parse_token_string_t cmd_lfc_set_rx =
6904 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6906 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6907 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6908 rx_lfc_mode, "on#off");
6909 cmdline_parse_token_string_t cmd_lfc_set_tx =
6910 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6912 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6913 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6914 tx_lfc_mode, "on#off");
6915 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6916 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6917 hw_str, "high_water");
6918 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6919 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6920 high_water, UINT32);
6921 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6922 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6923 lw_str, "low_water");
6924 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6925 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6927 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6928 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6929 pt_str, "pause_time");
6930 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6931 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6932 pause_time, UINT16);
6933 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6934 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6935 xon_str, "send_xon");
6936 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6937 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6939 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6940 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6941 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6942 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6943 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6944 mac_ctrl_frame_fwd_mode, "on#off");
6945 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6946 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6947 autoneg_str, "autoneg");
6948 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6949 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6951 cmdline_parse_token_num_t cmd_lfc_set_portid =
6952 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6955 /* forward declaration */
6957 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6960 cmdline_parse_inst_t cmd_link_flow_control_set = {
6961 .f = cmd_link_flow_ctrl_set_parsed,
6963 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6964 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6965 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6967 (void *)&cmd_lfc_set_set,
6968 (void *)&cmd_lfc_set_flow_ctrl,
6969 (void *)&cmd_lfc_set_rx,
6970 (void *)&cmd_lfc_set_rx_mode,
6971 (void *)&cmd_lfc_set_tx,
6972 (void *)&cmd_lfc_set_tx_mode,
6973 (void *)&cmd_lfc_set_high_water,
6974 (void *)&cmd_lfc_set_low_water,
6975 (void *)&cmd_lfc_set_pause_time,
6976 (void *)&cmd_lfc_set_send_xon,
6977 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6978 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6979 (void *)&cmd_lfc_set_autoneg_str,
6980 (void *)&cmd_lfc_set_autoneg,
6981 (void *)&cmd_lfc_set_portid,
6986 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6987 .f = cmd_link_flow_ctrl_set_parsed,
6988 .data = (void *)&cmd_link_flow_control_set_rx,
6989 .help_str = "set flow_ctrl rx on|off <port_id>: "
6990 "Change rx flow control parameter",
6992 (void *)&cmd_lfc_set_set,
6993 (void *)&cmd_lfc_set_flow_ctrl,
6994 (void *)&cmd_lfc_set_rx,
6995 (void *)&cmd_lfc_set_rx_mode,
6996 (void *)&cmd_lfc_set_portid,
7001 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7002 .f = cmd_link_flow_ctrl_set_parsed,
7003 .data = (void *)&cmd_link_flow_control_set_tx,
7004 .help_str = "set flow_ctrl tx on|off <port_id>: "
7005 "Change tx flow control parameter",
7007 (void *)&cmd_lfc_set_set,
7008 (void *)&cmd_lfc_set_flow_ctrl,
7009 (void *)&cmd_lfc_set_tx,
7010 (void *)&cmd_lfc_set_tx_mode,
7011 (void *)&cmd_lfc_set_portid,
7016 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7017 .f = cmd_link_flow_ctrl_set_parsed,
7018 .data = (void *)&cmd_link_flow_control_set_hw,
7019 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7020 "Change high water flow control parameter",
7022 (void *)&cmd_lfc_set_set,
7023 (void *)&cmd_lfc_set_flow_ctrl,
7024 (void *)&cmd_lfc_set_high_water_str,
7025 (void *)&cmd_lfc_set_high_water,
7026 (void *)&cmd_lfc_set_portid,
7031 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7032 .f = cmd_link_flow_ctrl_set_parsed,
7033 .data = (void *)&cmd_link_flow_control_set_lw,
7034 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7035 "Change low water flow control parameter",
7037 (void *)&cmd_lfc_set_set,
7038 (void *)&cmd_lfc_set_flow_ctrl,
7039 (void *)&cmd_lfc_set_low_water_str,
7040 (void *)&cmd_lfc_set_low_water,
7041 (void *)&cmd_lfc_set_portid,
7046 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7047 .f = cmd_link_flow_ctrl_set_parsed,
7048 .data = (void *)&cmd_link_flow_control_set_pt,
7049 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7050 "Change pause time flow control parameter",
7052 (void *)&cmd_lfc_set_set,
7053 (void *)&cmd_lfc_set_flow_ctrl,
7054 (void *)&cmd_lfc_set_pause_time_str,
7055 (void *)&cmd_lfc_set_pause_time,
7056 (void *)&cmd_lfc_set_portid,
7061 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7062 .f = cmd_link_flow_ctrl_set_parsed,
7063 .data = (void *)&cmd_link_flow_control_set_xon,
7064 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7065 "Change send_xon flow control parameter",
7067 (void *)&cmd_lfc_set_set,
7068 (void *)&cmd_lfc_set_flow_ctrl,
7069 (void *)&cmd_lfc_set_send_xon_str,
7070 (void *)&cmd_lfc_set_send_xon,
7071 (void *)&cmd_lfc_set_portid,
7076 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7077 .f = cmd_link_flow_ctrl_set_parsed,
7078 .data = (void *)&cmd_link_flow_control_set_macfwd,
7079 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7080 "Change mac ctrl fwd flow control parameter",
7082 (void *)&cmd_lfc_set_set,
7083 (void *)&cmd_lfc_set_flow_ctrl,
7084 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7085 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7086 (void *)&cmd_lfc_set_portid,
7091 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7092 .f = cmd_link_flow_ctrl_set_parsed,
7093 .data = (void *)&cmd_link_flow_control_set_autoneg,
7094 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7095 "Change autoneg flow control parameter",
7097 (void *)&cmd_lfc_set_set,
7098 (void *)&cmd_lfc_set_flow_ctrl,
7099 (void *)&cmd_lfc_set_autoneg_str,
7100 (void *)&cmd_lfc_set_autoneg,
7101 (void *)&cmd_lfc_set_portid,
7107 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7108 __rte_unused struct cmdline *cl,
7111 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7112 cmdline_parse_inst_t *cmd = data;
7113 struct rte_eth_fc_conf fc_conf;
7119 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7120 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7121 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7122 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7124 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7125 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7128 /* Partial command line, retrieve current configuration */
7130 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7132 printf("cannot get current flow ctrl parameters, return"
7133 "code = %d\n", ret);
7137 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7138 (fc_conf.mode == RTE_FC_FULL))
7140 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7141 (fc_conf.mode == RTE_FC_FULL))
7145 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7146 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7148 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7149 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7151 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7153 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7154 fc_conf.high_water = res->high_water;
7156 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7157 fc_conf.low_water = res->low_water;
7159 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7160 fc_conf.pause_time = res->pause_time;
7162 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7163 fc_conf.send_xon = res->send_xon;
7165 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7166 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7167 fc_conf.mac_ctrl_frame_fwd = 1;
7169 fc_conf.mac_ctrl_frame_fwd = 0;
7172 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7173 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7175 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7177 printf("bad flow contrl parameter, return code = %d \n", ret);
7180 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7181 struct cmd_priority_flow_ctrl_set_result {
7182 cmdline_fixed_string_t set;
7183 cmdline_fixed_string_t pfc_ctrl;
7184 cmdline_fixed_string_t rx;
7185 cmdline_fixed_string_t rx_pfc_mode;
7186 cmdline_fixed_string_t tx;
7187 cmdline_fixed_string_t tx_pfc_mode;
7188 uint32_t high_water;
7190 uint16_t pause_time;
7196 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7197 __rte_unused struct cmdline *cl,
7198 __rte_unused void *data)
7200 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7201 struct rte_eth_pfc_conf pfc_conf;
7202 int rx_fc_enable, tx_fc_enable;
7206 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7207 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7208 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7209 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7211 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7212 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7215 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7216 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7217 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7218 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7219 pfc_conf.fc.high_water = res->high_water;
7220 pfc_conf.fc.low_water = res->low_water;
7221 pfc_conf.fc.pause_time = res->pause_time;
7222 pfc_conf.priority = res->priority;
7224 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7226 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7229 cmdline_parse_token_string_t cmd_pfc_set_set =
7230 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7232 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7233 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7234 pfc_ctrl, "pfc_ctrl");
7235 cmdline_parse_token_string_t cmd_pfc_set_rx =
7236 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7238 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7239 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7240 rx_pfc_mode, "on#off");
7241 cmdline_parse_token_string_t cmd_pfc_set_tx =
7242 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7244 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7245 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7246 tx_pfc_mode, "on#off");
7247 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7248 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7249 high_water, UINT32);
7250 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7251 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7253 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7254 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7255 pause_time, UINT16);
7256 cmdline_parse_token_num_t cmd_pfc_set_priority =
7257 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7259 cmdline_parse_token_num_t cmd_pfc_set_portid =
7260 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7263 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7264 .f = cmd_priority_flow_ctrl_set_parsed,
7266 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7267 "<pause_time> <priority> <port_id>: "
7268 "Configure the Ethernet priority flow control",
7270 (void *)&cmd_pfc_set_set,
7271 (void *)&cmd_pfc_set_flow_ctrl,
7272 (void *)&cmd_pfc_set_rx,
7273 (void *)&cmd_pfc_set_rx_mode,
7274 (void *)&cmd_pfc_set_tx,
7275 (void *)&cmd_pfc_set_tx_mode,
7276 (void *)&cmd_pfc_set_high_water,
7277 (void *)&cmd_pfc_set_low_water,
7278 (void *)&cmd_pfc_set_pause_time,
7279 (void *)&cmd_pfc_set_priority,
7280 (void *)&cmd_pfc_set_portid,
7285 /* *** RESET CONFIGURATION *** */
7286 struct cmd_reset_result {
7287 cmdline_fixed_string_t reset;
7288 cmdline_fixed_string_t def;
7291 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7293 __rte_unused void *data)
7295 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7296 set_def_fwd_config();
7299 cmdline_parse_token_string_t cmd_reset_set =
7300 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7301 cmdline_parse_token_string_t cmd_reset_def =
7302 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7305 cmdline_parse_inst_t cmd_reset = {
7306 .f = cmd_reset_parsed,
7308 .help_str = "set default: Reset default forwarding configuration",
7310 (void *)&cmd_reset_set,
7311 (void *)&cmd_reset_def,
7316 /* *** START FORWARDING *** */
7317 struct cmd_start_result {
7318 cmdline_fixed_string_t start;
7321 cmdline_parse_token_string_t cmd_start_start =
7322 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7324 static void cmd_start_parsed(__rte_unused void *parsed_result,
7325 __rte_unused struct cmdline *cl,
7326 __rte_unused void *data)
7328 start_packet_forwarding(0);
7331 cmdline_parse_inst_t cmd_start = {
7332 .f = cmd_start_parsed,
7334 .help_str = "start: Start packet forwarding",
7336 (void *)&cmd_start_start,
7341 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7342 struct cmd_start_tx_first_result {
7343 cmdline_fixed_string_t start;
7344 cmdline_fixed_string_t tx_first;
7348 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7349 __rte_unused struct cmdline *cl,
7350 __rte_unused void *data)
7352 start_packet_forwarding(1);
7355 cmdline_parse_token_string_t cmd_start_tx_first_start =
7356 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7358 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7359 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7360 tx_first, "tx_first");
7362 cmdline_parse_inst_t cmd_start_tx_first = {
7363 .f = cmd_start_tx_first_parsed,
7365 .help_str = "start tx_first: Start packet forwarding, "
7366 "after sending 1 burst of packets",
7368 (void *)&cmd_start_tx_first_start,
7369 (void *)&cmd_start_tx_first_tx_first,
7374 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7375 struct cmd_start_tx_first_n_result {
7376 cmdline_fixed_string_t start;
7377 cmdline_fixed_string_t tx_first;
7382 cmd_start_tx_first_n_parsed(void *parsed_result,
7383 __rte_unused struct cmdline *cl,
7384 __rte_unused void *data)
7386 struct cmd_start_tx_first_n_result *res = parsed_result;
7388 start_packet_forwarding(res->tx_num);
7391 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7392 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7394 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7395 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7396 tx_first, "tx_first");
7397 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7398 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7401 cmdline_parse_inst_t cmd_start_tx_first_n = {
7402 .f = cmd_start_tx_first_n_parsed,
7404 .help_str = "start tx_first <num>: "
7405 "packet forwarding, after sending <num> bursts of packets",
7407 (void *)&cmd_start_tx_first_n_start,
7408 (void *)&cmd_start_tx_first_n_tx_first,
7409 (void *)&cmd_start_tx_first_n_tx_num,
7414 /* *** SET LINK UP *** */
7415 struct cmd_set_link_up_result {
7416 cmdline_fixed_string_t set;
7417 cmdline_fixed_string_t link_up;
7418 cmdline_fixed_string_t port;
7422 cmdline_parse_token_string_t cmd_set_link_up_set =
7423 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7424 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7425 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7427 cmdline_parse_token_string_t cmd_set_link_up_port =
7428 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7429 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7430 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7432 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7433 __rte_unused struct cmdline *cl,
7434 __rte_unused void *data)
7436 struct cmd_set_link_up_result *res = parsed_result;
7437 dev_set_link_up(res->port_id);
7440 cmdline_parse_inst_t cmd_set_link_up = {
7441 .f = cmd_set_link_up_parsed,
7443 .help_str = "set link-up port <port id>",
7445 (void *)&cmd_set_link_up_set,
7446 (void *)&cmd_set_link_up_link_up,
7447 (void *)&cmd_set_link_up_port,
7448 (void *)&cmd_set_link_up_port_id,
7453 /* *** SET LINK DOWN *** */
7454 struct cmd_set_link_down_result {
7455 cmdline_fixed_string_t set;
7456 cmdline_fixed_string_t link_down;
7457 cmdline_fixed_string_t port;
7461 cmdline_parse_token_string_t cmd_set_link_down_set =
7462 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7463 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7464 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7466 cmdline_parse_token_string_t cmd_set_link_down_port =
7467 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7468 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7469 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7471 static void cmd_set_link_down_parsed(
7472 __rte_unused void *parsed_result,
7473 __rte_unused struct cmdline *cl,
7474 __rte_unused void *data)
7476 struct cmd_set_link_down_result *res = parsed_result;
7477 dev_set_link_down(res->port_id);
7480 cmdline_parse_inst_t cmd_set_link_down = {
7481 .f = cmd_set_link_down_parsed,
7483 .help_str = "set link-down port <port id>",
7485 (void *)&cmd_set_link_down_set,
7486 (void *)&cmd_set_link_down_link_down,
7487 (void *)&cmd_set_link_down_port,
7488 (void *)&cmd_set_link_down_port_id,
7493 /* *** SHOW CFG *** */
7494 struct cmd_showcfg_result {
7495 cmdline_fixed_string_t show;
7496 cmdline_fixed_string_t cfg;
7497 cmdline_fixed_string_t what;
7500 static void cmd_showcfg_parsed(void *parsed_result,
7501 __rte_unused struct cmdline *cl,
7502 __rte_unused void *data)
7504 struct cmd_showcfg_result *res = parsed_result;
7505 if (!strcmp(res->what, "rxtx"))
7506 rxtx_config_display();
7507 else if (!strcmp(res->what, "cores"))
7508 fwd_lcores_config_display();
7509 else if (!strcmp(res->what, "fwd"))
7510 pkt_fwd_config_display(&cur_fwd_config);
7511 else if (!strcmp(res->what, "txpkts"))
7512 show_tx_pkt_segments();
7513 else if (!strcmp(res->what, "txtimes"))
7514 show_tx_pkt_times();
7517 cmdline_parse_token_string_t cmd_showcfg_show =
7518 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7519 cmdline_parse_token_string_t cmd_showcfg_port =
7520 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7521 cmdline_parse_token_string_t cmd_showcfg_what =
7522 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7523 "rxtx#cores#fwd#txpkts#txtimes");
7525 cmdline_parse_inst_t cmd_showcfg = {
7526 .f = cmd_showcfg_parsed,
7528 .help_str = "show config rxtx|cores|fwd|txpkts|txtimes",
7530 (void *)&cmd_showcfg_show,
7531 (void *)&cmd_showcfg_port,
7532 (void *)&cmd_showcfg_what,
7537 /* *** SHOW ALL PORT INFO *** */
7538 struct cmd_showportall_result {
7539 cmdline_fixed_string_t show;
7540 cmdline_fixed_string_t port;
7541 cmdline_fixed_string_t what;
7542 cmdline_fixed_string_t all;
7545 static void cmd_showportall_parsed(void *parsed_result,
7546 __rte_unused struct cmdline *cl,
7547 __rte_unused void *data)
7551 struct cmd_showportall_result *res = parsed_result;
7552 if (!strcmp(res->show, "clear")) {
7553 if (!strcmp(res->what, "stats"))
7554 RTE_ETH_FOREACH_DEV(i)
7556 else if (!strcmp(res->what, "xstats"))
7557 RTE_ETH_FOREACH_DEV(i)
7558 nic_xstats_clear(i);
7559 } else if (!strcmp(res->what, "info"))
7560 RTE_ETH_FOREACH_DEV(i)
7561 port_infos_display(i);
7562 else if (!strcmp(res->what, "summary")) {
7563 port_summary_header_display();
7564 RTE_ETH_FOREACH_DEV(i)
7565 port_summary_display(i);
7567 else if (!strcmp(res->what, "stats"))
7568 RTE_ETH_FOREACH_DEV(i)
7569 nic_stats_display(i);
7570 else if (!strcmp(res->what, "xstats"))
7571 RTE_ETH_FOREACH_DEV(i)
7572 nic_xstats_display(i);
7573 else if (!strcmp(res->what, "fdir"))
7574 RTE_ETH_FOREACH_DEV(i)
7576 else if (!strcmp(res->what, "stat_qmap"))
7577 RTE_ETH_FOREACH_DEV(i)
7578 nic_stats_mapping_display(i);
7579 else if (!strcmp(res->what, "dcb_tc"))
7580 RTE_ETH_FOREACH_DEV(i)
7581 port_dcb_info_display(i);
7582 else if (!strcmp(res->what, "cap"))
7583 RTE_ETH_FOREACH_DEV(i)
7584 port_offload_cap_display(i);
7587 cmdline_parse_token_string_t cmd_showportall_show =
7588 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7590 cmdline_parse_token_string_t cmd_showportall_port =
7591 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7592 cmdline_parse_token_string_t cmd_showportall_what =
7593 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7594 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7595 cmdline_parse_token_string_t cmd_showportall_all =
7596 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7597 cmdline_parse_inst_t cmd_showportall = {
7598 .f = cmd_showportall_parsed,
7600 .help_str = "show|clear port "
7601 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7603 (void *)&cmd_showportall_show,
7604 (void *)&cmd_showportall_port,
7605 (void *)&cmd_showportall_what,
7606 (void *)&cmd_showportall_all,
7611 /* *** SHOW PORT INFO *** */
7612 struct cmd_showport_result {
7613 cmdline_fixed_string_t show;
7614 cmdline_fixed_string_t port;
7615 cmdline_fixed_string_t what;
7619 static void cmd_showport_parsed(void *parsed_result,
7620 __rte_unused struct cmdline *cl,
7621 __rte_unused void *data)
7623 struct cmd_showport_result *res = parsed_result;
7624 if (!strcmp(res->show, "clear")) {
7625 if (!strcmp(res->what, "stats"))
7626 nic_stats_clear(res->portnum);
7627 else if (!strcmp(res->what, "xstats"))
7628 nic_xstats_clear(res->portnum);
7629 } else if (!strcmp(res->what, "info"))
7630 port_infos_display(res->portnum);
7631 else if (!strcmp(res->what, "summary")) {
7632 port_summary_header_display();
7633 port_summary_display(res->portnum);
7635 else if (!strcmp(res->what, "stats"))
7636 nic_stats_display(res->portnum);
7637 else if (!strcmp(res->what, "xstats"))
7638 nic_xstats_display(res->portnum);
7639 else if (!strcmp(res->what, "fdir"))
7640 fdir_get_infos(res->portnum);
7641 else if (!strcmp(res->what, "stat_qmap"))
7642 nic_stats_mapping_display(res->portnum);
7643 else if (!strcmp(res->what, "dcb_tc"))
7644 port_dcb_info_display(res->portnum);
7645 else if (!strcmp(res->what, "cap"))
7646 port_offload_cap_display(res->portnum);
7649 cmdline_parse_token_string_t cmd_showport_show =
7650 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7652 cmdline_parse_token_string_t cmd_showport_port =
7653 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7654 cmdline_parse_token_string_t cmd_showport_what =
7655 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7656 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7657 cmdline_parse_token_num_t cmd_showport_portnum =
7658 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7660 cmdline_parse_inst_t cmd_showport = {
7661 .f = cmd_showport_parsed,
7663 .help_str = "show|clear port "
7664 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7667 (void *)&cmd_showport_show,
7668 (void *)&cmd_showport_port,
7669 (void *)&cmd_showport_what,
7670 (void *)&cmd_showport_portnum,
7675 /* *** SHOW DEVICE INFO *** */
7676 struct cmd_showdevice_result {
7677 cmdline_fixed_string_t show;
7678 cmdline_fixed_string_t device;
7679 cmdline_fixed_string_t what;
7680 cmdline_fixed_string_t identifier;
7683 static void cmd_showdevice_parsed(void *parsed_result,
7684 __rte_unused struct cmdline *cl,
7685 __rte_unused void *data)
7687 struct cmd_showdevice_result *res = parsed_result;
7688 if (!strcmp(res->what, "info")) {
7689 if (!strcmp(res->identifier, "all"))
7690 device_infos_display(NULL);
7692 device_infos_display(res->identifier);
7696 cmdline_parse_token_string_t cmd_showdevice_show =
7697 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7699 cmdline_parse_token_string_t cmd_showdevice_device =
7700 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7701 cmdline_parse_token_string_t cmd_showdevice_what =
7702 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7704 cmdline_parse_token_string_t cmd_showdevice_identifier =
7705 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7708 cmdline_parse_inst_t cmd_showdevice = {
7709 .f = cmd_showdevice_parsed,
7711 .help_str = "show device info <identifier>|all",
7713 (void *)&cmd_showdevice_show,
7714 (void *)&cmd_showdevice_device,
7715 (void *)&cmd_showdevice_what,
7716 (void *)&cmd_showdevice_identifier,
7721 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7722 struct cmd_showeeprom_result {
7723 cmdline_fixed_string_t show;
7724 cmdline_fixed_string_t port;
7726 cmdline_fixed_string_t type;
7729 static void cmd_showeeprom_parsed(void *parsed_result,
7730 __rte_unused struct cmdline *cl,
7731 __rte_unused void *data)
7733 struct cmd_showeeprom_result *res = parsed_result;
7735 if (!strcmp(res->type, "eeprom"))
7736 port_eeprom_display(res->portnum);
7737 else if (!strcmp(res->type, "module_eeprom"))
7738 port_module_eeprom_display(res->portnum);
7740 printf("Unknown argument\n");
7743 cmdline_parse_token_string_t cmd_showeeprom_show =
7744 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7745 cmdline_parse_token_string_t cmd_showeeprom_port =
7746 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7747 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7748 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum, UINT16);
7749 cmdline_parse_token_string_t cmd_showeeprom_type =
7750 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7752 cmdline_parse_inst_t cmd_showeeprom = {
7753 .f = cmd_showeeprom_parsed,
7755 .help_str = "show port <port_id> module_eeprom|eeprom",
7757 (void *)&cmd_showeeprom_show,
7758 (void *)&cmd_showeeprom_port,
7759 (void *)&cmd_showeeprom_portnum,
7760 (void *)&cmd_showeeprom_type,
7765 /* *** SHOW QUEUE INFO *** */
7766 struct cmd_showqueue_result {
7767 cmdline_fixed_string_t show;
7768 cmdline_fixed_string_t type;
7769 cmdline_fixed_string_t what;
7775 cmd_showqueue_parsed(void *parsed_result,
7776 __rte_unused struct cmdline *cl,
7777 __rte_unused void *data)
7779 struct cmd_showqueue_result *res = parsed_result;
7781 if (!strcmp(res->type, "rxq"))
7782 rx_queue_infos_display(res->portnum, res->queuenum);
7783 else if (!strcmp(res->type, "txq"))
7784 tx_queue_infos_display(res->portnum, res->queuenum);
7787 cmdline_parse_token_string_t cmd_showqueue_show =
7788 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7789 cmdline_parse_token_string_t cmd_showqueue_type =
7790 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7791 cmdline_parse_token_string_t cmd_showqueue_what =
7792 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7793 cmdline_parse_token_num_t cmd_showqueue_portnum =
7794 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7795 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7796 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7798 cmdline_parse_inst_t cmd_showqueue = {
7799 .f = cmd_showqueue_parsed,
7801 .help_str = "show rxq|txq info <port_id> <queue_id>",
7803 (void *)&cmd_showqueue_show,
7804 (void *)&cmd_showqueue_type,
7805 (void *)&cmd_showqueue_what,
7806 (void *)&cmd_showqueue_portnum,
7807 (void *)&cmd_showqueue_queuenum,
7812 /* show/clear fwd engine statistics */
7814 cmdline_fixed_string_t action;
7815 cmdline_fixed_string_t fwd;
7816 cmdline_fixed_string_t stats;
7817 cmdline_fixed_string_t all;
7820 cmdline_parse_token_string_t cmd_fwd_action =
7821 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7822 cmdline_parse_token_string_t cmd_fwd_fwd =
7823 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7824 cmdline_parse_token_string_t cmd_fwd_stats =
7825 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7826 cmdline_parse_token_string_t cmd_fwd_all =
7827 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7830 cmd_showfwdall_parsed(void *parsed_result,
7831 __rte_unused struct cmdline *cl,
7832 __rte_unused void *data)
7834 struct fwd_result *res = parsed_result;
7836 if (!strcmp(res->action, "show"))
7837 fwd_stats_display();
7842 static cmdline_parse_inst_t cmd_showfwdall = {
7843 .f = cmd_showfwdall_parsed,
7845 .help_str = "show|clear fwd stats all",
7847 (void *)&cmd_fwd_action,
7848 (void *)&cmd_fwd_fwd,
7849 (void *)&cmd_fwd_stats,
7850 (void *)&cmd_fwd_all,
7855 /* *** READ PORT REGISTER *** */
7856 struct cmd_read_reg_result {
7857 cmdline_fixed_string_t read;
7858 cmdline_fixed_string_t reg;
7864 cmd_read_reg_parsed(void *parsed_result,
7865 __rte_unused struct cmdline *cl,
7866 __rte_unused void *data)
7868 struct cmd_read_reg_result *res = parsed_result;
7869 port_reg_display(res->port_id, res->reg_off);
7872 cmdline_parse_token_string_t cmd_read_reg_read =
7873 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7874 cmdline_parse_token_string_t cmd_read_reg_reg =
7875 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7876 cmdline_parse_token_num_t cmd_read_reg_port_id =
7877 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7878 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7879 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7881 cmdline_parse_inst_t cmd_read_reg = {
7882 .f = cmd_read_reg_parsed,
7884 .help_str = "read reg <port_id> <reg_off>",
7886 (void *)&cmd_read_reg_read,
7887 (void *)&cmd_read_reg_reg,
7888 (void *)&cmd_read_reg_port_id,
7889 (void *)&cmd_read_reg_reg_off,
7894 /* *** READ PORT REGISTER BIT FIELD *** */
7895 struct cmd_read_reg_bit_field_result {
7896 cmdline_fixed_string_t read;
7897 cmdline_fixed_string_t regfield;
7905 cmd_read_reg_bit_field_parsed(void *parsed_result,
7906 __rte_unused struct cmdline *cl,
7907 __rte_unused void *data)
7909 struct cmd_read_reg_bit_field_result *res = parsed_result;
7910 port_reg_bit_field_display(res->port_id, res->reg_off,
7911 res->bit1_pos, res->bit2_pos);
7914 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7915 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7917 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7918 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7919 regfield, "regfield");
7920 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7921 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7923 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7924 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7926 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7927 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7929 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7930 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7933 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7934 .f = cmd_read_reg_bit_field_parsed,
7936 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7937 "Read register bit field between bit_x and bit_y included",
7939 (void *)&cmd_read_reg_bit_field_read,
7940 (void *)&cmd_read_reg_bit_field_regfield,
7941 (void *)&cmd_read_reg_bit_field_port_id,
7942 (void *)&cmd_read_reg_bit_field_reg_off,
7943 (void *)&cmd_read_reg_bit_field_bit1_pos,
7944 (void *)&cmd_read_reg_bit_field_bit2_pos,
7949 /* *** READ PORT REGISTER BIT *** */
7950 struct cmd_read_reg_bit_result {
7951 cmdline_fixed_string_t read;
7952 cmdline_fixed_string_t regbit;
7959 cmd_read_reg_bit_parsed(void *parsed_result,
7960 __rte_unused struct cmdline *cl,
7961 __rte_unused void *data)
7963 struct cmd_read_reg_bit_result *res = parsed_result;
7964 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7967 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7968 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7969 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7970 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7972 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7973 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7974 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7975 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7976 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7977 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7979 cmdline_parse_inst_t cmd_read_reg_bit = {
7980 .f = cmd_read_reg_bit_parsed,
7982 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7984 (void *)&cmd_read_reg_bit_read,
7985 (void *)&cmd_read_reg_bit_regbit,
7986 (void *)&cmd_read_reg_bit_port_id,
7987 (void *)&cmd_read_reg_bit_reg_off,
7988 (void *)&cmd_read_reg_bit_bit_pos,
7993 /* *** WRITE PORT REGISTER *** */
7994 struct cmd_write_reg_result {
7995 cmdline_fixed_string_t write;
7996 cmdline_fixed_string_t reg;
8003 cmd_write_reg_parsed(void *parsed_result,
8004 __rte_unused struct cmdline *cl,
8005 __rte_unused void *data)
8007 struct cmd_write_reg_result *res = parsed_result;
8008 port_reg_set(res->port_id, res->reg_off, res->value);
8011 cmdline_parse_token_string_t cmd_write_reg_write =
8012 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8013 cmdline_parse_token_string_t cmd_write_reg_reg =
8014 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8015 cmdline_parse_token_num_t cmd_write_reg_port_id =
8016 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
8017 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8018 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
8019 cmdline_parse_token_num_t cmd_write_reg_value =
8020 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
8022 cmdline_parse_inst_t cmd_write_reg = {
8023 .f = cmd_write_reg_parsed,
8025 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8027 (void *)&cmd_write_reg_write,
8028 (void *)&cmd_write_reg_reg,
8029 (void *)&cmd_write_reg_port_id,
8030 (void *)&cmd_write_reg_reg_off,
8031 (void *)&cmd_write_reg_value,
8036 /* *** WRITE PORT REGISTER BIT FIELD *** */
8037 struct cmd_write_reg_bit_field_result {
8038 cmdline_fixed_string_t write;
8039 cmdline_fixed_string_t regfield;
8048 cmd_write_reg_bit_field_parsed(void *parsed_result,
8049 __rte_unused struct cmdline *cl,
8050 __rte_unused void *data)
8052 struct cmd_write_reg_bit_field_result *res = parsed_result;
8053 port_reg_bit_field_set(res->port_id, res->reg_off,
8054 res->bit1_pos, res->bit2_pos, res->value);
8057 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8058 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8060 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8061 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8062 regfield, "regfield");
8063 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8064 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8066 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8067 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8069 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8070 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8072 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8073 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8075 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8076 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8079 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8080 .f = cmd_write_reg_bit_field_parsed,
8082 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8084 "Set register bit field between bit_x and bit_y included",
8086 (void *)&cmd_write_reg_bit_field_write,
8087 (void *)&cmd_write_reg_bit_field_regfield,
8088 (void *)&cmd_write_reg_bit_field_port_id,
8089 (void *)&cmd_write_reg_bit_field_reg_off,
8090 (void *)&cmd_write_reg_bit_field_bit1_pos,
8091 (void *)&cmd_write_reg_bit_field_bit2_pos,
8092 (void *)&cmd_write_reg_bit_field_value,
8097 /* *** WRITE PORT REGISTER BIT *** */
8098 struct cmd_write_reg_bit_result {
8099 cmdline_fixed_string_t write;
8100 cmdline_fixed_string_t regbit;
8108 cmd_write_reg_bit_parsed(void *parsed_result,
8109 __rte_unused struct cmdline *cl,
8110 __rte_unused void *data)
8112 struct cmd_write_reg_bit_result *res = parsed_result;
8113 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8116 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8117 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8119 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8120 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8122 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8123 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
8124 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8125 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
8126 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8127 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
8128 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8129 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
8131 cmdline_parse_inst_t cmd_write_reg_bit = {
8132 .f = cmd_write_reg_bit_parsed,
8134 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8137 (void *)&cmd_write_reg_bit_write,
8138 (void *)&cmd_write_reg_bit_regbit,
8139 (void *)&cmd_write_reg_bit_port_id,
8140 (void *)&cmd_write_reg_bit_reg_off,
8141 (void *)&cmd_write_reg_bit_bit_pos,
8142 (void *)&cmd_write_reg_bit_value,
8147 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8148 struct cmd_read_rxd_txd_result {
8149 cmdline_fixed_string_t read;
8150 cmdline_fixed_string_t rxd_txd;
8157 cmd_read_rxd_txd_parsed(void *parsed_result,
8158 __rte_unused struct cmdline *cl,
8159 __rte_unused void *data)
8161 struct cmd_read_rxd_txd_result *res = parsed_result;
8163 if (!strcmp(res->rxd_txd, "rxd"))
8164 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8165 else if (!strcmp(res->rxd_txd, "txd"))
8166 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8169 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8170 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8171 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8172 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8174 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8175 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8176 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8177 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8178 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8179 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8181 cmdline_parse_inst_t cmd_read_rxd_txd = {
8182 .f = cmd_read_rxd_txd_parsed,
8184 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8186 (void *)&cmd_read_rxd_txd_read,
8187 (void *)&cmd_read_rxd_txd_rxd_txd,
8188 (void *)&cmd_read_rxd_txd_port_id,
8189 (void *)&cmd_read_rxd_txd_queue_id,
8190 (void *)&cmd_read_rxd_txd_desc_id,
8196 struct cmd_quit_result {
8197 cmdline_fixed_string_t quit;
8200 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8202 __rte_unused void *data)
8207 cmdline_parse_token_string_t cmd_quit_quit =
8208 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8210 cmdline_parse_inst_t cmd_quit = {
8211 .f = cmd_quit_parsed,
8213 .help_str = "quit: Exit application",
8215 (void *)&cmd_quit_quit,
8220 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8221 struct cmd_mac_addr_result {
8222 cmdline_fixed_string_t mac_addr_cmd;
8223 cmdline_fixed_string_t what;
8225 struct rte_ether_addr address;
8228 static void cmd_mac_addr_parsed(void *parsed_result,
8229 __rte_unused struct cmdline *cl,
8230 __rte_unused void *data)
8232 struct cmd_mac_addr_result *res = parsed_result;
8235 if (strcmp(res->what, "add") == 0)
8236 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8237 else if (strcmp(res->what, "set") == 0)
8238 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8241 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8243 /* check the return value and print it if is < 0 */
8245 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8249 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8250 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8252 cmdline_parse_token_string_t cmd_mac_addr_what =
8253 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8255 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8256 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8258 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8259 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8261 cmdline_parse_inst_t cmd_mac_addr = {
8262 .f = cmd_mac_addr_parsed,
8264 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8265 "Add/Remove/Set MAC address on port_id",
8267 (void *)&cmd_mac_addr_cmd,
8268 (void *)&cmd_mac_addr_what,
8269 (void *)&cmd_mac_addr_portnum,
8270 (void *)&cmd_mac_addr_addr,
8275 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8276 struct cmd_eth_peer_result {
8277 cmdline_fixed_string_t set;
8278 cmdline_fixed_string_t eth_peer;
8280 cmdline_fixed_string_t peer_addr;
8283 static void cmd_set_eth_peer_parsed(void *parsed_result,
8284 __rte_unused struct cmdline *cl,
8285 __rte_unused void *data)
8287 struct cmd_eth_peer_result *res = parsed_result;
8289 if (test_done == 0) {
8290 printf("Please stop forwarding first\n");
8293 if (!strcmp(res->eth_peer, "eth-peer")) {
8294 set_fwd_eth_peer(res->port_id, res->peer_addr);
8298 cmdline_parse_token_string_t cmd_eth_peer_set =
8299 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8300 cmdline_parse_token_string_t cmd_eth_peer =
8301 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8302 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8303 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8304 cmdline_parse_token_string_t cmd_eth_peer_addr =
8305 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8307 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8308 .f = cmd_set_eth_peer_parsed,
8310 .help_str = "set eth-peer <port_id> <peer_mac>",
8312 (void *)&cmd_eth_peer_set,
8313 (void *)&cmd_eth_peer,
8314 (void *)&cmd_eth_peer_port_id,
8315 (void *)&cmd_eth_peer_addr,
8320 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8321 struct cmd_set_qmap_result {
8322 cmdline_fixed_string_t set;
8323 cmdline_fixed_string_t qmap;
8324 cmdline_fixed_string_t what;
8331 cmd_set_qmap_parsed(void *parsed_result,
8332 __rte_unused struct cmdline *cl,
8333 __rte_unused void *data)
8335 struct cmd_set_qmap_result *res = parsed_result;
8336 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8338 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8341 cmdline_parse_token_string_t cmd_setqmap_set =
8342 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8344 cmdline_parse_token_string_t cmd_setqmap_qmap =
8345 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8347 cmdline_parse_token_string_t cmd_setqmap_what =
8348 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8350 cmdline_parse_token_num_t cmd_setqmap_portid =
8351 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8353 cmdline_parse_token_num_t cmd_setqmap_queueid =
8354 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8356 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8357 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8360 cmdline_parse_inst_t cmd_set_qmap = {
8361 .f = cmd_set_qmap_parsed,
8363 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8364 "Set statistics mapping value on tx|rx queue_id of port_id",
8366 (void *)&cmd_setqmap_set,
8367 (void *)&cmd_setqmap_qmap,
8368 (void *)&cmd_setqmap_what,
8369 (void *)&cmd_setqmap_portid,
8370 (void *)&cmd_setqmap_queueid,
8371 (void *)&cmd_setqmap_mapvalue,
8376 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8377 struct cmd_set_xstats_hide_zero_result {
8378 cmdline_fixed_string_t keyword;
8379 cmdline_fixed_string_t name;
8380 cmdline_fixed_string_t on_off;
8384 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8385 __rte_unused struct cmdline *cl,
8386 __rte_unused void *data)
8388 struct cmd_set_xstats_hide_zero_result *res;
8389 uint16_t on_off = 0;
8391 res = parsed_result;
8392 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8393 set_xstats_hide_zero(on_off);
8396 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8397 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8399 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8400 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8401 name, "xstats-hide-zero");
8402 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8403 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8406 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8407 .f = cmd_set_xstats_hide_zero_parsed,
8409 .help_str = "set xstats-hide-zero on|off",
8411 (void *)&cmd_set_xstats_hide_zero_keyword,
8412 (void *)&cmd_set_xstats_hide_zero_name,
8413 (void *)&cmd_set_xstats_hide_zero_on_off,
8418 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8419 struct cmd_set_record_core_cycles_result {
8420 cmdline_fixed_string_t keyword;
8421 cmdline_fixed_string_t name;
8422 cmdline_fixed_string_t on_off;
8426 cmd_set_record_core_cycles_parsed(void *parsed_result,
8427 __rte_unused struct cmdline *cl,
8428 __rte_unused void *data)
8430 struct cmd_set_record_core_cycles_result *res;
8431 uint16_t on_off = 0;
8433 res = parsed_result;
8434 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8435 set_record_core_cycles(on_off);
8438 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8439 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8441 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8442 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8443 name, "record-core-cycles");
8444 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8445 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8448 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8449 .f = cmd_set_record_core_cycles_parsed,
8451 .help_str = "set record-core-cycles on|off",
8453 (void *)&cmd_set_record_core_cycles_keyword,
8454 (void *)&cmd_set_record_core_cycles_name,
8455 (void *)&cmd_set_record_core_cycles_on_off,
8460 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8461 struct cmd_set_record_burst_stats_result {
8462 cmdline_fixed_string_t keyword;
8463 cmdline_fixed_string_t name;
8464 cmdline_fixed_string_t on_off;
8468 cmd_set_record_burst_stats_parsed(void *parsed_result,
8469 __rte_unused struct cmdline *cl,
8470 __rte_unused void *data)
8472 struct cmd_set_record_burst_stats_result *res;
8473 uint16_t on_off = 0;
8475 res = parsed_result;
8476 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8477 set_record_burst_stats(on_off);
8480 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8481 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8483 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8484 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8485 name, "record-burst-stats");
8486 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8487 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8490 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8491 .f = cmd_set_record_burst_stats_parsed,
8493 .help_str = "set record-burst-stats on|off",
8495 (void *)&cmd_set_record_burst_stats_keyword,
8496 (void *)&cmd_set_record_burst_stats_name,
8497 (void *)&cmd_set_record_burst_stats_on_off,
8502 /* *** CONFIGURE UNICAST HASH TABLE *** */
8503 struct cmd_set_uc_hash_table {
8504 cmdline_fixed_string_t set;
8505 cmdline_fixed_string_t port;
8507 cmdline_fixed_string_t what;
8508 struct rte_ether_addr address;
8509 cmdline_fixed_string_t mode;
8513 cmd_set_uc_hash_parsed(void *parsed_result,
8514 __rte_unused struct cmdline *cl,
8515 __rte_unused void *data)
8518 struct cmd_set_uc_hash_table *res = parsed_result;
8520 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8522 if (strcmp(res->what, "uta") == 0)
8523 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8524 &res->address,(uint8_t)is_on);
8526 printf("bad unicast hash table parameter, return code = %d \n", ret);
8530 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8531 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8533 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8534 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8536 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8537 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8539 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8540 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8542 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8543 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8545 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8546 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8549 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8550 .f = cmd_set_uc_hash_parsed,
8552 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8554 (void *)&cmd_set_uc_hash_set,
8555 (void *)&cmd_set_uc_hash_port,
8556 (void *)&cmd_set_uc_hash_portid,
8557 (void *)&cmd_set_uc_hash_what,
8558 (void *)&cmd_set_uc_hash_mac,
8559 (void *)&cmd_set_uc_hash_mode,
8564 struct cmd_set_uc_all_hash_table {
8565 cmdline_fixed_string_t set;
8566 cmdline_fixed_string_t port;
8568 cmdline_fixed_string_t what;
8569 cmdline_fixed_string_t value;
8570 cmdline_fixed_string_t mode;
8574 cmd_set_uc_all_hash_parsed(void *parsed_result,
8575 __rte_unused struct cmdline *cl,
8576 __rte_unused void *data)
8579 struct cmd_set_uc_all_hash_table *res = parsed_result;
8581 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8583 if ((strcmp(res->what, "uta") == 0) &&
8584 (strcmp(res->value, "all") == 0))
8585 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8587 printf("bad unicast hash table parameter,"
8588 "return code = %d \n", ret);
8591 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8592 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8594 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8595 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8597 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8598 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8600 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8601 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8603 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8604 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8606 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8607 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8610 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8611 .f = cmd_set_uc_all_hash_parsed,
8613 .help_str = "set port <port_id> uta all on|off",
8615 (void *)&cmd_set_uc_all_hash_set,
8616 (void *)&cmd_set_uc_all_hash_port,
8617 (void *)&cmd_set_uc_all_hash_portid,
8618 (void *)&cmd_set_uc_all_hash_what,
8619 (void *)&cmd_set_uc_all_hash_value,
8620 (void *)&cmd_set_uc_all_hash_mode,
8625 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8626 struct cmd_set_vf_macvlan_filter {
8627 cmdline_fixed_string_t set;
8628 cmdline_fixed_string_t port;
8630 cmdline_fixed_string_t vf;
8632 struct rte_ether_addr address;
8633 cmdline_fixed_string_t filter_type;
8634 cmdline_fixed_string_t mode;
8638 cmd_set_vf_macvlan_parsed(void *parsed_result,
8639 __rte_unused struct cmdline *cl,
8640 __rte_unused void *data)
8643 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8644 struct rte_eth_mac_filter filter;
8646 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8648 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8650 /* set VF MAC filter */
8654 filter.dst_id = res->vf_id;
8656 if (!strcmp(res->filter_type, "exact-mac"))
8657 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8658 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8659 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8660 else if (!strcmp(res->filter_type, "hashmac"))
8661 filter.filter_type = RTE_MAC_HASH_MATCH;
8662 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8663 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8665 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8668 ret = rte_eth_dev_filter_ctrl(res->port_id,
8669 RTE_ETH_FILTER_MACVLAN,
8673 ret = rte_eth_dev_filter_ctrl(res->port_id,
8674 RTE_ETH_FILTER_MACVLAN,
8675 RTE_ETH_FILTER_DELETE,
8679 printf("bad set MAC hash parameter, return code = %d\n", ret);
8683 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8684 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8686 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8687 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8689 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8690 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8692 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8693 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8695 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8696 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8698 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8699 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8701 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8702 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8703 filter_type, "exact-mac#exact-mac-vlan"
8704 "#hashmac#hashmac-vlan");
8705 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8706 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8709 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8710 .f = cmd_set_vf_macvlan_parsed,
8712 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8713 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8714 "Exact match rule: exact match of MAC or MAC and VLAN; "
8715 "hash match rule: hash match of MAC and exact match of VLAN",
8717 (void *)&cmd_set_vf_macvlan_set,
8718 (void *)&cmd_set_vf_macvlan_port,
8719 (void *)&cmd_set_vf_macvlan_portid,
8720 (void *)&cmd_set_vf_macvlan_vf,
8721 (void *)&cmd_set_vf_macvlan_vf_id,
8722 (void *)&cmd_set_vf_macvlan_mac,
8723 (void *)&cmd_set_vf_macvlan_filter_type,
8724 (void *)&cmd_set_vf_macvlan_mode,
8729 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8730 struct cmd_set_vf_traffic {
8731 cmdline_fixed_string_t set;
8732 cmdline_fixed_string_t port;
8734 cmdline_fixed_string_t vf;
8736 cmdline_fixed_string_t what;
8737 cmdline_fixed_string_t mode;
8741 cmd_set_vf_traffic_parsed(void *parsed_result,
8742 __rte_unused struct cmdline *cl,
8743 __rte_unused void *data)
8745 struct cmd_set_vf_traffic *res = parsed_result;
8746 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8747 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8749 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8752 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8753 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8755 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8756 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8758 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8759 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8761 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8762 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8764 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8765 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8767 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8768 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8770 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8771 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8774 cmdline_parse_inst_t cmd_set_vf_traffic = {
8775 .f = cmd_set_vf_traffic_parsed,
8777 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8779 (void *)&cmd_setvf_traffic_set,
8780 (void *)&cmd_setvf_traffic_port,
8781 (void *)&cmd_setvf_traffic_portid,
8782 (void *)&cmd_setvf_traffic_vf,
8783 (void *)&cmd_setvf_traffic_vfid,
8784 (void *)&cmd_setvf_traffic_what,
8785 (void *)&cmd_setvf_traffic_mode,
8790 /* *** CONFIGURE VF RECEIVE MODE *** */
8791 struct cmd_set_vf_rxmode {
8792 cmdline_fixed_string_t set;
8793 cmdline_fixed_string_t port;
8795 cmdline_fixed_string_t vf;
8797 cmdline_fixed_string_t what;
8798 cmdline_fixed_string_t mode;
8799 cmdline_fixed_string_t on;
8803 cmd_set_vf_rxmode_parsed(void *parsed_result,
8804 __rte_unused struct cmdline *cl,
8805 __rte_unused void *data)
8808 uint16_t vf_rxmode = 0;
8809 struct cmd_set_vf_rxmode *res = parsed_result;
8811 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8812 if (!strcmp(res->what,"rxmode")) {
8813 if (!strcmp(res->mode, "AUPE"))
8814 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8815 else if (!strcmp(res->mode, "ROPE"))
8816 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8817 else if (!strcmp(res->mode, "BAM"))
8818 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8819 else if (!strncmp(res->mode, "MPE",3))
8820 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8823 RTE_SET_USED(is_on);
8825 #ifdef RTE_LIBRTE_IXGBE_PMD
8826 if (ret == -ENOTSUP)
8827 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8828 vf_rxmode, (uint8_t)is_on);
8830 #ifdef RTE_LIBRTE_BNXT_PMD
8831 if (ret == -ENOTSUP)
8832 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8833 vf_rxmode, (uint8_t)is_on);
8836 printf("bad VF receive mode parameter, return code = %d \n",
8840 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8841 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8843 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8844 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8846 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8847 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8849 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8850 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8852 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8853 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8855 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8856 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8858 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8859 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8860 mode, "AUPE#ROPE#BAM#MPE");
8861 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8862 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8865 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8866 .f = cmd_set_vf_rxmode_parsed,
8868 .help_str = "set port <port_id> vf <vf_id> rxmode "
8869 "AUPE|ROPE|BAM|MPE on|off",
8871 (void *)&cmd_set_vf_rxmode_set,
8872 (void *)&cmd_set_vf_rxmode_port,
8873 (void *)&cmd_set_vf_rxmode_portid,
8874 (void *)&cmd_set_vf_rxmode_vf,
8875 (void *)&cmd_set_vf_rxmode_vfid,
8876 (void *)&cmd_set_vf_rxmode_what,
8877 (void *)&cmd_set_vf_rxmode_mode,
8878 (void *)&cmd_set_vf_rxmode_on,
8883 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8884 struct cmd_vf_mac_addr_result {
8885 cmdline_fixed_string_t mac_addr_cmd;
8886 cmdline_fixed_string_t what;
8887 cmdline_fixed_string_t port;
8889 cmdline_fixed_string_t vf;
8891 struct rte_ether_addr address;
8894 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8895 __rte_unused struct cmdline *cl,
8896 __rte_unused void *data)
8898 struct cmd_vf_mac_addr_result *res = parsed_result;
8901 if (strcmp(res->what, "add") != 0)
8904 #ifdef RTE_LIBRTE_I40E_PMD
8905 if (ret == -ENOTSUP)
8906 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8909 #ifdef RTE_LIBRTE_BNXT_PMD
8910 if (ret == -ENOTSUP)
8911 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8916 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8920 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8921 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8922 mac_addr_cmd,"mac_addr");
8923 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8924 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8926 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8927 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8929 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8930 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8932 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8933 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8935 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8936 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8938 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8939 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8942 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8943 .f = cmd_vf_mac_addr_parsed,
8945 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8946 "Add MAC address filtering for a VF on port_id",
8948 (void *)&cmd_vf_mac_addr_cmd,
8949 (void *)&cmd_vf_mac_addr_what,
8950 (void *)&cmd_vf_mac_addr_port,
8951 (void *)&cmd_vf_mac_addr_portnum,
8952 (void *)&cmd_vf_mac_addr_vf,
8953 (void *)&cmd_vf_mac_addr_vfnum,
8954 (void *)&cmd_vf_mac_addr_addr,
8959 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8960 struct cmd_vf_rx_vlan_filter {
8961 cmdline_fixed_string_t rx_vlan;
8962 cmdline_fixed_string_t what;
8964 cmdline_fixed_string_t port;
8966 cmdline_fixed_string_t vf;
8971 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8972 __rte_unused struct cmdline *cl,
8973 __rte_unused void *data)
8975 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8978 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8980 #ifdef RTE_LIBRTE_IXGBE_PMD
8981 if (ret == -ENOTSUP)
8982 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8983 res->vlan_id, res->vf_mask, is_add);
8985 #ifdef RTE_LIBRTE_I40E_PMD
8986 if (ret == -ENOTSUP)
8987 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8988 res->vlan_id, res->vf_mask, is_add);
8990 #ifdef RTE_LIBRTE_BNXT_PMD
8991 if (ret == -ENOTSUP)
8992 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8993 res->vlan_id, res->vf_mask, is_add);
9000 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
9001 res->vlan_id, res->vf_mask);
9004 printf("invalid port_id %d\n", res->port_id);
9007 printf("function not implemented or supported\n");
9010 printf("programming error: (%s)\n", strerror(-ret));
9014 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9015 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9016 rx_vlan, "rx_vlan");
9017 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9018 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9020 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9021 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9023 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9024 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9026 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9027 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9029 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9030 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9032 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9033 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9036 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9037 .f = cmd_vf_rx_vlan_filter_parsed,
9039 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9040 "(vf_mask = hexadecimal VF mask)",
9042 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9043 (void *)&cmd_vf_rx_vlan_filter_what,
9044 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9045 (void *)&cmd_vf_rx_vlan_filter_port,
9046 (void *)&cmd_vf_rx_vlan_filter_portid,
9047 (void *)&cmd_vf_rx_vlan_filter_vf,
9048 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9053 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9054 struct cmd_queue_rate_limit_result {
9055 cmdline_fixed_string_t set;
9056 cmdline_fixed_string_t port;
9058 cmdline_fixed_string_t queue;
9060 cmdline_fixed_string_t rate;
9064 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9065 __rte_unused struct cmdline *cl,
9066 __rte_unused void *data)
9068 struct cmd_queue_rate_limit_result *res = parsed_result;
9071 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9072 && (strcmp(res->queue, "queue") == 0)
9073 && (strcmp(res->rate, "rate") == 0))
9074 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9077 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
9081 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9082 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9084 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9085 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9087 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9088 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9090 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9091 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9093 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9094 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9096 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9097 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9099 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9100 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9103 cmdline_parse_inst_t cmd_queue_rate_limit = {
9104 .f = cmd_queue_rate_limit_parsed,
9106 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9107 "Set rate limit for a queue on port_id",
9109 (void *)&cmd_queue_rate_limit_set,
9110 (void *)&cmd_queue_rate_limit_port,
9111 (void *)&cmd_queue_rate_limit_portnum,
9112 (void *)&cmd_queue_rate_limit_queue,
9113 (void *)&cmd_queue_rate_limit_queuenum,
9114 (void *)&cmd_queue_rate_limit_rate,
9115 (void *)&cmd_queue_rate_limit_ratenum,
9120 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9121 struct cmd_vf_rate_limit_result {
9122 cmdline_fixed_string_t set;
9123 cmdline_fixed_string_t port;
9125 cmdline_fixed_string_t vf;
9127 cmdline_fixed_string_t rate;
9129 cmdline_fixed_string_t q_msk;
9133 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9134 __rte_unused struct cmdline *cl,
9135 __rte_unused void *data)
9137 struct cmd_vf_rate_limit_result *res = parsed_result;
9140 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9141 && (strcmp(res->vf, "vf") == 0)
9142 && (strcmp(res->rate, "rate") == 0)
9143 && (strcmp(res->q_msk, "queue_mask") == 0))
9144 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9145 res->rate_num, res->q_msk_val);
9147 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9151 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9152 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9154 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9155 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9157 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9158 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9160 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9161 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9163 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9164 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9166 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9167 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9169 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9170 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9172 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9173 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9174 q_msk, "queue_mask");
9175 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9176 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9179 cmdline_parse_inst_t cmd_vf_rate_limit = {
9180 .f = cmd_vf_rate_limit_parsed,
9182 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9183 "queue_mask <queue_mask_value>: "
9184 "Set rate limit for queues of VF on port_id",
9186 (void *)&cmd_vf_rate_limit_set,
9187 (void *)&cmd_vf_rate_limit_port,
9188 (void *)&cmd_vf_rate_limit_portnum,
9189 (void *)&cmd_vf_rate_limit_vf,
9190 (void *)&cmd_vf_rate_limit_vfnum,
9191 (void *)&cmd_vf_rate_limit_rate,
9192 (void *)&cmd_vf_rate_limit_ratenum,
9193 (void *)&cmd_vf_rate_limit_q_msk,
9194 (void *)&cmd_vf_rate_limit_q_msk_val,
9199 /* *** ADD TUNNEL FILTER OF A PORT *** */
9200 struct cmd_tunnel_filter_result {
9201 cmdline_fixed_string_t cmd;
9202 cmdline_fixed_string_t what;
9204 struct rte_ether_addr outer_mac;
9205 struct rte_ether_addr inner_mac;
9206 cmdline_ipaddr_t ip_value;
9207 uint16_t inner_vlan;
9208 cmdline_fixed_string_t tunnel_type;
9209 cmdline_fixed_string_t filter_type;
9215 cmd_tunnel_filter_parsed(void *parsed_result,
9216 __rte_unused struct cmdline *cl,
9217 __rte_unused void *data)
9219 struct cmd_tunnel_filter_result *res = parsed_result;
9220 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
9223 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
9225 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
9226 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
9227 tunnel_filter_conf.inner_vlan = res->inner_vlan;
9229 if (res->ip_value.family == AF_INET) {
9230 tunnel_filter_conf.ip_addr.ipv4_addr =
9231 res->ip_value.addr.ipv4.s_addr;
9232 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
9234 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
9235 &(res->ip_value.addr.ipv6),
9236 sizeof(struct in6_addr));
9237 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
9240 if (!strcmp(res->filter_type, "imac-ivlan"))
9241 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
9242 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
9243 tunnel_filter_conf.filter_type =
9244 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
9245 else if (!strcmp(res->filter_type, "imac-tenid"))
9246 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
9247 else if (!strcmp(res->filter_type, "imac"))
9248 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
9249 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
9250 tunnel_filter_conf.filter_type =
9251 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
9252 else if (!strcmp(res->filter_type, "oip"))
9253 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9254 else if (!strcmp(res->filter_type, "iip"))
9255 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9257 printf("The filter type is not supported");
9261 if (!strcmp(res->tunnel_type, "vxlan"))
9262 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9263 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9264 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9265 else if (!strcmp(res->tunnel_type, "nvgre"))
9266 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9267 else if (!strcmp(res->tunnel_type, "ipingre"))
9268 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9270 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9274 tunnel_filter_conf.tenant_id = res->tenant_id;
9275 tunnel_filter_conf.queue_id = res->queue_num;
9276 if (!strcmp(res->what, "add"))
9277 ret = rte_eth_dev_filter_ctrl(res->port_id,
9278 RTE_ETH_FILTER_TUNNEL,
9280 &tunnel_filter_conf);
9282 ret = rte_eth_dev_filter_ctrl(res->port_id,
9283 RTE_ETH_FILTER_TUNNEL,
9284 RTE_ETH_FILTER_DELETE,
9285 &tunnel_filter_conf);
9287 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9291 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9292 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9293 cmd, "tunnel_filter");
9294 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9295 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9297 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9298 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9300 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9301 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9303 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9304 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9306 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9307 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9308 inner_vlan, UINT16);
9309 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9310 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9312 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9313 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9314 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9316 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9317 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9318 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9319 "imac#omac-imac-tenid");
9320 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9321 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9323 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9324 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9327 cmdline_parse_inst_t cmd_tunnel_filter = {
9328 .f = cmd_tunnel_filter_parsed,
9330 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9331 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9332 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9333 "<queue_id>: Add/Rm tunnel filter of a port",
9335 (void *)&cmd_tunnel_filter_cmd,
9336 (void *)&cmd_tunnel_filter_what,
9337 (void *)&cmd_tunnel_filter_port_id,
9338 (void *)&cmd_tunnel_filter_outer_mac,
9339 (void *)&cmd_tunnel_filter_inner_mac,
9340 (void *)&cmd_tunnel_filter_ip_value,
9341 (void *)&cmd_tunnel_filter_innner_vlan,
9342 (void *)&cmd_tunnel_filter_tunnel_type,
9343 (void *)&cmd_tunnel_filter_filter_type,
9344 (void *)&cmd_tunnel_filter_tenant_id,
9345 (void *)&cmd_tunnel_filter_queue_num,
9350 /* *** CONFIGURE TUNNEL UDP PORT *** */
9351 struct cmd_tunnel_udp_config {
9352 cmdline_fixed_string_t cmd;
9353 cmdline_fixed_string_t what;
9359 cmd_tunnel_udp_config_parsed(void *parsed_result,
9360 __rte_unused struct cmdline *cl,
9361 __rte_unused void *data)
9363 struct cmd_tunnel_udp_config *res = parsed_result;
9364 struct rte_eth_udp_tunnel tunnel_udp;
9367 tunnel_udp.udp_port = res->udp_port;
9369 if (!strcmp(res->cmd, "rx_vxlan_port"))
9370 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9372 if (!strcmp(res->what, "add"))
9373 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9376 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9380 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9383 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9384 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9385 cmd, "rx_vxlan_port");
9386 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9387 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9389 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9390 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9392 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9393 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9396 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9397 .f = cmd_tunnel_udp_config_parsed,
9399 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9400 "Add/Remove a tunneling UDP port filter",
9402 (void *)&cmd_tunnel_udp_config_cmd,
9403 (void *)&cmd_tunnel_udp_config_what,
9404 (void *)&cmd_tunnel_udp_config_udp_port,
9405 (void *)&cmd_tunnel_udp_config_port_id,
9410 struct cmd_config_tunnel_udp_port {
9411 cmdline_fixed_string_t port;
9412 cmdline_fixed_string_t config;
9414 cmdline_fixed_string_t udp_tunnel_port;
9415 cmdline_fixed_string_t action;
9416 cmdline_fixed_string_t tunnel_type;
9421 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9422 __rte_unused struct cmdline *cl,
9423 __rte_unused void *data)
9425 struct cmd_config_tunnel_udp_port *res = parsed_result;
9426 struct rte_eth_udp_tunnel tunnel_udp;
9429 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9432 tunnel_udp.udp_port = res->udp_port;
9434 if (!strcmp(res->tunnel_type, "vxlan")) {
9435 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9436 } else if (!strcmp(res->tunnel_type, "geneve")) {
9437 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9438 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9439 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9441 printf("Invalid tunnel type\n");
9445 if (!strcmp(res->action, "add"))
9446 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9449 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9453 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9456 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9457 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9459 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9460 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9462 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9463 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9465 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9466 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9469 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9470 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9472 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9473 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9474 "vxlan#geneve#vxlan-gpe");
9475 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9476 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9479 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9480 .f = cmd_cfg_tunnel_udp_port_parsed,
9482 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9484 (void *)&cmd_config_tunnel_udp_port_port,
9485 (void *)&cmd_config_tunnel_udp_port_config,
9486 (void *)&cmd_config_tunnel_udp_port_port_id,
9487 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9488 (void *)&cmd_config_tunnel_udp_port_action,
9489 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9490 (void *)&cmd_config_tunnel_udp_port_value,
9495 /* *** GLOBAL CONFIG *** */
9496 struct cmd_global_config_result {
9497 cmdline_fixed_string_t cmd;
9499 cmdline_fixed_string_t cfg_type;
9504 cmd_global_config_parsed(void *parsed_result,
9505 __rte_unused struct cmdline *cl,
9506 __rte_unused void *data)
9508 struct cmd_global_config_result *res = parsed_result;
9509 struct rte_eth_global_cfg conf;
9512 memset(&conf, 0, sizeof(conf));
9513 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9514 conf.cfg.gre_key_len = res->len;
9515 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9516 RTE_ETH_FILTER_SET, &conf);
9517 #ifdef RTE_LIBRTE_I40E_PMD
9518 if (ret == -ENOTSUP)
9519 ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len);
9522 printf("Global config error\n");
9525 cmdline_parse_token_string_t cmd_global_config_cmd =
9526 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9528 cmdline_parse_token_num_t cmd_global_config_port_id =
9529 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9531 cmdline_parse_token_string_t cmd_global_config_type =
9532 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9533 cfg_type, "gre-key-len");
9534 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9535 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9538 cmdline_parse_inst_t cmd_global_config = {
9539 .f = cmd_global_config_parsed,
9540 .data = (void *)NULL,
9541 .help_str = "global_config <port_id> gre-key-len <key_len>",
9543 (void *)&cmd_global_config_cmd,
9544 (void *)&cmd_global_config_port_id,
9545 (void *)&cmd_global_config_type,
9546 (void *)&cmd_global_config_gre_key_len,
9551 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9552 struct cmd_set_mirror_mask_result {
9553 cmdline_fixed_string_t set;
9554 cmdline_fixed_string_t port;
9556 cmdline_fixed_string_t mirror;
9558 cmdline_fixed_string_t what;
9559 cmdline_fixed_string_t value;
9560 cmdline_fixed_string_t dstpool;
9562 cmdline_fixed_string_t on;
9565 cmdline_parse_token_string_t cmd_mirror_mask_set =
9566 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9568 cmdline_parse_token_string_t cmd_mirror_mask_port =
9569 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9571 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9572 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9574 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9575 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9576 mirror, "mirror-rule");
9577 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9578 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9580 cmdline_parse_token_string_t cmd_mirror_mask_what =
9581 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9582 what, "pool-mirror-up#pool-mirror-down"
9584 cmdline_parse_token_string_t cmd_mirror_mask_value =
9585 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9587 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9588 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9589 dstpool, "dst-pool");
9590 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9591 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9593 cmdline_parse_token_string_t cmd_mirror_mask_on =
9594 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9598 cmd_set_mirror_mask_parsed(void *parsed_result,
9599 __rte_unused struct cmdline *cl,
9600 __rte_unused void *data)
9603 struct cmd_set_mirror_mask_result *res = parsed_result;
9604 struct rte_eth_mirror_conf mr_conf;
9606 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9608 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9610 mr_conf.dst_pool = res->dstpool_id;
9612 if (!strcmp(res->what, "pool-mirror-up")) {
9613 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9614 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9615 } else if (!strcmp(res->what, "pool-mirror-down")) {
9616 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9617 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9618 } else if (!strcmp(res->what, "vlan-mirror")) {
9619 mr_conf.rule_type = ETH_MIRROR_VLAN;
9620 nb_item = parse_item_list(res->value, "vlan",
9621 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9625 for (i = 0; i < nb_item; i++) {
9626 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9627 printf("Invalid vlan_id: must be < 4096\n");
9631 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9632 mr_conf.vlan.vlan_mask |= 1ULL << i;
9636 if (!strcmp(res->on, "on"))
9637 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9640 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9643 printf("mirror rule add error: (%s)\n", strerror(-ret));
9646 cmdline_parse_inst_t cmd_set_mirror_mask = {
9647 .f = cmd_set_mirror_mask_parsed,
9649 .help_str = "set port <port_id> mirror-rule <rule_id> "
9650 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9651 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9653 (void *)&cmd_mirror_mask_set,
9654 (void *)&cmd_mirror_mask_port,
9655 (void *)&cmd_mirror_mask_portid,
9656 (void *)&cmd_mirror_mask_mirror,
9657 (void *)&cmd_mirror_mask_ruleid,
9658 (void *)&cmd_mirror_mask_what,
9659 (void *)&cmd_mirror_mask_value,
9660 (void *)&cmd_mirror_mask_dstpool,
9661 (void *)&cmd_mirror_mask_poolid,
9662 (void *)&cmd_mirror_mask_on,
9667 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9668 struct cmd_set_mirror_link_result {
9669 cmdline_fixed_string_t set;
9670 cmdline_fixed_string_t port;
9672 cmdline_fixed_string_t mirror;
9674 cmdline_fixed_string_t what;
9675 cmdline_fixed_string_t dstpool;
9677 cmdline_fixed_string_t on;
9680 cmdline_parse_token_string_t cmd_mirror_link_set =
9681 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9683 cmdline_parse_token_string_t cmd_mirror_link_port =
9684 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9686 cmdline_parse_token_num_t cmd_mirror_link_portid =
9687 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9689 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9690 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9691 mirror, "mirror-rule");
9692 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9693 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9695 cmdline_parse_token_string_t cmd_mirror_link_what =
9696 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9697 what, "uplink-mirror#downlink-mirror");
9698 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9699 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9700 dstpool, "dst-pool");
9701 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9702 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9704 cmdline_parse_token_string_t cmd_mirror_link_on =
9705 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9709 cmd_set_mirror_link_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;
9715 struct rte_eth_mirror_conf mr_conf;
9717 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9718 if (!strcmp(res->what, "uplink-mirror"))
9719 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9721 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9723 mr_conf.dst_pool = res->dstpool_id;
9725 if (!strcmp(res->on, "on"))
9726 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9729 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9732 /* check the return value and print it if is < 0 */
9734 printf("mirror rule add error: (%s)\n", strerror(-ret));
9738 cmdline_parse_inst_t cmd_set_mirror_link = {
9739 .f = cmd_set_mirror_link_parsed,
9741 .help_str = "set port <port_id> mirror-rule <rule_id> "
9742 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9744 (void *)&cmd_mirror_link_set,
9745 (void *)&cmd_mirror_link_port,
9746 (void *)&cmd_mirror_link_portid,
9747 (void *)&cmd_mirror_link_mirror,
9748 (void *)&cmd_mirror_link_ruleid,
9749 (void *)&cmd_mirror_link_what,
9750 (void *)&cmd_mirror_link_dstpool,
9751 (void *)&cmd_mirror_link_poolid,
9752 (void *)&cmd_mirror_link_on,
9757 /* *** RESET VM MIRROR RULE *** */
9758 struct cmd_rm_mirror_rule_result {
9759 cmdline_fixed_string_t reset;
9760 cmdline_fixed_string_t port;
9762 cmdline_fixed_string_t mirror;
9766 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9767 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9769 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9770 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9772 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9773 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9775 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9776 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9777 mirror, "mirror-rule");
9778 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9779 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9783 cmd_reset_mirror_rule_parsed(void *parsed_result,
9784 __rte_unused struct cmdline *cl,
9785 __rte_unused void *data)
9788 struct cmd_set_mirror_link_result *res = parsed_result;
9790 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9792 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9795 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9796 .f = cmd_reset_mirror_rule_parsed,
9798 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9800 (void *)&cmd_rm_mirror_rule_reset,
9801 (void *)&cmd_rm_mirror_rule_port,
9802 (void *)&cmd_rm_mirror_rule_portid,
9803 (void *)&cmd_rm_mirror_rule_mirror,
9804 (void *)&cmd_rm_mirror_rule_ruleid,
9809 /* ******************************************************************************** */
9811 struct cmd_dump_result {
9812 cmdline_fixed_string_t dump;
9816 dump_struct_sizes(void)
9818 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9819 DUMP_SIZE(struct rte_mbuf);
9820 DUMP_SIZE(struct rte_mempool);
9821 DUMP_SIZE(struct rte_ring);
9826 /* Dump the socket memory statistics on console */
9828 dump_socket_mem(FILE *f)
9830 struct rte_malloc_socket_stats socket_stats;
9835 unsigned int n_alloc = 0;
9836 unsigned int n_free = 0;
9837 static size_t last_allocs;
9838 static size_t last_total;
9841 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9842 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9843 !socket_stats.heap_totalsz_bytes)
9845 total += socket_stats.heap_totalsz_bytes;
9846 alloc += socket_stats.heap_allocsz_bytes;
9847 free += socket_stats.heap_freesz_bytes;
9848 n_alloc += socket_stats.alloc_count;
9849 n_free += socket_stats.free_count;
9851 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9853 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9854 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9855 (double)socket_stats.heap_allocsz_bytes * 100 /
9856 (double)socket_stats.heap_totalsz_bytes,
9857 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9858 socket_stats.alloc_count,
9859 socket_stats.free_count);
9862 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9863 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9864 (double)alloc * 100 / (double)total,
9865 (double)free / (1024 * 1024),
9868 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9869 ((double)total - (double)last_total) / (1024 * 1024),
9870 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9871 last_allocs = alloc;
9875 static void cmd_dump_parsed(void *parsed_result,
9876 __rte_unused struct cmdline *cl,
9877 __rte_unused void *data)
9879 struct cmd_dump_result *res = parsed_result;
9881 if (!strcmp(res->dump, "dump_physmem"))
9882 rte_dump_physmem_layout(stdout);
9883 else if (!strcmp(res->dump, "dump_socket_mem"))
9884 dump_socket_mem(stdout);
9885 else if (!strcmp(res->dump, "dump_memzone"))
9886 rte_memzone_dump(stdout);
9887 else if (!strcmp(res->dump, "dump_struct_sizes"))
9888 dump_struct_sizes();
9889 else if (!strcmp(res->dump, "dump_ring"))
9890 rte_ring_list_dump(stdout);
9891 else if (!strcmp(res->dump, "dump_mempool"))
9892 rte_mempool_list_dump(stdout);
9893 else if (!strcmp(res->dump, "dump_devargs"))
9894 rte_devargs_dump(stdout);
9895 else if (!strcmp(res->dump, "dump_log_types"))
9896 rte_log_dump(stdout);
9899 cmdline_parse_token_string_t cmd_dump_dump =
9900 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9904 "dump_struct_sizes#"
9910 cmdline_parse_inst_t cmd_dump = {
9911 .f = cmd_dump_parsed, /* function to call */
9912 .data = NULL, /* 2nd arg of func */
9913 .help_str = "Dump status",
9914 .tokens = { /* token list, NULL terminated */
9915 (void *)&cmd_dump_dump,
9920 /* ******************************************************************************** */
9922 struct cmd_dump_one_result {
9923 cmdline_fixed_string_t dump;
9924 cmdline_fixed_string_t name;
9927 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9928 __rte_unused void *data)
9930 struct cmd_dump_one_result *res = parsed_result;
9932 if (!strcmp(res->dump, "dump_ring")) {
9934 r = rte_ring_lookup(res->name);
9936 cmdline_printf(cl, "Cannot find ring\n");
9939 rte_ring_dump(stdout, r);
9940 } else if (!strcmp(res->dump, "dump_mempool")) {
9941 struct rte_mempool *mp;
9942 mp = rte_mempool_lookup(res->name);
9944 cmdline_printf(cl, "Cannot find mempool\n");
9947 rte_mempool_dump(stdout, mp);
9951 cmdline_parse_token_string_t cmd_dump_one_dump =
9952 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9953 "dump_ring#dump_mempool");
9955 cmdline_parse_token_string_t cmd_dump_one_name =
9956 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9958 cmdline_parse_inst_t cmd_dump_one = {
9959 .f = cmd_dump_one_parsed, /* function to call */
9960 .data = NULL, /* 2nd arg of func */
9961 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9962 .tokens = { /* token list, NULL terminated */
9963 (void *)&cmd_dump_one_dump,
9964 (void *)&cmd_dump_one_name,
9969 /* *** Add/Del syn filter *** */
9970 struct cmd_syn_filter_result {
9971 cmdline_fixed_string_t filter;
9973 cmdline_fixed_string_t ops;
9974 cmdline_fixed_string_t priority;
9975 cmdline_fixed_string_t high;
9976 cmdline_fixed_string_t queue;
9981 cmd_syn_filter_parsed(void *parsed_result,
9982 __rte_unused struct cmdline *cl,
9983 __rte_unused void *data)
9985 struct cmd_syn_filter_result *res = parsed_result;
9986 struct rte_eth_syn_filter syn_filter;
9989 ret = rte_eth_dev_filter_supported(res->port_id,
9990 RTE_ETH_FILTER_SYN);
9992 printf("syn filter is not supported on port %u.\n",
9997 memset(&syn_filter, 0, sizeof(syn_filter));
9999 if (!strcmp(res->ops, "add")) {
10000 if (!strcmp(res->high, "high"))
10001 syn_filter.hig_pri = 1;
10003 syn_filter.hig_pri = 0;
10005 syn_filter.queue = res->queue_id;
10006 ret = rte_eth_dev_filter_ctrl(res->port_id,
10007 RTE_ETH_FILTER_SYN,
10008 RTE_ETH_FILTER_ADD,
10011 ret = rte_eth_dev_filter_ctrl(res->port_id,
10012 RTE_ETH_FILTER_SYN,
10013 RTE_ETH_FILTER_DELETE,
10017 printf("syn filter programming error: (%s)\n",
10021 cmdline_parse_token_string_t cmd_syn_filter_filter =
10022 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10023 filter, "syn_filter");
10024 cmdline_parse_token_num_t cmd_syn_filter_port_id =
10025 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
10027 cmdline_parse_token_string_t cmd_syn_filter_ops =
10028 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10030 cmdline_parse_token_string_t cmd_syn_filter_priority =
10031 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10032 priority, "priority");
10033 cmdline_parse_token_string_t cmd_syn_filter_high =
10034 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10036 cmdline_parse_token_string_t cmd_syn_filter_queue =
10037 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10039 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
10040 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
10043 cmdline_parse_inst_t cmd_syn_filter = {
10044 .f = cmd_syn_filter_parsed,
10046 .help_str = "syn_filter <port_id> add|del priority high|low queue "
10047 "<queue_id>: Add/Delete syn filter",
10049 (void *)&cmd_syn_filter_filter,
10050 (void *)&cmd_syn_filter_port_id,
10051 (void *)&cmd_syn_filter_ops,
10052 (void *)&cmd_syn_filter_priority,
10053 (void *)&cmd_syn_filter_high,
10054 (void *)&cmd_syn_filter_queue,
10055 (void *)&cmd_syn_filter_queue_id,
10060 /* *** queue region set *** */
10061 struct cmd_queue_region_result {
10062 cmdline_fixed_string_t set;
10063 cmdline_fixed_string_t port;
10065 cmdline_fixed_string_t cmd;
10066 cmdline_fixed_string_t region;
10068 cmdline_fixed_string_t queue_start_index;
10070 cmdline_fixed_string_t queue_num;
10071 uint8_t queue_num_value;
10075 cmd_queue_region_parsed(void *parsed_result,
10076 __rte_unused struct cmdline *cl,
10077 __rte_unused void *data)
10079 struct cmd_queue_region_result *res = parsed_result;
10080 int ret = -ENOTSUP;
10081 #ifdef RTE_LIBRTE_I40E_PMD
10082 struct rte_pmd_i40e_queue_region_conf region_conf;
10083 enum rte_pmd_i40e_queue_region_op op_type;
10086 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10089 #ifdef RTE_LIBRTE_I40E_PMD
10090 memset(®ion_conf, 0, sizeof(region_conf));
10091 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
10092 region_conf.region_id = res->region_id;
10093 region_conf.queue_num = res->queue_num_value;
10094 region_conf.queue_start_index = res->queue_id;
10096 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10097 op_type, ®ion_conf);
10104 printf("function not implemented or supported\n");
10107 printf("queue region config error: (%s)\n", strerror(-ret));
10111 cmdline_parse_token_string_t cmd_queue_region_set =
10112 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10114 cmdline_parse_token_string_t cmd_queue_region_port =
10115 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10116 cmdline_parse_token_num_t cmd_queue_region_port_id =
10117 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10119 cmdline_parse_token_string_t cmd_queue_region_cmd =
10120 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10121 cmd, "queue-region");
10122 cmdline_parse_token_string_t cmd_queue_region_id =
10123 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10124 region, "region_id");
10125 cmdline_parse_token_num_t cmd_queue_region_index =
10126 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10128 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10129 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10130 queue_start_index, "queue_start_index");
10131 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10132 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10134 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10135 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10136 queue_num, "queue_num");
10137 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10138 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10139 queue_num_value, UINT8);
10141 cmdline_parse_inst_t cmd_queue_region = {
10142 .f = cmd_queue_region_parsed,
10144 .help_str = "set port <port_id> queue-region region_id <value> "
10145 "queue_start_index <value> queue_num <value>: Set a queue region",
10147 (void *)&cmd_queue_region_set,
10148 (void *)&cmd_queue_region_port,
10149 (void *)&cmd_queue_region_port_id,
10150 (void *)&cmd_queue_region_cmd,
10151 (void *)&cmd_queue_region_id,
10152 (void *)&cmd_queue_region_index,
10153 (void *)&cmd_queue_region_queue_start_index,
10154 (void *)&cmd_queue_region_queue_id,
10155 (void *)&cmd_queue_region_queue_num,
10156 (void *)&cmd_queue_region_queue_num_value,
10161 /* *** queue region and flowtype set *** */
10162 struct cmd_region_flowtype_result {
10163 cmdline_fixed_string_t set;
10164 cmdline_fixed_string_t port;
10166 cmdline_fixed_string_t cmd;
10167 cmdline_fixed_string_t region;
10169 cmdline_fixed_string_t flowtype;
10170 uint8_t flowtype_id;
10174 cmd_region_flowtype_parsed(void *parsed_result,
10175 __rte_unused struct cmdline *cl,
10176 __rte_unused void *data)
10178 struct cmd_region_flowtype_result *res = parsed_result;
10179 int ret = -ENOTSUP;
10180 #ifdef RTE_LIBRTE_I40E_PMD
10181 struct rte_pmd_i40e_queue_region_conf region_conf;
10182 enum rte_pmd_i40e_queue_region_op op_type;
10185 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10188 #ifdef RTE_LIBRTE_I40E_PMD
10189 memset(®ion_conf, 0, sizeof(region_conf));
10191 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10192 region_conf.region_id = res->region_id;
10193 region_conf.hw_flowtype = res->flowtype_id;
10195 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10196 op_type, ®ion_conf);
10203 printf("function not implemented or supported\n");
10206 printf("region flowtype config error: (%s)\n", strerror(-ret));
10210 cmdline_parse_token_string_t cmd_region_flowtype_set =
10211 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10213 cmdline_parse_token_string_t cmd_region_flowtype_port =
10214 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10216 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10217 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10219 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10220 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10221 cmd, "queue-region");
10222 cmdline_parse_token_string_t cmd_region_flowtype_index =
10223 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10224 region, "region_id");
10225 cmdline_parse_token_num_t cmd_region_flowtype_id =
10226 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10228 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10229 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10230 flowtype, "flowtype");
10231 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10232 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10233 flowtype_id, UINT8);
10234 cmdline_parse_inst_t cmd_region_flowtype = {
10235 .f = cmd_region_flowtype_parsed,
10237 .help_str = "set port <port_id> queue-region region_id <value> "
10238 "flowtype <value>: Set a flowtype region index",
10240 (void *)&cmd_region_flowtype_set,
10241 (void *)&cmd_region_flowtype_port,
10242 (void *)&cmd_region_flowtype_port_index,
10243 (void *)&cmd_region_flowtype_cmd,
10244 (void *)&cmd_region_flowtype_index,
10245 (void *)&cmd_region_flowtype_id,
10246 (void *)&cmd_region_flowtype_flow_index,
10247 (void *)&cmd_region_flowtype_flow_id,
10252 /* *** User Priority (UP) to queue region (region_id) set *** */
10253 struct cmd_user_priority_region_result {
10254 cmdline_fixed_string_t set;
10255 cmdline_fixed_string_t port;
10257 cmdline_fixed_string_t cmd;
10258 cmdline_fixed_string_t user_priority;
10259 uint8_t user_priority_id;
10260 cmdline_fixed_string_t region;
10265 cmd_user_priority_region_parsed(void *parsed_result,
10266 __rte_unused struct cmdline *cl,
10267 __rte_unused void *data)
10269 struct cmd_user_priority_region_result *res = parsed_result;
10270 int ret = -ENOTSUP;
10271 #ifdef RTE_LIBRTE_I40E_PMD
10272 struct rte_pmd_i40e_queue_region_conf region_conf;
10273 enum rte_pmd_i40e_queue_region_op op_type;
10276 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10279 #ifdef RTE_LIBRTE_I40E_PMD
10280 memset(®ion_conf, 0, sizeof(region_conf));
10281 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10282 region_conf.user_priority = res->user_priority_id;
10283 region_conf.region_id = res->region_id;
10285 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10286 op_type, ®ion_conf);
10293 printf("function not implemented or supported\n");
10296 printf("user_priority region config error: (%s)\n",
10301 cmdline_parse_token_string_t cmd_user_priority_region_set =
10302 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10304 cmdline_parse_token_string_t cmd_user_priority_region_port =
10305 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10307 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10308 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10310 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10311 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10312 cmd, "queue-region");
10313 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10314 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10315 user_priority, "UP");
10316 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10317 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10318 user_priority_id, UINT8);
10319 cmdline_parse_token_string_t cmd_user_priority_region_region =
10320 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10321 region, "region_id");
10322 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10323 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10326 cmdline_parse_inst_t cmd_user_priority_region = {
10327 .f = cmd_user_priority_region_parsed,
10329 .help_str = "set port <port_id> queue-region UP <value> "
10330 "region_id <value>: Set the mapping of User Priority (UP) "
10331 "to queue region (region_id) ",
10333 (void *)&cmd_user_priority_region_set,
10334 (void *)&cmd_user_priority_region_port,
10335 (void *)&cmd_user_priority_region_port_index,
10336 (void *)&cmd_user_priority_region_cmd,
10337 (void *)&cmd_user_priority_region_UP,
10338 (void *)&cmd_user_priority_region_UP_id,
10339 (void *)&cmd_user_priority_region_region,
10340 (void *)&cmd_user_priority_region_region_id,
10345 /* *** flush all queue region related configuration *** */
10346 struct cmd_flush_queue_region_result {
10347 cmdline_fixed_string_t set;
10348 cmdline_fixed_string_t port;
10350 cmdline_fixed_string_t cmd;
10351 cmdline_fixed_string_t flush;
10352 cmdline_fixed_string_t what;
10356 cmd_flush_queue_region_parsed(void *parsed_result,
10357 __rte_unused struct cmdline *cl,
10358 __rte_unused void *data)
10360 struct cmd_flush_queue_region_result *res = parsed_result;
10361 int ret = -ENOTSUP;
10362 #ifdef RTE_LIBRTE_I40E_PMD
10363 struct rte_pmd_i40e_queue_region_conf region_conf;
10364 enum rte_pmd_i40e_queue_region_op op_type;
10367 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10370 #ifdef RTE_LIBRTE_I40E_PMD
10371 memset(®ion_conf, 0, sizeof(region_conf));
10373 if (strcmp(res->what, "on") == 0)
10374 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10376 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10378 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10379 op_type, ®ion_conf);
10386 printf("function not implemented or supported\n");
10389 printf("queue region config flush error: (%s)\n",
10394 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10395 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10397 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10398 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10400 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10401 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10403 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10404 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10405 cmd, "queue-region");
10406 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10407 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10409 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10410 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10413 cmdline_parse_inst_t cmd_flush_queue_region = {
10414 .f = cmd_flush_queue_region_parsed,
10416 .help_str = "set port <port_id> queue-region flush on|off"
10417 ": flush all queue region related configuration",
10419 (void *)&cmd_flush_queue_region_set,
10420 (void *)&cmd_flush_queue_region_port,
10421 (void *)&cmd_flush_queue_region_port_index,
10422 (void *)&cmd_flush_queue_region_cmd,
10423 (void *)&cmd_flush_queue_region_flush,
10424 (void *)&cmd_flush_queue_region_what,
10429 /* *** get all queue region related configuration info *** */
10430 struct cmd_show_queue_region_info {
10431 cmdline_fixed_string_t show;
10432 cmdline_fixed_string_t port;
10434 cmdline_fixed_string_t cmd;
10438 cmd_show_queue_region_info_parsed(void *parsed_result,
10439 __rte_unused struct cmdline *cl,
10440 __rte_unused void *data)
10442 struct cmd_show_queue_region_info *res = parsed_result;
10443 int ret = -ENOTSUP;
10444 #ifdef RTE_LIBRTE_I40E_PMD
10445 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10446 enum rte_pmd_i40e_queue_region_op op_type;
10449 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10452 #ifdef RTE_LIBRTE_I40E_PMD
10453 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10455 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10457 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10458 op_type, &rte_pmd_regions);
10460 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10467 printf("function not implemented or supported\n");
10470 printf("queue region config info show error: (%s)\n",
10475 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10476 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10478 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10479 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10481 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10482 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10484 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10485 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10486 cmd, "queue-region");
10488 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10489 .f = cmd_show_queue_region_info_parsed,
10491 .help_str = "show port <port_id> queue-region"
10492 ": show all queue region related configuration info",
10494 (void *)&cmd_show_queue_region_info_get,
10495 (void *)&cmd_show_queue_region_info_port,
10496 (void *)&cmd_show_queue_region_info_port_index,
10497 (void *)&cmd_show_queue_region_info_cmd,
10502 /* *** ADD/REMOVE A 2tuple FILTER *** */
10503 struct cmd_2tuple_filter_result {
10504 cmdline_fixed_string_t filter;
10506 cmdline_fixed_string_t ops;
10507 cmdline_fixed_string_t dst_port;
10508 uint16_t dst_port_value;
10509 cmdline_fixed_string_t protocol;
10510 uint8_t protocol_value;
10511 cmdline_fixed_string_t mask;
10512 uint8_t mask_value;
10513 cmdline_fixed_string_t tcp_flags;
10514 uint8_t tcp_flags_value;
10515 cmdline_fixed_string_t priority;
10516 uint8_t priority_value;
10517 cmdline_fixed_string_t queue;
10522 cmd_2tuple_filter_parsed(void *parsed_result,
10523 __rte_unused struct cmdline *cl,
10524 __rte_unused void *data)
10526 struct rte_eth_ntuple_filter filter;
10527 struct cmd_2tuple_filter_result *res = parsed_result;
10530 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10532 printf("ntuple filter is not supported on port %u.\n",
10537 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10539 filter.flags = RTE_2TUPLE_FLAGS;
10540 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10541 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10542 filter.proto = res->protocol_value;
10543 filter.priority = res->priority_value;
10544 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10545 printf("nonzero tcp_flags is only meaningful"
10546 " when protocol is TCP.\n");
10549 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10550 printf("invalid TCP flags.\n");
10554 if (res->tcp_flags_value != 0) {
10555 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10556 filter.tcp_flags = res->tcp_flags_value;
10559 /* need convert to big endian. */
10560 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10561 filter.queue = res->queue_id;
10563 if (!strcmp(res->ops, "add"))
10564 ret = rte_eth_dev_filter_ctrl(res->port_id,
10565 RTE_ETH_FILTER_NTUPLE,
10566 RTE_ETH_FILTER_ADD,
10569 ret = rte_eth_dev_filter_ctrl(res->port_id,
10570 RTE_ETH_FILTER_NTUPLE,
10571 RTE_ETH_FILTER_DELETE,
10574 printf("2tuple filter programming error: (%s)\n",
10579 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10580 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10581 filter, "2tuple_filter");
10582 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10583 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10585 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10586 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10588 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10589 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10590 dst_port, "dst_port");
10591 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10592 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10593 dst_port_value, UINT16);
10594 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10595 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10596 protocol, "protocol");
10597 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10598 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10599 protocol_value, UINT8);
10600 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10601 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10603 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10604 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10606 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10607 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10608 tcp_flags, "tcp_flags");
10609 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10610 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10611 tcp_flags_value, UINT8);
10612 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10613 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10614 priority, "priority");
10615 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10616 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10617 priority_value, UINT8);
10618 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10619 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10621 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10622 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10625 cmdline_parse_inst_t cmd_2tuple_filter = {
10626 .f = cmd_2tuple_filter_parsed,
10628 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10629 "<value> mask <value> tcp_flags <value> priority <value> queue "
10630 "<queue_id>: Add a 2tuple filter",
10632 (void *)&cmd_2tuple_filter_filter,
10633 (void *)&cmd_2tuple_filter_port_id,
10634 (void *)&cmd_2tuple_filter_ops,
10635 (void *)&cmd_2tuple_filter_dst_port,
10636 (void *)&cmd_2tuple_filter_dst_port_value,
10637 (void *)&cmd_2tuple_filter_protocol,
10638 (void *)&cmd_2tuple_filter_protocol_value,
10639 (void *)&cmd_2tuple_filter_mask,
10640 (void *)&cmd_2tuple_filter_mask_value,
10641 (void *)&cmd_2tuple_filter_tcp_flags,
10642 (void *)&cmd_2tuple_filter_tcp_flags_value,
10643 (void *)&cmd_2tuple_filter_priority,
10644 (void *)&cmd_2tuple_filter_priority_value,
10645 (void *)&cmd_2tuple_filter_queue,
10646 (void *)&cmd_2tuple_filter_queue_id,
10651 /* *** ADD/REMOVE A 5tuple FILTER *** */
10652 struct cmd_5tuple_filter_result {
10653 cmdline_fixed_string_t filter;
10655 cmdline_fixed_string_t ops;
10656 cmdline_fixed_string_t dst_ip;
10657 cmdline_ipaddr_t dst_ip_value;
10658 cmdline_fixed_string_t src_ip;
10659 cmdline_ipaddr_t src_ip_value;
10660 cmdline_fixed_string_t dst_port;
10661 uint16_t dst_port_value;
10662 cmdline_fixed_string_t src_port;
10663 uint16_t src_port_value;
10664 cmdline_fixed_string_t protocol;
10665 uint8_t protocol_value;
10666 cmdline_fixed_string_t mask;
10667 uint8_t mask_value;
10668 cmdline_fixed_string_t tcp_flags;
10669 uint8_t tcp_flags_value;
10670 cmdline_fixed_string_t priority;
10671 uint8_t priority_value;
10672 cmdline_fixed_string_t queue;
10677 cmd_5tuple_filter_parsed(void *parsed_result,
10678 __rte_unused struct cmdline *cl,
10679 __rte_unused void *data)
10681 struct rte_eth_ntuple_filter filter;
10682 struct cmd_5tuple_filter_result *res = parsed_result;
10685 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10687 printf("ntuple filter is not supported on port %u.\n",
10692 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10694 filter.flags = RTE_5TUPLE_FLAGS;
10695 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10696 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10697 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10698 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10699 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10700 filter.proto = res->protocol_value;
10701 filter.priority = res->priority_value;
10702 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10703 printf("nonzero tcp_flags is only meaningful"
10704 " when protocol is TCP.\n");
10707 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10708 printf("invalid TCP flags.\n");
10712 if (res->tcp_flags_value != 0) {
10713 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10714 filter.tcp_flags = res->tcp_flags_value;
10717 if (res->dst_ip_value.family == AF_INET)
10718 /* no need to convert, already big endian. */
10719 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10721 if (filter.dst_ip_mask == 0) {
10722 printf("can not support ipv6 involved compare.\n");
10728 if (res->src_ip_value.family == AF_INET)
10729 /* no need to convert, already big endian. */
10730 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10732 if (filter.src_ip_mask == 0) {
10733 printf("can not support ipv6 involved compare.\n");
10738 /* need convert to big endian. */
10739 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10740 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10741 filter.queue = res->queue_id;
10743 if (!strcmp(res->ops, "add"))
10744 ret = rte_eth_dev_filter_ctrl(res->port_id,
10745 RTE_ETH_FILTER_NTUPLE,
10746 RTE_ETH_FILTER_ADD,
10749 ret = rte_eth_dev_filter_ctrl(res->port_id,
10750 RTE_ETH_FILTER_NTUPLE,
10751 RTE_ETH_FILTER_DELETE,
10754 printf("5tuple filter programming error: (%s)\n",
10758 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10759 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10760 filter, "5tuple_filter");
10761 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10762 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10764 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10765 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10767 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10768 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10770 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10771 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10773 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10774 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10776 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10777 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10779 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10780 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10781 dst_port, "dst_port");
10782 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10783 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10784 dst_port_value, UINT16);
10785 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10786 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10787 src_port, "src_port");
10788 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10789 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10790 src_port_value, UINT16);
10791 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10792 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10793 protocol, "protocol");
10794 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10795 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10796 protocol_value, UINT8);
10797 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10798 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10800 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10801 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10803 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10804 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10805 tcp_flags, "tcp_flags");
10806 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10807 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10808 tcp_flags_value, UINT8);
10809 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10810 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10811 priority, "priority");
10812 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10813 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10814 priority_value, UINT8);
10815 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10816 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10818 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10819 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10822 cmdline_parse_inst_t cmd_5tuple_filter = {
10823 .f = cmd_5tuple_filter_parsed,
10825 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10826 "src_ip <value> dst_port <value> src_port <value> "
10827 "protocol <value> mask <value> tcp_flags <value> "
10828 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10830 (void *)&cmd_5tuple_filter_filter,
10831 (void *)&cmd_5tuple_filter_port_id,
10832 (void *)&cmd_5tuple_filter_ops,
10833 (void *)&cmd_5tuple_filter_dst_ip,
10834 (void *)&cmd_5tuple_filter_dst_ip_value,
10835 (void *)&cmd_5tuple_filter_src_ip,
10836 (void *)&cmd_5tuple_filter_src_ip_value,
10837 (void *)&cmd_5tuple_filter_dst_port,
10838 (void *)&cmd_5tuple_filter_dst_port_value,
10839 (void *)&cmd_5tuple_filter_src_port,
10840 (void *)&cmd_5tuple_filter_src_port_value,
10841 (void *)&cmd_5tuple_filter_protocol,
10842 (void *)&cmd_5tuple_filter_protocol_value,
10843 (void *)&cmd_5tuple_filter_mask,
10844 (void *)&cmd_5tuple_filter_mask_value,
10845 (void *)&cmd_5tuple_filter_tcp_flags,
10846 (void *)&cmd_5tuple_filter_tcp_flags_value,
10847 (void *)&cmd_5tuple_filter_priority,
10848 (void *)&cmd_5tuple_filter_priority_value,
10849 (void *)&cmd_5tuple_filter_queue,
10850 (void *)&cmd_5tuple_filter_queue_id,
10855 /* *** ADD/REMOVE A flex FILTER *** */
10856 struct cmd_flex_filter_result {
10857 cmdline_fixed_string_t filter;
10858 cmdline_fixed_string_t ops;
10860 cmdline_fixed_string_t len;
10862 cmdline_fixed_string_t bytes;
10863 cmdline_fixed_string_t bytes_value;
10864 cmdline_fixed_string_t mask;
10865 cmdline_fixed_string_t mask_value;
10866 cmdline_fixed_string_t priority;
10867 uint8_t priority_value;
10868 cmdline_fixed_string_t queue;
10872 static int xdigit2val(unsigned char c)
10877 else if (isupper(c))
10878 val = c - 'A' + 10;
10880 val = c - 'a' + 10;
10885 cmd_flex_filter_parsed(void *parsed_result,
10886 __rte_unused struct cmdline *cl,
10887 __rte_unused void *data)
10890 struct rte_eth_flex_filter filter;
10891 struct cmd_flex_filter_result *res = parsed_result;
10892 char *bytes_ptr, *mask_ptr;
10893 uint16_t len, i, j = 0;
10898 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10899 printf("the len exceed the max length 128\n");
10902 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10903 filter.len = res->len_value;
10904 filter.priority = res->priority_value;
10905 filter.queue = res->queue_id;
10906 bytes_ptr = res->bytes_value;
10907 mask_ptr = res->mask_value;
10909 /* translate bytes string to array. */
10910 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10911 (bytes_ptr[1] == 'X')))
10913 len = strnlen(bytes_ptr, res->len_value * 2);
10914 if (len == 0 || (len % 8 != 0)) {
10915 printf("please check len and bytes input\n");
10918 for (i = 0; i < len; i++) {
10920 if (isxdigit(c) == 0) {
10921 /* invalid characters. */
10922 printf("invalid input\n");
10925 val = xdigit2val(c);
10928 filter.bytes[j] = byte;
10929 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10936 /* translate mask string to uint8_t array. */
10937 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10938 (mask_ptr[1] == 'X')))
10940 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10942 printf("invalid input\n");
10947 for (i = 0; i < len; i++) {
10949 if (isxdigit(c) == 0) {
10950 /* invalid characters. */
10951 printf("invalid input\n");
10954 val = xdigit2val(c);
10957 filter.mask[j] = byte;
10958 printf("mask[%d]:%02x ", j, filter.mask[j]);
10966 if (!strcmp(res->ops, "add"))
10967 ret = rte_eth_dev_filter_ctrl(res->port_id,
10968 RTE_ETH_FILTER_FLEXIBLE,
10969 RTE_ETH_FILTER_ADD,
10972 ret = rte_eth_dev_filter_ctrl(res->port_id,
10973 RTE_ETH_FILTER_FLEXIBLE,
10974 RTE_ETH_FILTER_DELETE,
10978 printf("flex filter setting error: (%s)\n", strerror(-ret));
10981 cmdline_parse_token_string_t cmd_flex_filter_filter =
10982 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10983 filter, "flex_filter");
10984 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10985 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10987 cmdline_parse_token_string_t cmd_flex_filter_ops =
10988 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10990 cmdline_parse_token_string_t cmd_flex_filter_len =
10991 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10993 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10994 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10996 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10997 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10999 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
11000 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11001 bytes_value, NULL);
11002 cmdline_parse_token_string_t cmd_flex_filter_mask =
11003 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11005 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
11006 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11008 cmdline_parse_token_string_t cmd_flex_filter_priority =
11009 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11010 priority, "priority");
11011 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
11012 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11013 priority_value, UINT8);
11014 cmdline_parse_token_string_t cmd_flex_filter_queue =
11015 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11017 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
11018 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11020 cmdline_parse_inst_t cmd_flex_filter = {
11021 .f = cmd_flex_filter_parsed,
11023 .help_str = "flex_filter <port_id> add|del len <value> bytes "
11024 "<value> mask <value> priority <value> queue <queue_id>: "
11025 "Add/Del a flex filter",
11027 (void *)&cmd_flex_filter_filter,
11028 (void *)&cmd_flex_filter_port_id,
11029 (void *)&cmd_flex_filter_ops,
11030 (void *)&cmd_flex_filter_len,
11031 (void *)&cmd_flex_filter_len_value,
11032 (void *)&cmd_flex_filter_bytes,
11033 (void *)&cmd_flex_filter_bytes_value,
11034 (void *)&cmd_flex_filter_mask,
11035 (void *)&cmd_flex_filter_mask_value,
11036 (void *)&cmd_flex_filter_priority,
11037 (void *)&cmd_flex_filter_priority_value,
11038 (void *)&cmd_flex_filter_queue,
11039 (void *)&cmd_flex_filter_queue_id,
11044 /* *** Filters Control *** */
11046 /* *** deal with ethertype filter *** */
11047 struct cmd_ethertype_filter_result {
11048 cmdline_fixed_string_t filter;
11050 cmdline_fixed_string_t ops;
11051 cmdline_fixed_string_t mac;
11052 struct rte_ether_addr mac_addr;
11053 cmdline_fixed_string_t ethertype;
11054 uint16_t ethertype_value;
11055 cmdline_fixed_string_t drop;
11056 cmdline_fixed_string_t queue;
11060 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
11061 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11062 filter, "ethertype_filter");
11063 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
11064 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
11066 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
11067 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11069 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
11070 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11071 mac, "mac_addr#mac_ignr");
11072 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
11073 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
11075 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
11076 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11077 ethertype, "ethertype");
11078 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
11079 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
11080 ethertype_value, UINT16);
11081 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
11082 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11084 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
11085 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11087 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
11088 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
11092 cmd_ethertype_filter_parsed(void *parsed_result,
11093 __rte_unused struct cmdline *cl,
11094 __rte_unused void *data)
11096 struct cmd_ethertype_filter_result *res = parsed_result;
11097 struct rte_eth_ethertype_filter filter;
11100 ret = rte_eth_dev_filter_supported(res->port_id,
11101 RTE_ETH_FILTER_ETHERTYPE);
11103 printf("ethertype filter is not supported on port %u.\n",
11108 memset(&filter, 0, sizeof(filter));
11109 if (!strcmp(res->mac, "mac_addr")) {
11110 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
11111 rte_memcpy(&filter.mac_addr, &res->mac_addr,
11112 sizeof(struct rte_ether_addr));
11114 if (!strcmp(res->drop, "drop"))
11115 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
11116 filter.ether_type = res->ethertype_value;
11117 filter.queue = res->queue_id;
11119 if (!strcmp(res->ops, "add"))
11120 ret = rte_eth_dev_filter_ctrl(res->port_id,
11121 RTE_ETH_FILTER_ETHERTYPE,
11122 RTE_ETH_FILTER_ADD,
11125 ret = rte_eth_dev_filter_ctrl(res->port_id,
11126 RTE_ETH_FILTER_ETHERTYPE,
11127 RTE_ETH_FILTER_DELETE,
11130 printf("ethertype filter programming error: (%s)\n",
11134 cmdline_parse_inst_t cmd_ethertype_filter = {
11135 .f = cmd_ethertype_filter_parsed,
11137 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
11138 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
11139 "Add or delete an ethertype filter entry",
11141 (void *)&cmd_ethertype_filter_filter,
11142 (void *)&cmd_ethertype_filter_port_id,
11143 (void *)&cmd_ethertype_filter_ops,
11144 (void *)&cmd_ethertype_filter_mac,
11145 (void *)&cmd_ethertype_filter_mac_addr,
11146 (void *)&cmd_ethertype_filter_ethertype,
11147 (void *)&cmd_ethertype_filter_ethertype_value,
11148 (void *)&cmd_ethertype_filter_drop,
11149 (void *)&cmd_ethertype_filter_queue,
11150 (void *)&cmd_ethertype_filter_queue_id,
11155 /* *** deal with flow director filter *** */
11156 struct cmd_flow_director_result {
11157 cmdline_fixed_string_t flow_director_filter;
11159 cmdline_fixed_string_t mode;
11160 cmdline_fixed_string_t mode_value;
11161 cmdline_fixed_string_t ops;
11162 cmdline_fixed_string_t flow;
11163 cmdline_fixed_string_t flow_type;
11164 cmdline_fixed_string_t ether;
11165 uint16_t ether_type;
11166 cmdline_fixed_string_t src;
11167 cmdline_ipaddr_t ip_src;
11169 cmdline_fixed_string_t dst;
11170 cmdline_ipaddr_t ip_dst;
11172 cmdline_fixed_string_t verify_tag;
11173 uint32_t verify_tag_value;
11174 cmdline_fixed_string_t tos;
11176 cmdline_fixed_string_t proto;
11177 uint8_t proto_value;
11178 cmdline_fixed_string_t ttl;
11180 cmdline_fixed_string_t vlan;
11181 uint16_t vlan_value;
11182 cmdline_fixed_string_t flexbytes;
11183 cmdline_fixed_string_t flexbytes_value;
11184 cmdline_fixed_string_t pf_vf;
11185 cmdline_fixed_string_t drop;
11186 cmdline_fixed_string_t queue;
11188 cmdline_fixed_string_t fd_id;
11189 uint32_t fd_id_value;
11190 cmdline_fixed_string_t mac;
11191 struct rte_ether_addr mac_addr;
11192 cmdline_fixed_string_t tunnel;
11193 cmdline_fixed_string_t tunnel_type;
11194 cmdline_fixed_string_t tunnel_id;
11195 uint32_t tunnel_id_value;
11196 cmdline_fixed_string_t packet;
11201 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
11204 const char *p, *p0 = q_arg;
11206 unsigned long int_fld;
11207 char *str_fld[max_num];
11212 p = strchr(p0, '(');
11216 p0 = strchr(p, ')');
11221 if (size >= sizeof(s))
11224 snprintf(s, sizeof(s), "%.*s", size, p);
11225 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11226 if (ret < 0 || ret > max_num)
11228 for (i = 0; i < ret; i++) {
11230 int_fld = strtoul(str_fld[i], &end, 0);
11231 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
11233 flexbytes[i] = (uint8_t)int_fld;
11239 str2flowtype(char *string)
11242 static const struct {
11245 } flowtype_str[] = {
11246 {"raw", RTE_ETH_FLOW_RAW},
11247 {"ipv4", RTE_ETH_FLOW_IPV4},
11248 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11249 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11250 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11251 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11252 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11253 {"ipv6", RTE_ETH_FLOW_IPV6},
11254 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11255 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11256 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11257 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11258 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11259 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11262 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
11263 if (!strcmp(flowtype_str[i].str, string))
11264 return flowtype_str[i].type;
11267 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
11268 return (uint16_t)atoi(string);
11270 return RTE_ETH_FLOW_UNKNOWN;
11273 static enum rte_eth_fdir_tunnel_type
11274 str2fdir_tunneltype(char *string)
11278 static const struct {
11280 enum rte_eth_fdir_tunnel_type type;
11281 } tunneltype_str[] = {
11282 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
11283 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
11286 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
11287 if (!strcmp(tunneltype_str[i].str, string))
11288 return tunneltype_str[i].type;
11290 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
11293 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
11295 if ((ip_addr).family == AF_INET) \
11296 (ip) = (ip_addr).addr.ipv4.s_addr; \
11298 printf("invalid parameter.\n"); \
11303 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
11305 if ((ip_addr).family == AF_INET6) \
11306 rte_memcpy(&(ip), \
11307 &((ip_addr).addr.ipv6), \
11308 sizeof(struct in6_addr)); \
11310 printf("invalid parameter.\n"); \
11316 cmd_flow_director_filter_parsed(void *parsed_result,
11317 __rte_unused struct cmdline *cl,
11318 __rte_unused void *data)
11320 struct cmd_flow_director_result *res = parsed_result;
11321 struct rte_eth_fdir_filter entry;
11322 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11324 unsigned long vf_id;
11327 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11329 printf("flow director is not supported on port %u.\n",
11333 memset(flexbytes, 0, sizeof(flexbytes));
11334 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11336 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11337 if (strcmp(res->mode_value, "MAC-VLAN")) {
11338 printf("Please set mode to MAC-VLAN.\n");
11341 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11342 if (strcmp(res->mode_value, "Tunnel")) {
11343 printf("Please set mode to Tunnel.\n");
11347 if (!strcmp(res->mode_value, "raw")) {
11348 #ifdef RTE_LIBRTE_I40E_PMD
11349 struct rte_pmd_i40e_flow_type_mapping
11350 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11351 struct rte_pmd_i40e_pkt_template_conf conf;
11352 uint16_t flow_type = str2flowtype(res->flow_type);
11353 uint16_t i, port = res->port_id;
11356 memset(&conf, 0, sizeof(conf));
11358 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11359 printf("Invalid flow type specified.\n");
11362 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11366 if (mapping[flow_type].pctype == 0ULL) {
11367 printf("Invalid flow type specified.\n");
11370 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11371 if (mapping[flow_type].pctype & (1ULL << i)) {
11372 conf.input.pctype = i;
11377 conf.input.packet = open_file(res->filepath,
11378 &conf.input.length);
11379 if (!conf.input.packet)
11381 if (!strcmp(res->drop, "drop"))
11382 conf.action.behavior =
11383 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11385 conf.action.behavior =
11386 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11387 conf.action.report_status =
11388 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11389 conf.action.rx_queue = res->queue_id;
11390 conf.soft_id = res->fd_id_value;
11391 add = strcmp(res->ops, "del") ? 1 : 0;
11392 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11396 printf("flow director config error: (%s)\n",
11398 close_file(conf.input.packet);
11401 } else if (strcmp(res->mode_value, "IP")) {
11402 printf("Please set mode to IP or raw.\n");
11405 entry.input.flow_type = str2flowtype(res->flow_type);
11408 ret = parse_flexbytes(res->flexbytes_value,
11410 RTE_ETH_FDIR_MAX_FLEXLEN);
11412 printf("error: Cannot parse flexbytes input.\n");
11416 switch (entry.input.flow_type) {
11417 case RTE_ETH_FLOW_FRAG_IPV4:
11418 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11419 entry.input.flow.ip4_flow.proto = res->proto_value;
11421 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11422 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11423 IPV4_ADDR_TO_UINT(res->ip_dst,
11424 entry.input.flow.ip4_flow.dst_ip);
11425 IPV4_ADDR_TO_UINT(res->ip_src,
11426 entry.input.flow.ip4_flow.src_ip);
11427 entry.input.flow.ip4_flow.tos = res->tos_value;
11428 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11429 /* need convert to big endian. */
11430 entry.input.flow.udp4_flow.dst_port =
11431 rte_cpu_to_be_16(res->port_dst);
11432 entry.input.flow.udp4_flow.src_port =
11433 rte_cpu_to_be_16(res->port_src);
11435 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11436 IPV4_ADDR_TO_UINT(res->ip_dst,
11437 entry.input.flow.sctp4_flow.ip.dst_ip);
11438 IPV4_ADDR_TO_UINT(res->ip_src,
11439 entry.input.flow.sctp4_flow.ip.src_ip);
11440 entry.input.flow.ip4_flow.tos = res->tos_value;
11441 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11442 /* need convert to big endian. */
11443 entry.input.flow.sctp4_flow.dst_port =
11444 rte_cpu_to_be_16(res->port_dst);
11445 entry.input.flow.sctp4_flow.src_port =
11446 rte_cpu_to_be_16(res->port_src);
11447 entry.input.flow.sctp4_flow.verify_tag =
11448 rte_cpu_to_be_32(res->verify_tag_value);
11450 case RTE_ETH_FLOW_FRAG_IPV6:
11451 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11452 entry.input.flow.ipv6_flow.proto = res->proto_value;
11454 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11455 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11456 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11457 entry.input.flow.ipv6_flow.dst_ip);
11458 IPV6_ADDR_TO_ARRAY(res->ip_src,
11459 entry.input.flow.ipv6_flow.src_ip);
11460 entry.input.flow.ipv6_flow.tc = res->tos_value;
11461 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11462 /* need convert to big endian. */
11463 entry.input.flow.udp6_flow.dst_port =
11464 rte_cpu_to_be_16(res->port_dst);
11465 entry.input.flow.udp6_flow.src_port =
11466 rte_cpu_to_be_16(res->port_src);
11468 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11469 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11470 entry.input.flow.sctp6_flow.ip.dst_ip);
11471 IPV6_ADDR_TO_ARRAY(res->ip_src,
11472 entry.input.flow.sctp6_flow.ip.src_ip);
11473 entry.input.flow.ipv6_flow.tc = res->tos_value;
11474 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11475 /* need convert to big endian. */
11476 entry.input.flow.sctp6_flow.dst_port =
11477 rte_cpu_to_be_16(res->port_dst);
11478 entry.input.flow.sctp6_flow.src_port =
11479 rte_cpu_to_be_16(res->port_src);
11480 entry.input.flow.sctp6_flow.verify_tag =
11481 rte_cpu_to_be_32(res->verify_tag_value);
11483 case RTE_ETH_FLOW_L2_PAYLOAD:
11484 entry.input.flow.l2_flow.ether_type =
11485 rte_cpu_to_be_16(res->ether_type);
11491 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11492 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11494 sizeof(struct rte_ether_addr));
11496 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11497 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11499 sizeof(struct rte_ether_addr));
11500 entry.input.flow.tunnel_flow.tunnel_type =
11501 str2fdir_tunneltype(res->tunnel_type);
11502 entry.input.flow.tunnel_flow.tunnel_id =
11503 rte_cpu_to_be_32(res->tunnel_id_value);
11506 rte_memcpy(entry.input.flow_ext.flexbytes,
11508 RTE_ETH_FDIR_MAX_FLEXLEN);
11510 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11512 entry.action.flex_off = 0; /*use 0 by default */
11513 if (!strcmp(res->drop, "drop"))
11514 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11516 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11518 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11519 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11520 if (!strcmp(res->pf_vf, "pf"))
11521 entry.input.flow_ext.is_vf = 0;
11522 else if (!strncmp(res->pf_vf, "vf", 2)) {
11523 struct rte_eth_dev_info dev_info;
11525 ret = eth_dev_info_get_print_err(res->port_id,
11531 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11532 if (errno != 0 || *end != '\0' ||
11533 vf_id >= dev_info.max_vfs) {
11534 printf("invalid parameter %s.\n", res->pf_vf);
11537 entry.input.flow_ext.is_vf = 1;
11538 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11540 printf("invalid parameter %s.\n", res->pf_vf);
11545 /* set to report FD ID by default */
11546 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11547 entry.action.rx_queue = res->queue_id;
11548 entry.soft_id = res->fd_id_value;
11549 if (!strcmp(res->ops, "add"))
11550 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11551 RTE_ETH_FILTER_ADD, &entry);
11552 else if (!strcmp(res->ops, "del"))
11553 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11554 RTE_ETH_FILTER_DELETE, &entry);
11556 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11557 RTE_ETH_FILTER_UPDATE, &entry);
11559 printf("flow director programming error: (%s)\n",
11563 cmdline_parse_token_string_t cmd_flow_director_filter =
11564 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11565 flow_director_filter, "flow_director_filter");
11566 cmdline_parse_token_num_t cmd_flow_director_port_id =
11567 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11569 cmdline_parse_token_string_t cmd_flow_director_ops =
11570 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11571 ops, "add#del#update");
11572 cmdline_parse_token_string_t cmd_flow_director_flow =
11573 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11575 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11576 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11578 cmdline_parse_token_string_t cmd_flow_director_ether =
11579 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11581 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11582 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11583 ether_type, UINT16);
11584 cmdline_parse_token_string_t cmd_flow_director_src =
11585 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11587 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11588 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11590 cmdline_parse_token_num_t cmd_flow_director_port_src =
11591 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11593 cmdline_parse_token_string_t cmd_flow_director_dst =
11594 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11596 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11597 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11599 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11600 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11602 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11603 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11604 verify_tag, "verify_tag");
11605 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11606 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11607 verify_tag_value, UINT32);
11608 cmdline_parse_token_string_t cmd_flow_director_tos =
11609 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11611 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11612 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11614 cmdline_parse_token_string_t cmd_flow_director_proto =
11615 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11617 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11618 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11619 proto_value, UINT8);
11620 cmdline_parse_token_string_t cmd_flow_director_ttl =
11621 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11623 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11624 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11626 cmdline_parse_token_string_t cmd_flow_director_vlan =
11627 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11629 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11630 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11631 vlan_value, UINT16);
11632 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11633 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11634 flexbytes, "flexbytes");
11635 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11636 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11637 flexbytes_value, NULL);
11638 cmdline_parse_token_string_t cmd_flow_director_drop =
11639 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11641 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11642 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11644 cmdline_parse_token_string_t cmd_flow_director_queue =
11645 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11647 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11648 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11650 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11651 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11653 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11654 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11655 fd_id_value, UINT32);
11657 cmdline_parse_token_string_t cmd_flow_director_mode =
11658 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11660 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11661 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11663 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11664 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11665 mode_value, "MAC-VLAN");
11666 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11667 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11668 mode_value, "Tunnel");
11669 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11670 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11671 mode_value, "raw");
11672 cmdline_parse_token_string_t cmd_flow_director_mac =
11673 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11675 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11676 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11678 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11679 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11681 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11682 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11683 tunnel_type, "NVGRE#VxLAN");
11684 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11685 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11686 tunnel_id, "tunnel-id");
11687 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11688 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11689 tunnel_id_value, UINT32);
11690 cmdline_parse_token_string_t cmd_flow_director_packet =
11691 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11693 cmdline_parse_token_string_t cmd_flow_director_filepath =
11694 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11697 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11698 .f = cmd_flow_director_filter_parsed,
11700 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11701 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11702 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11703 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11704 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11705 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11706 "fd_id <fd_id_value>: "
11707 "Add or delete an ip flow 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_dst,
11719 (void *)&cmd_flow_director_ip_dst,
11720 (void *)&cmd_flow_director_tos,
11721 (void *)&cmd_flow_director_tos_value,
11722 (void *)&cmd_flow_director_proto,
11723 (void *)&cmd_flow_director_proto_value,
11724 (void *)&cmd_flow_director_ttl,
11725 (void *)&cmd_flow_director_ttl_value,
11726 (void *)&cmd_flow_director_vlan,
11727 (void *)&cmd_flow_director_vlan_value,
11728 (void *)&cmd_flow_director_flexbytes,
11729 (void *)&cmd_flow_director_flexbytes_value,
11730 (void *)&cmd_flow_director_drop,
11731 (void *)&cmd_flow_director_pf_vf,
11732 (void *)&cmd_flow_director_queue,
11733 (void *)&cmd_flow_director_queue_id,
11734 (void *)&cmd_flow_director_fd_id,
11735 (void *)&cmd_flow_director_fd_id_value,
11740 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11741 .f = cmd_flow_director_filter_parsed,
11743 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11744 "director entry on NIC",
11746 (void *)&cmd_flow_director_filter,
11747 (void *)&cmd_flow_director_port_id,
11748 (void *)&cmd_flow_director_mode,
11749 (void *)&cmd_flow_director_mode_ip,
11750 (void *)&cmd_flow_director_ops,
11751 (void *)&cmd_flow_director_flow,
11752 (void *)&cmd_flow_director_flow_type,
11753 (void *)&cmd_flow_director_src,
11754 (void *)&cmd_flow_director_ip_src,
11755 (void *)&cmd_flow_director_port_src,
11756 (void *)&cmd_flow_director_dst,
11757 (void *)&cmd_flow_director_ip_dst,
11758 (void *)&cmd_flow_director_port_dst,
11759 (void *)&cmd_flow_director_tos,
11760 (void *)&cmd_flow_director_tos_value,
11761 (void *)&cmd_flow_director_ttl,
11762 (void *)&cmd_flow_director_ttl_value,
11763 (void *)&cmd_flow_director_vlan,
11764 (void *)&cmd_flow_director_vlan_value,
11765 (void *)&cmd_flow_director_flexbytes,
11766 (void *)&cmd_flow_director_flexbytes_value,
11767 (void *)&cmd_flow_director_drop,
11768 (void *)&cmd_flow_director_pf_vf,
11769 (void *)&cmd_flow_director_queue,
11770 (void *)&cmd_flow_director_queue_id,
11771 (void *)&cmd_flow_director_fd_id,
11772 (void *)&cmd_flow_director_fd_id_value,
11777 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11778 .f = cmd_flow_director_filter_parsed,
11780 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11781 "director entry on NIC",
11783 (void *)&cmd_flow_director_filter,
11784 (void *)&cmd_flow_director_port_id,
11785 (void *)&cmd_flow_director_mode,
11786 (void *)&cmd_flow_director_mode_ip,
11787 (void *)&cmd_flow_director_ops,
11788 (void *)&cmd_flow_director_flow,
11789 (void *)&cmd_flow_director_flow_type,
11790 (void *)&cmd_flow_director_src,
11791 (void *)&cmd_flow_director_ip_src,
11792 (void *)&cmd_flow_director_port_src,
11793 (void *)&cmd_flow_director_dst,
11794 (void *)&cmd_flow_director_ip_dst,
11795 (void *)&cmd_flow_director_port_dst,
11796 (void *)&cmd_flow_director_verify_tag,
11797 (void *)&cmd_flow_director_verify_tag_value,
11798 (void *)&cmd_flow_director_tos,
11799 (void *)&cmd_flow_director_tos_value,
11800 (void *)&cmd_flow_director_ttl,
11801 (void *)&cmd_flow_director_ttl_value,
11802 (void *)&cmd_flow_director_vlan,
11803 (void *)&cmd_flow_director_vlan_value,
11804 (void *)&cmd_flow_director_flexbytes,
11805 (void *)&cmd_flow_director_flexbytes_value,
11806 (void *)&cmd_flow_director_drop,
11807 (void *)&cmd_flow_director_pf_vf,
11808 (void *)&cmd_flow_director_queue,
11809 (void *)&cmd_flow_director_queue_id,
11810 (void *)&cmd_flow_director_fd_id,
11811 (void *)&cmd_flow_director_fd_id_value,
11816 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11817 .f = cmd_flow_director_filter_parsed,
11819 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11820 "director entry on NIC",
11822 (void *)&cmd_flow_director_filter,
11823 (void *)&cmd_flow_director_port_id,
11824 (void *)&cmd_flow_director_mode,
11825 (void *)&cmd_flow_director_mode_ip,
11826 (void *)&cmd_flow_director_ops,
11827 (void *)&cmd_flow_director_flow,
11828 (void *)&cmd_flow_director_flow_type,
11829 (void *)&cmd_flow_director_ether,
11830 (void *)&cmd_flow_director_ether_type,
11831 (void *)&cmd_flow_director_flexbytes,
11832 (void *)&cmd_flow_director_flexbytes_value,
11833 (void *)&cmd_flow_director_drop,
11834 (void *)&cmd_flow_director_pf_vf,
11835 (void *)&cmd_flow_director_queue,
11836 (void *)&cmd_flow_director_queue_id,
11837 (void *)&cmd_flow_director_fd_id,
11838 (void *)&cmd_flow_director_fd_id_value,
11843 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11844 .f = cmd_flow_director_filter_parsed,
11846 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11847 "director entry on NIC",
11849 (void *)&cmd_flow_director_filter,
11850 (void *)&cmd_flow_director_port_id,
11851 (void *)&cmd_flow_director_mode,
11852 (void *)&cmd_flow_director_mode_mac_vlan,
11853 (void *)&cmd_flow_director_ops,
11854 (void *)&cmd_flow_director_mac,
11855 (void *)&cmd_flow_director_mac_addr,
11856 (void *)&cmd_flow_director_vlan,
11857 (void *)&cmd_flow_director_vlan_value,
11858 (void *)&cmd_flow_director_flexbytes,
11859 (void *)&cmd_flow_director_flexbytes_value,
11860 (void *)&cmd_flow_director_drop,
11861 (void *)&cmd_flow_director_queue,
11862 (void *)&cmd_flow_director_queue_id,
11863 (void *)&cmd_flow_director_fd_id,
11864 (void *)&cmd_flow_director_fd_id_value,
11869 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11870 .f = cmd_flow_director_filter_parsed,
11872 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11873 "director entry on NIC",
11875 (void *)&cmd_flow_director_filter,
11876 (void *)&cmd_flow_director_port_id,
11877 (void *)&cmd_flow_director_mode,
11878 (void *)&cmd_flow_director_mode_tunnel,
11879 (void *)&cmd_flow_director_ops,
11880 (void *)&cmd_flow_director_mac,
11881 (void *)&cmd_flow_director_mac_addr,
11882 (void *)&cmd_flow_director_vlan,
11883 (void *)&cmd_flow_director_vlan_value,
11884 (void *)&cmd_flow_director_tunnel,
11885 (void *)&cmd_flow_director_tunnel_type,
11886 (void *)&cmd_flow_director_tunnel_id,
11887 (void *)&cmd_flow_director_tunnel_id_value,
11888 (void *)&cmd_flow_director_flexbytes,
11889 (void *)&cmd_flow_director_flexbytes_value,
11890 (void *)&cmd_flow_director_drop,
11891 (void *)&cmd_flow_director_queue,
11892 (void *)&cmd_flow_director_queue_id,
11893 (void *)&cmd_flow_director_fd_id,
11894 (void *)&cmd_flow_director_fd_id_value,
11899 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11900 .f = cmd_flow_director_filter_parsed,
11902 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11903 "director entry on NIC",
11905 (void *)&cmd_flow_director_filter,
11906 (void *)&cmd_flow_director_port_id,
11907 (void *)&cmd_flow_director_mode,
11908 (void *)&cmd_flow_director_mode_raw,
11909 (void *)&cmd_flow_director_ops,
11910 (void *)&cmd_flow_director_flow,
11911 (void *)&cmd_flow_director_flow_type,
11912 (void *)&cmd_flow_director_drop,
11913 (void *)&cmd_flow_director_queue,
11914 (void *)&cmd_flow_director_queue_id,
11915 (void *)&cmd_flow_director_fd_id,
11916 (void *)&cmd_flow_director_fd_id_value,
11917 (void *)&cmd_flow_director_packet,
11918 (void *)&cmd_flow_director_filepath,
11923 struct cmd_flush_flow_director_result {
11924 cmdline_fixed_string_t flush_flow_director;
11928 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11929 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11930 flush_flow_director, "flush_flow_director");
11931 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11932 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11936 cmd_flush_flow_director_parsed(void *parsed_result,
11937 __rte_unused struct cmdline *cl,
11938 __rte_unused void *data)
11940 struct cmd_flow_director_result *res = parsed_result;
11943 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11945 printf("flow director is not supported on port %u.\n",
11950 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11951 RTE_ETH_FILTER_FLUSH, NULL);
11953 printf("flow director table flushing error: (%s)\n",
11957 cmdline_parse_inst_t cmd_flush_flow_director = {
11958 .f = cmd_flush_flow_director_parsed,
11960 .help_str = "flush_flow_director <port_id>: "
11961 "Flush all flow director entries of a device on NIC",
11963 (void *)&cmd_flush_flow_director_flush,
11964 (void *)&cmd_flush_flow_director_port_id,
11969 /* *** deal with flow director mask *** */
11970 struct cmd_flow_director_mask_result {
11971 cmdline_fixed_string_t flow_director_mask;
11973 cmdline_fixed_string_t mode;
11974 cmdline_fixed_string_t mode_value;
11975 cmdline_fixed_string_t vlan;
11976 uint16_t vlan_mask;
11977 cmdline_fixed_string_t src_mask;
11978 cmdline_ipaddr_t ipv4_src;
11979 cmdline_ipaddr_t ipv6_src;
11981 cmdline_fixed_string_t dst_mask;
11982 cmdline_ipaddr_t ipv4_dst;
11983 cmdline_ipaddr_t ipv6_dst;
11985 cmdline_fixed_string_t mac;
11986 uint8_t mac_addr_byte_mask;
11987 cmdline_fixed_string_t tunnel_id;
11988 uint32_t tunnel_id_mask;
11989 cmdline_fixed_string_t tunnel_type;
11990 uint8_t tunnel_type_mask;
11994 cmd_flow_director_mask_parsed(void *parsed_result,
11995 __rte_unused struct cmdline *cl,
11996 __rte_unused void *data)
11998 struct cmd_flow_director_mask_result *res = parsed_result;
11999 struct rte_eth_fdir_masks *mask;
12000 struct rte_port *port;
12002 port = &ports[res->port_id];
12003 /** Check if the port is not started **/
12004 if (port->port_status != RTE_PORT_STOPPED) {
12005 printf("Please stop port %d first\n", res->port_id);
12009 mask = &port->dev_conf.fdir_conf.mask;
12011 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
12012 if (strcmp(res->mode_value, "MAC-VLAN")) {
12013 printf("Please set mode to MAC-VLAN.\n");
12017 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
12018 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
12019 if (strcmp(res->mode_value, "Tunnel")) {
12020 printf("Please set mode to Tunnel.\n");
12024 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
12025 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
12026 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
12027 mask->tunnel_type_mask = res->tunnel_type_mask;
12029 if (strcmp(res->mode_value, "IP")) {
12030 printf("Please set mode to IP.\n");
12034 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
12035 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
12036 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
12037 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
12038 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
12039 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
12040 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
12043 cmd_reconfig_device_queue(res->port_id, 1, 1);
12046 cmdline_parse_token_string_t cmd_flow_director_mask =
12047 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12048 flow_director_mask, "flow_director_mask");
12049 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
12050 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12052 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
12053 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12055 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
12056 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12057 vlan_mask, UINT16);
12058 cmdline_parse_token_string_t cmd_flow_director_mask_src =
12059 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12060 src_mask, "src_mask");
12061 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
12062 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12064 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
12065 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12067 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
12068 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12070 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
12071 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12072 dst_mask, "dst_mask");
12073 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
12074 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12076 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
12077 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12079 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
12080 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12083 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
12084 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12086 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
12087 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12089 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
12090 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12091 mode_value, "MAC-VLAN");
12092 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
12093 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12094 mode_value, "Tunnel");
12095 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
12096 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12098 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
12099 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12100 mac_addr_byte_mask, UINT8);
12101 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
12102 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12103 tunnel_type, "tunnel-type");
12104 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
12105 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12106 tunnel_type_mask, UINT8);
12107 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
12108 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12109 tunnel_id, "tunnel-id");
12110 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
12111 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12112 tunnel_id_mask, UINT32);
12114 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
12115 .f = cmd_flow_director_mask_parsed,
12117 .help_str = "flow_director_mask ... : "
12118 "Set IP mode flow director's mask on NIC",
12120 (void *)&cmd_flow_director_mask,
12121 (void *)&cmd_flow_director_mask_port_id,
12122 (void *)&cmd_flow_director_mask_mode,
12123 (void *)&cmd_flow_director_mask_mode_ip,
12124 (void *)&cmd_flow_director_mask_vlan,
12125 (void *)&cmd_flow_director_mask_vlan_value,
12126 (void *)&cmd_flow_director_mask_src,
12127 (void *)&cmd_flow_director_mask_ipv4_src,
12128 (void *)&cmd_flow_director_mask_ipv6_src,
12129 (void *)&cmd_flow_director_mask_port_src,
12130 (void *)&cmd_flow_director_mask_dst,
12131 (void *)&cmd_flow_director_mask_ipv4_dst,
12132 (void *)&cmd_flow_director_mask_ipv6_dst,
12133 (void *)&cmd_flow_director_mask_port_dst,
12138 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
12139 .f = cmd_flow_director_mask_parsed,
12141 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
12142 "flow director's mask on NIC",
12144 (void *)&cmd_flow_director_mask,
12145 (void *)&cmd_flow_director_mask_port_id,
12146 (void *)&cmd_flow_director_mask_mode,
12147 (void *)&cmd_flow_director_mask_mode_mac_vlan,
12148 (void *)&cmd_flow_director_mask_vlan,
12149 (void *)&cmd_flow_director_mask_vlan_value,
12154 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
12155 .f = cmd_flow_director_mask_parsed,
12157 .help_str = "flow_director_mask ... : Set tunnel mode "
12158 "flow director's mask on NIC",
12160 (void *)&cmd_flow_director_mask,
12161 (void *)&cmd_flow_director_mask_port_id,
12162 (void *)&cmd_flow_director_mask_mode,
12163 (void *)&cmd_flow_director_mask_mode_tunnel,
12164 (void *)&cmd_flow_director_mask_vlan,
12165 (void *)&cmd_flow_director_mask_vlan_value,
12166 (void *)&cmd_flow_director_mask_mac,
12167 (void *)&cmd_flow_director_mask_mac_value,
12168 (void *)&cmd_flow_director_mask_tunnel_type,
12169 (void *)&cmd_flow_director_mask_tunnel_type_value,
12170 (void *)&cmd_flow_director_mask_tunnel_id,
12171 (void *)&cmd_flow_director_mask_tunnel_id_value,
12176 /* *** deal with flow director mask on flexible payload *** */
12177 struct cmd_flow_director_flex_mask_result {
12178 cmdline_fixed_string_t flow_director_flexmask;
12180 cmdline_fixed_string_t flow;
12181 cmdline_fixed_string_t flow_type;
12182 cmdline_fixed_string_t mask;
12186 cmd_flow_director_flex_mask_parsed(void *parsed_result,
12187 __rte_unused struct cmdline *cl,
12188 __rte_unused void *data)
12190 struct cmd_flow_director_flex_mask_result *res = parsed_result;
12191 struct rte_eth_fdir_info fdir_info;
12192 struct rte_eth_fdir_flex_mask flex_mask;
12193 struct rte_port *port;
12194 uint64_t flow_type_mask;
12198 port = &ports[res->port_id];
12199 /** Check if the port is not started **/
12200 if (port->port_status != RTE_PORT_STOPPED) {
12201 printf("Please stop port %d first\n", res->port_id);
12205 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
12206 ret = parse_flexbytes(res->mask,
12208 RTE_ETH_FDIR_MAX_FLEXLEN);
12210 printf("error: Cannot parse mask input.\n");
12214 memset(&fdir_info, 0, sizeof(fdir_info));
12215 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12216 RTE_ETH_FILTER_INFO, &fdir_info);
12218 printf("Cannot get FDir filter info\n");
12222 if (!strcmp(res->flow_type, "none")) {
12223 /* means don't specify the flow type */
12224 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
12225 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
12226 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
12227 0, sizeof(struct rte_eth_fdir_flex_mask));
12228 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
12229 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
12231 sizeof(struct rte_eth_fdir_flex_mask));
12232 cmd_reconfig_device_queue(res->port_id, 1, 1);
12235 flow_type_mask = fdir_info.flow_types_mask[0];
12236 if (!strcmp(res->flow_type, "all")) {
12237 if (!flow_type_mask) {
12238 printf("No flow type supported\n");
12241 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
12242 if (flow_type_mask & (1ULL << i)) {
12243 flex_mask.flow_type = i;
12244 fdir_set_flex_mask(res->port_id, &flex_mask);
12247 cmd_reconfig_device_queue(res->port_id, 1, 1);
12250 flex_mask.flow_type = str2flowtype(res->flow_type);
12251 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
12252 printf("Flow type %s not supported on port %d\n",
12253 res->flow_type, res->port_id);
12256 fdir_set_flex_mask(res->port_id, &flex_mask);
12257 cmd_reconfig_device_queue(res->port_id, 1, 1);
12260 cmdline_parse_token_string_t cmd_flow_director_flexmask =
12261 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12262 flow_director_flexmask,
12263 "flow_director_flex_mask");
12264 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
12265 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12267 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
12268 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12270 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
12271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12272 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
12273 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
12274 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
12275 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12278 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
12279 .f = cmd_flow_director_flex_mask_parsed,
12281 .help_str = "flow_director_flex_mask ... : "
12282 "Set flow director's flex mask on NIC",
12284 (void *)&cmd_flow_director_flexmask,
12285 (void *)&cmd_flow_director_flexmask_port_id,
12286 (void *)&cmd_flow_director_flexmask_flow,
12287 (void *)&cmd_flow_director_flexmask_flow_type,
12288 (void *)&cmd_flow_director_flexmask_mask,
12293 /* *** deal with flow director flexible payload configuration *** */
12294 struct cmd_flow_director_flexpayload_result {
12295 cmdline_fixed_string_t flow_director_flexpayload;
12297 cmdline_fixed_string_t payload_layer;
12298 cmdline_fixed_string_t payload_cfg;
12302 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
12305 const char *p, *p0 = q_arg;
12307 unsigned long int_fld;
12308 char *str_fld[max_num];
12313 p = strchr(p0, '(');
12317 p0 = strchr(p, ')');
12322 if (size >= sizeof(s))
12325 snprintf(s, sizeof(s), "%.*s", size, p);
12326 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12327 if (ret < 0 || ret > max_num)
12329 for (i = 0; i < ret; i++) {
12331 int_fld = strtoul(str_fld[i], &end, 0);
12332 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12334 offsets[i] = (uint16_t)int_fld;
12340 cmd_flow_director_flxpld_parsed(void *parsed_result,
12341 __rte_unused struct cmdline *cl,
12342 __rte_unused void *data)
12344 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12345 struct rte_eth_flex_payload_cfg flex_cfg;
12346 struct rte_port *port;
12349 port = &ports[res->port_id];
12350 /** Check if the port is not started **/
12351 if (port->port_status != RTE_PORT_STOPPED) {
12352 printf("Please stop port %d first\n", res->port_id);
12356 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12358 if (!strcmp(res->payload_layer, "raw"))
12359 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12360 else if (!strcmp(res->payload_layer, "l2"))
12361 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12362 else if (!strcmp(res->payload_layer, "l3"))
12363 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12364 else if (!strcmp(res->payload_layer, "l4"))
12365 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12367 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12368 RTE_ETH_FDIR_MAX_FLEXLEN);
12370 printf("error: Cannot parse flex payload input.\n");
12374 fdir_set_flex_payload(res->port_id, &flex_cfg);
12375 cmd_reconfig_device_queue(res->port_id, 1, 1);
12378 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12379 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12380 flow_director_flexpayload,
12381 "flow_director_flex_payload");
12382 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12383 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12385 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12386 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12387 payload_layer, "raw#l2#l3#l4");
12388 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12389 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12390 payload_cfg, NULL);
12392 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12393 .f = cmd_flow_director_flxpld_parsed,
12395 .help_str = "flow_director_flexpayload ... : "
12396 "Set flow director's flex payload on NIC",
12398 (void *)&cmd_flow_director_flexpayload,
12399 (void *)&cmd_flow_director_flexpayload_port_id,
12400 (void *)&cmd_flow_director_flexpayload_payload_layer,
12401 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12406 /* Generic flow interface command. */
12407 extern cmdline_parse_inst_t cmd_flow;
12409 /* *** Classification Filters Control *** */
12410 /* *** Get symmetric hash enable per port *** */
12411 struct cmd_get_sym_hash_ena_per_port_result {
12412 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12417 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12418 __rte_unused struct cmdline *cl,
12419 __rte_unused void *data)
12421 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12422 struct rte_eth_hash_filter_info info;
12425 if (rte_eth_dev_filter_supported(res->port_id,
12426 RTE_ETH_FILTER_HASH) < 0) {
12427 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12432 memset(&info, 0, sizeof(info));
12433 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12434 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12435 RTE_ETH_FILTER_GET, &info);
12438 printf("Cannot get symmetric hash enable per port "
12439 "on port %u\n", res->port_id);
12443 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12444 "enabled" : "disabled", res->port_id);
12447 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12448 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12449 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12450 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12451 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12454 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12455 .f = cmd_get_sym_hash_per_port_parsed,
12457 .help_str = "get_sym_hash_ena_per_port <port_id>",
12459 (void *)&cmd_get_sym_hash_ena_per_port_all,
12460 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12465 /* *** Set symmetric hash enable per port *** */
12466 struct cmd_set_sym_hash_ena_per_port_result {
12467 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12468 cmdline_fixed_string_t enable;
12473 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12474 __rte_unused struct cmdline *cl,
12475 __rte_unused void *data)
12477 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12478 struct rte_eth_hash_filter_info info;
12481 if (rte_eth_dev_filter_supported(res->port_id,
12482 RTE_ETH_FILTER_HASH) < 0) {
12483 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12488 memset(&info, 0, sizeof(info));
12489 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12490 if (!strcmp(res->enable, "enable"))
12491 info.info.enable = 1;
12492 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12493 RTE_ETH_FILTER_SET, &info);
12495 printf("Cannot set symmetric hash enable per port on "
12496 "port %u\n", res->port_id);
12499 printf("Symmetric hash has been set to %s on port %u\n",
12500 res->enable, res->port_id);
12503 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12504 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12505 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12506 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12507 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12509 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12510 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12511 enable, "enable#disable");
12513 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12514 .f = cmd_set_sym_hash_per_port_parsed,
12516 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12518 (void *)&cmd_set_sym_hash_ena_per_port_all,
12519 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12520 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12525 /* Get global config of hash function */
12526 struct cmd_get_hash_global_config_result {
12527 cmdline_fixed_string_t get_hash_global_config;
12532 flowtype_to_str(uint16_t ftype)
12538 } ftype_table[] = {
12539 {"ipv4", RTE_ETH_FLOW_IPV4},
12540 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12541 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12542 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12543 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12544 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12545 {"ipv6", RTE_ETH_FLOW_IPV6},
12546 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12547 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12548 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12549 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12550 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12551 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12552 {"port", RTE_ETH_FLOW_PORT},
12553 {"vxlan", RTE_ETH_FLOW_VXLAN},
12554 {"geneve", RTE_ETH_FLOW_GENEVE},
12555 {"nvgre", RTE_ETH_FLOW_NVGRE},
12556 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12559 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12560 if (ftype_table[i].ftype == ftype)
12561 return ftype_table[i].str;
12568 cmd_get_hash_global_config_parsed(void *parsed_result,
12569 __rte_unused struct cmdline *cl,
12570 __rte_unused void *data)
12572 struct cmd_get_hash_global_config_result *res = parsed_result;
12573 struct rte_eth_hash_filter_info info;
12574 uint32_t idx, offset;
12579 if (rte_eth_dev_filter_supported(res->port_id,
12580 RTE_ETH_FILTER_HASH) < 0) {
12581 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12586 memset(&info, 0, sizeof(info));
12587 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12588 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12589 RTE_ETH_FILTER_GET, &info);
12591 printf("Cannot get hash global configurations by port %d\n",
12596 switch (info.info.global_conf.hash_func) {
12597 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12598 printf("Hash function is Toeplitz\n");
12600 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12601 printf("Hash function is Simple XOR\n");
12603 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12604 printf("Hash function is Symmetric Toeplitz\n");
12607 printf("Unknown hash function\n");
12611 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12612 idx = i / UINT64_BIT;
12613 offset = i % UINT64_BIT;
12614 if (!(info.info.global_conf.valid_bit_mask[idx] &
12617 str = flowtype_to_str(i);
12620 printf("Symmetric hash is %s globally for flow type %s "
12622 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12623 (1ULL << offset)) ? "enabled" : "disabled"), str,
12628 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12629 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12630 get_hash_global_config, "get_hash_global_config");
12631 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12632 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12635 cmdline_parse_inst_t cmd_get_hash_global_config = {
12636 .f = cmd_get_hash_global_config_parsed,
12638 .help_str = "get_hash_global_config <port_id>",
12640 (void *)&cmd_get_hash_global_config_all,
12641 (void *)&cmd_get_hash_global_config_port_id,
12646 /* Set global config of hash function */
12647 struct cmd_set_hash_global_config_result {
12648 cmdline_fixed_string_t set_hash_global_config;
12650 cmdline_fixed_string_t hash_func;
12651 cmdline_fixed_string_t flow_type;
12652 cmdline_fixed_string_t enable;
12656 cmd_set_hash_global_config_parsed(void *parsed_result,
12657 __rte_unused struct cmdline *cl,
12658 __rte_unused void *data)
12660 struct cmd_set_hash_global_config_result *res = parsed_result;
12661 struct rte_eth_hash_filter_info info;
12662 uint32_t ftype, idx, offset;
12665 if (rte_eth_dev_filter_supported(res->port_id,
12666 RTE_ETH_FILTER_HASH) < 0) {
12667 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12671 memset(&info, 0, sizeof(info));
12672 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12673 if (!strcmp(res->hash_func, "toeplitz"))
12674 info.info.global_conf.hash_func =
12675 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12676 else if (!strcmp(res->hash_func, "simple_xor"))
12677 info.info.global_conf.hash_func =
12678 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12679 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12680 info.info.global_conf.hash_func =
12681 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12682 else if (!strcmp(res->hash_func, "default"))
12683 info.info.global_conf.hash_func =
12684 RTE_ETH_HASH_FUNCTION_DEFAULT;
12686 ftype = str2flowtype(res->flow_type);
12687 idx = ftype / UINT64_BIT;
12688 offset = ftype % UINT64_BIT;
12689 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12690 if (!strcmp(res->enable, "enable"))
12691 info.info.global_conf.sym_hash_enable_mask[idx] |=
12693 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12694 RTE_ETH_FILTER_SET, &info);
12696 printf("Cannot set global hash configurations by port %d\n",
12699 printf("Global hash configurations have been set "
12700 "successfully by port %d\n", res->port_id);
12703 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12704 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12705 set_hash_global_config, "set_hash_global_config");
12706 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12707 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12709 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12710 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12711 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12712 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12713 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12715 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12716 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12717 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12718 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12719 enable, "enable#disable");
12721 cmdline_parse_inst_t cmd_set_hash_global_config = {
12722 .f = cmd_set_hash_global_config_parsed,
12724 .help_str = "set_hash_global_config <port_id> "
12725 "toeplitz|simple_xor|symmetric_toeplitz|default "
12726 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12727 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12728 "l2_payload enable|disable",
12730 (void *)&cmd_set_hash_global_config_all,
12731 (void *)&cmd_set_hash_global_config_port_id,
12732 (void *)&cmd_set_hash_global_config_hash_func,
12733 (void *)&cmd_set_hash_global_config_flow_type,
12734 (void *)&cmd_set_hash_global_config_enable,
12739 /* Set hash input set */
12740 struct cmd_set_hash_input_set_result {
12741 cmdline_fixed_string_t set_hash_input_set;
12743 cmdline_fixed_string_t flow_type;
12744 cmdline_fixed_string_t inset_field;
12745 cmdline_fixed_string_t select;
12748 static enum rte_eth_input_set_field
12749 str2inset(char *string)
12753 static const struct {
12755 enum rte_eth_input_set_field inset;
12756 } inset_table[] = {
12757 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12758 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12759 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12760 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12761 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12762 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12763 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12764 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12765 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12766 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12767 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12768 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12769 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12770 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12771 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12772 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12773 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12774 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12775 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12776 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12777 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12778 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12779 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12780 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12781 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12782 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12783 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12784 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12785 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12786 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12787 {"none", RTE_ETH_INPUT_SET_NONE},
12790 for (i = 0; i < RTE_DIM(inset_table); i++) {
12791 if (!strcmp(string, inset_table[i].str))
12792 return inset_table[i].inset;
12795 return RTE_ETH_INPUT_SET_UNKNOWN;
12799 cmd_set_hash_input_set_parsed(void *parsed_result,
12800 __rte_unused struct cmdline *cl,
12801 __rte_unused void *data)
12803 struct cmd_set_hash_input_set_result *res = parsed_result;
12804 struct rte_eth_hash_filter_info info;
12806 memset(&info, 0, sizeof(info));
12807 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12808 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12809 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12810 info.info.input_set_conf.inset_size = 1;
12811 if (!strcmp(res->select, "select"))
12812 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12813 else if (!strcmp(res->select, "add"))
12814 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12815 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12816 RTE_ETH_FILTER_SET, &info);
12819 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12820 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12821 set_hash_input_set, "set_hash_input_set");
12822 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12823 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12825 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12826 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12828 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12829 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12831 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12832 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12833 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12834 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12835 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12837 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12838 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12839 select, "select#add");
12841 cmdline_parse_inst_t cmd_set_hash_input_set = {
12842 .f = cmd_set_hash_input_set_parsed,
12844 .help_str = "set_hash_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|<flowtype_id> "
12847 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12848 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12849 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12850 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12851 "fld-7th|fld-8th|none select|add",
12853 (void *)&cmd_set_hash_input_set_cmd,
12854 (void *)&cmd_set_hash_input_set_port_id,
12855 (void *)&cmd_set_hash_input_set_flow_type,
12856 (void *)&cmd_set_hash_input_set_field,
12857 (void *)&cmd_set_hash_input_set_select,
12862 /* Set flow director input set */
12863 struct cmd_set_fdir_input_set_result {
12864 cmdline_fixed_string_t set_fdir_input_set;
12866 cmdline_fixed_string_t flow_type;
12867 cmdline_fixed_string_t inset_field;
12868 cmdline_fixed_string_t select;
12872 cmd_set_fdir_input_set_parsed(void *parsed_result,
12873 __rte_unused struct cmdline *cl,
12874 __rte_unused void *data)
12876 struct cmd_set_fdir_input_set_result *res = parsed_result;
12877 struct rte_eth_fdir_filter_info info;
12879 memset(&info, 0, sizeof(info));
12880 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12881 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12882 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12883 info.info.input_set_conf.inset_size = 1;
12884 if (!strcmp(res->select, "select"))
12885 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12886 else if (!strcmp(res->select, "add"))
12887 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12888 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12889 RTE_ETH_FILTER_SET, &info);
12892 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12893 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12894 set_fdir_input_set, "set_fdir_input_set");
12895 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12896 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12898 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12899 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12901 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12902 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12903 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12904 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12906 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12907 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12908 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12909 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12910 "sctp-veri-tag#none");
12911 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12912 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12913 select, "select#add");
12915 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12916 .f = cmd_set_fdir_input_set_parsed,
12918 .help_str = "set_fdir_input_set <port_id> "
12919 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12920 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12921 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12922 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12923 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12924 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12925 "sctp-veri-tag|none select|add",
12927 (void *)&cmd_set_fdir_input_set_cmd,
12928 (void *)&cmd_set_fdir_input_set_port_id,
12929 (void *)&cmd_set_fdir_input_set_flow_type,
12930 (void *)&cmd_set_fdir_input_set_field,
12931 (void *)&cmd_set_fdir_input_set_select,
12936 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12937 struct cmd_mcast_addr_result {
12938 cmdline_fixed_string_t mcast_addr_cmd;
12939 cmdline_fixed_string_t what;
12941 struct rte_ether_addr mc_addr;
12944 static void cmd_mcast_addr_parsed(void *parsed_result,
12945 __rte_unused struct cmdline *cl,
12946 __rte_unused void *data)
12948 struct cmd_mcast_addr_result *res = parsed_result;
12950 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12951 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12952 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12953 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12954 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12957 if (strcmp(res->what, "add") == 0)
12958 mcast_addr_add(res->port_num, &res->mc_addr);
12960 mcast_addr_remove(res->port_num, &res->mc_addr);
12963 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12964 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12965 mcast_addr_cmd, "mcast_addr");
12966 cmdline_parse_token_string_t cmd_mcast_addr_what =
12967 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12969 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12970 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12971 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12972 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12974 cmdline_parse_inst_t cmd_mcast_addr = {
12975 .f = cmd_mcast_addr_parsed,
12977 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12978 "Add/Remove multicast MAC address on port_id",
12980 (void *)&cmd_mcast_addr_cmd,
12981 (void *)&cmd_mcast_addr_what,
12982 (void *)&cmd_mcast_addr_portnum,
12983 (void *)&cmd_mcast_addr_addr,
12988 /* l2 tunnel config
12989 * only support E-tag now.
12992 /* Ether type config */
12993 struct cmd_config_l2_tunnel_eth_type_result {
12994 cmdline_fixed_string_t port;
12995 cmdline_fixed_string_t config;
12996 cmdline_fixed_string_t all;
12998 cmdline_fixed_string_t l2_tunnel;
12999 cmdline_fixed_string_t l2_tunnel_type;
13000 cmdline_fixed_string_t eth_type;
13001 uint16_t eth_type_val;
13004 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
13005 TOKEN_STRING_INITIALIZER
13006 (struct cmd_config_l2_tunnel_eth_type_result,
13008 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
13009 TOKEN_STRING_INITIALIZER
13010 (struct cmd_config_l2_tunnel_eth_type_result,
13012 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
13013 TOKEN_STRING_INITIALIZER
13014 (struct cmd_config_l2_tunnel_eth_type_result,
13016 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
13017 TOKEN_NUM_INITIALIZER
13018 (struct cmd_config_l2_tunnel_eth_type_result,
13020 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
13021 TOKEN_STRING_INITIALIZER
13022 (struct cmd_config_l2_tunnel_eth_type_result,
13023 l2_tunnel, "l2-tunnel");
13024 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
13025 TOKEN_STRING_INITIALIZER
13026 (struct cmd_config_l2_tunnel_eth_type_result,
13027 l2_tunnel_type, "E-tag");
13028 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
13029 TOKEN_STRING_INITIALIZER
13030 (struct cmd_config_l2_tunnel_eth_type_result,
13031 eth_type, "ether-type");
13032 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
13033 TOKEN_NUM_INITIALIZER
13034 (struct cmd_config_l2_tunnel_eth_type_result,
13035 eth_type_val, UINT16);
13037 static enum rte_eth_tunnel_type
13038 str2fdir_l2_tunnel_type(char *string)
13042 static const struct {
13044 enum rte_eth_tunnel_type type;
13045 } l2_tunnel_type_str[] = {
13046 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
13049 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
13050 if (!strcmp(l2_tunnel_type_str[i].str, string))
13051 return l2_tunnel_type_str[i].type;
13053 return RTE_TUNNEL_TYPE_NONE;
13056 /* ether type config for all ports */
13058 cmd_config_l2_tunnel_eth_type_all_parsed
13059 (void *parsed_result,
13060 __rte_unused struct cmdline *cl,
13061 __rte_unused void *data)
13063 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
13064 struct rte_eth_l2_tunnel_conf entry;
13067 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13068 entry.ether_type = res->eth_type_val;
13070 RTE_ETH_FOREACH_DEV(pid) {
13071 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
13075 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
13076 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
13078 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
13080 (void *)&cmd_config_l2_tunnel_eth_type_port,
13081 (void *)&cmd_config_l2_tunnel_eth_type_config,
13082 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
13083 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
13084 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
13085 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
13086 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
13091 /* ether type config for a specific port */
13093 cmd_config_l2_tunnel_eth_type_specific_parsed(
13094 void *parsed_result,
13095 __rte_unused struct cmdline *cl,
13096 __rte_unused void *data)
13098 struct cmd_config_l2_tunnel_eth_type_result *res =
13100 struct rte_eth_l2_tunnel_conf entry;
13102 if (port_id_is_invalid(res->id, ENABLED_WARN))
13105 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13106 entry.ether_type = res->eth_type_val;
13108 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
13111 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
13112 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
13114 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
13116 (void *)&cmd_config_l2_tunnel_eth_type_port,
13117 (void *)&cmd_config_l2_tunnel_eth_type_config,
13118 (void *)&cmd_config_l2_tunnel_eth_type_id,
13119 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
13120 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
13121 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
13122 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
13127 /* Enable/disable l2 tunnel */
13128 struct cmd_config_l2_tunnel_en_dis_result {
13129 cmdline_fixed_string_t port;
13130 cmdline_fixed_string_t config;
13131 cmdline_fixed_string_t all;
13133 cmdline_fixed_string_t l2_tunnel;
13134 cmdline_fixed_string_t l2_tunnel_type;
13135 cmdline_fixed_string_t en_dis;
13138 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
13139 TOKEN_STRING_INITIALIZER
13140 (struct cmd_config_l2_tunnel_en_dis_result,
13142 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
13143 TOKEN_STRING_INITIALIZER
13144 (struct cmd_config_l2_tunnel_en_dis_result,
13146 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
13147 TOKEN_STRING_INITIALIZER
13148 (struct cmd_config_l2_tunnel_en_dis_result,
13150 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
13151 TOKEN_NUM_INITIALIZER
13152 (struct cmd_config_l2_tunnel_en_dis_result,
13154 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
13155 TOKEN_STRING_INITIALIZER
13156 (struct cmd_config_l2_tunnel_en_dis_result,
13157 l2_tunnel, "l2-tunnel");
13158 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
13159 TOKEN_STRING_INITIALIZER
13160 (struct cmd_config_l2_tunnel_en_dis_result,
13161 l2_tunnel_type, "E-tag");
13162 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
13163 TOKEN_STRING_INITIALIZER
13164 (struct cmd_config_l2_tunnel_en_dis_result,
13165 en_dis, "enable#disable");
13167 /* enable/disable l2 tunnel for all ports */
13169 cmd_config_l2_tunnel_en_dis_all_parsed(
13170 void *parsed_result,
13171 __rte_unused struct cmdline *cl,
13172 __rte_unused void *data)
13174 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
13175 struct rte_eth_l2_tunnel_conf entry;
13179 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13181 if (!strcmp("enable", res->en_dis))
13186 RTE_ETH_FOREACH_DEV(pid) {
13187 rte_eth_dev_l2_tunnel_offload_set(pid,
13189 ETH_L2_TUNNEL_ENABLE_MASK,
13194 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
13195 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
13197 .help_str = "port config all l2-tunnel E-tag enable|disable",
13199 (void *)&cmd_config_l2_tunnel_en_dis_port,
13200 (void *)&cmd_config_l2_tunnel_en_dis_config,
13201 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
13202 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13203 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13204 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13209 /* enable/disable l2 tunnel for a port */
13211 cmd_config_l2_tunnel_en_dis_specific_parsed(
13212 void *parsed_result,
13213 __rte_unused struct cmdline *cl,
13214 __rte_unused void *data)
13216 struct cmd_config_l2_tunnel_en_dis_result *res =
13218 struct rte_eth_l2_tunnel_conf entry;
13220 if (port_id_is_invalid(res->id, ENABLED_WARN))
13223 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13225 if (!strcmp("enable", res->en_dis))
13226 rte_eth_dev_l2_tunnel_offload_set(res->id,
13228 ETH_L2_TUNNEL_ENABLE_MASK,
13231 rte_eth_dev_l2_tunnel_offload_set(res->id,
13233 ETH_L2_TUNNEL_ENABLE_MASK,
13237 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
13238 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
13240 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
13242 (void *)&cmd_config_l2_tunnel_en_dis_port,
13243 (void *)&cmd_config_l2_tunnel_en_dis_config,
13244 (void *)&cmd_config_l2_tunnel_en_dis_id,
13245 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13246 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13247 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13252 /* E-tag configuration */
13254 /* Common result structure for all E-tag configuration */
13255 struct cmd_config_e_tag_result {
13256 cmdline_fixed_string_t e_tag;
13257 cmdline_fixed_string_t set;
13258 cmdline_fixed_string_t insertion;
13259 cmdline_fixed_string_t stripping;
13260 cmdline_fixed_string_t forwarding;
13261 cmdline_fixed_string_t filter;
13262 cmdline_fixed_string_t add;
13263 cmdline_fixed_string_t del;
13264 cmdline_fixed_string_t on;
13265 cmdline_fixed_string_t off;
13266 cmdline_fixed_string_t on_off;
13267 cmdline_fixed_string_t port_tag_id;
13268 uint32_t port_tag_id_val;
13269 cmdline_fixed_string_t e_tag_id;
13270 uint16_t e_tag_id_val;
13271 cmdline_fixed_string_t dst_pool;
13272 uint8_t dst_pool_val;
13273 cmdline_fixed_string_t port;
13275 cmdline_fixed_string_t vf;
13279 /* Common CLI fields for all E-tag configuration */
13280 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
13281 TOKEN_STRING_INITIALIZER
13282 (struct cmd_config_e_tag_result,
13284 cmdline_parse_token_string_t cmd_config_e_tag_set =
13285 TOKEN_STRING_INITIALIZER
13286 (struct cmd_config_e_tag_result,
13288 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
13289 TOKEN_STRING_INITIALIZER
13290 (struct cmd_config_e_tag_result,
13291 insertion, "insertion");
13292 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
13293 TOKEN_STRING_INITIALIZER
13294 (struct cmd_config_e_tag_result,
13295 stripping, "stripping");
13296 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
13297 TOKEN_STRING_INITIALIZER
13298 (struct cmd_config_e_tag_result,
13299 forwarding, "forwarding");
13300 cmdline_parse_token_string_t cmd_config_e_tag_filter =
13301 TOKEN_STRING_INITIALIZER
13302 (struct cmd_config_e_tag_result,
13304 cmdline_parse_token_string_t cmd_config_e_tag_add =
13305 TOKEN_STRING_INITIALIZER
13306 (struct cmd_config_e_tag_result,
13308 cmdline_parse_token_string_t cmd_config_e_tag_del =
13309 TOKEN_STRING_INITIALIZER
13310 (struct cmd_config_e_tag_result,
13312 cmdline_parse_token_string_t cmd_config_e_tag_on =
13313 TOKEN_STRING_INITIALIZER
13314 (struct cmd_config_e_tag_result,
13316 cmdline_parse_token_string_t cmd_config_e_tag_off =
13317 TOKEN_STRING_INITIALIZER
13318 (struct cmd_config_e_tag_result,
13320 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13321 TOKEN_STRING_INITIALIZER
13322 (struct cmd_config_e_tag_result,
13324 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13325 TOKEN_STRING_INITIALIZER
13326 (struct cmd_config_e_tag_result,
13327 port_tag_id, "port-tag-id");
13328 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13329 TOKEN_NUM_INITIALIZER
13330 (struct cmd_config_e_tag_result,
13331 port_tag_id_val, UINT32);
13332 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13333 TOKEN_STRING_INITIALIZER
13334 (struct cmd_config_e_tag_result,
13335 e_tag_id, "e-tag-id");
13336 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13337 TOKEN_NUM_INITIALIZER
13338 (struct cmd_config_e_tag_result,
13339 e_tag_id_val, UINT16);
13340 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13341 TOKEN_STRING_INITIALIZER
13342 (struct cmd_config_e_tag_result,
13343 dst_pool, "dst-pool");
13344 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13345 TOKEN_NUM_INITIALIZER
13346 (struct cmd_config_e_tag_result,
13347 dst_pool_val, UINT8);
13348 cmdline_parse_token_string_t cmd_config_e_tag_port =
13349 TOKEN_STRING_INITIALIZER
13350 (struct cmd_config_e_tag_result,
13352 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13353 TOKEN_NUM_INITIALIZER
13354 (struct cmd_config_e_tag_result,
13356 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13357 TOKEN_STRING_INITIALIZER
13358 (struct cmd_config_e_tag_result,
13360 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13361 TOKEN_NUM_INITIALIZER
13362 (struct cmd_config_e_tag_result,
13365 /* E-tag insertion configuration */
13367 cmd_config_e_tag_insertion_en_parsed(
13368 void *parsed_result,
13369 __rte_unused struct cmdline *cl,
13370 __rte_unused void *data)
13372 struct cmd_config_e_tag_result *res =
13374 struct rte_eth_l2_tunnel_conf entry;
13376 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13379 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13380 entry.tunnel_id = res->port_tag_id_val;
13381 entry.vf_id = res->vf_id;
13382 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13384 ETH_L2_TUNNEL_INSERTION_MASK,
13389 cmd_config_e_tag_insertion_dis_parsed(
13390 void *parsed_result,
13391 __rte_unused struct cmdline *cl,
13392 __rte_unused void *data)
13394 struct cmd_config_e_tag_result *res =
13396 struct rte_eth_l2_tunnel_conf entry;
13398 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13401 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13402 entry.vf_id = res->vf_id;
13404 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13406 ETH_L2_TUNNEL_INSERTION_MASK,
13410 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13411 .f = cmd_config_e_tag_insertion_en_parsed,
13413 .help_str = "E-tag ... : E-tag insertion enable",
13415 (void *)&cmd_config_e_tag_e_tag,
13416 (void *)&cmd_config_e_tag_set,
13417 (void *)&cmd_config_e_tag_insertion,
13418 (void *)&cmd_config_e_tag_on,
13419 (void *)&cmd_config_e_tag_port_tag_id,
13420 (void *)&cmd_config_e_tag_port_tag_id_val,
13421 (void *)&cmd_config_e_tag_port,
13422 (void *)&cmd_config_e_tag_port_id,
13423 (void *)&cmd_config_e_tag_vf,
13424 (void *)&cmd_config_e_tag_vf_id,
13429 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13430 .f = cmd_config_e_tag_insertion_dis_parsed,
13432 .help_str = "E-tag ... : E-tag insertion disable",
13434 (void *)&cmd_config_e_tag_e_tag,
13435 (void *)&cmd_config_e_tag_set,
13436 (void *)&cmd_config_e_tag_insertion,
13437 (void *)&cmd_config_e_tag_off,
13438 (void *)&cmd_config_e_tag_port,
13439 (void *)&cmd_config_e_tag_port_id,
13440 (void *)&cmd_config_e_tag_vf,
13441 (void *)&cmd_config_e_tag_vf_id,
13446 /* E-tag stripping configuration */
13448 cmd_config_e_tag_stripping_parsed(
13449 void *parsed_result,
13450 __rte_unused struct cmdline *cl,
13451 __rte_unused void *data)
13453 struct cmd_config_e_tag_result *res =
13455 struct rte_eth_l2_tunnel_conf entry;
13457 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13460 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13462 if (!strcmp(res->on_off, "on"))
13463 rte_eth_dev_l2_tunnel_offload_set
13466 ETH_L2_TUNNEL_STRIPPING_MASK,
13469 rte_eth_dev_l2_tunnel_offload_set
13472 ETH_L2_TUNNEL_STRIPPING_MASK,
13476 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13477 .f = cmd_config_e_tag_stripping_parsed,
13479 .help_str = "E-tag ... : E-tag stripping enable/disable",
13481 (void *)&cmd_config_e_tag_e_tag,
13482 (void *)&cmd_config_e_tag_set,
13483 (void *)&cmd_config_e_tag_stripping,
13484 (void *)&cmd_config_e_tag_on_off,
13485 (void *)&cmd_config_e_tag_port,
13486 (void *)&cmd_config_e_tag_port_id,
13491 /* E-tag forwarding configuration */
13493 cmd_config_e_tag_forwarding_parsed(
13494 void *parsed_result,
13495 __rte_unused struct cmdline *cl,
13496 __rte_unused void *data)
13498 struct cmd_config_e_tag_result *res = parsed_result;
13499 struct rte_eth_l2_tunnel_conf entry;
13501 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13504 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13506 if (!strcmp(res->on_off, "on"))
13507 rte_eth_dev_l2_tunnel_offload_set
13510 ETH_L2_TUNNEL_FORWARDING_MASK,
13513 rte_eth_dev_l2_tunnel_offload_set
13516 ETH_L2_TUNNEL_FORWARDING_MASK,
13520 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13521 .f = cmd_config_e_tag_forwarding_parsed,
13523 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13525 (void *)&cmd_config_e_tag_e_tag,
13526 (void *)&cmd_config_e_tag_set,
13527 (void *)&cmd_config_e_tag_forwarding,
13528 (void *)&cmd_config_e_tag_on_off,
13529 (void *)&cmd_config_e_tag_port,
13530 (void *)&cmd_config_e_tag_port_id,
13535 /* E-tag filter configuration */
13537 cmd_config_e_tag_filter_add_parsed(
13538 void *parsed_result,
13539 __rte_unused struct cmdline *cl,
13540 __rte_unused void *data)
13542 struct cmd_config_e_tag_result *res = parsed_result;
13543 struct rte_eth_l2_tunnel_conf entry;
13546 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13549 if (res->e_tag_id_val > 0x3fff) {
13550 printf("e-tag-id must be equal or less than 0x3fff.\n");
13554 ret = rte_eth_dev_filter_supported(res->port_id,
13555 RTE_ETH_FILTER_L2_TUNNEL);
13557 printf("E-tag filter is not supported on port %u.\n",
13562 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13563 entry.tunnel_id = res->e_tag_id_val;
13564 entry.pool = res->dst_pool_val;
13566 ret = rte_eth_dev_filter_ctrl(res->port_id,
13567 RTE_ETH_FILTER_L2_TUNNEL,
13568 RTE_ETH_FILTER_ADD,
13571 printf("E-tag filter programming error: (%s)\n",
13575 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13576 .f = cmd_config_e_tag_filter_add_parsed,
13578 .help_str = "E-tag ... : E-tag filter add",
13580 (void *)&cmd_config_e_tag_e_tag,
13581 (void *)&cmd_config_e_tag_set,
13582 (void *)&cmd_config_e_tag_filter,
13583 (void *)&cmd_config_e_tag_add,
13584 (void *)&cmd_config_e_tag_e_tag_id,
13585 (void *)&cmd_config_e_tag_e_tag_id_val,
13586 (void *)&cmd_config_e_tag_dst_pool,
13587 (void *)&cmd_config_e_tag_dst_pool_val,
13588 (void *)&cmd_config_e_tag_port,
13589 (void *)&cmd_config_e_tag_port_id,
13595 cmd_config_e_tag_filter_del_parsed(
13596 void *parsed_result,
13597 __rte_unused struct cmdline *cl,
13598 __rte_unused void *data)
13600 struct cmd_config_e_tag_result *res = parsed_result;
13601 struct rte_eth_l2_tunnel_conf entry;
13604 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13607 if (res->e_tag_id_val > 0x3fff) {
13608 printf("e-tag-id must be less than 0x3fff.\n");
13612 ret = rte_eth_dev_filter_supported(res->port_id,
13613 RTE_ETH_FILTER_L2_TUNNEL);
13615 printf("E-tag filter is not supported on port %u.\n",
13620 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13621 entry.tunnel_id = res->e_tag_id_val;
13623 ret = rte_eth_dev_filter_ctrl(res->port_id,
13624 RTE_ETH_FILTER_L2_TUNNEL,
13625 RTE_ETH_FILTER_DELETE,
13628 printf("E-tag filter programming error: (%s)\n",
13632 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13633 .f = cmd_config_e_tag_filter_del_parsed,
13635 .help_str = "E-tag ... : E-tag filter delete",
13637 (void *)&cmd_config_e_tag_e_tag,
13638 (void *)&cmd_config_e_tag_set,
13639 (void *)&cmd_config_e_tag_filter,
13640 (void *)&cmd_config_e_tag_del,
13641 (void *)&cmd_config_e_tag_e_tag_id,
13642 (void *)&cmd_config_e_tag_e_tag_id_val,
13643 (void *)&cmd_config_e_tag_port,
13644 (void *)&cmd_config_e_tag_port_id,
13649 /* vf vlan anti spoof configuration */
13651 /* Common result structure for vf vlan anti spoof */
13652 struct cmd_vf_vlan_anti_spoof_result {
13653 cmdline_fixed_string_t set;
13654 cmdline_fixed_string_t vf;
13655 cmdline_fixed_string_t vlan;
13656 cmdline_fixed_string_t antispoof;
13659 cmdline_fixed_string_t on_off;
13662 /* Common CLI fields for vf vlan anti spoof enable disable */
13663 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13664 TOKEN_STRING_INITIALIZER
13665 (struct cmd_vf_vlan_anti_spoof_result,
13667 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13668 TOKEN_STRING_INITIALIZER
13669 (struct cmd_vf_vlan_anti_spoof_result,
13671 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13672 TOKEN_STRING_INITIALIZER
13673 (struct cmd_vf_vlan_anti_spoof_result,
13675 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13676 TOKEN_STRING_INITIALIZER
13677 (struct cmd_vf_vlan_anti_spoof_result,
13678 antispoof, "antispoof");
13679 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13680 TOKEN_NUM_INITIALIZER
13681 (struct cmd_vf_vlan_anti_spoof_result,
13683 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13684 TOKEN_NUM_INITIALIZER
13685 (struct cmd_vf_vlan_anti_spoof_result,
13687 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13688 TOKEN_STRING_INITIALIZER
13689 (struct cmd_vf_vlan_anti_spoof_result,
13693 cmd_set_vf_vlan_anti_spoof_parsed(
13694 void *parsed_result,
13695 __rte_unused struct cmdline *cl,
13696 __rte_unused void *data)
13698 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13699 int ret = -ENOTSUP;
13701 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13703 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13706 #ifdef RTE_LIBRTE_IXGBE_PMD
13707 if (ret == -ENOTSUP)
13708 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13709 res->vf_id, is_on);
13711 #ifdef RTE_LIBRTE_I40E_PMD
13712 if (ret == -ENOTSUP)
13713 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13714 res->vf_id, is_on);
13716 #ifdef RTE_LIBRTE_BNXT_PMD
13717 if (ret == -ENOTSUP)
13718 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13719 res->vf_id, is_on);
13726 printf("invalid vf_id %d\n", res->vf_id);
13729 printf("invalid port_id %d\n", res->port_id);
13732 printf("function not implemented\n");
13735 printf("programming error: (%s)\n", strerror(-ret));
13739 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13740 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13742 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13744 (void *)&cmd_vf_vlan_anti_spoof_set,
13745 (void *)&cmd_vf_vlan_anti_spoof_vf,
13746 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13747 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13748 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13749 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13750 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13755 /* vf mac anti spoof configuration */
13757 /* Common result structure for vf mac anti spoof */
13758 struct cmd_vf_mac_anti_spoof_result {
13759 cmdline_fixed_string_t set;
13760 cmdline_fixed_string_t vf;
13761 cmdline_fixed_string_t mac;
13762 cmdline_fixed_string_t antispoof;
13765 cmdline_fixed_string_t on_off;
13768 /* Common CLI fields for vf mac anti spoof enable disable */
13769 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13770 TOKEN_STRING_INITIALIZER
13771 (struct cmd_vf_mac_anti_spoof_result,
13773 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13774 TOKEN_STRING_INITIALIZER
13775 (struct cmd_vf_mac_anti_spoof_result,
13777 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13778 TOKEN_STRING_INITIALIZER
13779 (struct cmd_vf_mac_anti_spoof_result,
13781 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13782 TOKEN_STRING_INITIALIZER
13783 (struct cmd_vf_mac_anti_spoof_result,
13784 antispoof, "antispoof");
13785 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13786 TOKEN_NUM_INITIALIZER
13787 (struct cmd_vf_mac_anti_spoof_result,
13789 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13790 TOKEN_NUM_INITIALIZER
13791 (struct cmd_vf_mac_anti_spoof_result,
13793 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13794 TOKEN_STRING_INITIALIZER
13795 (struct cmd_vf_mac_anti_spoof_result,
13799 cmd_set_vf_mac_anti_spoof_parsed(
13800 void *parsed_result,
13801 __rte_unused struct cmdline *cl,
13802 __rte_unused void *data)
13804 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13805 int ret = -ENOTSUP;
13807 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13809 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13812 #ifdef RTE_LIBRTE_IXGBE_PMD
13813 if (ret == -ENOTSUP)
13814 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13815 res->vf_id, is_on);
13817 #ifdef RTE_LIBRTE_I40E_PMD
13818 if (ret == -ENOTSUP)
13819 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13820 res->vf_id, is_on);
13822 #ifdef RTE_LIBRTE_BNXT_PMD
13823 if (ret == -ENOTSUP)
13824 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13825 res->vf_id, is_on);
13832 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13835 printf("invalid port_id %d\n", res->port_id);
13838 printf("function not implemented\n");
13841 printf("programming error: (%s)\n", strerror(-ret));
13845 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13846 .f = cmd_set_vf_mac_anti_spoof_parsed,
13848 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13850 (void *)&cmd_vf_mac_anti_spoof_set,
13851 (void *)&cmd_vf_mac_anti_spoof_vf,
13852 (void *)&cmd_vf_mac_anti_spoof_mac,
13853 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13854 (void *)&cmd_vf_mac_anti_spoof_port_id,
13855 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13856 (void *)&cmd_vf_mac_anti_spoof_on_off,
13861 /* vf vlan strip queue configuration */
13863 /* Common result structure for vf mac anti spoof */
13864 struct cmd_vf_vlan_stripq_result {
13865 cmdline_fixed_string_t set;
13866 cmdline_fixed_string_t vf;
13867 cmdline_fixed_string_t vlan;
13868 cmdline_fixed_string_t stripq;
13871 cmdline_fixed_string_t on_off;
13874 /* Common CLI fields for vf vlan strip enable disable */
13875 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13876 TOKEN_STRING_INITIALIZER
13877 (struct cmd_vf_vlan_stripq_result,
13879 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13880 TOKEN_STRING_INITIALIZER
13881 (struct cmd_vf_vlan_stripq_result,
13883 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13884 TOKEN_STRING_INITIALIZER
13885 (struct cmd_vf_vlan_stripq_result,
13887 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13888 TOKEN_STRING_INITIALIZER
13889 (struct cmd_vf_vlan_stripq_result,
13891 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13892 TOKEN_NUM_INITIALIZER
13893 (struct cmd_vf_vlan_stripq_result,
13895 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13896 TOKEN_NUM_INITIALIZER
13897 (struct cmd_vf_vlan_stripq_result,
13899 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13900 TOKEN_STRING_INITIALIZER
13901 (struct cmd_vf_vlan_stripq_result,
13905 cmd_set_vf_vlan_stripq_parsed(
13906 void *parsed_result,
13907 __rte_unused struct cmdline *cl,
13908 __rte_unused void *data)
13910 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13911 int ret = -ENOTSUP;
13913 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13915 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13918 #ifdef RTE_LIBRTE_IXGBE_PMD
13919 if (ret == -ENOTSUP)
13920 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13921 res->vf_id, is_on);
13923 #ifdef RTE_LIBRTE_I40E_PMD
13924 if (ret == -ENOTSUP)
13925 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13926 res->vf_id, is_on);
13928 #ifdef RTE_LIBRTE_BNXT_PMD
13929 if (ret == -ENOTSUP)
13930 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13931 res->vf_id, is_on);
13938 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13941 printf("invalid port_id %d\n", res->port_id);
13944 printf("function not implemented\n");
13947 printf("programming error: (%s)\n", strerror(-ret));
13951 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13952 .f = cmd_set_vf_vlan_stripq_parsed,
13954 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13956 (void *)&cmd_vf_vlan_stripq_set,
13957 (void *)&cmd_vf_vlan_stripq_vf,
13958 (void *)&cmd_vf_vlan_stripq_vlan,
13959 (void *)&cmd_vf_vlan_stripq_stripq,
13960 (void *)&cmd_vf_vlan_stripq_port_id,
13961 (void *)&cmd_vf_vlan_stripq_vf_id,
13962 (void *)&cmd_vf_vlan_stripq_on_off,
13967 /* vf vlan insert configuration */
13969 /* Common result structure for vf vlan insert */
13970 struct cmd_vf_vlan_insert_result {
13971 cmdline_fixed_string_t set;
13972 cmdline_fixed_string_t vf;
13973 cmdline_fixed_string_t vlan;
13974 cmdline_fixed_string_t insert;
13980 /* Common CLI fields for vf vlan insert enable disable */
13981 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13982 TOKEN_STRING_INITIALIZER
13983 (struct cmd_vf_vlan_insert_result,
13985 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13986 TOKEN_STRING_INITIALIZER
13987 (struct cmd_vf_vlan_insert_result,
13989 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13990 TOKEN_STRING_INITIALIZER
13991 (struct cmd_vf_vlan_insert_result,
13993 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13994 TOKEN_STRING_INITIALIZER
13995 (struct cmd_vf_vlan_insert_result,
13997 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13998 TOKEN_NUM_INITIALIZER
13999 (struct cmd_vf_vlan_insert_result,
14001 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
14002 TOKEN_NUM_INITIALIZER
14003 (struct cmd_vf_vlan_insert_result,
14005 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
14006 TOKEN_NUM_INITIALIZER
14007 (struct cmd_vf_vlan_insert_result,
14011 cmd_set_vf_vlan_insert_parsed(
14012 void *parsed_result,
14013 __rte_unused struct cmdline *cl,
14014 __rte_unused void *data)
14016 struct cmd_vf_vlan_insert_result *res = parsed_result;
14017 int ret = -ENOTSUP;
14019 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14022 #ifdef RTE_LIBRTE_IXGBE_PMD
14023 if (ret == -ENOTSUP)
14024 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
14027 #ifdef RTE_LIBRTE_I40E_PMD
14028 if (ret == -ENOTSUP)
14029 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
14032 #ifdef RTE_LIBRTE_BNXT_PMD
14033 if (ret == -ENOTSUP)
14034 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
14042 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
14045 printf("invalid port_id %d\n", res->port_id);
14048 printf("function not implemented\n");
14051 printf("programming error: (%s)\n", strerror(-ret));
14055 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
14056 .f = cmd_set_vf_vlan_insert_parsed,
14058 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
14060 (void *)&cmd_vf_vlan_insert_set,
14061 (void *)&cmd_vf_vlan_insert_vf,
14062 (void *)&cmd_vf_vlan_insert_vlan,
14063 (void *)&cmd_vf_vlan_insert_insert,
14064 (void *)&cmd_vf_vlan_insert_port_id,
14065 (void *)&cmd_vf_vlan_insert_vf_id,
14066 (void *)&cmd_vf_vlan_insert_vlan_id,
14071 /* tx loopback configuration */
14073 /* Common result structure for tx loopback */
14074 struct cmd_tx_loopback_result {
14075 cmdline_fixed_string_t set;
14076 cmdline_fixed_string_t tx;
14077 cmdline_fixed_string_t loopback;
14079 cmdline_fixed_string_t on_off;
14082 /* Common CLI fields for tx loopback enable disable */
14083 cmdline_parse_token_string_t cmd_tx_loopback_set =
14084 TOKEN_STRING_INITIALIZER
14085 (struct cmd_tx_loopback_result,
14087 cmdline_parse_token_string_t cmd_tx_loopback_tx =
14088 TOKEN_STRING_INITIALIZER
14089 (struct cmd_tx_loopback_result,
14091 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
14092 TOKEN_STRING_INITIALIZER
14093 (struct cmd_tx_loopback_result,
14094 loopback, "loopback");
14095 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
14096 TOKEN_NUM_INITIALIZER
14097 (struct cmd_tx_loopback_result,
14099 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
14100 TOKEN_STRING_INITIALIZER
14101 (struct cmd_tx_loopback_result,
14105 cmd_set_tx_loopback_parsed(
14106 void *parsed_result,
14107 __rte_unused struct cmdline *cl,
14108 __rte_unused void *data)
14110 struct cmd_tx_loopback_result *res = parsed_result;
14111 int ret = -ENOTSUP;
14113 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14115 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14118 #ifdef RTE_LIBRTE_IXGBE_PMD
14119 if (ret == -ENOTSUP)
14120 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
14122 #ifdef RTE_LIBRTE_I40E_PMD
14123 if (ret == -ENOTSUP)
14124 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
14126 #ifdef RTE_LIBRTE_BNXT_PMD
14127 if (ret == -ENOTSUP)
14128 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
14130 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
14131 if (ret == -ENOTSUP)
14132 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
14139 printf("invalid is_on %d\n", is_on);
14142 printf("invalid port_id %d\n", res->port_id);
14145 printf("function not implemented\n");
14148 printf("programming error: (%s)\n", strerror(-ret));
14152 cmdline_parse_inst_t cmd_set_tx_loopback = {
14153 .f = cmd_set_tx_loopback_parsed,
14155 .help_str = "set tx loopback <port_id> on|off",
14157 (void *)&cmd_tx_loopback_set,
14158 (void *)&cmd_tx_loopback_tx,
14159 (void *)&cmd_tx_loopback_loopback,
14160 (void *)&cmd_tx_loopback_port_id,
14161 (void *)&cmd_tx_loopback_on_off,
14166 /* all queues drop enable configuration */
14168 /* Common result structure for all queues drop enable */
14169 struct cmd_all_queues_drop_en_result {
14170 cmdline_fixed_string_t set;
14171 cmdline_fixed_string_t all;
14172 cmdline_fixed_string_t queues;
14173 cmdline_fixed_string_t drop;
14175 cmdline_fixed_string_t on_off;
14178 /* Common CLI fields for tx loopback enable disable */
14179 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
14180 TOKEN_STRING_INITIALIZER
14181 (struct cmd_all_queues_drop_en_result,
14183 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
14184 TOKEN_STRING_INITIALIZER
14185 (struct cmd_all_queues_drop_en_result,
14187 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
14188 TOKEN_STRING_INITIALIZER
14189 (struct cmd_all_queues_drop_en_result,
14191 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
14192 TOKEN_STRING_INITIALIZER
14193 (struct cmd_all_queues_drop_en_result,
14195 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
14196 TOKEN_NUM_INITIALIZER
14197 (struct cmd_all_queues_drop_en_result,
14199 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
14200 TOKEN_STRING_INITIALIZER
14201 (struct cmd_all_queues_drop_en_result,
14205 cmd_set_all_queues_drop_en_parsed(
14206 void *parsed_result,
14207 __rte_unused struct cmdline *cl,
14208 __rte_unused void *data)
14210 struct cmd_all_queues_drop_en_result *res = parsed_result;
14211 int ret = -ENOTSUP;
14212 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14214 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14217 #ifdef RTE_LIBRTE_IXGBE_PMD
14218 if (ret == -ENOTSUP)
14219 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
14221 #ifdef RTE_LIBRTE_BNXT_PMD
14222 if (ret == -ENOTSUP)
14223 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
14229 printf("invalid is_on %d\n", is_on);
14232 printf("invalid port_id %d\n", res->port_id);
14235 printf("function not implemented\n");
14238 printf("programming error: (%s)\n", strerror(-ret));
14242 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
14243 .f = cmd_set_all_queues_drop_en_parsed,
14245 .help_str = "set all queues drop <port_id> on|off",
14247 (void *)&cmd_all_queues_drop_en_set,
14248 (void *)&cmd_all_queues_drop_en_all,
14249 (void *)&cmd_all_queues_drop_en_queues,
14250 (void *)&cmd_all_queues_drop_en_drop,
14251 (void *)&cmd_all_queues_drop_en_port_id,
14252 (void *)&cmd_all_queues_drop_en_on_off,
14257 /* vf split drop enable configuration */
14259 /* Common result structure for vf split drop enable */
14260 struct cmd_vf_split_drop_en_result {
14261 cmdline_fixed_string_t set;
14262 cmdline_fixed_string_t vf;
14263 cmdline_fixed_string_t split;
14264 cmdline_fixed_string_t drop;
14267 cmdline_fixed_string_t on_off;
14270 /* Common CLI fields for vf split drop enable disable */
14271 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
14272 TOKEN_STRING_INITIALIZER
14273 (struct cmd_vf_split_drop_en_result,
14275 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
14276 TOKEN_STRING_INITIALIZER
14277 (struct cmd_vf_split_drop_en_result,
14279 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
14280 TOKEN_STRING_INITIALIZER
14281 (struct cmd_vf_split_drop_en_result,
14283 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
14284 TOKEN_STRING_INITIALIZER
14285 (struct cmd_vf_split_drop_en_result,
14287 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
14288 TOKEN_NUM_INITIALIZER
14289 (struct cmd_vf_split_drop_en_result,
14291 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
14292 TOKEN_NUM_INITIALIZER
14293 (struct cmd_vf_split_drop_en_result,
14295 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
14296 TOKEN_STRING_INITIALIZER
14297 (struct cmd_vf_split_drop_en_result,
14301 cmd_set_vf_split_drop_en_parsed(
14302 void *parsed_result,
14303 __rte_unused struct cmdline *cl,
14304 __rte_unused void *data)
14306 struct cmd_vf_split_drop_en_result *res = parsed_result;
14307 int ret = -ENOTSUP;
14308 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14310 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14313 #ifdef RTE_LIBRTE_IXGBE_PMD
14314 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14321 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14324 printf("invalid port_id %d\n", res->port_id);
14327 printf("not supported on port %d\n", res->port_id);
14330 printf("programming error: (%s)\n", strerror(-ret));
14334 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14335 .f = cmd_set_vf_split_drop_en_parsed,
14337 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14339 (void *)&cmd_vf_split_drop_en_set,
14340 (void *)&cmd_vf_split_drop_en_vf,
14341 (void *)&cmd_vf_split_drop_en_split,
14342 (void *)&cmd_vf_split_drop_en_drop,
14343 (void *)&cmd_vf_split_drop_en_port_id,
14344 (void *)&cmd_vf_split_drop_en_vf_id,
14345 (void *)&cmd_vf_split_drop_en_on_off,
14350 /* vf mac address configuration */
14352 /* Common result structure for vf mac address */
14353 struct cmd_set_vf_mac_addr_result {
14354 cmdline_fixed_string_t set;
14355 cmdline_fixed_string_t vf;
14356 cmdline_fixed_string_t mac;
14357 cmdline_fixed_string_t addr;
14360 struct rte_ether_addr mac_addr;
14364 /* Common CLI fields for vf split drop enable disable */
14365 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14366 TOKEN_STRING_INITIALIZER
14367 (struct cmd_set_vf_mac_addr_result,
14369 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14370 TOKEN_STRING_INITIALIZER
14371 (struct cmd_set_vf_mac_addr_result,
14373 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14374 TOKEN_STRING_INITIALIZER
14375 (struct cmd_set_vf_mac_addr_result,
14377 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14378 TOKEN_STRING_INITIALIZER
14379 (struct cmd_set_vf_mac_addr_result,
14381 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14382 TOKEN_NUM_INITIALIZER
14383 (struct cmd_set_vf_mac_addr_result,
14385 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14386 TOKEN_NUM_INITIALIZER
14387 (struct cmd_set_vf_mac_addr_result,
14389 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14390 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14394 cmd_set_vf_mac_addr_parsed(
14395 void *parsed_result,
14396 __rte_unused struct cmdline *cl,
14397 __rte_unused void *data)
14399 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14400 int ret = -ENOTSUP;
14402 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14405 #ifdef RTE_LIBRTE_IXGBE_PMD
14406 if (ret == -ENOTSUP)
14407 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14410 #ifdef RTE_LIBRTE_I40E_PMD
14411 if (ret == -ENOTSUP)
14412 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14415 #ifdef RTE_LIBRTE_BNXT_PMD
14416 if (ret == -ENOTSUP)
14417 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14425 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14428 printf("invalid port_id %d\n", res->port_id);
14431 printf("function not implemented\n");
14434 printf("programming error: (%s)\n", strerror(-ret));
14438 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14439 .f = cmd_set_vf_mac_addr_parsed,
14441 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14443 (void *)&cmd_set_vf_mac_addr_set,
14444 (void *)&cmd_set_vf_mac_addr_vf,
14445 (void *)&cmd_set_vf_mac_addr_mac,
14446 (void *)&cmd_set_vf_mac_addr_addr,
14447 (void *)&cmd_set_vf_mac_addr_port_id,
14448 (void *)&cmd_set_vf_mac_addr_vf_id,
14449 (void *)&cmd_set_vf_mac_addr_mac_addr,
14454 /* MACsec configuration */
14456 /* Common result structure for MACsec offload enable */
14457 struct cmd_macsec_offload_on_result {
14458 cmdline_fixed_string_t set;
14459 cmdline_fixed_string_t macsec;
14460 cmdline_fixed_string_t offload;
14462 cmdline_fixed_string_t on;
14463 cmdline_fixed_string_t encrypt;
14464 cmdline_fixed_string_t en_on_off;
14465 cmdline_fixed_string_t replay_protect;
14466 cmdline_fixed_string_t rp_on_off;
14469 /* Common CLI fields for MACsec offload disable */
14470 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14471 TOKEN_STRING_INITIALIZER
14472 (struct cmd_macsec_offload_on_result,
14474 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14475 TOKEN_STRING_INITIALIZER
14476 (struct cmd_macsec_offload_on_result,
14478 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14479 TOKEN_STRING_INITIALIZER
14480 (struct cmd_macsec_offload_on_result,
14481 offload, "offload");
14482 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14483 TOKEN_NUM_INITIALIZER
14484 (struct cmd_macsec_offload_on_result,
14486 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14487 TOKEN_STRING_INITIALIZER
14488 (struct cmd_macsec_offload_on_result,
14490 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14491 TOKEN_STRING_INITIALIZER
14492 (struct cmd_macsec_offload_on_result,
14493 encrypt, "encrypt");
14494 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14495 TOKEN_STRING_INITIALIZER
14496 (struct cmd_macsec_offload_on_result,
14497 en_on_off, "on#off");
14498 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14499 TOKEN_STRING_INITIALIZER
14500 (struct cmd_macsec_offload_on_result,
14501 replay_protect, "replay-protect");
14502 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14503 TOKEN_STRING_INITIALIZER
14504 (struct cmd_macsec_offload_on_result,
14505 rp_on_off, "on#off");
14508 cmd_set_macsec_offload_on_parsed(
14509 void *parsed_result,
14510 __rte_unused struct cmdline *cl,
14511 __rte_unused void *data)
14513 struct cmd_macsec_offload_on_result *res = parsed_result;
14514 int ret = -ENOTSUP;
14515 portid_t port_id = res->port_id;
14516 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14517 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14518 struct rte_eth_dev_info dev_info;
14520 if (port_id_is_invalid(port_id, ENABLED_WARN))
14522 if (!port_is_stopped(port_id)) {
14523 printf("Please stop port %d first\n", port_id);
14527 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14531 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14532 #ifdef RTE_LIBRTE_IXGBE_PMD
14533 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14541 ports[port_id].dev_conf.txmode.offloads |=
14542 DEV_TX_OFFLOAD_MACSEC_INSERT;
14543 cmd_reconfig_device_queue(port_id, 1, 1);
14546 printf("invalid port_id %d\n", port_id);
14549 printf("not supported on port %d\n", port_id);
14552 printf("programming error: (%s)\n", strerror(-ret));
14556 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14557 .f = cmd_set_macsec_offload_on_parsed,
14559 .help_str = "set macsec offload <port_id> on "
14560 "encrypt on|off replay-protect on|off",
14562 (void *)&cmd_macsec_offload_on_set,
14563 (void *)&cmd_macsec_offload_on_macsec,
14564 (void *)&cmd_macsec_offload_on_offload,
14565 (void *)&cmd_macsec_offload_on_port_id,
14566 (void *)&cmd_macsec_offload_on_on,
14567 (void *)&cmd_macsec_offload_on_encrypt,
14568 (void *)&cmd_macsec_offload_on_en_on_off,
14569 (void *)&cmd_macsec_offload_on_replay_protect,
14570 (void *)&cmd_macsec_offload_on_rp_on_off,
14575 /* Common result structure for MACsec offload disable */
14576 struct cmd_macsec_offload_off_result {
14577 cmdline_fixed_string_t set;
14578 cmdline_fixed_string_t macsec;
14579 cmdline_fixed_string_t offload;
14581 cmdline_fixed_string_t off;
14584 /* Common CLI fields for MACsec offload disable */
14585 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14586 TOKEN_STRING_INITIALIZER
14587 (struct cmd_macsec_offload_off_result,
14589 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14590 TOKEN_STRING_INITIALIZER
14591 (struct cmd_macsec_offload_off_result,
14593 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14594 TOKEN_STRING_INITIALIZER
14595 (struct cmd_macsec_offload_off_result,
14596 offload, "offload");
14597 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14598 TOKEN_NUM_INITIALIZER
14599 (struct cmd_macsec_offload_off_result,
14601 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14602 TOKEN_STRING_INITIALIZER
14603 (struct cmd_macsec_offload_off_result,
14607 cmd_set_macsec_offload_off_parsed(
14608 void *parsed_result,
14609 __rte_unused struct cmdline *cl,
14610 __rte_unused void *data)
14612 struct cmd_macsec_offload_off_result *res = parsed_result;
14613 int ret = -ENOTSUP;
14614 struct rte_eth_dev_info dev_info;
14615 portid_t port_id = res->port_id;
14617 if (port_id_is_invalid(port_id, ENABLED_WARN))
14619 if (!port_is_stopped(port_id)) {
14620 printf("Please stop port %d first\n", port_id);
14624 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14628 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14629 #ifdef RTE_LIBRTE_IXGBE_PMD
14630 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14635 ports[port_id].dev_conf.txmode.offloads &=
14636 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14637 cmd_reconfig_device_queue(port_id, 1, 1);
14640 printf("invalid port_id %d\n", port_id);
14643 printf("not supported on port %d\n", port_id);
14646 printf("programming error: (%s)\n", strerror(-ret));
14650 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14651 .f = cmd_set_macsec_offload_off_parsed,
14653 .help_str = "set macsec offload <port_id> off",
14655 (void *)&cmd_macsec_offload_off_set,
14656 (void *)&cmd_macsec_offload_off_macsec,
14657 (void *)&cmd_macsec_offload_off_offload,
14658 (void *)&cmd_macsec_offload_off_port_id,
14659 (void *)&cmd_macsec_offload_off_off,
14664 /* Common result structure for MACsec secure connection configure */
14665 struct cmd_macsec_sc_result {
14666 cmdline_fixed_string_t set;
14667 cmdline_fixed_string_t macsec;
14668 cmdline_fixed_string_t sc;
14669 cmdline_fixed_string_t tx_rx;
14671 struct rte_ether_addr mac;
14675 /* Common CLI fields for MACsec secure connection configure */
14676 cmdline_parse_token_string_t cmd_macsec_sc_set =
14677 TOKEN_STRING_INITIALIZER
14678 (struct cmd_macsec_sc_result,
14680 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14681 TOKEN_STRING_INITIALIZER
14682 (struct cmd_macsec_sc_result,
14684 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14685 TOKEN_STRING_INITIALIZER
14686 (struct cmd_macsec_sc_result,
14688 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14689 TOKEN_STRING_INITIALIZER
14690 (struct cmd_macsec_sc_result,
14692 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14693 TOKEN_NUM_INITIALIZER
14694 (struct cmd_macsec_sc_result,
14696 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14697 TOKEN_ETHERADDR_INITIALIZER
14698 (struct cmd_macsec_sc_result,
14700 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14701 TOKEN_NUM_INITIALIZER
14702 (struct cmd_macsec_sc_result,
14706 cmd_set_macsec_sc_parsed(
14707 void *parsed_result,
14708 __rte_unused struct cmdline *cl,
14709 __rte_unused void *data)
14711 struct cmd_macsec_sc_result *res = parsed_result;
14712 int ret = -ENOTSUP;
14713 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14715 #ifdef RTE_LIBRTE_IXGBE_PMD
14717 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14718 res->mac.addr_bytes) :
14719 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14720 res->mac.addr_bytes, res->pi);
14722 RTE_SET_USED(is_tx);
14728 printf("invalid port_id %d\n", res->port_id);
14731 printf("not supported on port %d\n", res->port_id);
14734 printf("programming error: (%s)\n", strerror(-ret));
14738 cmdline_parse_inst_t cmd_set_macsec_sc = {
14739 .f = cmd_set_macsec_sc_parsed,
14741 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14743 (void *)&cmd_macsec_sc_set,
14744 (void *)&cmd_macsec_sc_macsec,
14745 (void *)&cmd_macsec_sc_sc,
14746 (void *)&cmd_macsec_sc_tx_rx,
14747 (void *)&cmd_macsec_sc_port_id,
14748 (void *)&cmd_macsec_sc_mac,
14749 (void *)&cmd_macsec_sc_pi,
14754 /* Common result structure for MACsec secure connection configure */
14755 struct cmd_macsec_sa_result {
14756 cmdline_fixed_string_t set;
14757 cmdline_fixed_string_t macsec;
14758 cmdline_fixed_string_t sa;
14759 cmdline_fixed_string_t tx_rx;
14764 cmdline_fixed_string_t key;
14767 /* Common CLI fields for MACsec secure connection configure */
14768 cmdline_parse_token_string_t cmd_macsec_sa_set =
14769 TOKEN_STRING_INITIALIZER
14770 (struct cmd_macsec_sa_result,
14772 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14773 TOKEN_STRING_INITIALIZER
14774 (struct cmd_macsec_sa_result,
14776 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14777 TOKEN_STRING_INITIALIZER
14778 (struct cmd_macsec_sa_result,
14780 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14781 TOKEN_STRING_INITIALIZER
14782 (struct cmd_macsec_sa_result,
14784 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14785 TOKEN_NUM_INITIALIZER
14786 (struct cmd_macsec_sa_result,
14788 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14789 TOKEN_NUM_INITIALIZER
14790 (struct cmd_macsec_sa_result,
14792 cmdline_parse_token_num_t cmd_macsec_sa_an =
14793 TOKEN_NUM_INITIALIZER
14794 (struct cmd_macsec_sa_result,
14796 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14797 TOKEN_NUM_INITIALIZER
14798 (struct cmd_macsec_sa_result,
14800 cmdline_parse_token_string_t cmd_macsec_sa_key =
14801 TOKEN_STRING_INITIALIZER
14802 (struct cmd_macsec_sa_result,
14806 cmd_set_macsec_sa_parsed(
14807 void *parsed_result,
14808 __rte_unused struct cmdline *cl,
14809 __rte_unused void *data)
14811 struct cmd_macsec_sa_result *res = parsed_result;
14812 int ret = -ENOTSUP;
14813 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14814 uint8_t key[16] = { 0 };
14820 key_len = strlen(res->key) / 2;
14824 for (i = 0; i < key_len; i++) {
14825 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14828 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14831 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14834 #ifdef RTE_LIBRTE_IXGBE_PMD
14836 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14837 res->idx, res->an, res->pn, key) :
14838 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14839 res->idx, res->an, res->pn, key);
14841 RTE_SET_USED(is_tx);
14848 printf("invalid idx %d or an %d\n", res->idx, res->an);
14851 printf("invalid port_id %d\n", res->port_id);
14854 printf("not supported on port %d\n", res->port_id);
14857 printf("programming error: (%s)\n", strerror(-ret));
14861 cmdline_parse_inst_t cmd_set_macsec_sa = {
14862 .f = cmd_set_macsec_sa_parsed,
14864 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14866 (void *)&cmd_macsec_sa_set,
14867 (void *)&cmd_macsec_sa_macsec,
14868 (void *)&cmd_macsec_sa_sa,
14869 (void *)&cmd_macsec_sa_tx_rx,
14870 (void *)&cmd_macsec_sa_port_id,
14871 (void *)&cmd_macsec_sa_idx,
14872 (void *)&cmd_macsec_sa_an,
14873 (void *)&cmd_macsec_sa_pn,
14874 (void *)&cmd_macsec_sa_key,
14879 /* VF unicast promiscuous mode configuration */
14881 /* Common result structure for VF unicast promiscuous mode */
14882 struct cmd_vf_promisc_result {
14883 cmdline_fixed_string_t set;
14884 cmdline_fixed_string_t vf;
14885 cmdline_fixed_string_t promisc;
14888 cmdline_fixed_string_t on_off;
14891 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14892 cmdline_parse_token_string_t cmd_vf_promisc_set =
14893 TOKEN_STRING_INITIALIZER
14894 (struct cmd_vf_promisc_result,
14896 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14897 TOKEN_STRING_INITIALIZER
14898 (struct cmd_vf_promisc_result,
14900 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14901 TOKEN_STRING_INITIALIZER
14902 (struct cmd_vf_promisc_result,
14903 promisc, "promisc");
14904 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14905 TOKEN_NUM_INITIALIZER
14906 (struct cmd_vf_promisc_result,
14908 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14909 TOKEN_NUM_INITIALIZER
14910 (struct cmd_vf_promisc_result,
14912 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14913 TOKEN_STRING_INITIALIZER
14914 (struct cmd_vf_promisc_result,
14918 cmd_set_vf_promisc_parsed(
14919 void *parsed_result,
14920 __rte_unused struct cmdline *cl,
14921 __rte_unused void *data)
14923 struct cmd_vf_promisc_result *res = parsed_result;
14924 int ret = -ENOTSUP;
14926 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14928 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14931 #ifdef RTE_LIBRTE_I40E_PMD
14932 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14933 res->vf_id, is_on);
14940 printf("invalid vf_id %d\n", res->vf_id);
14943 printf("invalid port_id %d\n", res->port_id);
14946 printf("function not implemented\n");
14949 printf("programming error: (%s)\n", strerror(-ret));
14953 cmdline_parse_inst_t cmd_set_vf_promisc = {
14954 .f = cmd_set_vf_promisc_parsed,
14956 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14957 "Set unicast promiscuous mode for a VF from the PF",
14959 (void *)&cmd_vf_promisc_set,
14960 (void *)&cmd_vf_promisc_vf,
14961 (void *)&cmd_vf_promisc_promisc,
14962 (void *)&cmd_vf_promisc_port_id,
14963 (void *)&cmd_vf_promisc_vf_id,
14964 (void *)&cmd_vf_promisc_on_off,
14969 /* VF multicast promiscuous mode configuration */
14971 /* Common result structure for VF multicast promiscuous mode */
14972 struct cmd_vf_allmulti_result {
14973 cmdline_fixed_string_t set;
14974 cmdline_fixed_string_t vf;
14975 cmdline_fixed_string_t allmulti;
14978 cmdline_fixed_string_t on_off;
14981 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14982 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14983 TOKEN_STRING_INITIALIZER
14984 (struct cmd_vf_allmulti_result,
14986 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14987 TOKEN_STRING_INITIALIZER
14988 (struct cmd_vf_allmulti_result,
14990 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14991 TOKEN_STRING_INITIALIZER
14992 (struct cmd_vf_allmulti_result,
14993 allmulti, "allmulti");
14994 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14995 TOKEN_NUM_INITIALIZER
14996 (struct cmd_vf_allmulti_result,
14998 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14999 TOKEN_NUM_INITIALIZER
15000 (struct cmd_vf_allmulti_result,
15002 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
15003 TOKEN_STRING_INITIALIZER
15004 (struct cmd_vf_allmulti_result,
15008 cmd_set_vf_allmulti_parsed(
15009 void *parsed_result,
15010 __rte_unused struct cmdline *cl,
15011 __rte_unused void *data)
15013 struct cmd_vf_allmulti_result *res = parsed_result;
15014 int ret = -ENOTSUP;
15016 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15018 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15021 #ifdef RTE_LIBRTE_I40E_PMD
15022 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
15023 res->vf_id, is_on);
15030 printf("invalid vf_id %d\n", res->vf_id);
15033 printf("invalid port_id %d\n", res->port_id);
15036 printf("function not implemented\n");
15039 printf("programming error: (%s)\n", strerror(-ret));
15043 cmdline_parse_inst_t cmd_set_vf_allmulti = {
15044 .f = cmd_set_vf_allmulti_parsed,
15046 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
15047 "Set multicast promiscuous mode for a VF from the PF",
15049 (void *)&cmd_vf_allmulti_set,
15050 (void *)&cmd_vf_allmulti_vf,
15051 (void *)&cmd_vf_allmulti_allmulti,
15052 (void *)&cmd_vf_allmulti_port_id,
15053 (void *)&cmd_vf_allmulti_vf_id,
15054 (void *)&cmd_vf_allmulti_on_off,
15059 /* vf broadcast mode configuration */
15061 /* Common result structure for vf broadcast */
15062 struct cmd_set_vf_broadcast_result {
15063 cmdline_fixed_string_t set;
15064 cmdline_fixed_string_t vf;
15065 cmdline_fixed_string_t broadcast;
15068 cmdline_fixed_string_t on_off;
15071 /* Common CLI fields for vf broadcast enable disable */
15072 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
15073 TOKEN_STRING_INITIALIZER
15074 (struct cmd_set_vf_broadcast_result,
15076 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
15077 TOKEN_STRING_INITIALIZER
15078 (struct cmd_set_vf_broadcast_result,
15080 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
15081 TOKEN_STRING_INITIALIZER
15082 (struct cmd_set_vf_broadcast_result,
15083 broadcast, "broadcast");
15084 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
15085 TOKEN_NUM_INITIALIZER
15086 (struct cmd_set_vf_broadcast_result,
15088 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
15089 TOKEN_NUM_INITIALIZER
15090 (struct cmd_set_vf_broadcast_result,
15092 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
15093 TOKEN_STRING_INITIALIZER
15094 (struct cmd_set_vf_broadcast_result,
15098 cmd_set_vf_broadcast_parsed(
15099 void *parsed_result,
15100 __rte_unused struct cmdline *cl,
15101 __rte_unused void *data)
15103 struct cmd_set_vf_broadcast_result *res = parsed_result;
15104 int ret = -ENOTSUP;
15106 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15108 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15111 #ifdef RTE_LIBRTE_I40E_PMD
15112 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
15113 res->vf_id, is_on);
15120 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15123 printf("invalid port_id %d\n", res->port_id);
15126 printf("function not implemented\n");
15129 printf("programming error: (%s)\n", strerror(-ret));
15133 cmdline_parse_inst_t cmd_set_vf_broadcast = {
15134 .f = cmd_set_vf_broadcast_parsed,
15136 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
15138 (void *)&cmd_set_vf_broadcast_set,
15139 (void *)&cmd_set_vf_broadcast_vf,
15140 (void *)&cmd_set_vf_broadcast_broadcast,
15141 (void *)&cmd_set_vf_broadcast_port_id,
15142 (void *)&cmd_set_vf_broadcast_vf_id,
15143 (void *)&cmd_set_vf_broadcast_on_off,
15148 /* vf vlan tag configuration */
15150 /* Common result structure for vf vlan tag */
15151 struct cmd_set_vf_vlan_tag_result {
15152 cmdline_fixed_string_t set;
15153 cmdline_fixed_string_t vf;
15154 cmdline_fixed_string_t vlan;
15155 cmdline_fixed_string_t tag;
15158 cmdline_fixed_string_t on_off;
15161 /* Common CLI fields for vf vlan tag enable disable */
15162 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
15163 TOKEN_STRING_INITIALIZER
15164 (struct cmd_set_vf_vlan_tag_result,
15166 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
15167 TOKEN_STRING_INITIALIZER
15168 (struct cmd_set_vf_vlan_tag_result,
15170 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
15171 TOKEN_STRING_INITIALIZER
15172 (struct cmd_set_vf_vlan_tag_result,
15174 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
15175 TOKEN_STRING_INITIALIZER
15176 (struct cmd_set_vf_vlan_tag_result,
15178 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
15179 TOKEN_NUM_INITIALIZER
15180 (struct cmd_set_vf_vlan_tag_result,
15182 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
15183 TOKEN_NUM_INITIALIZER
15184 (struct cmd_set_vf_vlan_tag_result,
15186 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
15187 TOKEN_STRING_INITIALIZER
15188 (struct cmd_set_vf_vlan_tag_result,
15192 cmd_set_vf_vlan_tag_parsed(
15193 void *parsed_result,
15194 __rte_unused struct cmdline *cl,
15195 __rte_unused void *data)
15197 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
15198 int ret = -ENOTSUP;
15200 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15202 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15205 #ifdef RTE_LIBRTE_I40E_PMD
15206 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
15207 res->vf_id, is_on);
15214 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15217 printf("invalid port_id %d\n", res->port_id);
15220 printf("function not implemented\n");
15223 printf("programming error: (%s)\n", strerror(-ret));
15227 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
15228 .f = cmd_set_vf_vlan_tag_parsed,
15230 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
15232 (void *)&cmd_set_vf_vlan_tag_set,
15233 (void *)&cmd_set_vf_vlan_tag_vf,
15234 (void *)&cmd_set_vf_vlan_tag_vlan,
15235 (void *)&cmd_set_vf_vlan_tag_tag,
15236 (void *)&cmd_set_vf_vlan_tag_port_id,
15237 (void *)&cmd_set_vf_vlan_tag_vf_id,
15238 (void *)&cmd_set_vf_vlan_tag_on_off,
15243 /* Common definition of VF and TC TX bandwidth configuration */
15244 struct cmd_vf_tc_bw_result {
15245 cmdline_fixed_string_t set;
15246 cmdline_fixed_string_t vf;
15247 cmdline_fixed_string_t tc;
15248 cmdline_fixed_string_t tx;
15249 cmdline_fixed_string_t min_bw;
15250 cmdline_fixed_string_t max_bw;
15251 cmdline_fixed_string_t strict_link_prio;
15256 cmdline_fixed_string_t bw_list;
15260 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
15261 TOKEN_STRING_INITIALIZER
15262 (struct cmd_vf_tc_bw_result,
15264 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
15265 TOKEN_STRING_INITIALIZER
15266 (struct cmd_vf_tc_bw_result,
15268 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
15269 TOKEN_STRING_INITIALIZER
15270 (struct cmd_vf_tc_bw_result,
15272 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
15273 TOKEN_STRING_INITIALIZER
15274 (struct cmd_vf_tc_bw_result,
15276 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
15277 TOKEN_STRING_INITIALIZER
15278 (struct cmd_vf_tc_bw_result,
15279 strict_link_prio, "strict-link-priority");
15280 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
15281 TOKEN_STRING_INITIALIZER
15282 (struct cmd_vf_tc_bw_result,
15283 min_bw, "min-bandwidth");
15284 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
15285 TOKEN_STRING_INITIALIZER
15286 (struct cmd_vf_tc_bw_result,
15287 max_bw, "max-bandwidth");
15288 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
15289 TOKEN_NUM_INITIALIZER
15290 (struct cmd_vf_tc_bw_result,
15292 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
15293 TOKEN_NUM_INITIALIZER
15294 (struct cmd_vf_tc_bw_result,
15296 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
15297 TOKEN_NUM_INITIALIZER
15298 (struct cmd_vf_tc_bw_result,
15300 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
15301 TOKEN_NUM_INITIALIZER
15302 (struct cmd_vf_tc_bw_result,
15304 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
15305 TOKEN_STRING_INITIALIZER
15306 (struct cmd_vf_tc_bw_result,
15308 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
15309 TOKEN_NUM_INITIALIZER
15310 (struct cmd_vf_tc_bw_result,
15313 /* VF max bandwidth setting */
15315 cmd_vf_max_bw_parsed(
15316 void *parsed_result,
15317 __rte_unused struct cmdline *cl,
15318 __rte_unused void *data)
15320 struct cmd_vf_tc_bw_result *res = parsed_result;
15321 int ret = -ENOTSUP;
15323 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15326 #ifdef RTE_LIBRTE_I40E_PMD
15327 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15328 res->vf_id, res->bw);
15335 printf("invalid vf_id %d or bandwidth %d\n",
15336 res->vf_id, res->bw);
15339 printf("invalid port_id %d\n", res->port_id);
15342 printf("function not implemented\n");
15345 printf("programming error: (%s)\n", strerror(-ret));
15349 cmdline_parse_inst_t cmd_vf_max_bw = {
15350 .f = cmd_vf_max_bw_parsed,
15352 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15354 (void *)&cmd_vf_tc_bw_set,
15355 (void *)&cmd_vf_tc_bw_vf,
15356 (void *)&cmd_vf_tc_bw_tx,
15357 (void *)&cmd_vf_tc_bw_max_bw,
15358 (void *)&cmd_vf_tc_bw_port_id,
15359 (void *)&cmd_vf_tc_bw_vf_id,
15360 (void *)&cmd_vf_tc_bw_bw,
15366 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15371 const char *p, *p0 = str;
15378 p = strchr(p0, '(');
15380 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15384 p0 = strchr(p, ')');
15386 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15390 if (size >= sizeof(s)) {
15391 printf("The string size exceeds the internal buffer size\n");
15394 snprintf(s, sizeof(s), "%.*s", size, p);
15395 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15397 printf("Failed to get the bandwidth list. ");
15401 for (i = 0; i < ret; i++)
15402 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15407 /* TC min bandwidth setting */
15409 cmd_vf_tc_min_bw_parsed(
15410 void *parsed_result,
15411 __rte_unused struct cmdline *cl,
15412 __rte_unused void *data)
15414 struct cmd_vf_tc_bw_result *res = parsed_result;
15417 int ret = -ENOTSUP;
15419 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15422 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15426 #ifdef RTE_LIBRTE_I40E_PMD
15427 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15435 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15438 printf("invalid port_id %d\n", res->port_id);
15441 printf("function not implemented\n");
15444 printf("programming error: (%s)\n", strerror(-ret));
15448 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15449 .f = cmd_vf_tc_min_bw_parsed,
15451 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15452 " <bw1, bw2, ...>",
15454 (void *)&cmd_vf_tc_bw_set,
15455 (void *)&cmd_vf_tc_bw_vf,
15456 (void *)&cmd_vf_tc_bw_tc,
15457 (void *)&cmd_vf_tc_bw_tx,
15458 (void *)&cmd_vf_tc_bw_min_bw,
15459 (void *)&cmd_vf_tc_bw_port_id,
15460 (void *)&cmd_vf_tc_bw_vf_id,
15461 (void *)&cmd_vf_tc_bw_bw_list,
15467 cmd_tc_min_bw_parsed(
15468 void *parsed_result,
15469 __rte_unused struct cmdline *cl,
15470 __rte_unused void *data)
15472 struct cmd_vf_tc_bw_result *res = parsed_result;
15473 struct rte_port *port;
15476 int ret = -ENOTSUP;
15478 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15481 port = &ports[res->port_id];
15482 /** Check if the port is not started **/
15483 if (port->port_status != RTE_PORT_STOPPED) {
15484 printf("Please stop port %d first\n", res->port_id);
15488 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15492 #ifdef RTE_LIBRTE_IXGBE_PMD
15493 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15500 printf("invalid bandwidth\n");
15503 printf("invalid port_id %d\n", res->port_id);
15506 printf("function not implemented\n");
15509 printf("programming error: (%s)\n", strerror(-ret));
15513 cmdline_parse_inst_t cmd_tc_min_bw = {
15514 .f = cmd_tc_min_bw_parsed,
15516 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15518 (void *)&cmd_vf_tc_bw_set,
15519 (void *)&cmd_vf_tc_bw_tc,
15520 (void *)&cmd_vf_tc_bw_tx,
15521 (void *)&cmd_vf_tc_bw_min_bw,
15522 (void *)&cmd_vf_tc_bw_port_id,
15523 (void *)&cmd_vf_tc_bw_bw_list,
15528 /* TC max bandwidth setting */
15530 cmd_vf_tc_max_bw_parsed(
15531 void *parsed_result,
15532 __rte_unused struct cmdline *cl,
15533 __rte_unused void *data)
15535 struct cmd_vf_tc_bw_result *res = parsed_result;
15536 int ret = -ENOTSUP;
15538 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15541 #ifdef RTE_LIBRTE_I40E_PMD
15542 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15543 res->tc_no, res->bw);
15550 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15551 res->vf_id, res->tc_no, res->bw);
15554 printf("invalid port_id %d\n", res->port_id);
15557 printf("function not implemented\n");
15560 printf("programming error: (%s)\n", strerror(-ret));
15564 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15565 .f = cmd_vf_tc_max_bw_parsed,
15567 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15570 (void *)&cmd_vf_tc_bw_set,
15571 (void *)&cmd_vf_tc_bw_vf,
15572 (void *)&cmd_vf_tc_bw_tc,
15573 (void *)&cmd_vf_tc_bw_tx,
15574 (void *)&cmd_vf_tc_bw_max_bw,
15575 (void *)&cmd_vf_tc_bw_port_id,
15576 (void *)&cmd_vf_tc_bw_vf_id,
15577 (void *)&cmd_vf_tc_bw_tc_no,
15578 (void *)&cmd_vf_tc_bw_bw,
15583 /** Set VXLAN encapsulation details */
15584 struct cmd_set_vxlan_result {
15585 cmdline_fixed_string_t set;
15586 cmdline_fixed_string_t vxlan;
15587 cmdline_fixed_string_t pos_token;
15588 cmdline_fixed_string_t ip_version;
15589 uint32_t vlan_present:1;
15593 cmdline_ipaddr_t ip_src;
15594 cmdline_ipaddr_t ip_dst;
15598 struct rte_ether_addr eth_src;
15599 struct rte_ether_addr eth_dst;
15602 cmdline_parse_token_string_t cmd_set_vxlan_set =
15603 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15604 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15605 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15606 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15607 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15609 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15610 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15611 "vxlan-with-vlan");
15612 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15613 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15615 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15616 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15618 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15619 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15621 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15622 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15623 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15624 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15626 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15627 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15628 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15629 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15631 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15632 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15633 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15634 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15636 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15637 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15638 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15639 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15641 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15642 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15643 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15644 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15646 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15647 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15648 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15649 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15651 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15652 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15653 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15654 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15656 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15657 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15658 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15659 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15661 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15662 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15663 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15664 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15666 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15667 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15669 static void cmd_set_vxlan_parsed(void *parsed_result,
15670 __rte_unused struct cmdline *cl,
15671 __rte_unused void *data)
15673 struct cmd_set_vxlan_result *res = parsed_result;
15678 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15681 vxlan_encap_conf.select_tos_ttl = 0;
15682 if (strcmp(res->vxlan, "vxlan") == 0)
15683 vxlan_encap_conf.select_vlan = 0;
15684 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15685 vxlan_encap_conf.select_vlan = 1;
15686 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15687 vxlan_encap_conf.select_vlan = 0;
15688 vxlan_encap_conf.select_tos_ttl = 1;
15690 if (strcmp(res->ip_version, "ipv4") == 0)
15691 vxlan_encap_conf.select_ipv4 = 1;
15692 else if (strcmp(res->ip_version, "ipv6") == 0)
15693 vxlan_encap_conf.select_ipv4 = 0;
15696 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15697 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15698 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15699 vxlan_encap_conf.ip_tos = res->tos;
15700 vxlan_encap_conf.ip_ttl = res->ttl;
15701 if (vxlan_encap_conf.select_ipv4) {
15702 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15703 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15705 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15706 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15708 if (vxlan_encap_conf.select_vlan)
15709 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15710 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15711 RTE_ETHER_ADDR_LEN);
15712 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15713 RTE_ETHER_ADDR_LEN);
15716 cmdline_parse_inst_t cmd_set_vxlan = {
15717 .f = cmd_set_vxlan_parsed,
15719 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15720 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15721 " eth-src <eth-src> eth-dst <eth-dst>",
15723 (void *)&cmd_set_vxlan_set,
15724 (void *)&cmd_set_vxlan_vxlan,
15725 (void *)&cmd_set_vxlan_ip_version,
15726 (void *)&cmd_set_vxlan_ip_version_value,
15727 (void *)&cmd_set_vxlan_vni,
15728 (void *)&cmd_set_vxlan_vni_value,
15729 (void *)&cmd_set_vxlan_udp_src,
15730 (void *)&cmd_set_vxlan_udp_src_value,
15731 (void *)&cmd_set_vxlan_udp_dst,
15732 (void *)&cmd_set_vxlan_udp_dst_value,
15733 (void *)&cmd_set_vxlan_ip_src,
15734 (void *)&cmd_set_vxlan_ip_src_value,
15735 (void *)&cmd_set_vxlan_ip_dst,
15736 (void *)&cmd_set_vxlan_ip_dst_value,
15737 (void *)&cmd_set_vxlan_eth_src,
15738 (void *)&cmd_set_vxlan_eth_src_value,
15739 (void *)&cmd_set_vxlan_eth_dst,
15740 (void *)&cmd_set_vxlan_eth_dst_value,
15745 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15746 .f = cmd_set_vxlan_parsed,
15748 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15749 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15750 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15751 " eth-dst <eth-dst>",
15753 (void *)&cmd_set_vxlan_set,
15754 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15755 (void *)&cmd_set_vxlan_ip_version,
15756 (void *)&cmd_set_vxlan_ip_version_value,
15757 (void *)&cmd_set_vxlan_vni,
15758 (void *)&cmd_set_vxlan_vni_value,
15759 (void *)&cmd_set_vxlan_udp_src,
15760 (void *)&cmd_set_vxlan_udp_src_value,
15761 (void *)&cmd_set_vxlan_udp_dst,
15762 (void *)&cmd_set_vxlan_udp_dst_value,
15763 (void *)&cmd_set_vxlan_ip_tos,
15764 (void *)&cmd_set_vxlan_ip_tos_value,
15765 (void *)&cmd_set_vxlan_ip_ttl,
15766 (void *)&cmd_set_vxlan_ip_ttl_value,
15767 (void *)&cmd_set_vxlan_ip_src,
15768 (void *)&cmd_set_vxlan_ip_src_value,
15769 (void *)&cmd_set_vxlan_ip_dst,
15770 (void *)&cmd_set_vxlan_ip_dst_value,
15771 (void *)&cmd_set_vxlan_eth_src,
15772 (void *)&cmd_set_vxlan_eth_src_value,
15773 (void *)&cmd_set_vxlan_eth_dst,
15774 (void *)&cmd_set_vxlan_eth_dst_value,
15779 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15780 .f = cmd_set_vxlan_parsed,
15782 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15783 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15784 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15787 (void *)&cmd_set_vxlan_set,
15788 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15789 (void *)&cmd_set_vxlan_ip_version,
15790 (void *)&cmd_set_vxlan_ip_version_value,
15791 (void *)&cmd_set_vxlan_vni,
15792 (void *)&cmd_set_vxlan_vni_value,
15793 (void *)&cmd_set_vxlan_udp_src,
15794 (void *)&cmd_set_vxlan_udp_src_value,
15795 (void *)&cmd_set_vxlan_udp_dst,
15796 (void *)&cmd_set_vxlan_udp_dst_value,
15797 (void *)&cmd_set_vxlan_ip_src,
15798 (void *)&cmd_set_vxlan_ip_src_value,
15799 (void *)&cmd_set_vxlan_ip_dst,
15800 (void *)&cmd_set_vxlan_ip_dst_value,
15801 (void *)&cmd_set_vxlan_vlan,
15802 (void *)&cmd_set_vxlan_vlan_value,
15803 (void *)&cmd_set_vxlan_eth_src,
15804 (void *)&cmd_set_vxlan_eth_src_value,
15805 (void *)&cmd_set_vxlan_eth_dst,
15806 (void *)&cmd_set_vxlan_eth_dst_value,
15811 /** Set NVGRE encapsulation details */
15812 struct cmd_set_nvgre_result {
15813 cmdline_fixed_string_t set;
15814 cmdline_fixed_string_t nvgre;
15815 cmdline_fixed_string_t pos_token;
15816 cmdline_fixed_string_t ip_version;
15818 cmdline_ipaddr_t ip_src;
15819 cmdline_ipaddr_t ip_dst;
15821 struct rte_ether_addr eth_src;
15822 struct rte_ether_addr eth_dst;
15825 cmdline_parse_token_string_t cmd_set_nvgre_set =
15826 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15827 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15828 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15829 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15830 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15831 "nvgre-with-vlan");
15832 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15833 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15835 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15836 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15838 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15839 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15841 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15842 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15843 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15844 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15846 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15847 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15848 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15849 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15851 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15852 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15853 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15854 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15856 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15857 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15858 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15859 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15861 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15862 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15863 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15864 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15866 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15867 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15869 static void cmd_set_nvgre_parsed(void *parsed_result,
15870 __rte_unused struct cmdline *cl,
15871 __rte_unused void *data)
15873 struct cmd_set_nvgre_result *res = parsed_result;
15875 uint32_t nvgre_tni;
15878 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15881 if (strcmp(res->nvgre, "nvgre") == 0)
15882 nvgre_encap_conf.select_vlan = 0;
15883 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15884 nvgre_encap_conf.select_vlan = 1;
15885 if (strcmp(res->ip_version, "ipv4") == 0)
15886 nvgre_encap_conf.select_ipv4 = 1;
15887 else if (strcmp(res->ip_version, "ipv6") == 0)
15888 nvgre_encap_conf.select_ipv4 = 0;
15891 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15892 if (nvgre_encap_conf.select_ipv4) {
15893 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15894 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15896 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15897 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15899 if (nvgre_encap_conf.select_vlan)
15900 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15901 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15902 RTE_ETHER_ADDR_LEN);
15903 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15904 RTE_ETHER_ADDR_LEN);
15907 cmdline_parse_inst_t cmd_set_nvgre = {
15908 .f = cmd_set_nvgre_parsed,
15910 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15911 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15912 " eth-dst <eth-dst>",
15914 (void *)&cmd_set_nvgre_set,
15915 (void *)&cmd_set_nvgre_nvgre,
15916 (void *)&cmd_set_nvgre_ip_version,
15917 (void *)&cmd_set_nvgre_ip_version_value,
15918 (void *)&cmd_set_nvgre_tni,
15919 (void *)&cmd_set_nvgre_tni_value,
15920 (void *)&cmd_set_nvgre_ip_src,
15921 (void *)&cmd_set_nvgre_ip_src_value,
15922 (void *)&cmd_set_nvgre_ip_dst,
15923 (void *)&cmd_set_nvgre_ip_dst_value,
15924 (void *)&cmd_set_nvgre_eth_src,
15925 (void *)&cmd_set_nvgre_eth_src_value,
15926 (void *)&cmd_set_nvgre_eth_dst,
15927 (void *)&cmd_set_nvgre_eth_dst_value,
15932 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15933 .f = cmd_set_nvgre_parsed,
15935 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15936 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15937 " eth-src <eth-src> eth-dst <eth-dst>",
15939 (void *)&cmd_set_nvgre_set,
15940 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15941 (void *)&cmd_set_nvgre_ip_version,
15942 (void *)&cmd_set_nvgre_ip_version_value,
15943 (void *)&cmd_set_nvgre_tni,
15944 (void *)&cmd_set_nvgre_tni_value,
15945 (void *)&cmd_set_nvgre_ip_src,
15946 (void *)&cmd_set_nvgre_ip_src_value,
15947 (void *)&cmd_set_nvgre_ip_dst,
15948 (void *)&cmd_set_nvgre_ip_dst_value,
15949 (void *)&cmd_set_nvgre_vlan,
15950 (void *)&cmd_set_nvgre_vlan_value,
15951 (void *)&cmd_set_nvgre_eth_src,
15952 (void *)&cmd_set_nvgre_eth_src_value,
15953 (void *)&cmd_set_nvgre_eth_dst,
15954 (void *)&cmd_set_nvgre_eth_dst_value,
15959 /** Set L2 encapsulation details */
15960 struct cmd_set_l2_encap_result {
15961 cmdline_fixed_string_t set;
15962 cmdline_fixed_string_t l2_encap;
15963 cmdline_fixed_string_t pos_token;
15964 cmdline_fixed_string_t ip_version;
15965 uint32_t vlan_present:1;
15967 struct rte_ether_addr eth_src;
15968 struct rte_ether_addr eth_dst;
15971 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15972 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15973 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15974 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15975 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15976 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15977 "l2_encap-with-vlan");
15978 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15979 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15981 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15982 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15984 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15985 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15987 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15988 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15989 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15990 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15992 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15993 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15994 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15995 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15997 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15998 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
16000 static void cmd_set_l2_encap_parsed(void *parsed_result,
16001 __rte_unused struct cmdline *cl,
16002 __rte_unused void *data)
16004 struct cmd_set_l2_encap_result *res = parsed_result;
16006 if (strcmp(res->l2_encap, "l2_encap") == 0)
16007 l2_encap_conf.select_vlan = 0;
16008 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
16009 l2_encap_conf.select_vlan = 1;
16010 if (strcmp(res->ip_version, "ipv4") == 0)
16011 l2_encap_conf.select_ipv4 = 1;
16012 else if (strcmp(res->ip_version, "ipv6") == 0)
16013 l2_encap_conf.select_ipv4 = 0;
16016 if (l2_encap_conf.select_vlan)
16017 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16018 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
16019 RTE_ETHER_ADDR_LEN);
16020 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16021 RTE_ETHER_ADDR_LEN);
16024 cmdline_parse_inst_t cmd_set_l2_encap = {
16025 .f = cmd_set_l2_encap_parsed,
16027 .help_str = "set l2_encap ip-version ipv4|ipv6"
16028 " eth-src <eth-src> eth-dst <eth-dst>",
16030 (void *)&cmd_set_l2_encap_set,
16031 (void *)&cmd_set_l2_encap_l2_encap,
16032 (void *)&cmd_set_l2_encap_ip_version,
16033 (void *)&cmd_set_l2_encap_ip_version_value,
16034 (void *)&cmd_set_l2_encap_eth_src,
16035 (void *)&cmd_set_l2_encap_eth_src_value,
16036 (void *)&cmd_set_l2_encap_eth_dst,
16037 (void *)&cmd_set_l2_encap_eth_dst_value,
16042 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
16043 .f = cmd_set_l2_encap_parsed,
16045 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
16046 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16048 (void *)&cmd_set_l2_encap_set,
16049 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
16050 (void *)&cmd_set_l2_encap_ip_version,
16051 (void *)&cmd_set_l2_encap_ip_version_value,
16052 (void *)&cmd_set_l2_encap_vlan,
16053 (void *)&cmd_set_l2_encap_vlan_value,
16054 (void *)&cmd_set_l2_encap_eth_src,
16055 (void *)&cmd_set_l2_encap_eth_src_value,
16056 (void *)&cmd_set_l2_encap_eth_dst,
16057 (void *)&cmd_set_l2_encap_eth_dst_value,
16062 /** Set L2 decapsulation details */
16063 struct cmd_set_l2_decap_result {
16064 cmdline_fixed_string_t set;
16065 cmdline_fixed_string_t l2_decap;
16066 cmdline_fixed_string_t pos_token;
16067 uint32_t vlan_present:1;
16070 cmdline_parse_token_string_t cmd_set_l2_decap_set =
16071 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
16072 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
16073 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
16075 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
16076 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
16077 "l2_decap-with-vlan");
16079 static void cmd_set_l2_decap_parsed(void *parsed_result,
16080 __rte_unused struct cmdline *cl,
16081 __rte_unused void *data)
16083 struct cmd_set_l2_decap_result *res = parsed_result;
16085 if (strcmp(res->l2_decap, "l2_decap") == 0)
16086 l2_decap_conf.select_vlan = 0;
16087 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
16088 l2_decap_conf.select_vlan = 1;
16091 cmdline_parse_inst_t cmd_set_l2_decap = {
16092 .f = cmd_set_l2_decap_parsed,
16094 .help_str = "set l2_decap",
16096 (void *)&cmd_set_l2_decap_set,
16097 (void *)&cmd_set_l2_decap_l2_decap,
16102 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
16103 .f = cmd_set_l2_decap_parsed,
16105 .help_str = "set l2_decap-with-vlan",
16107 (void *)&cmd_set_l2_decap_set,
16108 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
16113 /** Set MPLSoGRE encapsulation details */
16114 struct cmd_set_mplsogre_encap_result {
16115 cmdline_fixed_string_t set;
16116 cmdline_fixed_string_t mplsogre;
16117 cmdline_fixed_string_t pos_token;
16118 cmdline_fixed_string_t ip_version;
16119 uint32_t vlan_present:1;
16121 cmdline_ipaddr_t ip_src;
16122 cmdline_ipaddr_t ip_dst;
16124 struct rte_ether_addr eth_src;
16125 struct rte_ether_addr eth_dst;
16128 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
16129 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
16131 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
16132 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
16134 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
16135 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16136 mplsogre, "mplsogre_encap-with-vlan");
16137 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
16138 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16139 pos_token, "ip-version");
16140 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
16141 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16142 ip_version, "ipv4#ipv6");
16143 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
16144 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16145 pos_token, "label");
16146 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
16147 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
16149 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
16150 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16151 pos_token, "ip-src");
16152 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
16153 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
16154 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
16155 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16156 pos_token, "ip-dst");
16157 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
16158 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
16159 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
16160 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16161 pos_token, "vlan-tci");
16162 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
16163 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
16165 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
16166 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16167 pos_token, "eth-src");
16168 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
16169 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16171 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
16172 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16173 pos_token, "eth-dst");
16174 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
16175 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16178 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
16179 __rte_unused struct cmdline *cl,
16180 __rte_unused void *data)
16182 struct cmd_set_mplsogre_encap_result *res = parsed_result;
16184 uint32_t mplsogre_label;
16187 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
16190 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
16191 mplsogre_encap_conf.select_vlan = 0;
16192 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
16193 mplsogre_encap_conf.select_vlan = 1;
16194 if (strcmp(res->ip_version, "ipv4") == 0)
16195 mplsogre_encap_conf.select_ipv4 = 1;
16196 else if (strcmp(res->ip_version, "ipv6") == 0)
16197 mplsogre_encap_conf.select_ipv4 = 0;
16200 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
16201 if (mplsogre_encap_conf.select_ipv4) {
16202 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
16203 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
16205 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
16206 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
16208 if (mplsogre_encap_conf.select_vlan)
16209 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16210 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
16211 RTE_ETHER_ADDR_LEN);
16212 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16213 RTE_ETHER_ADDR_LEN);
16216 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
16217 .f = cmd_set_mplsogre_encap_parsed,
16219 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
16220 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
16221 " eth-dst <eth-dst>",
16223 (void *)&cmd_set_mplsogre_encap_set,
16224 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
16225 (void *)&cmd_set_mplsogre_encap_ip_version,
16226 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16227 (void *)&cmd_set_mplsogre_encap_label,
16228 (void *)&cmd_set_mplsogre_encap_label_value,
16229 (void *)&cmd_set_mplsogre_encap_ip_src,
16230 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16231 (void *)&cmd_set_mplsogre_encap_ip_dst,
16232 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16233 (void *)&cmd_set_mplsogre_encap_eth_src,
16234 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16235 (void *)&cmd_set_mplsogre_encap_eth_dst,
16236 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16241 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16242 .f = cmd_set_mplsogre_encap_parsed,
16244 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16245 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16246 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16248 (void *)&cmd_set_mplsogre_encap_set,
16249 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16250 (void *)&cmd_set_mplsogre_encap_ip_version,
16251 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16252 (void *)&cmd_set_mplsogre_encap_label,
16253 (void *)&cmd_set_mplsogre_encap_label_value,
16254 (void *)&cmd_set_mplsogre_encap_ip_src,
16255 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16256 (void *)&cmd_set_mplsogre_encap_ip_dst,
16257 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16258 (void *)&cmd_set_mplsogre_encap_vlan,
16259 (void *)&cmd_set_mplsogre_encap_vlan_value,
16260 (void *)&cmd_set_mplsogre_encap_eth_src,
16261 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16262 (void *)&cmd_set_mplsogre_encap_eth_dst,
16263 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16268 /** Set MPLSoGRE decapsulation details */
16269 struct cmd_set_mplsogre_decap_result {
16270 cmdline_fixed_string_t set;
16271 cmdline_fixed_string_t mplsogre;
16272 cmdline_fixed_string_t pos_token;
16273 cmdline_fixed_string_t ip_version;
16274 uint32_t vlan_present:1;
16277 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16278 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16280 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16281 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16283 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16284 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16285 mplsogre, "mplsogre_decap-with-vlan");
16286 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16287 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16288 pos_token, "ip-version");
16289 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16290 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16291 ip_version, "ipv4#ipv6");
16293 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16294 __rte_unused struct cmdline *cl,
16295 __rte_unused void *data)
16297 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16299 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16300 mplsogre_decap_conf.select_vlan = 0;
16301 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16302 mplsogre_decap_conf.select_vlan = 1;
16303 if (strcmp(res->ip_version, "ipv4") == 0)
16304 mplsogre_decap_conf.select_ipv4 = 1;
16305 else if (strcmp(res->ip_version, "ipv6") == 0)
16306 mplsogre_decap_conf.select_ipv4 = 0;
16309 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16310 .f = cmd_set_mplsogre_decap_parsed,
16312 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16314 (void *)&cmd_set_mplsogre_decap_set,
16315 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16316 (void *)&cmd_set_mplsogre_decap_ip_version,
16317 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16322 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16323 .f = cmd_set_mplsogre_decap_parsed,
16325 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16327 (void *)&cmd_set_mplsogre_decap_set,
16328 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16329 (void *)&cmd_set_mplsogre_decap_ip_version,
16330 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16335 /** Set MPLSoUDP encapsulation details */
16336 struct cmd_set_mplsoudp_encap_result {
16337 cmdline_fixed_string_t set;
16338 cmdline_fixed_string_t mplsoudp;
16339 cmdline_fixed_string_t pos_token;
16340 cmdline_fixed_string_t ip_version;
16341 uint32_t vlan_present:1;
16345 cmdline_ipaddr_t ip_src;
16346 cmdline_ipaddr_t ip_dst;
16348 struct rte_ether_addr eth_src;
16349 struct rte_ether_addr eth_dst;
16352 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16353 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16355 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16356 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16358 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16359 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16360 mplsoudp, "mplsoudp_encap-with-vlan");
16361 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16362 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16363 pos_token, "ip-version");
16364 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16365 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16366 ip_version, "ipv4#ipv6");
16367 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16368 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16369 pos_token, "label");
16370 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16371 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16373 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16374 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16375 pos_token, "udp-src");
16376 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16377 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16379 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16380 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16381 pos_token, "udp-dst");
16382 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16383 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16385 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16386 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16387 pos_token, "ip-src");
16388 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16389 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16390 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16391 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16392 pos_token, "ip-dst");
16393 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16394 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16395 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16396 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16397 pos_token, "vlan-tci");
16398 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16399 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16401 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16402 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16403 pos_token, "eth-src");
16404 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16405 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16407 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16408 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16409 pos_token, "eth-dst");
16410 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16411 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16414 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16415 __rte_unused struct cmdline *cl,
16416 __rte_unused void *data)
16418 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16420 uint32_t mplsoudp_label;
16423 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16426 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16427 mplsoudp_encap_conf.select_vlan = 0;
16428 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16429 mplsoudp_encap_conf.select_vlan = 1;
16430 if (strcmp(res->ip_version, "ipv4") == 0)
16431 mplsoudp_encap_conf.select_ipv4 = 1;
16432 else if (strcmp(res->ip_version, "ipv6") == 0)
16433 mplsoudp_encap_conf.select_ipv4 = 0;
16436 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16437 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16438 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16439 if (mplsoudp_encap_conf.select_ipv4) {
16440 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16441 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16443 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16444 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16446 if (mplsoudp_encap_conf.select_vlan)
16447 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16448 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16449 RTE_ETHER_ADDR_LEN);
16450 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16451 RTE_ETHER_ADDR_LEN);
16454 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16455 .f = cmd_set_mplsoudp_encap_parsed,
16457 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16458 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16459 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16461 (void *)&cmd_set_mplsoudp_encap_set,
16462 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16463 (void *)&cmd_set_mplsoudp_encap_ip_version,
16464 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16465 (void *)&cmd_set_mplsoudp_encap_label,
16466 (void *)&cmd_set_mplsoudp_encap_label_value,
16467 (void *)&cmd_set_mplsoudp_encap_udp_src,
16468 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16469 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16470 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16471 (void *)&cmd_set_mplsoudp_encap_ip_src,
16472 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16473 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16474 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16475 (void *)&cmd_set_mplsoudp_encap_eth_src,
16476 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16477 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16478 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16483 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16484 .f = cmd_set_mplsoudp_encap_parsed,
16486 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16487 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16488 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16489 " eth-src <eth-src> eth-dst <eth-dst>",
16491 (void *)&cmd_set_mplsoudp_encap_set,
16492 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16493 (void *)&cmd_set_mplsoudp_encap_ip_version,
16494 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16495 (void *)&cmd_set_mplsoudp_encap_label,
16496 (void *)&cmd_set_mplsoudp_encap_label_value,
16497 (void *)&cmd_set_mplsoudp_encap_udp_src,
16498 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16499 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16500 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16501 (void *)&cmd_set_mplsoudp_encap_ip_src,
16502 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16503 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16504 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16505 (void *)&cmd_set_mplsoudp_encap_vlan,
16506 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16507 (void *)&cmd_set_mplsoudp_encap_eth_src,
16508 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16509 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16510 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16515 /** Set MPLSoUDP decapsulation details */
16516 struct cmd_set_mplsoudp_decap_result {
16517 cmdline_fixed_string_t set;
16518 cmdline_fixed_string_t mplsoudp;
16519 cmdline_fixed_string_t pos_token;
16520 cmdline_fixed_string_t ip_version;
16521 uint32_t vlan_present:1;
16524 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16525 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16527 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16528 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16530 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16531 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16532 mplsoudp, "mplsoudp_decap-with-vlan");
16533 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16534 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16535 pos_token, "ip-version");
16536 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16537 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16538 ip_version, "ipv4#ipv6");
16540 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16541 __rte_unused struct cmdline *cl,
16542 __rte_unused void *data)
16544 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16546 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16547 mplsoudp_decap_conf.select_vlan = 0;
16548 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16549 mplsoudp_decap_conf.select_vlan = 1;
16550 if (strcmp(res->ip_version, "ipv4") == 0)
16551 mplsoudp_decap_conf.select_ipv4 = 1;
16552 else if (strcmp(res->ip_version, "ipv6") == 0)
16553 mplsoudp_decap_conf.select_ipv4 = 0;
16556 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16557 .f = cmd_set_mplsoudp_decap_parsed,
16559 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16561 (void *)&cmd_set_mplsoudp_decap_set,
16562 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16563 (void *)&cmd_set_mplsoudp_decap_ip_version,
16564 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16569 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16570 .f = cmd_set_mplsoudp_decap_parsed,
16572 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16574 (void *)&cmd_set_mplsoudp_decap_set,
16575 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16576 (void *)&cmd_set_mplsoudp_decap_ip_version,
16577 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16582 /* Strict link priority scheduling mode setting */
16584 cmd_strict_link_prio_parsed(
16585 void *parsed_result,
16586 __rte_unused struct cmdline *cl,
16587 __rte_unused void *data)
16589 struct cmd_vf_tc_bw_result *res = parsed_result;
16590 int ret = -ENOTSUP;
16592 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16595 #ifdef RTE_LIBRTE_I40E_PMD
16596 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16603 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16606 printf("invalid port_id %d\n", res->port_id);
16609 printf("function not implemented\n");
16612 printf("programming error: (%s)\n", strerror(-ret));
16616 cmdline_parse_inst_t cmd_strict_link_prio = {
16617 .f = cmd_strict_link_prio_parsed,
16619 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16621 (void *)&cmd_vf_tc_bw_set,
16622 (void *)&cmd_vf_tc_bw_tx,
16623 (void *)&cmd_vf_tc_bw_strict_link_prio,
16624 (void *)&cmd_vf_tc_bw_port_id,
16625 (void *)&cmd_vf_tc_bw_tc_map,
16630 /* Load dynamic device personalization*/
16631 struct cmd_ddp_add_result {
16632 cmdline_fixed_string_t ddp;
16633 cmdline_fixed_string_t add;
16638 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16639 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16640 cmdline_parse_token_string_t cmd_ddp_add_add =
16641 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16642 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16643 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16644 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16645 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16648 cmd_ddp_add_parsed(
16649 void *parsed_result,
16650 __rte_unused struct cmdline *cl,
16651 __rte_unused void *data)
16653 struct cmd_ddp_add_result *res = parsed_result;
16659 int ret = -ENOTSUP;
16661 if (!all_ports_stopped()) {
16662 printf("Please stop all ports first\n");
16666 filepath = strdup(res->filepath);
16667 if (filepath == NULL) {
16668 printf("Failed to allocate memory\n");
16671 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16673 buff = open_file(file_fld[0], &size);
16675 free((void *)filepath);
16679 #ifdef RTE_LIBRTE_I40E_PMD
16680 if (ret == -ENOTSUP)
16681 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16683 RTE_PMD_I40E_PKG_OP_WR_ADD);
16686 if (ret == -EEXIST)
16687 printf("Profile has already existed.\n");
16689 printf("Failed to load profile.\n");
16690 else if (file_num == 2)
16691 save_file(file_fld[1], buff, size);
16694 free((void *)filepath);
16697 cmdline_parse_inst_t cmd_ddp_add = {
16698 .f = cmd_ddp_add_parsed,
16700 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16702 (void *)&cmd_ddp_add_ddp,
16703 (void *)&cmd_ddp_add_add,
16704 (void *)&cmd_ddp_add_port_id,
16705 (void *)&cmd_ddp_add_filepath,
16710 /* Delete dynamic device personalization*/
16711 struct cmd_ddp_del_result {
16712 cmdline_fixed_string_t ddp;
16713 cmdline_fixed_string_t del;
16718 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16719 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16720 cmdline_parse_token_string_t cmd_ddp_del_del =
16721 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16722 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16723 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16724 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16725 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16728 cmd_ddp_del_parsed(
16729 void *parsed_result,
16730 __rte_unused struct cmdline *cl,
16731 __rte_unused void *data)
16733 struct cmd_ddp_del_result *res = parsed_result;
16736 int ret = -ENOTSUP;
16738 if (!all_ports_stopped()) {
16739 printf("Please stop all ports first\n");
16743 buff = open_file(res->filepath, &size);
16747 #ifdef RTE_LIBRTE_I40E_PMD
16748 if (ret == -ENOTSUP)
16749 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16751 RTE_PMD_I40E_PKG_OP_WR_DEL);
16754 if (ret == -EACCES)
16755 printf("Profile does not exist.\n");
16757 printf("Failed to delete profile.\n");
16762 cmdline_parse_inst_t cmd_ddp_del = {
16763 .f = cmd_ddp_del_parsed,
16765 .help_str = "ddp del <port_id> <backup_profile_path>",
16767 (void *)&cmd_ddp_del_ddp,
16768 (void *)&cmd_ddp_del_del,
16769 (void *)&cmd_ddp_del_port_id,
16770 (void *)&cmd_ddp_del_filepath,
16775 /* Get dynamic device personalization profile info */
16776 struct cmd_ddp_info_result {
16777 cmdline_fixed_string_t ddp;
16778 cmdline_fixed_string_t get;
16779 cmdline_fixed_string_t info;
16783 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16784 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16785 cmdline_parse_token_string_t cmd_ddp_info_get =
16786 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16787 cmdline_parse_token_string_t cmd_ddp_info_info =
16788 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16789 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16790 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16793 cmd_ddp_info_parsed(
16794 void *parsed_result,
16795 __rte_unused struct cmdline *cl,
16796 __rte_unused void *data)
16798 struct cmd_ddp_info_result *res = parsed_result;
16801 int ret = -ENOTSUP;
16802 #ifdef RTE_LIBRTE_I40E_PMD
16805 uint32_t buff_size = 0;
16806 struct rte_pmd_i40e_profile_info info;
16807 uint32_t dev_num = 0;
16808 struct rte_pmd_i40e_ddp_device_id *devs;
16809 uint32_t proto_num = 0;
16810 struct rte_pmd_i40e_proto_info *proto = NULL;
16811 uint32_t pctype_num = 0;
16812 struct rte_pmd_i40e_ptype_info *pctype;
16813 uint32_t ptype_num = 0;
16814 struct rte_pmd_i40e_ptype_info *ptype;
16819 pkg = open_file(res->filepath, &pkg_size);
16823 #ifdef RTE_LIBRTE_I40E_PMD
16824 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16825 (uint8_t *)&info, sizeof(info),
16826 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16828 printf("Global Track id: 0x%x\n", info.track_id);
16829 printf("Global Version: %d.%d.%d.%d\n",
16830 info.version.major,
16831 info.version.minor,
16832 info.version.update,
16833 info.version.draft);
16834 printf("Global Package name: %s\n\n", info.name);
16837 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16838 (uint8_t *)&info, sizeof(info),
16839 RTE_PMD_I40E_PKG_INFO_HEADER);
16841 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16842 printf("i40e Profile Version: %d.%d.%d.%d\n",
16843 info.version.major,
16844 info.version.minor,
16845 info.version.update,
16846 info.version.draft);
16847 printf("i40e Profile name: %s\n\n", info.name);
16850 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16851 (uint8_t *)&buff_size, sizeof(buff_size),
16852 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16853 if (!ret && buff_size) {
16854 buff = (uint8_t *)malloc(buff_size);
16856 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16858 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16860 printf("Package Notes:\n%s\n\n", buff);
16865 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16866 (uint8_t *)&dev_num, sizeof(dev_num),
16867 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16868 if (!ret && dev_num) {
16869 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16870 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16872 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16873 (uint8_t *)devs, buff_size,
16874 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16876 printf("List of supported devices:\n");
16877 for (i = 0; i < dev_num; i++) {
16878 printf(" %04X:%04X %04X:%04X\n",
16879 devs[i].vendor_dev_id >> 16,
16880 devs[i].vendor_dev_id & 0xFFFF,
16881 devs[i].sub_vendor_dev_id >> 16,
16882 devs[i].sub_vendor_dev_id & 0xFFFF);
16890 /* get information about protocols and packet types */
16891 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16892 (uint8_t *)&proto_num, sizeof(proto_num),
16893 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16894 if (ret || !proto_num)
16895 goto no_print_return;
16897 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16898 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16900 goto no_print_return;
16902 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16904 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16906 printf("List of used protocols:\n");
16907 for (i = 0; i < proto_num; i++)
16908 printf(" %2u: %s\n", proto[i].proto_id,
16912 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16913 (uint8_t *)&pctype_num, sizeof(pctype_num),
16914 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16915 if (ret || !pctype_num)
16916 goto no_print_pctypes;
16918 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16919 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16921 goto no_print_pctypes;
16923 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16925 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16928 goto no_print_pctypes;
16931 printf("List of defined packet classification types:\n");
16932 for (i = 0; i < pctype_num; i++) {
16933 printf(" %2u:", pctype[i].ptype_id);
16934 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16935 proto_id = pctype[i].protocols[j];
16936 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16937 for (n = 0; n < proto_num; n++) {
16938 if (proto[n].proto_id == proto_id) {
16939 printf(" %s", proto[n].name);
16952 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16954 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16955 if (ret || !ptype_num)
16956 goto no_print_return;
16958 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16959 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16961 goto no_print_return;
16963 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16965 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16968 goto no_print_return;
16970 printf("List of defined packet types:\n");
16971 for (i = 0; i < ptype_num; i++) {
16972 printf(" %2u:", ptype[i].ptype_id);
16973 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16974 proto_id = ptype[i].protocols[j];
16975 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16976 for (n = 0; n < proto_num; n++) {
16977 if (proto[n].proto_id == proto_id) {
16978 printf(" %s", proto[n].name);
16994 if (ret == -ENOTSUP)
16995 printf("Function not supported in PMD driver\n");
16999 cmdline_parse_inst_t cmd_ddp_get_info = {
17000 .f = cmd_ddp_info_parsed,
17002 .help_str = "ddp get info <profile_path>",
17004 (void *)&cmd_ddp_info_ddp,
17005 (void *)&cmd_ddp_info_get,
17006 (void *)&cmd_ddp_info_info,
17007 (void *)&cmd_ddp_info_filepath,
17012 /* Get dynamic device personalization profile info list*/
17013 #define PROFILE_INFO_SIZE 48
17014 #define MAX_PROFILE_NUM 16
17016 struct cmd_ddp_get_list_result {
17017 cmdline_fixed_string_t ddp;
17018 cmdline_fixed_string_t get;
17019 cmdline_fixed_string_t list;
17023 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
17024 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
17025 cmdline_parse_token_string_t cmd_ddp_get_list_get =
17026 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
17027 cmdline_parse_token_string_t cmd_ddp_get_list_list =
17028 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
17029 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
17030 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
17033 cmd_ddp_get_list_parsed(
17034 __rte_unused void *parsed_result,
17035 __rte_unused struct cmdline *cl,
17036 __rte_unused void *data)
17038 #ifdef RTE_LIBRTE_I40E_PMD
17039 struct cmd_ddp_get_list_result *res = parsed_result;
17040 struct rte_pmd_i40e_profile_list *p_list;
17041 struct rte_pmd_i40e_profile_info *p_info;
17046 int ret = -ENOTSUP;
17048 #ifdef RTE_LIBRTE_I40E_PMD
17049 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
17050 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
17052 printf("%s: Failed to malloc buffer\n", __func__);
17056 if (ret == -ENOTSUP)
17057 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
17058 (uint8_t *)p_list, size);
17061 p_num = p_list->p_count;
17062 printf("Profile number is: %d\n\n", p_num);
17064 for (i = 0; i < p_num; i++) {
17065 p_info = &p_list->p_info[i];
17066 printf("Profile %d:\n", i);
17067 printf("Track id: 0x%x\n", p_info->track_id);
17068 printf("Version: %d.%d.%d.%d\n",
17069 p_info->version.major,
17070 p_info->version.minor,
17071 p_info->version.update,
17072 p_info->version.draft);
17073 printf("Profile name: %s\n\n", p_info->name);
17081 printf("Failed to get ddp list\n");
17084 cmdline_parse_inst_t cmd_ddp_get_list = {
17085 .f = cmd_ddp_get_list_parsed,
17087 .help_str = "ddp get list <port_id>",
17089 (void *)&cmd_ddp_get_list_ddp,
17090 (void *)&cmd_ddp_get_list_get,
17091 (void *)&cmd_ddp_get_list_list,
17092 (void *)&cmd_ddp_get_list_port_id,
17097 /* Configure input set */
17098 struct cmd_cfg_input_set_result {
17099 cmdline_fixed_string_t port;
17100 cmdline_fixed_string_t cfg;
17102 cmdline_fixed_string_t pctype;
17104 cmdline_fixed_string_t inset_type;
17105 cmdline_fixed_string_t opt;
17106 cmdline_fixed_string_t field;
17111 cmd_cfg_input_set_parsed(
17112 __rte_unused void *parsed_result,
17113 __rte_unused struct cmdline *cl,
17114 __rte_unused void *data)
17116 #ifdef RTE_LIBRTE_I40E_PMD
17117 struct cmd_cfg_input_set_result *res = parsed_result;
17118 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17119 struct rte_pmd_i40e_inset inset;
17121 int ret = -ENOTSUP;
17123 if (!all_ports_stopped()) {
17124 printf("Please stop all ports first\n");
17128 #ifdef RTE_LIBRTE_I40E_PMD
17129 if (!strcmp(res->inset_type, "hash_inset"))
17130 inset_type = INSET_HASH;
17131 else if (!strcmp(res->inset_type, "fdir_inset"))
17132 inset_type = INSET_FDIR;
17133 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17134 inset_type = INSET_FDIR_FLX;
17135 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
17136 &inset, inset_type);
17138 printf("Failed to get input set.\n");
17142 if (!strcmp(res->opt, "get")) {
17143 ret = rte_pmd_i40e_inset_field_get(inset.inset,
17146 printf("Field index %d is enabled.\n", res->field_idx);
17148 printf("Field index %d is disabled.\n", res->field_idx);
17150 } else if (!strcmp(res->opt, "set"))
17151 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
17153 else if (!strcmp(res->opt, "clear"))
17154 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
17157 printf("Failed to configure input set field.\n");
17161 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17162 &inset, inset_type);
17164 printf("Failed to set input set.\n");
17169 if (ret == -ENOTSUP)
17170 printf("Function not supported\n");
17173 cmdline_parse_token_string_t cmd_cfg_input_set_port =
17174 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17176 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
17177 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17179 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
17180 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17182 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
17183 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17185 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
17186 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17188 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
17189 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17191 "hash_inset#fdir_inset#fdir_flx_inset");
17192 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
17193 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17194 opt, "get#set#clear");
17195 cmdline_parse_token_string_t cmd_cfg_input_set_field =
17196 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17198 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
17199 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17202 cmdline_parse_inst_t cmd_cfg_input_set = {
17203 .f = cmd_cfg_input_set_parsed,
17205 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17206 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
17208 (void *)&cmd_cfg_input_set_port,
17209 (void *)&cmd_cfg_input_set_cfg,
17210 (void *)&cmd_cfg_input_set_port_id,
17211 (void *)&cmd_cfg_input_set_pctype,
17212 (void *)&cmd_cfg_input_set_pctype_id,
17213 (void *)&cmd_cfg_input_set_inset_type,
17214 (void *)&cmd_cfg_input_set_opt,
17215 (void *)&cmd_cfg_input_set_field,
17216 (void *)&cmd_cfg_input_set_field_idx,
17221 /* Clear input set */
17222 struct cmd_clear_input_set_result {
17223 cmdline_fixed_string_t port;
17224 cmdline_fixed_string_t cfg;
17226 cmdline_fixed_string_t pctype;
17228 cmdline_fixed_string_t inset_type;
17229 cmdline_fixed_string_t clear;
17230 cmdline_fixed_string_t all;
17234 cmd_clear_input_set_parsed(
17235 __rte_unused void *parsed_result,
17236 __rte_unused struct cmdline *cl,
17237 __rte_unused void *data)
17239 #ifdef RTE_LIBRTE_I40E_PMD
17240 struct cmd_clear_input_set_result *res = parsed_result;
17241 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17242 struct rte_pmd_i40e_inset inset;
17244 int ret = -ENOTSUP;
17246 if (!all_ports_stopped()) {
17247 printf("Please stop all ports first\n");
17251 #ifdef RTE_LIBRTE_I40E_PMD
17252 if (!strcmp(res->inset_type, "hash_inset"))
17253 inset_type = INSET_HASH;
17254 else if (!strcmp(res->inset_type, "fdir_inset"))
17255 inset_type = INSET_FDIR;
17256 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17257 inset_type = INSET_FDIR_FLX;
17259 memset(&inset, 0, sizeof(inset));
17261 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17262 &inset, inset_type);
17264 printf("Failed to clear input set.\n");
17270 if (ret == -ENOTSUP)
17271 printf("Function not supported\n");
17274 cmdline_parse_token_string_t cmd_clear_input_set_port =
17275 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17277 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17278 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17280 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17281 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17283 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17284 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17286 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17287 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17289 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17290 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17292 "hash_inset#fdir_inset#fdir_flx_inset");
17293 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17294 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17296 cmdline_parse_token_string_t cmd_clear_input_set_all =
17297 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17300 cmdline_parse_inst_t cmd_clear_input_set = {
17301 .f = cmd_clear_input_set_parsed,
17303 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17304 "fdir_inset|fdir_flx_inset clear all",
17306 (void *)&cmd_clear_input_set_port,
17307 (void *)&cmd_clear_input_set_cfg,
17308 (void *)&cmd_clear_input_set_port_id,
17309 (void *)&cmd_clear_input_set_pctype,
17310 (void *)&cmd_clear_input_set_pctype_id,
17311 (void *)&cmd_clear_input_set_inset_type,
17312 (void *)&cmd_clear_input_set_clear,
17313 (void *)&cmd_clear_input_set_all,
17318 /* show vf stats */
17320 /* Common result structure for show vf stats */
17321 struct cmd_show_vf_stats_result {
17322 cmdline_fixed_string_t show;
17323 cmdline_fixed_string_t vf;
17324 cmdline_fixed_string_t stats;
17329 /* Common CLI fields show vf stats*/
17330 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17331 TOKEN_STRING_INITIALIZER
17332 (struct cmd_show_vf_stats_result,
17334 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17335 TOKEN_STRING_INITIALIZER
17336 (struct cmd_show_vf_stats_result,
17338 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17339 TOKEN_STRING_INITIALIZER
17340 (struct cmd_show_vf_stats_result,
17342 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17343 TOKEN_NUM_INITIALIZER
17344 (struct cmd_show_vf_stats_result,
17346 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17347 TOKEN_NUM_INITIALIZER
17348 (struct cmd_show_vf_stats_result,
17352 cmd_show_vf_stats_parsed(
17353 void *parsed_result,
17354 __rte_unused struct cmdline *cl,
17355 __rte_unused void *data)
17357 struct cmd_show_vf_stats_result *res = parsed_result;
17358 struct rte_eth_stats stats;
17359 int ret = -ENOTSUP;
17360 static const char *nic_stats_border = "########################";
17362 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17365 memset(&stats, 0, sizeof(stats));
17367 #ifdef RTE_LIBRTE_I40E_PMD
17368 if (ret == -ENOTSUP)
17369 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17373 #ifdef RTE_LIBRTE_BNXT_PMD
17374 if (ret == -ENOTSUP)
17375 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17384 printf("invalid vf_id %d\n", res->vf_id);
17387 printf("invalid port_id %d\n", res->port_id);
17390 printf("function not implemented\n");
17393 printf("programming error: (%s)\n", strerror(-ret));
17396 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17397 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17399 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17401 stats.ipackets, stats.imissed, stats.ibytes);
17402 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17403 printf(" RX-nombuf: %-10"PRIu64"\n",
17405 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17407 stats.opackets, stats.oerrors, stats.obytes);
17409 printf(" %s############################%s\n",
17410 nic_stats_border, nic_stats_border);
17413 cmdline_parse_inst_t cmd_show_vf_stats = {
17414 .f = cmd_show_vf_stats_parsed,
17416 .help_str = "show vf stats <port_id> <vf_id>",
17418 (void *)&cmd_show_vf_stats_show,
17419 (void *)&cmd_show_vf_stats_vf,
17420 (void *)&cmd_show_vf_stats_stats,
17421 (void *)&cmd_show_vf_stats_port_id,
17422 (void *)&cmd_show_vf_stats_vf_id,
17427 /* clear vf stats */
17429 /* Common result structure for clear vf stats */
17430 struct cmd_clear_vf_stats_result {
17431 cmdline_fixed_string_t clear;
17432 cmdline_fixed_string_t vf;
17433 cmdline_fixed_string_t stats;
17438 /* Common CLI fields clear vf stats*/
17439 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17440 TOKEN_STRING_INITIALIZER
17441 (struct cmd_clear_vf_stats_result,
17443 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17444 TOKEN_STRING_INITIALIZER
17445 (struct cmd_clear_vf_stats_result,
17447 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17448 TOKEN_STRING_INITIALIZER
17449 (struct cmd_clear_vf_stats_result,
17451 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17452 TOKEN_NUM_INITIALIZER
17453 (struct cmd_clear_vf_stats_result,
17455 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17456 TOKEN_NUM_INITIALIZER
17457 (struct cmd_clear_vf_stats_result,
17461 cmd_clear_vf_stats_parsed(
17462 void *parsed_result,
17463 __rte_unused struct cmdline *cl,
17464 __rte_unused void *data)
17466 struct cmd_clear_vf_stats_result *res = parsed_result;
17467 int ret = -ENOTSUP;
17469 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17472 #ifdef RTE_LIBRTE_I40E_PMD
17473 if (ret == -ENOTSUP)
17474 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17477 #ifdef RTE_LIBRTE_BNXT_PMD
17478 if (ret == -ENOTSUP)
17479 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17487 printf("invalid vf_id %d\n", res->vf_id);
17490 printf("invalid port_id %d\n", res->port_id);
17493 printf("function not implemented\n");
17496 printf("programming error: (%s)\n", strerror(-ret));
17500 cmdline_parse_inst_t cmd_clear_vf_stats = {
17501 .f = cmd_clear_vf_stats_parsed,
17503 .help_str = "clear vf stats <port_id> <vf_id>",
17505 (void *)&cmd_clear_vf_stats_clear,
17506 (void *)&cmd_clear_vf_stats_vf,
17507 (void *)&cmd_clear_vf_stats_stats,
17508 (void *)&cmd_clear_vf_stats_port_id,
17509 (void *)&cmd_clear_vf_stats_vf_id,
17514 /* port config pctype mapping reset */
17516 /* Common result structure for port config pctype mapping reset */
17517 struct cmd_pctype_mapping_reset_result {
17518 cmdline_fixed_string_t port;
17519 cmdline_fixed_string_t config;
17521 cmdline_fixed_string_t pctype;
17522 cmdline_fixed_string_t mapping;
17523 cmdline_fixed_string_t reset;
17526 /* Common CLI fields for port config pctype mapping reset*/
17527 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17528 TOKEN_STRING_INITIALIZER
17529 (struct cmd_pctype_mapping_reset_result,
17531 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17532 TOKEN_STRING_INITIALIZER
17533 (struct cmd_pctype_mapping_reset_result,
17535 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17536 TOKEN_NUM_INITIALIZER
17537 (struct cmd_pctype_mapping_reset_result,
17539 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17540 TOKEN_STRING_INITIALIZER
17541 (struct cmd_pctype_mapping_reset_result,
17543 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17544 TOKEN_STRING_INITIALIZER
17545 (struct cmd_pctype_mapping_reset_result,
17546 mapping, "mapping");
17547 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17548 TOKEN_STRING_INITIALIZER
17549 (struct cmd_pctype_mapping_reset_result,
17553 cmd_pctype_mapping_reset_parsed(
17554 void *parsed_result,
17555 __rte_unused struct cmdline *cl,
17556 __rte_unused void *data)
17558 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17559 int ret = -ENOTSUP;
17561 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17564 #ifdef RTE_LIBRTE_I40E_PMD
17565 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17572 printf("invalid port_id %d\n", res->port_id);
17575 printf("function not implemented\n");
17578 printf("programming error: (%s)\n", strerror(-ret));
17582 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17583 .f = cmd_pctype_mapping_reset_parsed,
17585 .help_str = "port config <port_id> pctype mapping reset",
17587 (void *)&cmd_pctype_mapping_reset_port,
17588 (void *)&cmd_pctype_mapping_reset_config,
17589 (void *)&cmd_pctype_mapping_reset_port_id,
17590 (void *)&cmd_pctype_mapping_reset_pctype,
17591 (void *)&cmd_pctype_mapping_reset_mapping,
17592 (void *)&cmd_pctype_mapping_reset_reset,
17597 /* show port pctype mapping */
17599 /* Common result structure for show port pctype mapping */
17600 struct cmd_pctype_mapping_get_result {
17601 cmdline_fixed_string_t show;
17602 cmdline_fixed_string_t port;
17604 cmdline_fixed_string_t pctype;
17605 cmdline_fixed_string_t mapping;
17608 /* Common CLI fields for pctype mapping get */
17609 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17610 TOKEN_STRING_INITIALIZER
17611 (struct cmd_pctype_mapping_get_result,
17613 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17614 TOKEN_STRING_INITIALIZER
17615 (struct cmd_pctype_mapping_get_result,
17617 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17618 TOKEN_NUM_INITIALIZER
17619 (struct cmd_pctype_mapping_get_result,
17621 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17622 TOKEN_STRING_INITIALIZER
17623 (struct cmd_pctype_mapping_get_result,
17625 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17626 TOKEN_STRING_INITIALIZER
17627 (struct cmd_pctype_mapping_get_result,
17628 mapping, "mapping");
17631 cmd_pctype_mapping_get_parsed(
17632 void *parsed_result,
17633 __rte_unused struct cmdline *cl,
17634 __rte_unused void *data)
17636 struct cmd_pctype_mapping_get_result *res = parsed_result;
17637 int ret = -ENOTSUP;
17638 #ifdef RTE_LIBRTE_I40E_PMD
17639 struct rte_pmd_i40e_flow_type_mapping
17640 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17641 int i, j, first_pctype;
17644 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17647 #ifdef RTE_LIBRTE_I40E_PMD
17648 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17655 printf("invalid port_id %d\n", res->port_id);
17658 printf("function not implemented\n");
17661 printf("programming error: (%s)\n", strerror(-ret));
17665 #ifdef RTE_LIBRTE_I40E_PMD
17666 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17667 if (mapping[i].pctype != 0ULL) {
17670 printf("pctype: ");
17671 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17672 if (mapping[i].pctype & (1ULL << j)) {
17673 printf(first_pctype ?
17674 "%02d" : ",%02d", j);
17678 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17684 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17685 .f = cmd_pctype_mapping_get_parsed,
17687 .help_str = "show port <port_id> pctype mapping",
17689 (void *)&cmd_pctype_mapping_get_show,
17690 (void *)&cmd_pctype_mapping_get_port,
17691 (void *)&cmd_pctype_mapping_get_port_id,
17692 (void *)&cmd_pctype_mapping_get_pctype,
17693 (void *)&cmd_pctype_mapping_get_mapping,
17698 /* port config pctype mapping update */
17700 /* Common result structure for port config pctype mapping update */
17701 struct cmd_pctype_mapping_update_result {
17702 cmdline_fixed_string_t port;
17703 cmdline_fixed_string_t config;
17705 cmdline_fixed_string_t pctype;
17706 cmdline_fixed_string_t mapping;
17707 cmdline_fixed_string_t update;
17708 cmdline_fixed_string_t pctype_list;
17709 uint16_t flow_type;
17712 /* Common CLI fields for pctype mapping update*/
17713 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17714 TOKEN_STRING_INITIALIZER
17715 (struct cmd_pctype_mapping_update_result,
17717 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17718 TOKEN_STRING_INITIALIZER
17719 (struct cmd_pctype_mapping_update_result,
17721 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17722 TOKEN_NUM_INITIALIZER
17723 (struct cmd_pctype_mapping_update_result,
17725 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17726 TOKEN_STRING_INITIALIZER
17727 (struct cmd_pctype_mapping_update_result,
17729 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17730 TOKEN_STRING_INITIALIZER
17731 (struct cmd_pctype_mapping_update_result,
17732 mapping, "mapping");
17733 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17734 TOKEN_STRING_INITIALIZER
17735 (struct cmd_pctype_mapping_update_result,
17737 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17738 TOKEN_STRING_INITIALIZER
17739 (struct cmd_pctype_mapping_update_result,
17740 pctype_list, NULL);
17741 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17742 TOKEN_NUM_INITIALIZER
17743 (struct cmd_pctype_mapping_update_result,
17744 flow_type, UINT16);
17747 cmd_pctype_mapping_update_parsed(
17748 void *parsed_result,
17749 __rte_unused struct cmdline *cl,
17750 __rte_unused void *data)
17752 struct cmd_pctype_mapping_update_result *res = parsed_result;
17753 int ret = -ENOTSUP;
17754 #ifdef RTE_LIBRTE_I40E_PMD
17755 struct rte_pmd_i40e_flow_type_mapping mapping;
17757 unsigned int nb_item;
17758 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17761 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17764 #ifdef RTE_LIBRTE_I40E_PMD
17765 nb_item = parse_item_list(res->pctype_list, "pctypes",
17766 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17767 mapping.flow_type = res->flow_type;
17768 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17769 mapping.pctype |= (1ULL << pctype_list[i]);
17770 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17780 printf("invalid pctype or flow type\n");
17783 printf("invalid port_id %d\n", res->port_id);
17786 printf("function not implemented\n");
17789 printf("programming error: (%s)\n", strerror(-ret));
17793 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17794 .f = cmd_pctype_mapping_update_parsed,
17796 .help_str = "port config <port_id> pctype mapping update"
17797 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17799 (void *)&cmd_pctype_mapping_update_port,
17800 (void *)&cmd_pctype_mapping_update_config,
17801 (void *)&cmd_pctype_mapping_update_port_id,
17802 (void *)&cmd_pctype_mapping_update_pctype,
17803 (void *)&cmd_pctype_mapping_update_mapping,
17804 (void *)&cmd_pctype_mapping_update_update,
17805 (void *)&cmd_pctype_mapping_update_pc_type,
17806 (void *)&cmd_pctype_mapping_update_flow_type,
17811 /* ptype mapping get */
17813 /* Common result structure for ptype mapping get */
17814 struct cmd_ptype_mapping_get_result {
17815 cmdline_fixed_string_t ptype;
17816 cmdline_fixed_string_t mapping;
17817 cmdline_fixed_string_t get;
17819 uint8_t valid_only;
17822 /* Common CLI fields for ptype mapping get */
17823 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17824 TOKEN_STRING_INITIALIZER
17825 (struct cmd_ptype_mapping_get_result,
17827 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17828 TOKEN_STRING_INITIALIZER
17829 (struct cmd_ptype_mapping_get_result,
17830 mapping, "mapping");
17831 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17832 TOKEN_STRING_INITIALIZER
17833 (struct cmd_ptype_mapping_get_result,
17835 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17836 TOKEN_NUM_INITIALIZER
17837 (struct cmd_ptype_mapping_get_result,
17839 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17840 TOKEN_NUM_INITIALIZER
17841 (struct cmd_ptype_mapping_get_result,
17842 valid_only, UINT8);
17845 cmd_ptype_mapping_get_parsed(
17846 void *parsed_result,
17847 __rte_unused struct cmdline *cl,
17848 __rte_unused void *data)
17850 struct cmd_ptype_mapping_get_result *res = parsed_result;
17851 int ret = -ENOTSUP;
17852 #ifdef RTE_LIBRTE_I40E_PMD
17853 int max_ptype_num = 256;
17854 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17859 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17862 #ifdef RTE_LIBRTE_I40E_PMD
17863 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17874 printf("invalid port_id %d\n", res->port_id);
17877 printf("function not implemented\n");
17880 printf("programming error: (%s)\n", strerror(-ret));
17883 #ifdef RTE_LIBRTE_I40E_PMD
17885 for (i = 0; i < count; i++)
17886 printf("%3d\t0x%08x\n",
17887 mapping[i].hw_ptype, mapping[i].sw_ptype);
17892 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17893 .f = cmd_ptype_mapping_get_parsed,
17895 .help_str = "ptype mapping get <port_id> <valid_only>",
17897 (void *)&cmd_ptype_mapping_get_ptype,
17898 (void *)&cmd_ptype_mapping_get_mapping,
17899 (void *)&cmd_ptype_mapping_get_get,
17900 (void *)&cmd_ptype_mapping_get_port_id,
17901 (void *)&cmd_ptype_mapping_get_valid_only,
17906 /* ptype mapping replace */
17908 /* Common result structure for ptype mapping replace */
17909 struct cmd_ptype_mapping_replace_result {
17910 cmdline_fixed_string_t ptype;
17911 cmdline_fixed_string_t mapping;
17912 cmdline_fixed_string_t replace;
17919 /* Common CLI fields for ptype mapping replace */
17920 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17921 TOKEN_STRING_INITIALIZER
17922 (struct cmd_ptype_mapping_replace_result,
17924 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17925 TOKEN_STRING_INITIALIZER
17926 (struct cmd_ptype_mapping_replace_result,
17927 mapping, "mapping");
17928 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17929 TOKEN_STRING_INITIALIZER
17930 (struct cmd_ptype_mapping_replace_result,
17931 replace, "replace");
17932 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17933 TOKEN_NUM_INITIALIZER
17934 (struct cmd_ptype_mapping_replace_result,
17936 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17937 TOKEN_NUM_INITIALIZER
17938 (struct cmd_ptype_mapping_replace_result,
17940 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17941 TOKEN_NUM_INITIALIZER
17942 (struct cmd_ptype_mapping_replace_result,
17944 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17945 TOKEN_NUM_INITIALIZER
17946 (struct cmd_ptype_mapping_replace_result,
17950 cmd_ptype_mapping_replace_parsed(
17951 void *parsed_result,
17952 __rte_unused struct cmdline *cl,
17953 __rte_unused void *data)
17955 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17956 int ret = -ENOTSUP;
17958 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17961 #ifdef RTE_LIBRTE_I40E_PMD
17962 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17972 printf("invalid ptype 0x%8x or 0x%8x\n",
17973 res->target, res->pkt_type);
17976 printf("invalid port_id %d\n", res->port_id);
17979 printf("function not implemented\n");
17982 printf("programming error: (%s)\n", strerror(-ret));
17986 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17987 .f = cmd_ptype_mapping_replace_parsed,
17990 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17992 (void *)&cmd_ptype_mapping_replace_ptype,
17993 (void *)&cmd_ptype_mapping_replace_mapping,
17994 (void *)&cmd_ptype_mapping_replace_replace,
17995 (void *)&cmd_ptype_mapping_replace_port_id,
17996 (void *)&cmd_ptype_mapping_replace_target,
17997 (void *)&cmd_ptype_mapping_replace_mask,
17998 (void *)&cmd_ptype_mapping_replace_pkt_type,
18003 /* ptype mapping reset */
18005 /* Common result structure for ptype mapping reset */
18006 struct cmd_ptype_mapping_reset_result {
18007 cmdline_fixed_string_t ptype;
18008 cmdline_fixed_string_t mapping;
18009 cmdline_fixed_string_t reset;
18013 /* Common CLI fields for ptype mapping reset*/
18014 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
18015 TOKEN_STRING_INITIALIZER
18016 (struct cmd_ptype_mapping_reset_result,
18018 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
18019 TOKEN_STRING_INITIALIZER
18020 (struct cmd_ptype_mapping_reset_result,
18021 mapping, "mapping");
18022 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
18023 TOKEN_STRING_INITIALIZER
18024 (struct cmd_ptype_mapping_reset_result,
18026 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
18027 TOKEN_NUM_INITIALIZER
18028 (struct cmd_ptype_mapping_reset_result,
18032 cmd_ptype_mapping_reset_parsed(
18033 void *parsed_result,
18034 __rte_unused struct cmdline *cl,
18035 __rte_unused void *data)
18037 struct cmd_ptype_mapping_reset_result *res = parsed_result;
18038 int ret = -ENOTSUP;
18040 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18043 #ifdef RTE_LIBRTE_I40E_PMD
18044 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
18051 printf("invalid port_id %d\n", res->port_id);
18054 printf("function not implemented\n");
18057 printf("programming error: (%s)\n", strerror(-ret));
18061 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
18062 .f = cmd_ptype_mapping_reset_parsed,
18064 .help_str = "ptype mapping reset <port_id>",
18066 (void *)&cmd_ptype_mapping_reset_ptype,
18067 (void *)&cmd_ptype_mapping_reset_mapping,
18068 (void *)&cmd_ptype_mapping_reset_reset,
18069 (void *)&cmd_ptype_mapping_reset_port_id,
18074 /* ptype mapping update */
18076 /* Common result structure for ptype mapping update */
18077 struct cmd_ptype_mapping_update_result {
18078 cmdline_fixed_string_t ptype;
18079 cmdline_fixed_string_t mapping;
18080 cmdline_fixed_string_t reset;
18086 /* Common CLI fields for ptype mapping update*/
18087 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
18088 TOKEN_STRING_INITIALIZER
18089 (struct cmd_ptype_mapping_update_result,
18091 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
18092 TOKEN_STRING_INITIALIZER
18093 (struct cmd_ptype_mapping_update_result,
18094 mapping, "mapping");
18095 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
18096 TOKEN_STRING_INITIALIZER
18097 (struct cmd_ptype_mapping_update_result,
18099 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
18100 TOKEN_NUM_INITIALIZER
18101 (struct cmd_ptype_mapping_update_result,
18103 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
18104 TOKEN_NUM_INITIALIZER
18105 (struct cmd_ptype_mapping_update_result,
18107 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
18108 TOKEN_NUM_INITIALIZER
18109 (struct cmd_ptype_mapping_update_result,
18113 cmd_ptype_mapping_update_parsed(
18114 void *parsed_result,
18115 __rte_unused struct cmdline *cl,
18116 __rte_unused void *data)
18118 struct cmd_ptype_mapping_update_result *res = parsed_result;
18119 int ret = -ENOTSUP;
18120 #ifdef RTE_LIBRTE_I40E_PMD
18121 struct rte_pmd_i40e_ptype_mapping mapping;
18123 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18126 #ifdef RTE_LIBRTE_I40E_PMD
18127 mapping.hw_ptype = res->hw_ptype;
18128 mapping.sw_ptype = res->sw_ptype;
18129 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
18139 printf("invalid ptype 0x%8x\n", res->sw_ptype);
18142 printf("invalid port_id %d\n", res->port_id);
18145 printf("function not implemented\n");
18148 printf("programming error: (%s)\n", strerror(-ret));
18152 cmdline_parse_inst_t cmd_ptype_mapping_update = {
18153 .f = cmd_ptype_mapping_update_parsed,
18155 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
18157 (void *)&cmd_ptype_mapping_update_ptype,
18158 (void *)&cmd_ptype_mapping_update_mapping,
18159 (void *)&cmd_ptype_mapping_update_update,
18160 (void *)&cmd_ptype_mapping_update_port_id,
18161 (void *)&cmd_ptype_mapping_update_hw_ptype,
18162 (void *)&cmd_ptype_mapping_update_sw_ptype,
18167 /* Common result structure for file commands */
18168 struct cmd_cmdfile_result {
18169 cmdline_fixed_string_t load;
18170 cmdline_fixed_string_t filename;
18173 /* Common CLI fields for file commands */
18174 cmdline_parse_token_string_t cmd_load_cmdfile =
18175 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
18176 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
18177 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
18180 cmd_load_from_file_parsed(
18181 void *parsed_result,
18182 __rte_unused struct cmdline *cl,
18183 __rte_unused void *data)
18185 struct cmd_cmdfile_result *res = parsed_result;
18187 cmdline_read_from_file(res->filename);
18190 cmdline_parse_inst_t cmd_load_from_file = {
18191 .f = cmd_load_from_file_parsed,
18193 .help_str = "load <filename>",
18195 (void *)&cmd_load_cmdfile,
18196 (void *)&cmd_load_cmdfile_filename,
18201 /* Get Rx offloads capabilities */
18202 struct cmd_rx_offload_get_capa_result {
18203 cmdline_fixed_string_t show;
18204 cmdline_fixed_string_t port;
18206 cmdline_fixed_string_t rx_offload;
18207 cmdline_fixed_string_t capabilities;
18210 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
18211 TOKEN_STRING_INITIALIZER
18212 (struct cmd_rx_offload_get_capa_result,
18214 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
18215 TOKEN_STRING_INITIALIZER
18216 (struct cmd_rx_offload_get_capa_result,
18218 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
18219 TOKEN_NUM_INITIALIZER
18220 (struct cmd_rx_offload_get_capa_result,
18222 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
18223 TOKEN_STRING_INITIALIZER
18224 (struct cmd_rx_offload_get_capa_result,
18225 rx_offload, "rx_offload");
18226 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
18227 TOKEN_STRING_INITIALIZER
18228 (struct cmd_rx_offload_get_capa_result,
18229 capabilities, "capabilities");
18232 print_rx_offloads(uint64_t offloads)
18234 uint64_t single_offload;
18242 begin = __builtin_ctzll(offloads);
18243 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18245 single_offload = 1ULL << begin;
18246 for (bit = begin; bit < end; bit++) {
18247 if (offloads & single_offload)
18249 rte_eth_dev_rx_offload_name(single_offload));
18250 single_offload <<= 1;
18255 cmd_rx_offload_get_capa_parsed(
18256 void *parsed_result,
18257 __rte_unused struct cmdline *cl,
18258 __rte_unused void *data)
18260 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18261 struct rte_eth_dev_info dev_info;
18262 portid_t port_id = res->port_id;
18263 uint64_t queue_offloads;
18264 uint64_t port_offloads;
18267 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18271 queue_offloads = dev_info.rx_queue_offload_capa;
18272 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18274 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18275 printf(" Per Queue :");
18276 print_rx_offloads(queue_offloads);
18279 printf(" Per Port :");
18280 print_rx_offloads(port_offloads);
18284 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18285 .f = cmd_rx_offload_get_capa_parsed,
18287 .help_str = "show port <port_id> rx_offload capabilities",
18289 (void *)&cmd_rx_offload_get_capa_show,
18290 (void *)&cmd_rx_offload_get_capa_port,
18291 (void *)&cmd_rx_offload_get_capa_port_id,
18292 (void *)&cmd_rx_offload_get_capa_rx_offload,
18293 (void *)&cmd_rx_offload_get_capa_capabilities,
18298 /* Get Rx offloads configuration */
18299 struct cmd_rx_offload_get_configuration_result {
18300 cmdline_fixed_string_t show;
18301 cmdline_fixed_string_t port;
18303 cmdline_fixed_string_t rx_offload;
18304 cmdline_fixed_string_t configuration;
18307 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18308 TOKEN_STRING_INITIALIZER
18309 (struct cmd_rx_offload_get_configuration_result,
18311 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18312 TOKEN_STRING_INITIALIZER
18313 (struct cmd_rx_offload_get_configuration_result,
18315 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18316 TOKEN_NUM_INITIALIZER
18317 (struct cmd_rx_offload_get_configuration_result,
18319 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18320 TOKEN_STRING_INITIALIZER
18321 (struct cmd_rx_offload_get_configuration_result,
18322 rx_offload, "rx_offload");
18323 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18324 TOKEN_STRING_INITIALIZER
18325 (struct cmd_rx_offload_get_configuration_result,
18326 configuration, "configuration");
18329 cmd_rx_offload_get_configuration_parsed(
18330 void *parsed_result,
18331 __rte_unused struct cmdline *cl,
18332 __rte_unused void *data)
18334 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18335 struct rte_eth_dev_info dev_info;
18336 portid_t port_id = res->port_id;
18337 struct rte_port *port = &ports[port_id];
18338 uint64_t port_offloads;
18339 uint64_t queue_offloads;
18340 uint16_t nb_rx_queues;
18344 printf("Rx Offloading Configuration of port %d :\n", port_id);
18346 port_offloads = port->dev_conf.rxmode.offloads;
18348 print_rx_offloads(port_offloads);
18351 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18355 nb_rx_queues = dev_info.nb_rx_queues;
18356 for (q = 0; q < nb_rx_queues; q++) {
18357 queue_offloads = port->rx_conf[q].offloads;
18358 printf(" Queue[%2d] :", q);
18359 print_rx_offloads(queue_offloads);
18365 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18366 .f = cmd_rx_offload_get_configuration_parsed,
18368 .help_str = "show port <port_id> rx_offload configuration",
18370 (void *)&cmd_rx_offload_get_configuration_show,
18371 (void *)&cmd_rx_offload_get_configuration_port,
18372 (void *)&cmd_rx_offload_get_configuration_port_id,
18373 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18374 (void *)&cmd_rx_offload_get_configuration_configuration,
18379 /* Enable/Disable a per port offloading */
18380 struct cmd_config_per_port_rx_offload_result {
18381 cmdline_fixed_string_t port;
18382 cmdline_fixed_string_t config;
18384 cmdline_fixed_string_t rx_offload;
18385 cmdline_fixed_string_t offload;
18386 cmdline_fixed_string_t on_off;
18389 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18390 TOKEN_STRING_INITIALIZER
18391 (struct cmd_config_per_port_rx_offload_result,
18393 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18394 TOKEN_STRING_INITIALIZER
18395 (struct cmd_config_per_port_rx_offload_result,
18397 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18398 TOKEN_NUM_INITIALIZER
18399 (struct cmd_config_per_port_rx_offload_result,
18401 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18402 TOKEN_STRING_INITIALIZER
18403 (struct cmd_config_per_port_rx_offload_result,
18404 rx_offload, "rx_offload");
18405 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18406 TOKEN_STRING_INITIALIZER
18407 (struct cmd_config_per_port_rx_offload_result,
18408 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18409 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18410 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18411 "scatter#timestamp#security#keep_crc#rss_hash");
18412 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18413 TOKEN_STRING_INITIALIZER
18414 (struct cmd_config_per_port_rx_offload_result,
18418 search_rx_offload(const char *name)
18420 uint64_t single_offload;
18421 const char *single_name;
18425 single_offload = 1;
18426 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18427 single_name = rte_eth_dev_rx_offload_name(single_offload);
18428 if (!strcasecmp(single_name, name)) {
18432 single_offload <<= 1;
18436 return single_offload;
18442 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18443 __rte_unused struct cmdline *cl,
18444 __rte_unused void *data)
18446 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18447 portid_t port_id = res->port_id;
18448 struct rte_eth_dev_info dev_info;
18449 struct rte_port *port = &ports[port_id];
18450 uint64_t single_offload;
18451 uint16_t nb_rx_queues;
18455 if (port->port_status != RTE_PORT_STOPPED) {
18456 printf("Error: Can't config offload when Port %d "
18457 "is not stopped\n", port_id);
18461 single_offload = search_rx_offload(res->offload);
18462 if (single_offload == 0) {
18463 printf("Unknown offload name: %s\n", res->offload);
18467 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18471 nb_rx_queues = dev_info.nb_rx_queues;
18472 if (!strcmp(res->on_off, "on")) {
18473 port->dev_conf.rxmode.offloads |= single_offload;
18474 for (q = 0; q < nb_rx_queues; q++)
18475 port->rx_conf[q].offloads |= single_offload;
18477 port->dev_conf.rxmode.offloads &= ~single_offload;
18478 for (q = 0; q < nb_rx_queues; q++)
18479 port->rx_conf[q].offloads &= ~single_offload;
18482 cmd_reconfig_device_queue(port_id, 1, 1);
18485 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18486 .f = cmd_config_per_port_rx_offload_parsed,
18488 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18489 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18490 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18491 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18494 (void *)&cmd_config_per_port_rx_offload_result_port,
18495 (void *)&cmd_config_per_port_rx_offload_result_config,
18496 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18497 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18498 (void *)&cmd_config_per_port_rx_offload_result_offload,
18499 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18504 /* Enable/Disable a per queue offloading */
18505 struct cmd_config_per_queue_rx_offload_result {
18506 cmdline_fixed_string_t port;
18508 cmdline_fixed_string_t rxq;
18510 cmdline_fixed_string_t rx_offload;
18511 cmdline_fixed_string_t offload;
18512 cmdline_fixed_string_t on_off;
18515 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18516 TOKEN_STRING_INITIALIZER
18517 (struct cmd_config_per_queue_rx_offload_result,
18519 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18520 TOKEN_NUM_INITIALIZER
18521 (struct cmd_config_per_queue_rx_offload_result,
18523 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18524 TOKEN_STRING_INITIALIZER
18525 (struct cmd_config_per_queue_rx_offload_result,
18527 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18528 TOKEN_NUM_INITIALIZER
18529 (struct cmd_config_per_queue_rx_offload_result,
18531 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18532 TOKEN_STRING_INITIALIZER
18533 (struct cmd_config_per_queue_rx_offload_result,
18534 rx_offload, "rx_offload");
18535 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18536 TOKEN_STRING_INITIALIZER
18537 (struct cmd_config_per_queue_rx_offload_result,
18538 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18539 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18540 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18541 "scatter#timestamp#security#keep_crc");
18542 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18543 TOKEN_STRING_INITIALIZER
18544 (struct cmd_config_per_queue_rx_offload_result,
18548 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18549 __rte_unused struct cmdline *cl,
18550 __rte_unused void *data)
18552 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18553 struct rte_eth_dev_info dev_info;
18554 portid_t port_id = res->port_id;
18555 uint16_t queue_id = res->queue_id;
18556 struct rte_port *port = &ports[port_id];
18557 uint64_t single_offload;
18560 if (port->port_status != RTE_PORT_STOPPED) {
18561 printf("Error: Can't config offload when Port %d "
18562 "is not stopped\n", port_id);
18566 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18570 if (queue_id >= dev_info.nb_rx_queues) {
18571 printf("Error: input queue_id should be 0 ... "
18572 "%d\n", dev_info.nb_rx_queues - 1);
18576 single_offload = search_rx_offload(res->offload);
18577 if (single_offload == 0) {
18578 printf("Unknown offload name: %s\n", res->offload);
18582 if (!strcmp(res->on_off, "on"))
18583 port->rx_conf[queue_id].offloads |= single_offload;
18585 port->rx_conf[queue_id].offloads &= ~single_offload;
18587 cmd_reconfig_device_queue(port_id, 1, 1);
18590 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18591 .f = cmd_config_per_queue_rx_offload_parsed,
18593 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18594 "vlan_strip|ipv4_cksum|"
18595 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18596 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18597 "jumbo_frame|scatter|timestamp|security|keep_crc "
18600 (void *)&cmd_config_per_queue_rx_offload_result_port,
18601 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18602 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18603 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18604 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18605 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18606 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18611 /* Get Tx offloads capabilities */
18612 struct cmd_tx_offload_get_capa_result {
18613 cmdline_fixed_string_t show;
18614 cmdline_fixed_string_t port;
18616 cmdline_fixed_string_t tx_offload;
18617 cmdline_fixed_string_t capabilities;
18620 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18621 TOKEN_STRING_INITIALIZER
18622 (struct cmd_tx_offload_get_capa_result,
18624 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18625 TOKEN_STRING_INITIALIZER
18626 (struct cmd_tx_offload_get_capa_result,
18628 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18629 TOKEN_NUM_INITIALIZER
18630 (struct cmd_tx_offload_get_capa_result,
18632 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18633 TOKEN_STRING_INITIALIZER
18634 (struct cmd_tx_offload_get_capa_result,
18635 tx_offload, "tx_offload");
18636 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18637 TOKEN_STRING_INITIALIZER
18638 (struct cmd_tx_offload_get_capa_result,
18639 capabilities, "capabilities");
18642 print_tx_offloads(uint64_t offloads)
18644 uint64_t single_offload;
18652 begin = __builtin_ctzll(offloads);
18653 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18655 single_offload = 1ULL << begin;
18656 for (bit = begin; bit < end; bit++) {
18657 if (offloads & single_offload)
18659 rte_eth_dev_tx_offload_name(single_offload));
18660 single_offload <<= 1;
18665 cmd_tx_offload_get_capa_parsed(
18666 void *parsed_result,
18667 __rte_unused struct cmdline *cl,
18668 __rte_unused void *data)
18670 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18671 struct rte_eth_dev_info dev_info;
18672 portid_t port_id = res->port_id;
18673 uint64_t queue_offloads;
18674 uint64_t port_offloads;
18677 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18681 queue_offloads = dev_info.tx_queue_offload_capa;
18682 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18684 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18685 printf(" Per Queue :");
18686 print_tx_offloads(queue_offloads);
18689 printf(" Per Port :");
18690 print_tx_offloads(port_offloads);
18694 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18695 .f = cmd_tx_offload_get_capa_parsed,
18697 .help_str = "show port <port_id> tx_offload capabilities",
18699 (void *)&cmd_tx_offload_get_capa_show,
18700 (void *)&cmd_tx_offload_get_capa_port,
18701 (void *)&cmd_tx_offload_get_capa_port_id,
18702 (void *)&cmd_tx_offload_get_capa_tx_offload,
18703 (void *)&cmd_tx_offload_get_capa_capabilities,
18708 /* Get Tx offloads configuration */
18709 struct cmd_tx_offload_get_configuration_result {
18710 cmdline_fixed_string_t show;
18711 cmdline_fixed_string_t port;
18713 cmdline_fixed_string_t tx_offload;
18714 cmdline_fixed_string_t configuration;
18717 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18718 TOKEN_STRING_INITIALIZER
18719 (struct cmd_tx_offload_get_configuration_result,
18721 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18722 TOKEN_STRING_INITIALIZER
18723 (struct cmd_tx_offload_get_configuration_result,
18725 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18726 TOKEN_NUM_INITIALIZER
18727 (struct cmd_tx_offload_get_configuration_result,
18729 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18730 TOKEN_STRING_INITIALIZER
18731 (struct cmd_tx_offload_get_configuration_result,
18732 tx_offload, "tx_offload");
18733 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18734 TOKEN_STRING_INITIALIZER
18735 (struct cmd_tx_offload_get_configuration_result,
18736 configuration, "configuration");
18739 cmd_tx_offload_get_configuration_parsed(
18740 void *parsed_result,
18741 __rte_unused struct cmdline *cl,
18742 __rte_unused void *data)
18744 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18745 struct rte_eth_dev_info dev_info;
18746 portid_t port_id = res->port_id;
18747 struct rte_port *port = &ports[port_id];
18748 uint64_t port_offloads;
18749 uint64_t queue_offloads;
18750 uint16_t nb_tx_queues;
18754 printf("Tx Offloading Configuration of port %d :\n", port_id);
18756 port_offloads = port->dev_conf.txmode.offloads;
18758 print_tx_offloads(port_offloads);
18761 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18765 nb_tx_queues = dev_info.nb_tx_queues;
18766 for (q = 0; q < nb_tx_queues; q++) {
18767 queue_offloads = port->tx_conf[q].offloads;
18768 printf(" Queue[%2d] :", q);
18769 print_tx_offloads(queue_offloads);
18775 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18776 .f = cmd_tx_offload_get_configuration_parsed,
18778 .help_str = "show port <port_id> tx_offload configuration",
18780 (void *)&cmd_tx_offload_get_configuration_show,
18781 (void *)&cmd_tx_offload_get_configuration_port,
18782 (void *)&cmd_tx_offload_get_configuration_port_id,
18783 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18784 (void *)&cmd_tx_offload_get_configuration_configuration,
18789 /* Enable/Disable a per port offloading */
18790 struct cmd_config_per_port_tx_offload_result {
18791 cmdline_fixed_string_t port;
18792 cmdline_fixed_string_t config;
18794 cmdline_fixed_string_t tx_offload;
18795 cmdline_fixed_string_t offload;
18796 cmdline_fixed_string_t on_off;
18799 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18800 TOKEN_STRING_INITIALIZER
18801 (struct cmd_config_per_port_tx_offload_result,
18803 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18804 TOKEN_STRING_INITIALIZER
18805 (struct cmd_config_per_port_tx_offload_result,
18807 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18808 TOKEN_NUM_INITIALIZER
18809 (struct cmd_config_per_port_tx_offload_result,
18811 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18812 TOKEN_STRING_INITIALIZER
18813 (struct cmd_config_per_port_tx_offload_result,
18814 tx_offload, "tx_offload");
18815 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18816 TOKEN_STRING_INITIALIZER
18817 (struct cmd_config_per_port_tx_offload_result,
18818 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18819 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18820 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18821 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18822 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18823 "send_on_timestamp");
18824 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18825 TOKEN_STRING_INITIALIZER
18826 (struct cmd_config_per_port_tx_offload_result,
18830 search_tx_offload(const char *name)
18832 uint64_t single_offload;
18833 const char *single_name;
18837 single_offload = 1;
18838 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18839 single_name = rte_eth_dev_tx_offload_name(single_offload);
18840 if (single_name == NULL)
18842 if (!strcasecmp(single_name, name)) {
18845 } else if (!strcasecmp(single_name, "UNKNOWN"))
18847 single_offload <<= 1;
18851 return single_offload;
18857 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18858 __rte_unused struct cmdline *cl,
18859 __rte_unused void *data)
18861 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18862 portid_t port_id = res->port_id;
18863 struct rte_eth_dev_info dev_info;
18864 struct rte_port *port = &ports[port_id];
18865 uint64_t single_offload;
18866 uint16_t nb_tx_queues;
18870 if (port->port_status != RTE_PORT_STOPPED) {
18871 printf("Error: Can't config offload when Port %d "
18872 "is not stopped\n", port_id);
18876 single_offload = search_tx_offload(res->offload);
18877 if (single_offload == 0) {
18878 printf("Unknown offload name: %s\n", res->offload);
18882 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18886 nb_tx_queues = dev_info.nb_tx_queues;
18887 if (!strcmp(res->on_off, "on")) {
18888 port->dev_conf.txmode.offloads |= single_offload;
18889 for (q = 0; q < nb_tx_queues; q++)
18890 port->tx_conf[q].offloads |= single_offload;
18892 port->dev_conf.txmode.offloads &= ~single_offload;
18893 for (q = 0; q < nb_tx_queues; q++)
18894 port->tx_conf[q].offloads &= ~single_offload;
18897 cmd_reconfig_device_queue(port_id, 1, 1);
18900 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18901 .f = cmd_config_per_port_tx_offload_parsed,
18903 .help_str = "port config <port_id> tx_offload "
18904 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18905 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18906 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18907 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18908 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18909 "send_on_timestamp on|off",
18911 (void *)&cmd_config_per_port_tx_offload_result_port,
18912 (void *)&cmd_config_per_port_tx_offload_result_config,
18913 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18914 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18915 (void *)&cmd_config_per_port_tx_offload_result_offload,
18916 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18921 /* Enable/Disable a per queue offloading */
18922 struct cmd_config_per_queue_tx_offload_result {
18923 cmdline_fixed_string_t port;
18925 cmdline_fixed_string_t txq;
18927 cmdline_fixed_string_t tx_offload;
18928 cmdline_fixed_string_t offload;
18929 cmdline_fixed_string_t on_off;
18932 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18933 TOKEN_STRING_INITIALIZER
18934 (struct cmd_config_per_queue_tx_offload_result,
18936 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18937 TOKEN_NUM_INITIALIZER
18938 (struct cmd_config_per_queue_tx_offload_result,
18940 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18941 TOKEN_STRING_INITIALIZER
18942 (struct cmd_config_per_queue_tx_offload_result,
18944 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18945 TOKEN_NUM_INITIALIZER
18946 (struct cmd_config_per_queue_tx_offload_result,
18948 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18949 TOKEN_STRING_INITIALIZER
18950 (struct cmd_config_per_queue_tx_offload_result,
18951 tx_offload, "tx_offload");
18952 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18953 TOKEN_STRING_INITIALIZER
18954 (struct cmd_config_per_queue_tx_offload_result,
18955 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18956 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18957 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18958 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18959 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18960 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18961 TOKEN_STRING_INITIALIZER
18962 (struct cmd_config_per_queue_tx_offload_result,
18966 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18967 __rte_unused struct cmdline *cl,
18968 __rte_unused void *data)
18970 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18971 struct rte_eth_dev_info dev_info;
18972 portid_t port_id = res->port_id;
18973 uint16_t queue_id = res->queue_id;
18974 struct rte_port *port = &ports[port_id];
18975 uint64_t single_offload;
18978 if (port->port_status != RTE_PORT_STOPPED) {
18979 printf("Error: Can't config offload when Port %d "
18980 "is not stopped\n", port_id);
18984 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18988 if (queue_id >= dev_info.nb_tx_queues) {
18989 printf("Error: input queue_id should be 0 ... "
18990 "%d\n", dev_info.nb_tx_queues - 1);
18994 single_offload = search_tx_offload(res->offload);
18995 if (single_offload == 0) {
18996 printf("Unknown offload name: %s\n", res->offload);
19000 if (!strcmp(res->on_off, "on"))
19001 port->tx_conf[queue_id].offloads |= single_offload;
19003 port->tx_conf[queue_id].offloads &= ~single_offload;
19005 cmd_reconfig_device_queue(port_id, 1, 1);
19008 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
19009 .f = cmd_config_per_queue_tx_offload_parsed,
19011 .help_str = "port <port_id> txq <queue_id> tx_offload "
19012 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
19013 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
19014 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
19015 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
19016 "mt_lockfree|multi_segs|mbuf_fast_free|security "
19019 (void *)&cmd_config_per_queue_tx_offload_result_port,
19020 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
19021 (void *)&cmd_config_per_queue_tx_offload_result_txq,
19022 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
19023 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
19024 (void *)&cmd_config_per_queue_tx_offload_result_offload,
19025 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
19030 /* *** configure tx_metadata for specific port *** */
19031 struct cmd_config_tx_metadata_specific_result {
19032 cmdline_fixed_string_t port;
19033 cmdline_fixed_string_t keyword;
19035 cmdline_fixed_string_t item;
19040 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
19041 __rte_unused struct cmdline *cl,
19042 __rte_unused void *data)
19044 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
19046 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
19048 ports[res->port_id].tx_metadata = res->value;
19049 /* Add/remove callback to insert valid metadata in every Tx packet. */
19050 if (ports[res->port_id].tx_metadata)
19051 add_tx_md_callback(res->port_id);
19053 remove_tx_md_callback(res->port_id);
19054 rte_flow_dynf_metadata_register();
19057 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
19058 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19060 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
19061 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19062 keyword, "config");
19063 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
19064 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19066 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
19067 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19068 item, "tx_metadata");
19069 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
19070 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19073 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
19074 .f = cmd_config_tx_metadata_specific_parsed,
19076 .help_str = "port config <port_id> tx_metadata <value>",
19078 (void *)&cmd_config_tx_metadata_specific_port,
19079 (void *)&cmd_config_tx_metadata_specific_keyword,
19080 (void *)&cmd_config_tx_metadata_specific_id,
19081 (void *)&cmd_config_tx_metadata_specific_item,
19082 (void *)&cmd_config_tx_metadata_specific_value,
19087 /* *** set dynf *** */
19088 struct cmd_config_tx_dynf_specific_result {
19089 cmdline_fixed_string_t port;
19090 cmdline_fixed_string_t keyword;
19092 cmdline_fixed_string_t item;
19093 cmdline_fixed_string_t name;
19094 cmdline_fixed_string_t value;
19098 cmd_config_dynf_specific_parsed(void *parsed_result,
19099 __rte_unused struct cmdline *cl,
19100 __rte_unused void *data)
19102 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
19103 struct rte_mbuf_dynflag desc_flag;
19105 uint64_t old_port_flags;
19107 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
19109 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
19111 if (strlcpy(desc_flag.name, res->name,
19112 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
19113 printf("Flag name too long\n");
19116 desc_flag.flags = 0;
19117 flag = rte_mbuf_dynflag_register(&desc_flag);
19119 printf("Can't register flag\n");
19122 strcpy(dynf_names[flag], desc_flag.name);
19124 old_port_flags = ports[res->port_id].mbuf_dynf;
19125 if (!strcmp(res->value, "set")) {
19126 ports[res->port_id].mbuf_dynf |= 1UL << flag;
19127 if (old_port_flags == 0)
19128 add_tx_dynf_callback(res->port_id);
19130 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
19131 if (ports[res->port_id].mbuf_dynf == 0)
19132 remove_tx_dynf_callback(res->port_id);
19136 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
19137 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19139 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
19140 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19141 keyword, "config");
19142 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
19143 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19145 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
19146 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19148 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
19149 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19151 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
19152 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19153 value, "set#clear");
19155 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
19156 .f = cmd_config_dynf_specific_parsed,
19158 .help_str = "port config <port id> dynf <name> set|clear",
19160 (void *)&cmd_config_tx_dynf_specific_port,
19161 (void *)&cmd_config_tx_dynf_specific_keyword,
19162 (void *)&cmd_config_tx_dynf_specific_port_id,
19163 (void *)&cmd_config_tx_dynf_specific_item,
19164 (void *)&cmd_config_tx_dynf_specific_name,
19165 (void *)&cmd_config_tx_dynf_specific_value,
19170 /* *** display tx_metadata per port configuration *** */
19171 struct cmd_show_tx_metadata_result {
19172 cmdline_fixed_string_t cmd_show;
19173 cmdline_fixed_string_t cmd_port;
19174 cmdline_fixed_string_t cmd_keyword;
19179 cmd_show_tx_metadata_parsed(void *parsed_result,
19180 __rte_unused struct cmdline *cl,
19181 __rte_unused void *data)
19183 struct cmd_show_tx_metadata_result *res = parsed_result;
19185 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19186 printf("invalid port id %u\n", res->cmd_pid);
19189 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
19190 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
19191 ports[res->cmd_pid].tx_metadata);
19195 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
19196 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19198 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
19199 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19201 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
19202 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
19204 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
19205 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19206 cmd_keyword, "tx_metadata");
19208 cmdline_parse_inst_t cmd_show_tx_metadata = {
19209 .f = cmd_show_tx_metadata_parsed,
19211 .help_str = "show port <port_id> tx_metadata",
19213 (void *)&cmd_show_tx_metadata_show,
19214 (void *)&cmd_show_tx_metadata_port,
19215 (void *)&cmd_show_tx_metadata_pid,
19216 (void *)&cmd_show_tx_metadata_keyword,
19221 /* show port supported ptypes */
19223 /* Common result structure for show port ptypes */
19224 struct cmd_show_port_supported_ptypes_result {
19225 cmdline_fixed_string_t show;
19226 cmdline_fixed_string_t port;
19228 cmdline_fixed_string_t ptypes;
19231 /* Common CLI fields for show port ptypes */
19232 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
19233 TOKEN_STRING_INITIALIZER
19234 (struct cmd_show_port_supported_ptypes_result,
19236 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
19237 TOKEN_STRING_INITIALIZER
19238 (struct cmd_show_port_supported_ptypes_result,
19240 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19241 TOKEN_NUM_INITIALIZER
19242 (struct cmd_show_port_supported_ptypes_result,
19244 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19245 TOKEN_STRING_INITIALIZER
19246 (struct cmd_show_port_supported_ptypes_result,
19250 cmd_show_port_supported_ptypes_parsed(
19251 void *parsed_result,
19252 __rte_unused struct cmdline *cl,
19253 __rte_unused void *data)
19255 #define RSVD_PTYPE_MASK 0xf0000000
19256 #define MAX_PTYPES_PER_LAYER 16
19257 #define LTYPE_NAMESIZE 32
19258 #define PTYPE_NAMESIZE 256
19259 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19260 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19261 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19262 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19263 uint16_t port_id = res->port_id;
19266 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19270 while (ptype_mask != RSVD_PTYPE_MASK) {
19272 switch (ptype_mask) {
19273 case RTE_PTYPE_L2_MASK:
19274 strlcpy(ltype, "L2", sizeof(ltype));
19276 case RTE_PTYPE_L3_MASK:
19277 strlcpy(ltype, "L3", sizeof(ltype));
19279 case RTE_PTYPE_L4_MASK:
19280 strlcpy(ltype, "L4", sizeof(ltype));
19282 case RTE_PTYPE_TUNNEL_MASK:
19283 strlcpy(ltype, "Tunnel", sizeof(ltype));
19285 case RTE_PTYPE_INNER_L2_MASK:
19286 strlcpy(ltype, "Inner L2", sizeof(ltype));
19288 case RTE_PTYPE_INNER_L3_MASK:
19289 strlcpy(ltype, "Inner L3", sizeof(ltype));
19291 case RTE_PTYPE_INNER_L4_MASK:
19292 strlcpy(ltype, "Inner L4", sizeof(ltype));
19298 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19299 ptype_mask, ptypes,
19300 MAX_PTYPES_PER_LAYER);
19303 printf("Supported %s ptypes:\n", ltype);
19305 printf("%s ptypes unsupported\n", ltype);
19307 for (i = 0; i < ret; ++i) {
19308 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19309 printf("%s\n", buf);
19316 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19317 .f = cmd_show_port_supported_ptypes_parsed,
19319 .help_str = "show port <port_id> ptypes",
19321 (void *)&cmd_show_port_supported_ptypes_show,
19322 (void *)&cmd_show_port_supported_ptypes_port,
19323 (void *)&cmd_show_port_supported_ptypes_port_id,
19324 (void *)&cmd_show_port_supported_ptypes_ptypes,
19329 /* *** display rx/tx descriptor status *** */
19330 struct cmd_show_rx_tx_desc_status_result {
19331 cmdline_fixed_string_t cmd_show;
19332 cmdline_fixed_string_t cmd_port;
19333 cmdline_fixed_string_t cmd_keyword;
19334 cmdline_fixed_string_t cmd_desc;
19335 cmdline_fixed_string_t cmd_status;
19342 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19343 __rte_unused struct cmdline *cl,
19344 __rte_unused void *data)
19346 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19349 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19350 printf("invalid port id %u\n", res->cmd_pid);
19354 if (!strcmp(res->cmd_keyword, "rxq")) {
19355 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19358 printf("Invalid queueid = %d\n", res->cmd_qid);
19361 if (rc == RTE_ETH_RX_DESC_AVAIL)
19362 printf("Desc status = AVAILABLE\n");
19363 else if (rc == RTE_ETH_RX_DESC_DONE)
19364 printf("Desc status = DONE\n");
19366 printf("Desc status = UNAVAILABLE\n");
19367 } else if (!strcmp(res->cmd_keyword, "txq")) {
19368 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19371 printf("Invalid queueid = %d\n", res->cmd_qid);
19374 if (rc == RTE_ETH_TX_DESC_FULL)
19375 printf("Desc status = FULL\n");
19376 else if (rc == RTE_ETH_TX_DESC_DONE)
19377 printf("Desc status = DONE\n");
19379 printf("Desc status = UNAVAILABLE\n");
19383 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19384 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19386 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19387 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19389 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19390 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19392 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19393 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19394 cmd_keyword, "rxq#txq");
19395 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19396 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19398 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19399 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19401 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19402 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19404 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19405 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19406 cmd_status, "status");
19407 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19408 .f = cmd_show_rx_tx_desc_status_parsed,
19410 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19413 (void *)&cmd_show_rx_tx_desc_status_show,
19414 (void *)&cmd_show_rx_tx_desc_status_port,
19415 (void *)&cmd_show_rx_tx_desc_status_pid,
19416 (void *)&cmd_show_rx_tx_desc_status_keyword,
19417 (void *)&cmd_show_rx_tx_desc_status_qid,
19418 (void *)&cmd_show_rx_tx_desc_status_desc,
19419 (void *)&cmd_show_rx_tx_desc_status_did,
19420 (void *)&cmd_show_rx_tx_desc_status_status,
19425 /* Common result structure for set port ptypes */
19426 struct cmd_set_port_ptypes_result {
19427 cmdline_fixed_string_t set;
19428 cmdline_fixed_string_t port;
19430 cmdline_fixed_string_t ptype_mask;
19434 /* Common CLI fields for set port ptypes */
19435 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19436 TOKEN_STRING_INITIALIZER
19437 (struct cmd_set_port_ptypes_result,
19439 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19440 TOKEN_STRING_INITIALIZER
19441 (struct cmd_set_port_ptypes_result,
19443 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19444 TOKEN_NUM_INITIALIZER
19445 (struct cmd_set_port_ptypes_result,
19447 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19448 TOKEN_STRING_INITIALIZER
19449 (struct cmd_set_port_ptypes_result,
19450 ptype_mask, "ptype_mask");
19451 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19452 TOKEN_NUM_INITIALIZER
19453 (struct cmd_set_port_ptypes_result,
19457 cmd_set_port_ptypes_parsed(
19458 void *parsed_result,
19459 __rte_unused struct cmdline *cl,
19460 __rte_unused void *data)
19462 struct cmd_set_port_ptypes_result *res = parsed_result;
19463 #define PTYPE_NAMESIZE 256
19464 char ptype_name[PTYPE_NAMESIZE];
19465 uint16_t port_id = res->port_id;
19466 uint32_t ptype_mask = res->mask;
19469 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19472 printf("Port %d doesn't support any ptypes.\n", port_id);
19476 uint32_t ptypes[ret];
19478 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19480 printf("Unable to set requested ptypes for Port %d\n", port_id);
19484 printf("Successfully set following ptypes for Port %d\n", port_id);
19485 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19486 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19487 printf("%s\n", ptype_name);
19490 clear_ptypes = false;
19493 cmdline_parse_inst_t cmd_set_port_ptypes = {
19494 .f = cmd_set_port_ptypes_parsed,
19496 .help_str = "set port <port_id> ptype_mask <mask>",
19498 (void *)&cmd_set_port_ptypes_set,
19499 (void *)&cmd_set_port_ptypes_port,
19500 (void *)&cmd_set_port_ptypes_port_id,
19501 (void *)&cmd_set_port_ptypes_mask_str,
19502 (void *)&cmd_set_port_ptypes_mask_u32,
19507 /* *** display mac addresses added to a port *** */
19508 struct cmd_showport_macs_result {
19509 cmdline_fixed_string_t cmd_show;
19510 cmdline_fixed_string_t cmd_port;
19511 cmdline_fixed_string_t cmd_keyword;
19516 cmd_showport_macs_parsed(void *parsed_result,
19517 __rte_unused struct cmdline *cl,
19518 __rte_unused void *data)
19520 struct cmd_showport_macs_result *res = parsed_result;
19522 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19525 if (!strcmp(res->cmd_keyword, "macs"))
19526 show_macs(res->cmd_pid);
19527 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19528 show_mcast_macs(res->cmd_pid);
19531 cmdline_parse_token_string_t cmd_showport_macs_show =
19532 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19534 cmdline_parse_token_string_t cmd_showport_macs_port =
19535 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19537 cmdline_parse_token_num_t cmd_showport_macs_pid =
19538 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19540 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19541 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19542 cmd_keyword, "macs#mcast_macs");
19544 cmdline_parse_inst_t cmd_showport_macs = {
19545 .f = cmd_showport_macs_parsed,
19547 .help_str = "show port <port_id> macs|mcast_macs",
19549 (void *)&cmd_showport_macs_show,
19550 (void *)&cmd_showport_macs_port,
19551 (void *)&cmd_showport_macs_pid,
19552 (void *)&cmd_showport_macs_keyword,
19557 /* ******************************************************************************** */
19559 /* list of instructions */
19560 cmdline_parse_ctx_t main_ctx[] = {
19561 (cmdline_parse_inst_t *)&cmd_help_brief,
19562 (cmdline_parse_inst_t *)&cmd_help_long,
19563 (cmdline_parse_inst_t *)&cmd_quit,
19564 (cmdline_parse_inst_t *)&cmd_load_from_file,
19565 (cmdline_parse_inst_t *)&cmd_showport,
19566 (cmdline_parse_inst_t *)&cmd_showqueue,
19567 (cmdline_parse_inst_t *)&cmd_showeeprom,
19568 (cmdline_parse_inst_t *)&cmd_showportall,
19569 (cmdline_parse_inst_t *)&cmd_showdevice,
19570 (cmdline_parse_inst_t *)&cmd_showcfg,
19571 (cmdline_parse_inst_t *)&cmd_showfwdall,
19572 (cmdline_parse_inst_t *)&cmd_start,
19573 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19574 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19575 (cmdline_parse_inst_t *)&cmd_set_link_up,
19576 (cmdline_parse_inst_t *)&cmd_set_link_down,
19577 (cmdline_parse_inst_t *)&cmd_reset,
19578 (cmdline_parse_inst_t *)&cmd_set_numbers,
19579 (cmdline_parse_inst_t *)&cmd_set_log,
19580 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19581 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19582 (cmdline_parse_inst_t *)&cmd_set_txtimes,
19583 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19584 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19585 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19586 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19587 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19588 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19589 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19590 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19591 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19592 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19593 (cmdline_parse_inst_t *)&cmd_set_link_check,
19594 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19595 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19596 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19597 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19598 #ifdef RTE_LIBRTE_PMD_BOND
19599 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19600 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19601 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19602 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19603 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19604 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19605 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19606 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19607 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19608 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19609 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19611 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19612 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19613 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19614 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19615 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19616 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19617 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19618 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19619 (cmdline_parse_inst_t *)&cmd_csum_set,
19620 (cmdline_parse_inst_t *)&cmd_csum_show,
19621 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19622 (cmdline_parse_inst_t *)&cmd_tso_set,
19623 (cmdline_parse_inst_t *)&cmd_tso_show,
19624 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19625 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19626 (cmdline_parse_inst_t *)&cmd_gro_enable,
19627 (cmdline_parse_inst_t *)&cmd_gro_flush,
19628 (cmdline_parse_inst_t *)&cmd_gro_show,
19629 (cmdline_parse_inst_t *)&cmd_gso_enable,
19630 (cmdline_parse_inst_t *)&cmd_gso_size,
19631 (cmdline_parse_inst_t *)&cmd_gso_show,
19632 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19633 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19634 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19635 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19636 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19637 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19638 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19639 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19640 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19641 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19642 (cmdline_parse_inst_t *)&cmd_config_dcb,
19643 (cmdline_parse_inst_t *)&cmd_read_reg,
19644 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19645 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19646 (cmdline_parse_inst_t *)&cmd_write_reg,
19647 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19648 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19649 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19650 (cmdline_parse_inst_t *)&cmd_stop,
19651 (cmdline_parse_inst_t *)&cmd_mac_addr,
19652 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19653 (cmdline_parse_inst_t *)&cmd_set_qmap,
19654 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19655 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
19656 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
19657 (cmdline_parse_inst_t *)&cmd_operate_port,
19658 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19659 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19660 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19661 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19662 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19663 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19664 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19665 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19666 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19667 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19668 (cmdline_parse_inst_t *)&cmd_config_mtu,
19669 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19670 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19671 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19672 (cmdline_parse_inst_t *)&cmd_config_rss,
19673 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19674 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19675 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19676 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19677 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19678 (cmdline_parse_inst_t *)&cmd_showport_reta,
19679 (cmdline_parse_inst_t *)&cmd_showport_macs,
19680 (cmdline_parse_inst_t *)&cmd_config_burst,
19681 (cmdline_parse_inst_t *)&cmd_config_thresh,
19682 (cmdline_parse_inst_t *)&cmd_config_threshold,
19683 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19684 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19685 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19686 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19687 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19688 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19689 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19690 (cmdline_parse_inst_t *)&cmd_global_config,
19691 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19692 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19693 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19694 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19695 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19696 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19697 (cmdline_parse_inst_t *)&cmd_dump,
19698 (cmdline_parse_inst_t *)&cmd_dump_one,
19699 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19700 (cmdline_parse_inst_t *)&cmd_syn_filter,
19701 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19702 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19703 (cmdline_parse_inst_t *)&cmd_flex_filter,
19704 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19705 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19706 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19707 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19708 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19709 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19710 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19711 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19712 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19713 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19714 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19715 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19716 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19717 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19718 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19719 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19720 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19721 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19722 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19723 (cmdline_parse_inst_t *)&cmd_flow,
19724 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19725 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19726 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19727 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19728 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19729 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19730 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19731 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19732 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19733 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19734 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19735 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19736 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19737 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19738 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19739 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19740 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19741 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19742 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19743 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19744 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19745 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19746 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19747 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19748 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19749 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19750 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19751 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19752 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19753 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19754 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19755 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19756 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19757 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19758 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19759 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19760 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19761 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19762 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19763 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19764 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19765 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19766 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19767 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19768 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19769 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19770 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19771 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19772 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19773 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19774 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19775 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19776 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19777 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19778 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19779 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19780 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19781 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19782 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19783 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19784 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19785 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19786 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19787 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19788 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19789 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19790 (cmdline_parse_inst_t *)&cmd_ddp_add,
19791 (cmdline_parse_inst_t *)&cmd_ddp_del,
19792 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19793 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19794 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19795 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19796 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19797 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19798 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19799 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19800 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19801 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19802 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19803 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19805 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19806 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19807 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19808 (cmdline_parse_inst_t *)&cmd_queue_region,
19809 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19810 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19811 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19812 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19813 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19814 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19815 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19816 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19817 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19818 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19819 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19820 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19821 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19822 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19823 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19824 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19825 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19826 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
19827 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19828 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19829 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19830 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19831 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19832 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19833 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19834 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19835 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19836 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19837 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19838 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19839 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19840 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19841 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19842 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19843 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19844 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19845 #ifdef RTE_LIBRTE_BPF
19846 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19847 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19849 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19850 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19851 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19852 (cmdline_parse_inst_t *)&cmd_set_raw,
19853 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19854 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19855 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
19859 /* read cmdline commands from file */
19861 cmdline_read_from_file(const char *filename)
19863 struct cmdline *cl;
19865 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19867 printf("Failed to create file based cmdline context: %s\n",
19872 cmdline_interact(cl);
19877 printf("Read CLI commands from %s\n", filename);
19880 /* prompt function, called from main on MASTER lcore */
19884 /* initialize non-constant commands */
19885 cmd_set_fwd_mode_init();
19886 cmd_set_fwd_retry_mode_init();
19888 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19889 if (testpmd_cl == NULL)
19891 cmdline_interact(testpmd_cl);
19892 cmdline_stdin_exit(testpmd_cl);
19898 if (testpmd_cl != NULL)
19899 cmdline_quit(testpmd_cl);
19903 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19905 if (id == (portid_t)RTE_PORT_ALL) {
19908 RTE_ETH_FOREACH_DEV(pid) {
19909 /* check if need_reconfig has been set to 1 */
19910 if (ports[pid].need_reconfig == 0)
19911 ports[pid].need_reconfig = dev;
19912 /* check if need_reconfig_queues has been set to 1 */
19913 if (ports[pid].need_reconfig_queues == 0)
19914 ports[pid].need_reconfig_queues = queue;
19916 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19917 /* check if need_reconfig has been set to 1 */
19918 if (ports[id].need_reconfig == 0)
19919 ports[id].need_reconfig = dev;
19920 /* check if need_reconfig_queues has been set to 1 */
19921 if (ports[id].need_reconfig_queues == 0)
19922 ports[id].need_reconfig_queues = queue;