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"
252 "show port (port_id) fec capabilities"
253 " Show fec capabilities of a port.\n\n"
255 "show port (port_id) fec_mode"
256 " Show fec mode of a port.\n\n"
260 if (show_all || !strcmp(res->section, "config")) {
266 "Configuration changes only become active when"
267 " forwarding is started/restarted.\n\n"
270 " Reset forwarding to the default configuration.\n\n"
272 "set verbose (level)\n"
273 " Set the debug verbosity level X.\n\n"
275 "set log global|(type) (level)\n"
276 " Set the log level.\n\n"
279 " Set number of ports.\n\n"
282 " Set number of cores.\n\n"
284 "set coremask (mask)\n"
285 " Set the forwarding cores hexadecimal mask.\n\n"
287 "set portmask (mask)\n"
288 " Set the forwarding ports hexadecimal mask.\n\n"
291 " Set number of packets per burst.\n\n"
293 "set burst tx delay (microseconds) retry (num)\n"
294 " Set the transmit delay time and number of retries,"
295 " effective when retry is enabled.\n\n"
297 "set txpkts (x[,y]*)\n"
298 " Set the length of each segment of TXONLY"
299 " and optionally CSUM packets.\n\n"
301 "set txsplit (off|on|rand)\n"
302 " Set the split policy for the TX packets."
303 " Right now only applicable for CSUM and TXONLY"
306 "set txtimes (x, y)\n"
307 " Set the scheduling on timestamps"
308 " timings for the TXONLY mode\n\n"
310 "set corelist (x[,y]*)\n"
311 " Set the list of forwarding cores.\n\n"
313 "set portlist (x[,y]*)\n"
314 " Set the list of forwarding ports.\n\n"
316 "set port setup on (iterator|event)\n"
317 " Select how attached port is retrieved for setup.\n\n"
319 "set tx loopback (port_id) (on|off)\n"
320 " Enable or disable tx loopback.\n\n"
322 "set all queues drop (port_id) (on|off)\n"
323 " Set drop enable bit for all queues.\n\n"
325 "set vf split drop (port_id) (vf_id) (on|off)\n"
326 " Set split drop enable bit for a VF from the PF.\n\n"
328 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
329 " Set MAC antispoof for a VF from the PF.\n\n"
331 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
332 " Enable MACsec offload.\n\n"
334 "set macsec offload (port_id) off\n"
335 " Disable MACsec offload.\n\n"
337 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
338 " Configure MACsec secure connection (SC).\n\n"
340 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
341 " Configure MACsec secure association (SA).\n\n"
343 "set vf broadcast (port_id) (vf_id) (on|off)\n"
344 " Set VF broadcast for a VF from the PF.\n\n"
346 "vlan set stripq (on|off) (port_id,queue_id)\n"
347 " Set the VLAN strip for a queue on a port.\n\n"
349 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
350 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
352 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
353 " Set VLAN insert for a VF from the PF.\n\n"
355 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
356 " Set VLAN antispoof for a VF from the PF.\n\n"
358 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
359 " Set VLAN tag for a VF from the PF.\n\n"
361 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
362 " Set a VF's max bandwidth(Mbps).\n\n"
364 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
365 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
367 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
368 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
370 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
371 " Set some TCs' strict link priority mode on a physical port.\n\n"
373 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
374 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
376 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
377 " Set the VLAN strip or filter or qinq strip or extend\n\n"
379 "vlan set (inner|outer) tpid (value) (port_id)\n"
380 " Set the VLAN TPID for Packet Filtering on"
383 "rx_vlan add (vlan_id|all) (port_id)\n"
384 " Add a vlan_id, or all identifiers, to the set"
385 " of VLAN identifiers filtered by port_id.\n\n"
387 "rx_vlan rm (vlan_id|all) (port_id)\n"
388 " Remove a vlan_id, or all identifiers, from the set"
389 " of VLAN identifiers filtered by port_id.\n\n"
391 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
392 " Add a vlan_id, to the set of VLAN identifiers"
393 "filtered for VF(s) from port_id.\n\n"
395 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
396 " Remove a vlan_id, to the set of VLAN identifiers"
397 "filtered for VF(s) from port_id.\n\n"
399 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
400 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
401 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
402 " add a tunnel filter of a port.\n\n"
404 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
405 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
406 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
407 " remove a tunnel filter of a port.\n\n"
409 "rx_vxlan_port add (udp_port) (port_id)\n"
410 " Add an UDP port for VXLAN packet filter on a port\n\n"
412 "rx_vxlan_port rm (udp_port) (port_id)\n"
413 " Remove an UDP port for VXLAN packet filter on a port\n\n"
415 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
416 " Set hardware insertion of VLAN IDs (single or double VLAN "
417 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
419 "tx_vlan set pvid port_id vlan_id (on|off)\n"
420 " Set port based TX VLAN insertion.\n\n"
422 "tx_vlan reset (port_id)\n"
423 " Disable hardware insertion of a VLAN header in"
424 " packets sent on a port.\n\n"
426 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
427 " Select hardware or software calculation of the"
428 " checksum when transmitting a packet using the"
429 " csum forward engine.\n"
430 " ip|udp|tcp|sctp always concern the inner layer.\n"
431 " outer-ip concerns the outer IP layer in"
432 " outer-udp concerns the outer UDP layer in"
433 " case the packet is recognized as a tunnel packet by"
434 " the forward engine (vxlan, gre and ipip are supported)\n"
435 " Please check the NIC datasheet for HW limits.\n\n"
437 "csum parse-tunnel (on|off) (tx_port_id)\n"
438 " If disabled, treat tunnel packets as non-tunneled"
439 " packets (treat inner headers as payload). The port\n"
440 " argument is the port used for TX in csum forward"
443 "csum show (port_id)\n"
444 " Display tx checksum offload configuration\n\n"
446 "tso set (segsize) (portid)\n"
447 " Enable TCP Segmentation Offload in csum forward"
449 " Please check the NIC datasheet for HW limits.\n\n"
452 " Display the status of TCP Segmentation Offload.\n\n"
454 "set port (port_id) gro on|off\n"
455 " Enable or disable Generic Receive Offload in"
456 " csum forwarding engine.\n\n"
458 "show port (port_id) gro\n"
459 " Display GRO configuration.\n\n"
461 "set gro flush (cycles)\n"
462 " Set the cycle to flush GROed packets from"
463 " reassembly tables.\n\n"
465 "set port (port_id) gso (on|off)"
466 " Enable or disable Generic Segmentation Offload in"
467 " csum forwarding engine.\n\n"
469 "set gso segsz (length)\n"
470 " Set max packet length for output GSO segments,"
471 " including packet header and payload.\n\n"
473 "show port (port_id) gso\n"
474 " Show GSO configuration.\n\n"
477 " Set packet forwarding mode.\n\n"
479 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
480 " Add a MAC address on port_id.\n\n"
482 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
483 " Remove a MAC address from port_id.\n\n"
485 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
486 " Set the default MAC address for port_id.\n\n"
488 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
489 " Add a MAC address for a VF on the port.\n\n"
491 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
492 " Set the MAC address for a VF from the PF.\n\n"
494 "set eth-peer (port_id) (peer_addr)\n"
495 " set the peer address for certain port.\n\n"
497 "set port (port_id) uta (mac_address|all) (on|off)\n"
498 " Add/Remove a or all unicast hash filter(s)"
501 "set promisc (port_id|all) (on|off)\n"
502 " Set the promiscuous mode on port_id, or all.\n\n"
504 "set allmulti (port_id|all) (on|off)\n"
505 " Set the allmulti mode on port_id, or all.\n\n"
507 "set vf promisc (port_id) (vf_id) (on|off)\n"
508 " Set unicast promiscuous mode for a VF from the PF.\n\n"
510 "set vf allmulti (port_id) (vf_id) (on|off)\n"
511 " Set multicast promiscuous mode for a VF from the PF.\n\n"
513 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
514 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
515 " (on|off) autoneg (on|off) (port_id)\n"
516 "set flow_ctrl rx (on|off) (portid)\n"
517 "set flow_ctrl tx (on|off) (portid)\n"
518 "set flow_ctrl high_water (high_water) (portid)\n"
519 "set flow_ctrl low_water (low_water) (portid)\n"
520 "set flow_ctrl pause_time (pause_time) (portid)\n"
521 "set flow_ctrl send_xon (send_xon) (portid)\n"
522 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
523 "set flow_ctrl autoneg (on|off) (port_id)\n"
524 " Set the link flow control parameter on a port.\n\n"
526 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
527 " (low_water) (pause_time) (priority) (port_id)\n"
528 " Set the priority flow control parameter on a"
531 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
532 " Set statistics mapping (qmapping 0..15) for RX/TX"
534 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
535 " on port 0 to mapping 5.\n\n"
537 "set xstats-hide-zero on|off\n"
538 " Set the option to hide the zero values"
539 " for xstats display.\n"
541 "set record-core-cycles on|off\n"
542 " Set the option to enable measurement of CPU cycles.\n"
544 "set record-burst-stats on|off\n"
545 " Set the option to enable display of RX and TX bursts.\n"
547 "set port (port_id) vf (vf_id) rx|tx on|off\n"
548 " Enable/Disable a VF receive/tranmit from a port\n\n"
550 "set port (port_id) vf (vf_id) (mac_addr)"
551 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
552 " Add/Remove unicast or multicast MAC addr filter"
555 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
557 " AUPE:accepts untagged VLAN;"
558 "ROPE:accept unicast hash\n\n"
559 " BAM:accepts broadcast packets;"
560 "MPE:accepts all multicast packets\n\n"
561 " Enable/Disable a VF receive mode of a port\n\n"
563 "set port (port_id) queue (queue_id) rate (rate_num)\n"
564 " Set rate limit for a queue of a port\n\n"
566 "set port (port_id) vf (vf_id) rate (rate_num) "
567 "queue_mask (queue_mask_value)\n"
568 " Set rate limit for queues in VF of a port\n\n"
570 "set port (port_id) mirror-rule (rule_id)"
571 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
572 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
573 " Set pool or vlan type mirror rule on a port.\n"
574 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
575 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
578 "set port (port_id) mirror-rule (rule_id)"
579 " (uplink-mirror|downlink-mirror) dst-pool"
580 " (pool_id) (on|off)\n"
581 " Set uplink or downlink type mirror rule on a port.\n"
582 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
583 " 0 on' enable mirror income traffic to pool 0.\n\n"
585 "reset port (port_id) mirror-rule (rule_id)\n"
586 " Reset a mirror rule.\n\n"
588 "set flush_rx (on|off)\n"
589 " Flush (default) or don't flush RX streams before"
590 " forwarding. Mainly used with PCAP drivers.\n\n"
592 "set bypass mode (normal|bypass|isolate) (port_id)\n"
593 " Set the bypass mode for the lowest port on bypass enabled"
596 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
597 "mode (normal|bypass|isolate) (port_id)\n"
598 " Set the event required to initiate specified bypass mode for"
599 " the lowest port on a bypass enabled NIC where:\n"
600 " timeout = enable bypass after watchdog timeout.\n"
601 " os_on = enable bypass when OS/board is powered on.\n"
602 " os_off = enable bypass when OS/board is powered off.\n"
603 " power_on = enable bypass when power supply is turned on.\n"
604 " power_off = enable bypass when power supply is turned off."
607 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
608 " Set the bypass watchdog timeout to 'n' seconds"
609 " where 0 = instant.\n\n"
611 "show bypass config (port_id)\n"
612 " Show the bypass configuration for a bypass enabled NIC"
613 " using the lowest port on the NIC.\n\n"
615 #ifdef RTE_LIBRTE_PMD_BOND
616 "create bonded device (mode) (socket)\n"
617 " Create a new bonded device with specific bonding mode and socket.\n\n"
619 "add bonding slave (slave_id) (port_id)\n"
620 " Add a slave device to a bonded device.\n\n"
622 "remove bonding slave (slave_id) (port_id)\n"
623 " Remove a slave device from a bonded device.\n\n"
625 "set bonding mode (value) (port_id)\n"
626 " Set the bonding mode on a bonded device.\n\n"
628 "set bonding primary (slave_id) (port_id)\n"
629 " Set the primary slave for a bonded device.\n\n"
631 "show bonding config (port_id)\n"
632 " Show the bonding config for port_id.\n\n"
634 "set bonding mac_addr (port_id) (address)\n"
635 " Set the MAC address of a bonded device.\n\n"
637 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
638 " Set Aggregation mode for IEEE802.3AD (mode 4)"
640 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
641 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
643 "set bonding mon_period (port_id) (value)\n"
644 " Set the bonding link status monitoring polling period in ms.\n\n"
646 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
647 " Enable/disable dedicated queues for LACP control traffic.\n\n"
650 "set link-up port (port_id)\n"
651 " Set link up for a port.\n\n"
653 "set link-down port (port_id)\n"
654 " Set link down for a port.\n\n"
656 "E-tag set insertion on port-tag-id (value)"
657 " port (port_id) vf (vf_id)\n"
658 " Enable E-tag insertion for a VF on a port\n\n"
660 "E-tag set insertion off port (port_id) vf (vf_id)\n"
661 " Disable E-tag insertion for a VF on a port\n\n"
663 "E-tag set stripping (on|off) port (port_id)\n"
664 " Enable/disable E-tag stripping on a port\n\n"
666 "E-tag set forwarding (on|off) port (port_id)\n"
667 " Enable/disable E-tag based forwarding"
670 "E-tag set filter add e-tag-id (value) dst-pool"
671 " (pool_id) port (port_id)\n"
672 " Add an E-tag forwarding filter on a port\n\n"
674 "E-tag set filter del e-tag-id (value) port (port_id)\n"
675 " Delete an E-tag forwarding filter on a port\n\n"
677 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
678 " Load a profile package on a port\n\n"
680 "ddp del (port_id) (backup_profile_path)\n"
681 " Delete a profile package from a port\n\n"
683 "ptype mapping get (port_id) (valid_only)\n"
684 " Get ptype mapping on a port\n\n"
686 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
687 " Replace target with the pkt_type in ptype mapping\n\n"
689 "ptype mapping reset (port_id)\n"
690 " Reset ptype mapping on a port\n\n"
692 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
693 " Update a ptype mapping item on a port\n\n"
695 "set port (port_id) ptype_mask (ptype_mask)\n"
696 " set packet types classification for a specific port\n\n"
698 "set port (port_id) queue-region region_id (value) "
699 "queue_start_index (value) queue_num (value)\n"
700 " Set a queue region on a port\n\n"
702 "set port (port_id) queue-region region_id (value) "
704 " Set a flowtype region index on a port\n\n"
706 "set port (port_id) queue-region UP (value) region_id (value)\n"
707 " Set the mapping of User Priority to "
708 "queue region on a port\n\n"
710 "set port (port_id) queue-region flush (on|off)\n"
711 " flush all queue region related configuration\n\n"
713 "show port meter cap (port_id)\n"
714 " Show port meter capability information\n\n"
716 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
717 " meter profile add - srtcm rfc 2697\n\n"
719 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
720 " meter profile add - trtcm rfc 2698\n\n"
722 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
723 " meter profile add - trtcm rfc 4115\n\n"
725 "del port meter profile (port_id) (profile_id)\n"
726 " meter profile delete\n\n"
728 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
729 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
730 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
731 "(dscp_tbl_entry63)]\n"
734 "enable port meter (port_id) (mtr_id)\n"
737 "disable port meter (port_id) (mtr_id)\n"
740 "del port meter (port_id) (mtr_id)\n"
743 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
744 " meter update meter profile\n\n"
746 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
747 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
748 " update meter dscp table entries\n\n"
750 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
751 "(action0) [(action1) (action2)]\n"
752 " meter update policer action\n\n"
754 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
755 " meter update stats\n\n"
757 "show port (port_id) queue-region\n"
758 " show all queue region related configuration info\n\n"
760 "set port (port_id) fec_mode auto|off|rs|baser\n"
761 " set fec mode for a specific port\n\n"
763 , list_pkt_forwarding_modes()
767 if (show_all || !strcmp(res->section, "ports")) {
773 "----------------\n\n"
775 "port start (port_id|all)\n"
776 " Start all ports or port_id.\n\n"
778 "port stop (port_id|all)\n"
779 " Stop all ports or port_id.\n\n"
781 "port close (port_id|all)\n"
782 " Close all ports or port_id.\n\n"
784 "port reset (port_id|all)\n"
785 " Reset all ports or port_id.\n\n"
787 "port attach (ident)\n"
788 " Attach physical or virtual dev by pci address or virtual device name\n\n"
790 "port detach (port_id)\n"
791 " Detach physical or virtual dev by port_id\n\n"
793 "port config (port_id|all)"
794 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
795 " duplex (half|full|auto)\n"
796 " Set speed and duplex for all ports or port_id\n\n"
798 "port config (port_id|all) loopback (mode)\n"
799 " Set loopback mode for all ports or port_id\n\n"
801 "port config all (rxq|txq|rxd|txd) (value)\n"
802 " Set number for rxq/txq/rxd/txd.\n\n"
804 "port config all max-pkt-len (value)\n"
805 " Set the max packet length.\n\n"
807 "port config all max-lro-pkt-size (value)\n"
808 " Set the max LRO aggregated packet size.\n\n"
810 "port config all drop-en (on|off)\n"
811 " Enable or disable packet drop on all RX queues of all ports when no "
812 "receive buffers available.\n\n"
814 "port config all rss (all|default|ip|tcp|udp|sctp|"
815 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|level-default|"
816 "level-outer|level-inner|<flowtype_id>)\n"
817 " Set the RSS mode.\n\n"
819 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
820 " Set the RSS redirection table.\n\n"
822 "port config (port_id) dcb vt (on|off) (traffic_class)"
824 " Set the DCB mode.\n\n"
826 "port config all burst (value)\n"
827 " Set the number of packets per burst.\n\n"
829 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
831 " Set the ring prefetch/host/writeback threshold"
832 " for tx/rx queue.\n\n"
834 "port config all (txfreet|txrst|rxfreet) (value)\n"
835 " Set free threshold for rx/tx, or set"
836 " tx rs bit threshold.\n\n"
837 "port config mtu X value\n"
838 " Set the MTU of port X to a given value\n\n"
840 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
841 " Set a rx/tx queue's ring size configuration, the new"
842 " value will take effect after command that (re-)start the port"
843 " or command that setup the specific queue\n\n"
845 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
846 " Start/stop a rx/tx queue of port X. Only take effect"
847 " when port X is started\n\n"
849 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
850 " Switch on/off a deferred start of port X rx/tx queue. Only"
851 " take effect when port X is stopped.\n\n"
853 "port (port_id) (rxq|txq) (queue_id) setup\n"
854 " Setup a rx/tx queue of port X.\n\n"
856 "port config (port_id|all) l2-tunnel E-tag ether-type"
858 " Set the value of E-tag ether-type.\n\n"
860 "port config (port_id|all) l2-tunnel E-tag"
861 " (enable|disable)\n"
862 " Enable/disable the E-tag support.\n\n"
864 "port config (port_id) pctype mapping reset\n"
865 " Reset flow type to pctype mapping on a port\n\n"
867 "port config (port_id) pctype mapping update"
868 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
869 " Update a flow type to pctype mapping item on a port\n\n"
871 "port config (port_id) pctype (pctype_id) hash_inset|"
872 "fdir_inset|fdir_flx_inset get|set|clear field\n"
874 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
876 "port config (port_id) pctype (pctype_id) hash_inset|"
877 "fdir_inset|fdir_flx_inset clear all"
878 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
880 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
881 " Add/remove UDP tunnel port for tunneling offload\n\n"
883 "port config <port_id> rx_offload vlan_strip|"
884 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
885 "outer_ipv4_cksum|macsec_strip|header_split|"
886 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
887 "buffer_split|timestamp|security|keep_crc on|off\n"
888 " Enable or disable a per port Rx offloading"
889 " on all Rx queues of a port\n\n"
891 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
892 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
893 "outer_ipv4_cksum|macsec_strip|header_split|"
894 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
895 "buffer_split|timestamp|security|keep_crc on|off\n"
896 " Enable or disable a per queue Rx offloading"
897 " only on a specific Rx queue\n\n"
899 "port config (port_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|"
903 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
905 " Enable or disable a per port Tx offloading"
906 " on all Tx queues of a port\n\n"
908 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
909 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
910 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
911 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
912 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
914 " Enable or disable a per queue Tx offloading"
915 " only on a specific Tx queue\n\n"
917 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
918 " Load an eBPF program as a callback"
919 " for particular RX/TX queue\n\n"
921 "bpf-unload rx|tx (port) (queue)\n"
922 " Unload previously loaded eBPF program"
923 " for particular RX/TX queue\n\n"
925 "port config (port_id) tx_metadata (value)\n"
926 " Set Tx metadata value per port. Testpmd will add this value"
927 " to any Tx packet sent from this port\n\n"
929 "port config (port_id) dynf (name) set|clear\n"
930 " Register a dynf and Set/clear this flag on Tx. "
931 "Testpmd will set this value to any Tx packet "
932 "sent from this port\n\n"
936 if (show_all || !strcmp(res->section, "registers")) {
944 "read reg (port_id) (address)\n"
945 " Display value of a port register.\n\n"
947 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
948 " Display a port register bit field.\n\n"
950 "read regbit (port_id) (address) (bit_x)\n"
951 " Display a single port register bit.\n\n"
953 "write reg (port_id) (address) (value)\n"
954 " Set value of a port register.\n\n"
956 "write regfield (port_id) (address) (bit_x) (bit_y)"
958 " Set bit field of a port register.\n\n"
960 "write regbit (port_id) (address) (bit_x) (value)\n"
961 " Set single bit value of a port register.\n\n"
964 if (show_all || !strcmp(res->section, "filters")) {
972 "ethertype_filter (port_id) (add|del)"
973 " (mac_addr|mac_ignr) (mac_address) ethertype"
974 " (ether_type) (drop|fwd) queue (queue_id)\n"
975 " Add/Del an ethertype filter.\n\n"
977 "2tuple_filter (port_id) (add|del)"
978 " dst_port (dst_port_value) protocol (protocol_value)"
979 " mask (mask_value) tcp_flags (tcp_flags_value)"
980 " priority (prio_value) queue (queue_id)\n"
981 " Add/Del a 2tuple filter.\n\n"
983 "5tuple_filter (port_id) (add|del)"
984 " dst_ip (dst_address) src_ip (src_address)"
985 " dst_port (dst_port_value) src_port (src_port_value)"
986 " protocol (protocol_value)"
987 " mask (mask_value) tcp_flags (tcp_flags_value)"
988 " priority (prio_value) queue (queue_id)\n"
989 " Add/Del a 5tuple filter.\n\n"
991 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
992 " Add/Del syn filter.\n\n"
994 "flex_filter (port_id) (add|del) len (len_value)"
995 " bytes (bytes_value) mask (mask_value)"
996 " priority (prio_value) queue (queue_id)\n"
997 " Add/Del a flex filter.\n\n"
999 "flow_director_filter (port_id) mode IP (add|del|update)"
1000 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
1001 " src (src_ip_address) dst (dst_ip_address)"
1002 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
1003 " vlan (vlan_value) flexbytes (flexbytes_value)"
1004 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1005 " fd_id (fd_id_value)\n"
1006 " Add/Del an IP type flow director filter.\n\n"
1008 "flow_director_filter (port_id) mode IP (add|del|update)"
1009 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
1010 " src (src_ip_address) (src_port)"
1011 " dst (dst_ip_address) (dst_port)"
1012 " tos (tos_value) ttl (ttl_value)"
1013 " vlan (vlan_value) flexbytes (flexbytes_value)"
1014 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1015 " fd_id (fd_id_value)\n"
1016 " Add/Del an UDP/TCP type flow director filter.\n\n"
1018 "flow_director_filter (port_id) mode IP (add|del|update)"
1019 " flow (ipv4-sctp|ipv6-sctp)"
1020 " src (src_ip_address) (src_port)"
1021 " dst (dst_ip_address) (dst_port)"
1022 " tag (verification_tag) "
1023 " tos (tos_value) ttl (ttl_value)"
1024 " vlan (vlan_value)"
1025 " flexbytes (flexbytes_value) (drop|fwd)"
1026 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1027 " Add/Del a SCTP type flow director filter.\n\n"
1029 "flow_director_filter (port_id) mode IP (add|del|update)"
1030 " flow l2_payload ether (ethertype)"
1031 " flexbytes (flexbytes_value) (drop|fwd)"
1032 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1033 " Add/Del a l2 payload type flow director filter.\n\n"
1035 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1036 " mac (mac_address) vlan (vlan_value)"
1037 " flexbytes (flexbytes_value) (drop|fwd)"
1038 " queue (queue_id) fd_id (fd_id_value)\n"
1039 " Add/Del a MAC-VLAN flow director filter.\n\n"
1041 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1042 " mac (mac_address) vlan (vlan_value)"
1043 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1044 " flexbytes (flexbytes_value) (drop|fwd)"
1045 " queue (queue_id) fd_id (fd_id_value)\n"
1046 " Add/Del a Tunnel flow director filter.\n\n"
1048 "flow_director_filter (port_id) mode raw (add|del|update)"
1049 " flow (flow_id) (drop|fwd) queue (queue_id)"
1050 " fd_id (fd_id_value) packet (packet file name)\n"
1051 " Add/Del a raw type flow director filter.\n\n"
1053 "flush_flow_director (port_id)\n"
1054 " Flush all flow director entries of a device.\n\n"
1056 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1057 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1058 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1059 " Set flow director IP mask.\n\n"
1061 "flow_director_mask (port_id) mode MAC-VLAN"
1062 " vlan (vlan_value)\n"
1063 " Set flow director MAC-VLAN mask.\n\n"
1065 "flow_director_mask (port_id) mode Tunnel"
1066 " vlan (vlan_value) mac (mac_value)"
1067 " tunnel-type (tunnel_type_value)"
1068 " tunnel-id (tunnel_id_value)\n"
1069 " Set flow director Tunnel mask.\n\n"
1071 "flow_director_flex_mask (port_id)"
1072 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1073 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1075 " Configure mask of flex payload.\n\n"
1077 "flow_director_flex_payload (port_id)"
1078 " (raw|l2|l3|l4) (config)\n"
1079 " Configure flex payload selection.\n\n"
1081 "get_sym_hash_ena_per_port (port_id)\n"
1082 " get symmetric hash enable configuration per port.\n\n"
1084 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1085 " set symmetric hash enable configuration per port"
1086 " to enable or disable.\n\n"
1088 "get_hash_global_config (port_id)\n"
1089 " Get the global configurations of hash filters.\n\n"
1091 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1092 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1093 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1094 " (enable|disable)\n"
1095 " Set the global configurations of hash filters.\n\n"
1097 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1098 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1099 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1100 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1101 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1102 "ipv6-next-header|udp-src-port|udp-dst-port|"
1103 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1104 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1105 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1106 "fld-8th|none) (select|add)\n"
1107 " Set the input set for hash.\n\n"
1109 "set_fdir_input_set (port_id) "
1110 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1111 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1112 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1113 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1114 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1115 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1116 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1118 " Set the input set for FDir.\n\n"
1120 "flow validate {port_id}"
1121 " [group {group_id}] [priority {level}]"
1122 " [ingress] [egress]"
1123 " pattern {item} [/ {item} [...]] / end"
1124 " actions {action} [/ {action} [...]] / end\n"
1125 " Check whether a flow rule can be created.\n\n"
1127 "flow create {port_id}"
1128 " [group {group_id}] [priority {level}]"
1129 " [ingress] [egress]"
1130 " pattern {item} [/ {item} [...]] / end"
1131 " actions {action} [/ {action} [...]] / end\n"
1132 " Create a flow rule.\n\n"
1134 "flow destroy {port_id} rule {rule_id} [...]\n"
1135 " Destroy specific flow rules.\n\n"
1137 "flow flush {port_id}\n"
1138 " Destroy all flow rules.\n\n"
1140 "flow query {port_id} {rule_id} {action}\n"
1141 " Query an existing flow rule.\n\n"
1143 "flow list {port_id} [group {group_id}] [...]\n"
1144 " List existing flow rules sorted by priority,"
1145 " filtered by group identifiers.\n\n"
1147 "flow isolate {port_id} {boolean}\n"
1148 " Restrict ingress traffic to the defined"
1151 "flow aged {port_id} [destroy]\n"
1152 " List and destroy aged flows"
1155 "flow shared_action {port_id} create"
1156 " [action_id {shared_action_id}]"
1157 " [ingress] [egress]"
1158 " action {action} / end\n"
1159 " Create shared action.\n\n"
1161 "flow shared_action {port_id} update"
1162 " {shared_action_id} action {action} / end\n"
1163 " Update shared action.\n\n"
1165 "flow shared_action {port_id} destroy"
1166 " action_id {shared_action_id} [...]\n"
1167 " Destroy specific shared actions.\n\n"
1169 "flow shared_action {port_id} query"
1170 " {shared_action_id}\n"
1171 " Query an existing shared action.\n\n"
1173 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1174 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1175 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1176 " Configure the VXLAN encapsulation for flows.\n\n"
1178 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1179 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1180 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1181 " eth-dst (eth-dst)\n"
1182 " Configure the VXLAN encapsulation for flows.\n\n"
1184 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1185 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1186 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1187 " eth-dst (eth-dst)\n"
1188 " Configure the VXLAN encapsulation for flows.\n\n"
1190 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1191 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1193 " Configure the NVGRE encapsulation for flows.\n\n"
1195 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1196 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1197 " eth-src (eth-src) eth-dst (eth-dst)\n"
1198 " Configure the NVGRE encapsulation for flows.\n\n"
1200 "set raw_encap {flow items}\n"
1201 " Configure the encapsulation with raw data.\n\n"
1203 "set raw_decap {flow items}\n"
1204 " Configure the decapsulation with raw data.\n\n"
1209 if (show_all || !strcmp(res->section, "traffic_management")) {
1213 "Traffic Management:\n"
1215 "show port tm cap (port_id)\n"
1216 " Display the port TM capability.\n\n"
1218 "show port tm level cap (port_id) (level_id)\n"
1219 " Display the port TM hierarchical level capability.\n\n"
1221 "show port tm node cap (port_id) (node_id)\n"
1222 " Display the port TM node capability.\n\n"
1224 "show port tm node type (port_id) (node_id)\n"
1225 " Display the port TM node type.\n\n"
1227 "show port tm node stats (port_id) (node_id) (clear)\n"
1228 " Display the port TM node stats.\n\n"
1230 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1231 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1232 " (packet_length_adjust) (packet_mode)\n"
1233 " Add port tm node private shaper profile.\n\n"
1235 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1236 " Delete port tm node private shaper profile.\n\n"
1238 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1239 " (shaper_profile_id)\n"
1240 " Add/update port tm node shared shaper.\n\n"
1242 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1243 " Delete port tm node shared shaper.\n\n"
1245 "set port tm node shaper profile (port_id) (node_id)"
1246 " (shaper_profile_id)\n"
1247 " Set port tm node shaper profile.\n\n"
1249 "add port tm node wred profile (port_id) (wred_profile_id)"
1250 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1251 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1252 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1253 " Add port tm node wred profile.\n\n"
1255 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1256 " Delete port tm node wred profile.\n\n"
1258 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1259 " (priority) (weight) (level_id) (shaper_profile_id)"
1260 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1261 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1262 " Add port tm nonleaf node.\n\n"
1264 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1265 " (priority) (weight) (level_id) (shaper_profile_id)"
1266 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1267 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1268 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1270 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1271 " (priority) (weight) (level_id) (shaper_profile_id)"
1272 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1273 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1274 " Add port tm leaf node.\n\n"
1276 "del port tm node (port_id) (node_id)\n"
1277 " Delete port tm node.\n\n"
1279 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1280 " (priority) (weight)\n"
1281 " Set port tm node parent.\n\n"
1283 "suspend port tm node (port_id) (node_id)"
1284 " Suspend tm node.\n\n"
1286 "resume port tm node (port_id) (node_id)"
1287 " Resume tm node.\n\n"
1289 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1290 " Commit tm hierarchy.\n\n"
1292 "set port tm mark ip_ecn (port) (green) (yellow)"
1294 " Enables/Disables the traffic management marking"
1295 " for IP ECN (Explicit Congestion Notification)"
1296 " packets on a given port\n\n"
1298 "set port tm mark ip_dscp (port) (green) (yellow)"
1300 " Enables/Disables the traffic management marking"
1301 " on the port for IP dscp packets\n\n"
1303 "set port tm mark vlan_dei (port) (green) (yellow)"
1305 " Enables/Disables the traffic management marking"
1306 " on the port for VLAN packets with DEI enabled\n\n"
1310 if (show_all || !strcmp(res->section, "devices")) {
1314 "Device Operations:\n"
1316 "device detach (identifier)\n"
1317 " Detach device by identifier.\n\n"
1323 cmdline_parse_token_string_t cmd_help_long_help =
1324 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1326 cmdline_parse_token_string_t cmd_help_long_section =
1327 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1328 "all#control#display#config#"
1329 "ports#registers#filters#traffic_management#devices");
1331 cmdline_parse_inst_t cmd_help_long = {
1332 .f = cmd_help_long_parsed,
1334 .help_str = "help all|control|display|config|ports|register|"
1335 "filters|traffic_management|devices: "
1338 (void *)&cmd_help_long_help,
1339 (void *)&cmd_help_long_section,
1345 /* *** start/stop/close all ports *** */
1346 struct cmd_operate_port_result {
1347 cmdline_fixed_string_t keyword;
1348 cmdline_fixed_string_t name;
1349 cmdline_fixed_string_t value;
1352 static void cmd_operate_port_parsed(void *parsed_result,
1353 __rte_unused struct cmdline *cl,
1354 __rte_unused void *data)
1356 struct cmd_operate_port_result *res = parsed_result;
1358 if (!strcmp(res->name, "start"))
1359 start_port(RTE_PORT_ALL);
1360 else if (!strcmp(res->name, "stop"))
1361 stop_port(RTE_PORT_ALL);
1362 else if (!strcmp(res->name, "close"))
1363 close_port(RTE_PORT_ALL);
1364 else if (!strcmp(res->name, "reset"))
1365 reset_port(RTE_PORT_ALL);
1367 printf("Unknown parameter\n");
1370 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1371 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1373 cmdline_parse_token_string_t cmd_operate_port_all_port =
1374 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1375 "start#stop#close#reset");
1376 cmdline_parse_token_string_t cmd_operate_port_all_all =
1377 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1379 cmdline_parse_inst_t cmd_operate_port = {
1380 .f = cmd_operate_port_parsed,
1382 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1384 (void *)&cmd_operate_port_all_cmd,
1385 (void *)&cmd_operate_port_all_port,
1386 (void *)&cmd_operate_port_all_all,
1391 /* *** start/stop/close specific port *** */
1392 struct cmd_operate_specific_port_result {
1393 cmdline_fixed_string_t keyword;
1394 cmdline_fixed_string_t name;
1398 static void cmd_operate_specific_port_parsed(void *parsed_result,
1399 __rte_unused struct cmdline *cl,
1400 __rte_unused void *data)
1402 struct cmd_operate_specific_port_result *res = parsed_result;
1404 if (!strcmp(res->name, "start"))
1405 start_port(res->value);
1406 else if (!strcmp(res->name, "stop"))
1407 stop_port(res->value);
1408 else if (!strcmp(res->name, "close"))
1409 close_port(res->value);
1410 else if (!strcmp(res->name, "reset"))
1411 reset_port(res->value);
1413 printf("Unknown parameter\n");
1416 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1417 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1419 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1420 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1421 name, "start#stop#close#reset");
1422 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1423 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1426 cmdline_parse_inst_t cmd_operate_specific_port = {
1427 .f = cmd_operate_specific_port_parsed,
1429 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1431 (void *)&cmd_operate_specific_port_cmd,
1432 (void *)&cmd_operate_specific_port_port,
1433 (void *)&cmd_operate_specific_port_id,
1438 /* *** enable port setup (after attach) via iterator or event *** */
1439 struct cmd_set_port_setup_on_result {
1440 cmdline_fixed_string_t set;
1441 cmdline_fixed_string_t port;
1442 cmdline_fixed_string_t setup;
1443 cmdline_fixed_string_t on;
1444 cmdline_fixed_string_t mode;
1447 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1448 __rte_unused struct cmdline *cl,
1449 __rte_unused void *data)
1451 struct cmd_set_port_setup_on_result *res = parsed_result;
1453 if (strcmp(res->mode, "event") == 0)
1454 setup_on_probe_event = true;
1455 else if (strcmp(res->mode, "iterator") == 0)
1456 setup_on_probe_event = false;
1458 printf("Unknown mode\n");
1461 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1462 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1464 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1465 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1467 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1468 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1470 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1471 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1473 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1474 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1475 mode, "iterator#event");
1477 cmdline_parse_inst_t cmd_set_port_setup_on = {
1478 .f = cmd_set_port_setup_on_parsed,
1480 .help_str = "set port setup on iterator|event",
1482 (void *)&cmd_set_port_setup_on_set,
1483 (void *)&cmd_set_port_setup_on_port,
1484 (void *)&cmd_set_port_setup_on_setup,
1485 (void *)&cmd_set_port_setup_on_on,
1486 (void *)&cmd_set_port_setup_on_mode,
1491 /* *** attach a specified port *** */
1492 struct cmd_operate_attach_port_result {
1493 cmdline_fixed_string_t port;
1494 cmdline_fixed_string_t keyword;
1495 cmdline_multi_string_t identifier;
1498 static void cmd_operate_attach_port_parsed(void *parsed_result,
1499 __rte_unused struct cmdline *cl,
1500 __rte_unused void *data)
1502 struct cmd_operate_attach_port_result *res = parsed_result;
1504 if (!strcmp(res->keyword, "attach"))
1505 attach_port(res->identifier);
1507 printf("Unknown parameter\n");
1510 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1511 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1513 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1514 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1516 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1517 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1518 identifier, TOKEN_STRING_MULTI);
1520 cmdline_parse_inst_t cmd_operate_attach_port = {
1521 .f = cmd_operate_attach_port_parsed,
1523 .help_str = "port attach <identifier>: "
1524 "(identifier: pci address or virtual dev name)",
1526 (void *)&cmd_operate_attach_port_port,
1527 (void *)&cmd_operate_attach_port_keyword,
1528 (void *)&cmd_operate_attach_port_identifier,
1533 /* *** detach a specified port *** */
1534 struct cmd_operate_detach_port_result {
1535 cmdline_fixed_string_t port;
1536 cmdline_fixed_string_t keyword;
1540 static void cmd_operate_detach_port_parsed(void *parsed_result,
1541 __rte_unused struct cmdline *cl,
1542 __rte_unused void *data)
1544 struct cmd_operate_detach_port_result *res = parsed_result;
1546 if (!strcmp(res->keyword, "detach")) {
1547 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1548 detach_port_device(res->port_id);
1550 printf("Unknown parameter\n");
1554 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1555 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1557 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1558 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1560 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1561 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1564 cmdline_parse_inst_t cmd_operate_detach_port = {
1565 .f = cmd_operate_detach_port_parsed,
1567 .help_str = "port detach <port_id>",
1569 (void *)&cmd_operate_detach_port_port,
1570 (void *)&cmd_operate_detach_port_keyword,
1571 (void *)&cmd_operate_detach_port_port_id,
1576 /* *** detach device by identifier *** */
1577 struct cmd_operate_detach_device_result {
1578 cmdline_fixed_string_t device;
1579 cmdline_fixed_string_t keyword;
1580 cmdline_fixed_string_t identifier;
1583 static void cmd_operate_detach_device_parsed(void *parsed_result,
1584 __rte_unused struct cmdline *cl,
1585 __rte_unused void *data)
1587 struct cmd_operate_detach_device_result *res = parsed_result;
1589 if (!strcmp(res->keyword, "detach"))
1590 detach_devargs(res->identifier);
1592 printf("Unknown parameter\n");
1595 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1596 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1598 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1599 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1601 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1602 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1605 cmdline_parse_inst_t cmd_operate_detach_device = {
1606 .f = cmd_operate_detach_device_parsed,
1608 .help_str = "device detach <identifier>:"
1609 "(identifier: pci address or virtual dev name)",
1611 (void *)&cmd_operate_detach_device_device,
1612 (void *)&cmd_operate_detach_device_keyword,
1613 (void *)&cmd_operate_detach_device_identifier,
1617 /* *** configure speed for all ports *** */
1618 struct cmd_config_speed_all {
1619 cmdline_fixed_string_t port;
1620 cmdline_fixed_string_t keyword;
1621 cmdline_fixed_string_t all;
1622 cmdline_fixed_string_t item1;
1623 cmdline_fixed_string_t item2;
1624 cmdline_fixed_string_t value1;
1625 cmdline_fixed_string_t value2;
1629 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1634 if (!strcmp(duplexstr, "half")) {
1635 duplex = ETH_LINK_HALF_DUPLEX;
1636 } else if (!strcmp(duplexstr, "full")) {
1637 duplex = ETH_LINK_FULL_DUPLEX;
1638 } else if (!strcmp(duplexstr, "auto")) {
1639 duplex = ETH_LINK_FULL_DUPLEX;
1641 printf("Unknown duplex parameter\n");
1645 if (!strcmp(speedstr, "10")) {
1646 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1647 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1648 } else if (!strcmp(speedstr, "100")) {
1649 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1650 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1652 if (duplex != ETH_LINK_FULL_DUPLEX) {
1653 printf("Invalid speed/duplex parameters\n");
1656 if (!strcmp(speedstr, "1000")) {
1657 *speed = ETH_LINK_SPEED_1G;
1658 } else if (!strcmp(speedstr, "10000")) {
1659 *speed = ETH_LINK_SPEED_10G;
1660 } else if (!strcmp(speedstr, "25000")) {
1661 *speed = ETH_LINK_SPEED_25G;
1662 } else if (!strcmp(speedstr, "40000")) {
1663 *speed = ETH_LINK_SPEED_40G;
1664 } else if (!strcmp(speedstr, "50000")) {
1665 *speed = ETH_LINK_SPEED_50G;
1666 } else if (!strcmp(speedstr, "100000")) {
1667 *speed = ETH_LINK_SPEED_100G;
1668 } else if (!strcmp(speedstr, "200000")) {
1669 *speed = ETH_LINK_SPEED_200G;
1670 } else if (!strcmp(speedstr, "auto")) {
1671 *speed = ETH_LINK_SPEED_AUTONEG;
1673 printf("Unknown speed parameter\n");
1682 cmd_config_speed_all_parsed(void *parsed_result,
1683 __rte_unused struct cmdline *cl,
1684 __rte_unused void *data)
1686 struct cmd_config_speed_all *res = parsed_result;
1687 uint32_t link_speed;
1690 if (!all_ports_stopped()) {
1691 printf("Please stop all ports first\n");
1695 if (parse_and_check_speed_duplex(res->value1, res->value2,
1699 RTE_ETH_FOREACH_DEV(pid) {
1700 ports[pid].dev_conf.link_speeds = link_speed;
1703 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1706 cmdline_parse_token_string_t cmd_config_speed_all_port =
1707 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1708 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1709 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1711 cmdline_parse_token_string_t cmd_config_speed_all_all =
1712 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1713 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1714 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1715 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1716 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1717 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1718 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1719 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1720 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1721 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1724 cmdline_parse_inst_t cmd_config_speed_all = {
1725 .f = cmd_config_speed_all_parsed,
1727 .help_str = "port config all speed "
1728 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1731 (void *)&cmd_config_speed_all_port,
1732 (void *)&cmd_config_speed_all_keyword,
1733 (void *)&cmd_config_speed_all_all,
1734 (void *)&cmd_config_speed_all_item1,
1735 (void *)&cmd_config_speed_all_value1,
1736 (void *)&cmd_config_speed_all_item2,
1737 (void *)&cmd_config_speed_all_value2,
1742 /* *** configure speed for specific port *** */
1743 struct cmd_config_speed_specific {
1744 cmdline_fixed_string_t port;
1745 cmdline_fixed_string_t keyword;
1747 cmdline_fixed_string_t item1;
1748 cmdline_fixed_string_t item2;
1749 cmdline_fixed_string_t value1;
1750 cmdline_fixed_string_t value2;
1754 cmd_config_speed_specific_parsed(void *parsed_result,
1755 __rte_unused struct cmdline *cl,
1756 __rte_unused void *data)
1758 struct cmd_config_speed_specific *res = parsed_result;
1759 uint32_t link_speed;
1761 if (!all_ports_stopped()) {
1762 printf("Please stop all ports first\n");
1766 if (port_id_is_invalid(res->id, ENABLED_WARN))
1769 if (parse_and_check_speed_duplex(res->value1, res->value2,
1773 ports[res->id].dev_conf.link_speeds = link_speed;
1775 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1779 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1780 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1782 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1783 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1785 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1786 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1787 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1788 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1790 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1791 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1792 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1793 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1794 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1796 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1797 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1800 cmdline_parse_inst_t cmd_config_speed_specific = {
1801 .f = cmd_config_speed_specific_parsed,
1803 .help_str = "port config <port_id> speed "
1804 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1807 (void *)&cmd_config_speed_specific_port,
1808 (void *)&cmd_config_speed_specific_keyword,
1809 (void *)&cmd_config_speed_specific_id,
1810 (void *)&cmd_config_speed_specific_item1,
1811 (void *)&cmd_config_speed_specific_value1,
1812 (void *)&cmd_config_speed_specific_item2,
1813 (void *)&cmd_config_speed_specific_value2,
1818 /* *** configure loopback for all ports *** */
1819 struct cmd_config_loopback_all {
1820 cmdline_fixed_string_t port;
1821 cmdline_fixed_string_t keyword;
1822 cmdline_fixed_string_t all;
1823 cmdline_fixed_string_t item;
1828 cmd_config_loopback_all_parsed(void *parsed_result,
1829 __rte_unused struct cmdline *cl,
1830 __rte_unused void *data)
1832 struct cmd_config_loopback_all *res = parsed_result;
1835 if (!all_ports_stopped()) {
1836 printf("Please stop all ports first\n");
1840 RTE_ETH_FOREACH_DEV(pid) {
1841 ports[pid].dev_conf.lpbk_mode = res->mode;
1844 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1847 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1848 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1849 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1850 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1852 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1853 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1854 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1855 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1857 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1858 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1860 cmdline_parse_inst_t cmd_config_loopback_all = {
1861 .f = cmd_config_loopback_all_parsed,
1863 .help_str = "port config all loopback <mode>",
1865 (void *)&cmd_config_loopback_all_port,
1866 (void *)&cmd_config_loopback_all_keyword,
1867 (void *)&cmd_config_loopback_all_all,
1868 (void *)&cmd_config_loopback_all_item,
1869 (void *)&cmd_config_loopback_all_mode,
1874 /* *** configure loopback for specific port *** */
1875 struct cmd_config_loopback_specific {
1876 cmdline_fixed_string_t port;
1877 cmdline_fixed_string_t keyword;
1879 cmdline_fixed_string_t item;
1884 cmd_config_loopback_specific_parsed(void *parsed_result,
1885 __rte_unused struct cmdline *cl,
1886 __rte_unused void *data)
1888 struct cmd_config_loopback_specific *res = parsed_result;
1890 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1893 if (!port_is_stopped(res->port_id)) {
1894 printf("Please stop port %u first\n", res->port_id);
1898 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1900 cmd_reconfig_device_queue(res->port_id, 1, 1);
1904 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1905 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1907 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1908 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1910 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1911 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1913 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1914 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1916 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1917 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1920 cmdline_parse_inst_t cmd_config_loopback_specific = {
1921 .f = cmd_config_loopback_specific_parsed,
1923 .help_str = "port config <port_id> loopback <mode>",
1925 (void *)&cmd_config_loopback_specific_port,
1926 (void *)&cmd_config_loopback_specific_keyword,
1927 (void *)&cmd_config_loopback_specific_id,
1928 (void *)&cmd_config_loopback_specific_item,
1929 (void *)&cmd_config_loopback_specific_mode,
1934 /* *** configure txq/rxq, txd/rxd *** */
1935 struct cmd_config_rx_tx {
1936 cmdline_fixed_string_t port;
1937 cmdline_fixed_string_t keyword;
1938 cmdline_fixed_string_t all;
1939 cmdline_fixed_string_t name;
1944 cmd_config_rx_tx_parsed(void *parsed_result,
1945 __rte_unused struct cmdline *cl,
1946 __rte_unused void *data)
1948 struct cmd_config_rx_tx *res = parsed_result;
1950 if (!all_ports_stopped()) {
1951 printf("Please stop all ports first\n");
1954 if (!strcmp(res->name, "rxq")) {
1955 if (!res->value && !nb_txq) {
1956 printf("Warning: Either rx or tx queues should be non zero\n");
1959 if (check_nb_rxq(res->value) != 0)
1961 nb_rxq = res->value;
1963 else if (!strcmp(res->name, "txq")) {
1964 if (!res->value && !nb_rxq) {
1965 printf("Warning: Either rx or tx queues should be non zero\n");
1968 if (check_nb_txq(res->value) != 0)
1970 nb_txq = res->value;
1972 else if (!strcmp(res->name, "rxd")) {
1973 if (check_nb_rxd(res->value) != 0)
1975 nb_rxd = res->value;
1976 } else if (!strcmp(res->name, "txd")) {
1977 if (check_nb_txd(res->value) != 0)
1980 nb_txd = res->value;
1982 printf("Unknown parameter\n");
1990 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1993 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1994 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1995 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1996 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1997 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1998 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1999 cmdline_parse_token_string_t cmd_config_rx_tx_name =
2000 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
2002 cmdline_parse_token_num_t cmd_config_rx_tx_value =
2003 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
2005 cmdline_parse_inst_t cmd_config_rx_tx = {
2006 .f = cmd_config_rx_tx_parsed,
2008 .help_str = "port config all rxq|txq|rxd|txd <value>",
2010 (void *)&cmd_config_rx_tx_port,
2011 (void *)&cmd_config_rx_tx_keyword,
2012 (void *)&cmd_config_rx_tx_all,
2013 (void *)&cmd_config_rx_tx_name,
2014 (void *)&cmd_config_rx_tx_value,
2019 /* *** config max packet length *** */
2020 struct cmd_config_max_pkt_len_result {
2021 cmdline_fixed_string_t port;
2022 cmdline_fixed_string_t keyword;
2023 cmdline_fixed_string_t all;
2024 cmdline_fixed_string_t name;
2029 cmd_config_max_pkt_len_parsed(void *parsed_result,
2030 __rte_unused struct cmdline *cl,
2031 __rte_unused void *data)
2033 struct cmd_config_max_pkt_len_result *res = parsed_result;
2036 if (!all_ports_stopped()) {
2037 printf("Please stop all ports first\n");
2041 RTE_ETH_FOREACH_DEV(pid) {
2042 struct rte_port *port = &ports[pid];
2043 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
2045 if (!strcmp(res->name, "max-pkt-len")) {
2046 if (res->value < RTE_ETHER_MIN_LEN) {
2047 printf("max-pkt-len can not be less than %d\n",
2051 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2054 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2055 if (res->value > RTE_ETHER_MAX_LEN)
2056 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2058 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2059 port->dev_conf.rxmode.offloads = rx_offloads;
2061 printf("Unknown parameter\n");
2068 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2071 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2072 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2074 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2075 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2077 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2078 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2080 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2081 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2083 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2084 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2087 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2088 .f = cmd_config_max_pkt_len_parsed,
2090 .help_str = "port config all max-pkt-len <value>",
2092 (void *)&cmd_config_max_pkt_len_port,
2093 (void *)&cmd_config_max_pkt_len_keyword,
2094 (void *)&cmd_config_max_pkt_len_all,
2095 (void *)&cmd_config_max_pkt_len_name,
2096 (void *)&cmd_config_max_pkt_len_value,
2101 /* *** config max LRO aggregated packet size *** */
2102 struct cmd_config_max_lro_pkt_size_result {
2103 cmdline_fixed_string_t port;
2104 cmdline_fixed_string_t keyword;
2105 cmdline_fixed_string_t all;
2106 cmdline_fixed_string_t name;
2111 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2112 __rte_unused struct cmdline *cl,
2113 __rte_unused void *data)
2115 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2118 if (!all_ports_stopped()) {
2119 printf("Please stop all ports first\n");
2123 RTE_ETH_FOREACH_DEV(pid) {
2124 struct rte_port *port = &ports[pid];
2126 if (!strcmp(res->name, "max-lro-pkt-size")) {
2128 port->dev_conf.rxmode.max_lro_pkt_size)
2131 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2133 printf("Unknown parameter\n");
2140 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2143 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2144 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2146 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2147 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2149 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2150 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2152 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2153 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2154 name, "max-lro-pkt-size");
2155 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2156 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2159 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2160 .f = cmd_config_max_lro_pkt_size_parsed,
2162 .help_str = "port config all max-lro-pkt-size <value>",
2164 (void *)&cmd_config_max_lro_pkt_size_port,
2165 (void *)&cmd_config_max_lro_pkt_size_keyword,
2166 (void *)&cmd_config_max_lro_pkt_size_all,
2167 (void *)&cmd_config_max_lro_pkt_size_name,
2168 (void *)&cmd_config_max_lro_pkt_size_value,
2173 /* *** configure port MTU *** */
2174 struct cmd_config_mtu_result {
2175 cmdline_fixed_string_t port;
2176 cmdline_fixed_string_t keyword;
2177 cmdline_fixed_string_t mtu;
2183 cmd_config_mtu_parsed(void *parsed_result,
2184 __rte_unused struct cmdline *cl,
2185 __rte_unused void *data)
2187 struct cmd_config_mtu_result *res = parsed_result;
2189 if (res->value < RTE_ETHER_MIN_LEN) {
2190 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2193 port_mtu_set(res->port_id, res->value);
2196 cmdline_parse_token_string_t cmd_config_mtu_port =
2197 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2199 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2200 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2202 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2203 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2205 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2206 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2207 cmdline_parse_token_num_t cmd_config_mtu_value =
2208 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2210 cmdline_parse_inst_t cmd_config_mtu = {
2211 .f = cmd_config_mtu_parsed,
2213 .help_str = "port config mtu <port_id> <value>",
2215 (void *)&cmd_config_mtu_port,
2216 (void *)&cmd_config_mtu_keyword,
2217 (void *)&cmd_config_mtu_mtu,
2218 (void *)&cmd_config_mtu_port_id,
2219 (void *)&cmd_config_mtu_value,
2224 /* *** configure rx mode *** */
2225 struct cmd_config_rx_mode_flag {
2226 cmdline_fixed_string_t port;
2227 cmdline_fixed_string_t keyword;
2228 cmdline_fixed_string_t all;
2229 cmdline_fixed_string_t name;
2230 cmdline_fixed_string_t value;
2234 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2235 __rte_unused struct cmdline *cl,
2236 __rte_unused void *data)
2238 struct cmd_config_rx_mode_flag *res = parsed_result;
2240 if (!all_ports_stopped()) {
2241 printf("Please stop all ports first\n");
2245 if (!strcmp(res->name, "drop-en")) {
2246 if (!strcmp(res->value, "on"))
2248 else if (!strcmp(res->value, "off"))
2251 printf("Unknown parameter\n");
2255 printf("Unknown parameter\n");
2261 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2264 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2265 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2266 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2267 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2269 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2270 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2271 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2272 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2274 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2275 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2278 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2279 .f = cmd_config_rx_mode_flag_parsed,
2281 .help_str = "port config all drop-en on|off",
2283 (void *)&cmd_config_rx_mode_flag_port,
2284 (void *)&cmd_config_rx_mode_flag_keyword,
2285 (void *)&cmd_config_rx_mode_flag_all,
2286 (void *)&cmd_config_rx_mode_flag_name,
2287 (void *)&cmd_config_rx_mode_flag_value,
2292 /* *** configure rss *** */
2293 struct cmd_config_rss {
2294 cmdline_fixed_string_t port;
2295 cmdline_fixed_string_t keyword;
2296 cmdline_fixed_string_t all;
2297 cmdline_fixed_string_t name;
2298 cmdline_fixed_string_t value;
2302 cmd_config_rss_parsed(void *parsed_result,
2303 __rte_unused struct cmdline *cl,
2304 __rte_unused void *data)
2306 struct cmd_config_rss *res = parsed_result;
2307 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2308 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2309 int use_default = 0;
2310 int all_updated = 1;
2315 if (!strcmp(res->value, "all"))
2316 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2317 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2318 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2319 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU;
2320 else if (!strcmp(res->value, "eth"))
2321 rss_conf.rss_hf = ETH_RSS_ETH;
2322 else if (!strcmp(res->value, "vlan"))
2323 rss_conf.rss_hf = ETH_RSS_VLAN;
2324 else if (!strcmp(res->value, "ip"))
2325 rss_conf.rss_hf = ETH_RSS_IP;
2326 else if (!strcmp(res->value, "udp"))
2327 rss_conf.rss_hf = ETH_RSS_UDP;
2328 else if (!strcmp(res->value, "tcp"))
2329 rss_conf.rss_hf = ETH_RSS_TCP;
2330 else if (!strcmp(res->value, "sctp"))
2331 rss_conf.rss_hf = ETH_RSS_SCTP;
2332 else if (!strcmp(res->value, "ether"))
2333 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2334 else if (!strcmp(res->value, "port"))
2335 rss_conf.rss_hf = ETH_RSS_PORT;
2336 else if (!strcmp(res->value, "vxlan"))
2337 rss_conf.rss_hf = ETH_RSS_VXLAN;
2338 else if (!strcmp(res->value, "geneve"))
2339 rss_conf.rss_hf = ETH_RSS_GENEVE;
2340 else if (!strcmp(res->value, "nvgre"))
2341 rss_conf.rss_hf = ETH_RSS_NVGRE;
2342 else if (!strcmp(res->value, "l3-pre32"))
2343 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2344 else if (!strcmp(res->value, "l3-pre40"))
2345 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2346 else if (!strcmp(res->value, "l3-pre48"))
2347 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2348 else if (!strcmp(res->value, "l3-pre56"))
2349 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2350 else if (!strcmp(res->value, "l3-pre64"))
2351 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2352 else if (!strcmp(res->value, "l3-pre96"))
2353 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2354 else if (!strcmp(res->value, "l3-src-only"))
2355 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2356 else if (!strcmp(res->value, "l3-dst-only"))
2357 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2358 else if (!strcmp(res->value, "l4-src-only"))
2359 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2360 else if (!strcmp(res->value, "l4-dst-only"))
2361 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2362 else if (!strcmp(res->value, "l2-src-only"))
2363 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2364 else if (!strcmp(res->value, "l2-dst-only"))
2365 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2366 else if (!strcmp(res->value, "l2tpv3"))
2367 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2368 else if (!strcmp(res->value, "esp"))
2369 rss_conf.rss_hf = ETH_RSS_ESP;
2370 else if (!strcmp(res->value, "ah"))
2371 rss_conf.rss_hf = ETH_RSS_AH;
2372 else if (!strcmp(res->value, "pfcp"))
2373 rss_conf.rss_hf = ETH_RSS_PFCP;
2374 else if (!strcmp(res->value, "pppoe"))
2375 rss_conf.rss_hf = ETH_RSS_PPPOE;
2376 else if (!strcmp(res->value, "gtpu"))
2377 rss_conf.rss_hf = ETH_RSS_GTPU;
2378 else if (!strcmp(res->value, "none"))
2379 rss_conf.rss_hf = 0;
2380 else if (!strcmp(res->value, "level-default")) {
2381 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2382 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2383 } else if (!strcmp(res->value, "level-outer")) {
2384 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2385 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2386 } else if (!strcmp(res->value, "level-inner")) {
2387 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2388 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2389 } else if (!strcmp(res->value, "default"))
2391 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2392 atoi(res->value) < 64)
2393 rss_conf.rss_hf = 1ULL << atoi(res->value);
2395 printf("Unknown parameter\n");
2398 rss_conf.rss_key = NULL;
2399 /* Update global configuration for RSS types. */
2400 RTE_ETH_FOREACH_DEV(i) {
2401 struct rte_eth_rss_conf local_rss_conf;
2403 ret = eth_dev_info_get_print_err(i, &dev_info);
2408 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2410 local_rss_conf = rss_conf;
2411 local_rss_conf.rss_hf = rss_conf.rss_hf &
2412 dev_info.flow_type_rss_offloads;
2413 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2414 printf("Port %u modified RSS hash function based on hardware support,"
2415 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2416 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2418 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2421 printf("Configuration of RSS hash at ethernet port %d "
2422 "failed with error (%d): %s.\n",
2423 i, -diag, strerror(-diag));
2426 if (all_updated && !use_default) {
2427 rss_hf = rss_conf.rss_hf;
2428 printf("rss_hf %#"PRIx64"\n", rss_hf);
2432 cmdline_parse_token_string_t cmd_config_rss_port =
2433 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2434 cmdline_parse_token_string_t cmd_config_rss_keyword =
2435 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2436 cmdline_parse_token_string_t cmd_config_rss_all =
2437 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2438 cmdline_parse_token_string_t cmd_config_rss_name =
2439 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2440 cmdline_parse_token_string_t cmd_config_rss_value =
2441 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2443 cmdline_parse_inst_t cmd_config_rss = {
2444 .f = cmd_config_rss_parsed,
2446 .help_str = "port config all rss "
2447 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2448 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|level-default|"
2449 "level-outer|level-inner|<flowtype_id>",
2451 (void *)&cmd_config_rss_port,
2452 (void *)&cmd_config_rss_keyword,
2453 (void *)&cmd_config_rss_all,
2454 (void *)&cmd_config_rss_name,
2455 (void *)&cmd_config_rss_value,
2460 /* *** configure rss hash key *** */
2461 struct cmd_config_rss_hash_key {
2462 cmdline_fixed_string_t port;
2463 cmdline_fixed_string_t config;
2465 cmdline_fixed_string_t rss_hash_key;
2466 cmdline_fixed_string_t rss_type;
2467 cmdline_fixed_string_t key;
2471 hexa_digit_to_value(char hexa_digit)
2473 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2474 return (uint8_t) (hexa_digit - '0');
2475 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2476 return (uint8_t) ((hexa_digit - 'a') + 10);
2477 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2478 return (uint8_t) ((hexa_digit - 'A') + 10);
2479 /* Invalid hexa digit */
2484 parse_and_check_key_hexa_digit(char *key, int idx)
2488 hexa_v = hexa_digit_to_value(key[idx]);
2490 printf("invalid key: character %c at position %d is not a "
2491 "valid hexa digit\n", key[idx], idx);
2496 cmd_config_rss_hash_key_parsed(void *parsed_result,
2497 __rte_unused struct cmdline *cl,
2498 __rte_unused void *data)
2500 struct cmd_config_rss_hash_key *res = parsed_result;
2501 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2505 struct rte_eth_dev_info dev_info;
2506 uint8_t hash_key_size;
2510 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2514 if (dev_info.hash_key_size > 0 &&
2515 dev_info.hash_key_size <= sizeof(hash_key))
2516 hash_key_size = dev_info.hash_key_size;
2518 printf("dev_info did not provide a valid hash key size\n");
2521 /* Check the length of the RSS hash key */
2522 key_len = strlen(res->key);
2523 if (key_len != (hash_key_size * 2)) {
2524 printf("key length: %d invalid - key must be a string of %d"
2525 " hexa-decimal numbers\n",
2526 (int) key_len, hash_key_size * 2);
2529 /* Translate RSS hash key into binary representation */
2530 for (i = 0; i < hash_key_size; i++) {
2531 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2534 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2537 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2539 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2543 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2544 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2545 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2546 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2548 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2549 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2550 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2551 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2552 rss_hash_key, "rss-hash-key");
2553 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2554 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2555 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2556 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2557 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2558 "ipv6-tcp-ex#ipv6-udp-ex#"
2559 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2560 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2561 "l2tpv3#esp#ah#pfcp#pppoe#gtpu");
2562 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2563 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2565 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2566 .f = cmd_config_rss_hash_key_parsed,
2568 .help_str = "port config <port_id> rss-hash-key "
2569 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2570 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2571 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2572 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2573 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2574 "l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2575 "<string of hex digits (variable length, NIC dependent)>",
2577 (void *)&cmd_config_rss_hash_key_port,
2578 (void *)&cmd_config_rss_hash_key_config,
2579 (void *)&cmd_config_rss_hash_key_port_id,
2580 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2581 (void *)&cmd_config_rss_hash_key_rss_type,
2582 (void *)&cmd_config_rss_hash_key_value,
2587 /* *** configure port rxq/txq ring size *** */
2588 struct cmd_config_rxtx_ring_size {
2589 cmdline_fixed_string_t port;
2590 cmdline_fixed_string_t config;
2592 cmdline_fixed_string_t rxtxq;
2594 cmdline_fixed_string_t rsize;
2599 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2600 __rte_unused struct cmdline *cl,
2601 __rte_unused void *data)
2603 struct cmd_config_rxtx_ring_size *res = parsed_result;
2604 struct rte_port *port;
2607 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2610 if (res->portid == (portid_t)RTE_PORT_ALL) {
2611 printf("Invalid port id\n");
2615 port = &ports[res->portid];
2617 if (!strcmp(res->rxtxq, "rxq"))
2619 else if (!strcmp(res->rxtxq, "txq"))
2622 printf("Unknown parameter\n");
2626 if (isrx && rx_queue_id_is_invalid(res->qid))
2628 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2631 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2632 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2638 port->nb_rx_desc[res->qid] = res->size;
2640 port->nb_tx_desc[res->qid] = res->size;
2642 cmd_reconfig_device_queue(res->portid, 0, 1);
2645 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2646 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2648 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2649 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2651 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2652 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2654 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2655 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2657 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2658 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2660 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2661 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2662 rsize, "ring_size");
2663 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2664 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2667 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2668 .f = cmd_config_rxtx_ring_size_parsed,
2670 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2672 (void *)&cmd_config_rxtx_ring_size_port,
2673 (void *)&cmd_config_rxtx_ring_size_config,
2674 (void *)&cmd_config_rxtx_ring_size_portid,
2675 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2676 (void *)&cmd_config_rxtx_ring_size_qid,
2677 (void *)&cmd_config_rxtx_ring_size_rsize,
2678 (void *)&cmd_config_rxtx_ring_size_size,
2683 /* *** configure port rxq/txq start/stop *** */
2684 struct cmd_config_rxtx_queue {
2685 cmdline_fixed_string_t port;
2687 cmdline_fixed_string_t rxtxq;
2689 cmdline_fixed_string_t opname;
2693 cmd_config_rxtx_queue_parsed(void *parsed_result,
2694 __rte_unused struct cmdline *cl,
2695 __rte_unused void *data)
2697 struct cmd_config_rxtx_queue *res = parsed_result;
2702 if (test_done == 0) {
2703 printf("Please stop forwarding first\n");
2707 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2710 if (port_is_started(res->portid) != 1) {
2711 printf("Please start port %u first\n", res->portid);
2715 if (!strcmp(res->rxtxq, "rxq"))
2717 else if (!strcmp(res->rxtxq, "txq"))
2720 printf("Unknown parameter\n");
2724 if (isrx && rx_queue_id_is_invalid(res->qid))
2726 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2729 if (!strcmp(res->opname, "start"))
2731 else if (!strcmp(res->opname, "stop"))
2734 printf("Unknown parameter\n");
2738 if (isstart && isrx)
2739 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2740 else if (!isstart && isrx)
2741 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2742 else if (isstart && !isrx)
2743 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2745 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2747 if (ret == -ENOTSUP)
2748 printf("Function not supported in PMD driver\n");
2751 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2752 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2753 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2754 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2755 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2756 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2757 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2758 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2759 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2760 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2763 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2764 .f = cmd_config_rxtx_queue_parsed,
2766 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2768 (void *)&cmd_config_rxtx_queue_port,
2769 (void *)&cmd_config_rxtx_queue_portid,
2770 (void *)&cmd_config_rxtx_queue_rxtxq,
2771 (void *)&cmd_config_rxtx_queue_qid,
2772 (void *)&cmd_config_rxtx_queue_opname,
2777 /* *** configure port rxq/txq deferred start on/off *** */
2778 struct cmd_config_deferred_start_rxtx_queue {
2779 cmdline_fixed_string_t port;
2781 cmdline_fixed_string_t rxtxq;
2783 cmdline_fixed_string_t opname;
2784 cmdline_fixed_string_t state;
2788 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2789 __rte_unused struct cmdline *cl,
2790 __rte_unused void *data)
2792 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2793 struct rte_port *port;
2796 uint8_t needreconfig = 0;
2798 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2801 if (port_is_started(res->port_id) != 0) {
2802 printf("Please stop port %u first\n", res->port_id);
2806 port = &ports[res->port_id];
2808 isrx = !strcmp(res->rxtxq, "rxq");
2810 if (isrx && rx_queue_id_is_invalid(res->qid))
2812 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2815 ison = !strcmp(res->state, "on");
2817 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2818 port->rx_conf[res->qid].rx_deferred_start = ison;
2820 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2821 port->tx_conf[res->qid].tx_deferred_start = ison;
2826 cmd_reconfig_device_queue(res->port_id, 0, 1);
2829 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2830 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2832 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2833 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2835 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2836 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2838 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2839 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2841 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2842 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2843 opname, "deferred_start");
2844 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2845 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2848 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2849 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2851 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2853 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2854 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2855 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2856 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2857 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2858 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2863 /* *** configure port rxq/txq setup *** */
2864 struct cmd_setup_rxtx_queue {
2865 cmdline_fixed_string_t port;
2867 cmdline_fixed_string_t rxtxq;
2869 cmdline_fixed_string_t setup;
2872 /* Common CLI fields for queue setup */
2873 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2874 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2875 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2876 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2877 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2878 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2879 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2880 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2881 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2882 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2885 cmd_setup_rxtx_queue_parsed(
2886 void *parsed_result,
2887 __rte_unused struct cmdline *cl,
2888 __rte_unused void *data)
2890 struct cmd_setup_rxtx_queue *res = parsed_result;
2891 struct rte_port *port;
2892 struct rte_mempool *mp;
2893 unsigned int socket_id;
2897 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2900 if (res->portid == (portid_t)RTE_PORT_ALL) {
2901 printf("Invalid port id\n");
2905 if (!strcmp(res->rxtxq, "rxq"))
2907 else if (!strcmp(res->rxtxq, "txq"))
2910 printf("Unknown parameter\n");
2914 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2915 printf("Invalid rx queue\n");
2917 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2918 printf("Invalid tx queue\n");
2922 port = &ports[res->portid];
2924 socket_id = rxring_numa[res->portid];
2925 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2926 socket_id = port->socket_id;
2928 mp = mbuf_pool_find(socket_id, 0);
2930 printf("Failed to setup RX queue: "
2931 "No mempool allocation"
2932 " on the socket %d\n",
2933 rxring_numa[res->portid]);
2936 ret = rte_eth_rx_queue_setup(res->portid,
2938 port->nb_rx_desc[res->qid],
2940 &port->rx_conf[res->qid],
2943 printf("Failed to setup RX queue\n");
2945 socket_id = txring_numa[res->portid];
2946 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2947 socket_id = port->socket_id;
2949 ret = rte_eth_tx_queue_setup(res->portid,
2951 port->nb_tx_desc[res->qid],
2953 &port->tx_conf[res->qid]);
2955 printf("Failed to setup TX queue\n");
2959 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2960 .f = cmd_setup_rxtx_queue_parsed,
2962 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2964 (void *)&cmd_setup_rxtx_queue_port,
2965 (void *)&cmd_setup_rxtx_queue_portid,
2966 (void *)&cmd_setup_rxtx_queue_rxtxq,
2967 (void *)&cmd_setup_rxtx_queue_qid,
2968 (void *)&cmd_setup_rxtx_queue_setup,
2974 /* *** Configure RSS RETA *** */
2975 struct cmd_config_rss_reta {
2976 cmdline_fixed_string_t port;
2977 cmdline_fixed_string_t keyword;
2979 cmdline_fixed_string_t name;
2980 cmdline_fixed_string_t list_name;
2981 cmdline_fixed_string_t list_of_items;
2985 parse_reta_config(const char *str,
2986 struct rte_eth_rss_reta_entry64 *reta_conf,
2987 uint16_t nb_entries)
2991 uint16_t hash_index, idx, shift;
2994 const char *p, *p0 = str;
3001 unsigned long int_fld[_NUM_FLD];
3002 char *str_fld[_NUM_FLD];
3004 while ((p = strchr(p0,'(')) != NULL) {
3006 if((p0 = strchr(p,')')) == NULL)
3010 if(size >= sizeof(s))
3013 snprintf(s, sizeof(s), "%.*s", size, p);
3014 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
3016 for (i = 0; i < _NUM_FLD; i++) {
3018 int_fld[i] = strtoul(str_fld[i], &end, 0);
3019 if (errno != 0 || end == str_fld[i] ||
3024 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
3025 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
3027 if (hash_index >= nb_entries) {
3028 printf("Invalid RETA hash index=%d\n", hash_index);
3032 idx = hash_index / RTE_RETA_GROUP_SIZE;
3033 shift = hash_index % RTE_RETA_GROUP_SIZE;
3034 reta_conf[idx].mask |= (1ULL << shift);
3035 reta_conf[idx].reta[shift] = nb_queue;
3042 cmd_set_rss_reta_parsed(void *parsed_result,
3043 __rte_unused struct cmdline *cl,
3044 __rte_unused void *data)
3047 struct rte_eth_dev_info dev_info;
3048 struct rte_eth_rss_reta_entry64 reta_conf[8];
3049 struct cmd_config_rss_reta *res = parsed_result;
3051 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3055 if (dev_info.reta_size == 0) {
3056 printf("Redirection table size is 0 which is "
3057 "invalid for RSS\n");
3060 printf("The reta size of port %d is %u\n",
3061 res->port_id, dev_info.reta_size);
3062 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3063 printf("Currently do not support more than %u entries of "
3064 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3068 memset(reta_conf, 0, sizeof(reta_conf));
3069 if (!strcmp(res->list_name, "reta")) {
3070 if (parse_reta_config(res->list_of_items, reta_conf,
3071 dev_info.reta_size)) {
3072 printf("Invalid RSS Redirection Table "
3073 "config entered\n");
3076 ret = rte_eth_dev_rss_reta_update(res->port_id,
3077 reta_conf, dev_info.reta_size);
3079 printf("Bad redirection table parameter, "
3080 "return code = %d \n", ret);
3084 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3085 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3086 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3087 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3088 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3089 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3090 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3091 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3092 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3093 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3094 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3095 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3097 cmdline_parse_inst_t cmd_config_rss_reta = {
3098 .f = cmd_set_rss_reta_parsed,
3100 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3102 (void *)&cmd_config_rss_reta_port,
3103 (void *)&cmd_config_rss_reta_keyword,
3104 (void *)&cmd_config_rss_reta_port_id,
3105 (void *)&cmd_config_rss_reta_name,
3106 (void *)&cmd_config_rss_reta_list_name,
3107 (void *)&cmd_config_rss_reta_list_of_items,
3112 /* *** SHOW PORT RETA INFO *** */
3113 struct cmd_showport_reta {
3114 cmdline_fixed_string_t show;
3115 cmdline_fixed_string_t port;
3117 cmdline_fixed_string_t rss;
3118 cmdline_fixed_string_t reta;
3120 cmdline_fixed_string_t list_of_items;
3124 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3125 uint16_t nb_entries,
3129 const char *p, *p0 = str;
3134 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3135 RTE_RETA_GROUP_SIZE;
3138 p = strchr(p0, '(');
3142 p0 = strchr(p, ')');
3146 if (size >= sizeof(s)) {
3147 printf("The string size exceeds the internal buffer size\n");
3150 snprintf(s, sizeof(s), "%.*s", size, p);
3151 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3152 if (ret <= 0 || ret != num) {
3153 printf("The bits of masks do not match the number of "
3154 "reta entries: %u\n", num);
3157 for (i = 0; i < ret; i++)
3158 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3164 cmd_showport_reta_parsed(void *parsed_result,
3165 __rte_unused struct cmdline *cl,
3166 __rte_unused void *data)
3168 struct cmd_showport_reta *res = parsed_result;
3169 struct rte_eth_rss_reta_entry64 reta_conf[8];
3170 struct rte_eth_dev_info dev_info;
3171 uint16_t max_reta_size;
3174 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3178 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3179 if (res->size == 0 || res->size > max_reta_size) {
3180 printf("Invalid redirection table size: %u (1-%u)\n",
3181 res->size, max_reta_size);
3185 memset(reta_conf, 0, sizeof(reta_conf));
3186 if (showport_parse_reta_config(reta_conf, res->size,
3187 res->list_of_items) < 0) {
3188 printf("Invalid string: %s for reta masks\n",
3189 res->list_of_items);
3192 port_rss_reta_info(res->port_id, reta_conf, res->size);
3195 cmdline_parse_token_string_t cmd_showport_reta_show =
3196 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3197 cmdline_parse_token_string_t cmd_showport_reta_port =
3198 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3199 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3200 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3201 cmdline_parse_token_string_t cmd_showport_reta_rss =
3202 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3203 cmdline_parse_token_string_t cmd_showport_reta_reta =
3204 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3205 cmdline_parse_token_num_t cmd_showport_reta_size =
3206 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3207 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3208 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3209 list_of_items, NULL);
3211 cmdline_parse_inst_t cmd_showport_reta = {
3212 .f = cmd_showport_reta_parsed,
3214 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3216 (void *)&cmd_showport_reta_show,
3217 (void *)&cmd_showport_reta_port,
3218 (void *)&cmd_showport_reta_port_id,
3219 (void *)&cmd_showport_reta_rss,
3220 (void *)&cmd_showport_reta_reta,
3221 (void *)&cmd_showport_reta_size,
3222 (void *)&cmd_showport_reta_list_of_items,
3227 /* *** Show RSS hash configuration *** */
3228 struct cmd_showport_rss_hash {
3229 cmdline_fixed_string_t show;
3230 cmdline_fixed_string_t port;
3232 cmdline_fixed_string_t rss_hash;
3233 cmdline_fixed_string_t rss_type;
3234 cmdline_fixed_string_t key; /* optional argument */
3237 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3238 __rte_unused struct cmdline *cl,
3241 struct cmd_showport_rss_hash *res = parsed_result;
3243 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3246 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3247 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3248 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3249 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3250 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3251 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3252 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3253 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3255 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3256 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3258 cmdline_parse_inst_t cmd_showport_rss_hash = {
3259 .f = cmd_showport_rss_hash_parsed,
3261 .help_str = "show port <port_id> rss-hash",
3263 (void *)&cmd_showport_rss_hash_show,
3264 (void *)&cmd_showport_rss_hash_port,
3265 (void *)&cmd_showport_rss_hash_port_id,
3266 (void *)&cmd_showport_rss_hash_rss_hash,
3271 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3272 .f = cmd_showport_rss_hash_parsed,
3274 .help_str = "show port <port_id> rss-hash key",
3276 (void *)&cmd_showport_rss_hash_show,
3277 (void *)&cmd_showport_rss_hash_port,
3278 (void *)&cmd_showport_rss_hash_port_id,
3279 (void *)&cmd_showport_rss_hash_rss_hash,
3280 (void *)&cmd_showport_rss_hash_rss_key,
3285 /* *** Configure DCB *** */
3286 struct cmd_config_dcb {
3287 cmdline_fixed_string_t port;
3288 cmdline_fixed_string_t config;
3290 cmdline_fixed_string_t dcb;
3291 cmdline_fixed_string_t vt;
3292 cmdline_fixed_string_t vt_en;
3294 cmdline_fixed_string_t pfc;
3295 cmdline_fixed_string_t pfc_en;
3299 cmd_config_dcb_parsed(void *parsed_result,
3300 __rte_unused struct cmdline *cl,
3301 __rte_unused void *data)
3303 struct cmd_config_dcb *res = parsed_result;
3304 portid_t port_id = res->port_id;
3305 struct rte_port *port;
3309 port = &ports[port_id];
3310 /** Check if the port is not started **/
3311 if (port->port_status != RTE_PORT_STOPPED) {
3312 printf("Please stop port %d first\n", port_id);
3316 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3317 printf("The invalid number of traffic class,"
3318 " only 4 or 8 allowed.\n");
3322 if (nb_fwd_lcores < res->num_tcs) {
3323 printf("nb_cores shouldn't be less than number of TCs.\n");
3326 if (!strncmp(res->pfc_en, "on", 2))
3331 /* DCB in VT mode */
3332 if (!strncmp(res->vt_en, "on", 2))
3333 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3334 (enum rte_eth_nb_tcs)res->num_tcs,
3337 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3338 (enum rte_eth_nb_tcs)res->num_tcs,
3343 printf("Cannot initialize network ports.\n");
3347 cmd_reconfig_device_queue(port_id, 1, 1);
3350 cmdline_parse_token_string_t cmd_config_dcb_port =
3351 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3352 cmdline_parse_token_string_t cmd_config_dcb_config =
3353 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3354 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3355 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3356 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3357 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3358 cmdline_parse_token_string_t cmd_config_dcb_vt =
3359 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3360 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3361 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3362 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3363 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3364 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3365 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3366 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3367 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3369 cmdline_parse_inst_t cmd_config_dcb = {
3370 .f = cmd_config_dcb_parsed,
3372 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3374 (void *)&cmd_config_dcb_port,
3375 (void *)&cmd_config_dcb_config,
3376 (void *)&cmd_config_dcb_port_id,
3377 (void *)&cmd_config_dcb_dcb,
3378 (void *)&cmd_config_dcb_vt,
3379 (void *)&cmd_config_dcb_vt_en,
3380 (void *)&cmd_config_dcb_num_tcs,
3381 (void *)&cmd_config_dcb_pfc,
3382 (void *)&cmd_config_dcb_pfc_en,
3387 /* *** configure number of packets per burst *** */
3388 struct cmd_config_burst {
3389 cmdline_fixed_string_t port;
3390 cmdline_fixed_string_t keyword;
3391 cmdline_fixed_string_t all;
3392 cmdline_fixed_string_t name;
3397 cmd_config_burst_parsed(void *parsed_result,
3398 __rte_unused struct cmdline *cl,
3399 __rte_unused void *data)
3401 struct cmd_config_burst *res = parsed_result;
3402 struct rte_eth_dev_info dev_info;
3403 uint16_t rec_nb_pkts;
3406 if (!all_ports_stopped()) {
3407 printf("Please stop all ports first\n");
3411 if (!strcmp(res->name, "burst")) {
3412 if (res->value == 0) {
3413 /* If user gives a value of zero, query the PMD for
3414 * its recommended Rx burst size. Testpmd uses a single
3415 * size for all ports, so assume all ports are the same
3416 * NIC model and use the values from Port 0.
3418 ret = eth_dev_info_get_print_err(0, &dev_info);
3422 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3424 if (rec_nb_pkts == 0) {
3425 printf("PMD does not recommend a burst size.\n"
3426 "User provided value must be between"
3427 " 1 and %d\n", MAX_PKT_BURST);
3429 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3430 printf("PMD recommended burst size of %d"
3431 " exceeds maximum value of %d\n",
3432 rec_nb_pkts, MAX_PKT_BURST);
3435 printf("Using PMD-provided burst value of %d\n",
3437 nb_pkt_per_burst = rec_nb_pkts;
3438 } else if (res->value > MAX_PKT_BURST) {
3439 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3442 nb_pkt_per_burst = res->value;
3444 printf("Unknown parameter\n");
3450 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3453 cmdline_parse_token_string_t cmd_config_burst_port =
3454 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3455 cmdline_parse_token_string_t cmd_config_burst_keyword =
3456 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3457 cmdline_parse_token_string_t cmd_config_burst_all =
3458 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3459 cmdline_parse_token_string_t cmd_config_burst_name =
3460 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3461 cmdline_parse_token_num_t cmd_config_burst_value =
3462 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3464 cmdline_parse_inst_t cmd_config_burst = {
3465 .f = cmd_config_burst_parsed,
3467 .help_str = "port config all burst <value>",
3469 (void *)&cmd_config_burst_port,
3470 (void *)&cmd_config_burst_keyword,
3471 (void *)&cmd_config_burst_all,
3472 (void *)&cmd_config_burst_name,
3473 (void *)&cmd_config_burst_value,
3478 /* *** configure rx/tx queues *** */
3479 struct cmd_config_thresh {
3480 cmdline_fixed_string_t port;
3481 cmdline_fixed_string_t keyword;
3482 cmdline_fixed_string_t all;
3483 cmdline_fixed_string_t name;
3488 cmd_config_thresh_parsed(void *parsed_result,
3489 __rte_unused struct cmdline *cl,
3490 __rte_unused void *data)
3492 struct cmd_config_thresh *res = parsed_result;
3494 if (!all_ports_stopped()) {
3495 printf("Please stop all ports first\n");
3499 if (!strcmp(res->name, "txpt"))
3500 tx_pthresh = res->value;
3501 else if(!strcmp(res->name, "txht"))
3502 tx_hthresh = res->value;
3503 else if(!strcmp(res->name, "txwt"))
3504 tx_wthresh = res->value;
3505 else if(!strcmp(res->name, "rxpt"))
3506 rx_pthresh = res->value;
3507 else if(!strcmp(res->name, "rxht"))
3508 rx_hthresh = res->value;
3509 else if(!strcmp(res->name, "rxwt"))
3510 rx_wthresh = res->value;
3512 printf("Unknown parameter\n");
3518 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3521 cmdline_parse_token_string_t cmd_config_thresh_port =
3522 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3523 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3524 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3525 cmdline_parse_token_string_t cmd_config_thresh_all =
3526 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3527 cmdline_parse_token_string_t cmd_config_thresh_name =
3528 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3529 "txpt#txht#txwt#rxpt#rxht#rxwt");
3530 cmdline_parse_token_num_t cmd_config_thresh_value =
3531 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3533 cmdline_parse_inst_t cmd_config_thresh = {
3534 .f = cmd_config_thresh_parsed,
3536 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3538 (void *)&cmd_config_thresh_port,
3539 (void *)&cmd_config_thresh_keyword,
3540 (void *)&cmd_config_thresh_all,
3541 (void *)&cmd_config_thresh_name,
3542 (void *)&cmd_config_thresh_value,
3547 /* *** configure free/rs threshold *** */
3548 struct cmd_config_threshold {
3549 cmdline_fixed_string_t port;
3550 cmdline_fixed_string_t keyword;
3551 cmdline_fixed_string_t all;
3552 cmdline_fixed_string_t name;
3557 cmd_config_threshold_parsed(void *parsed_result,
3558 __rte_unused struct cmdline *cl,
3559 __rte_unused void *data)
3561 struct cmd_config_threshold *res = parsed_result;
3563 if (!all_ports_stopped()) {
3564 printf("Please stop all ports first\n");
3568 if (!strcmp(res->name, "txfreet"))
3569 tx_free_thresh = res->value;
3570 else if (!strcmp(res->name, "txrst"))
3571 tx_rs_thresh = res->value;
3572 else if (!strcmp(res->name, "rxfreet"))
3573 rx_free_thresh = res->value;
3575 printf("Unknown parameter\n");
3581 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3584 cmdline_parse_token_string_t cmd_config_threshold_port =
3585 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3586 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3587 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3589 cmdline_parse_token_string_t cmd_config_threshold_all =
3590 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3591 cmdline_parse_token_string_t cmd_config_threshold_name =
3592 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3593 "txfreet#txrst#rxfreet");
3594 cmdline_parse_token_num_t cmd_config_threshold_value =
3595 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3597 cmdline_parse_inst_t cmd_config_threshold = {
3598 .f = cmd_config_threshold_parsed,
3600 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3602 (void *)&cmd_config_threshold_port,
3603 (void *)&cmd_config_threshold_keyword,
3604 (void *)&cmd_config_threshold_all,
3605 (void *)&cmd_config_threshold_name,
3606 (void *)&cmd_config_threshold_value,
3612 struct cmd_stop_result {
3613 cmdline_fixed_string_t stop;
3616 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3617 __rte_unused struct cmdline *cl,
3618 __rte_unused void *data)
3620 stop_packet_forwarding();
3623 cmdline_parse_token_string_t cmd_stop_stop =
3624 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3626 cmdline_parse_inst_t cmd_stop = {
3627 .f = cmd_stop_parsed,
3629 .help_str = "stop: Stop packet forwarding",
3631 (void *)&cmd_stop_stop,
3636 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3639 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3640 unsigned int *parsed_items, int check_unique_values)
3642 unsigned int nb_item;
3650 * First parse all items in the list and store their value.
3655 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3657 if ((c >= '0') && (c <= '9')) {
3658 value = (unsigned int) (value * 10 + (c - '0'));
3663 printf("character %c is not a decimal digit\n", c);
3667 printf("No valid value before comma\n");
3670 if (nb_item < max_items) {
3671 parsed_items[nb_item] = value;
3677 if (nb_item >= max_items) {
3678 printf("Number of %s = %u > %u (maximum items)\n",
3679 item_name, nb_item + 1, max_items);
3682 parsed_items[nb_item++] = value;
3683 if (! check_unique_values)
3687 * Then, check that all values in the list are differents.
3688 * No optimization here...
3690 for (i = 0; i < nb_item; i++) {
3691 for (j = i + 1; j < nb_item; j++) {
3692 if (parsed_items[j] == parsed_items[i]) {
3693 printf("duplicated %s %u at index %u and %u\n",
3694 item_name, parsed_items[i], i, j);
3702 struct cmd_set_list_result {
3703 cmdline_fixed_string_t cmd_keyword;
3704 cmdline_fixed_string_t list_name;
3705 cmdline_fixed_string_t list_of_items;
3708 static void cmd_set_list_parsed(void *parsed_result,
3709 __rte_unused struct cmdline *cl,
3710 __rte_unused void *data)
3712 struct cmd_set_list_result *res;
3714 unsigned int lcorelist[RTE_MAX_LCORE];
3715 unsigned int portlist[RTE_MAX_ETHPORTS];
3717 unsigned int nb_item;
3719 if (test_done == 0) {
3720 printf("Please stop forwarding first\n");
3724 res = parsed_result;
3725 if (!strcmp(res->list_name, "corelist")) {
3726 nb_item = parse_item_list(res->list_of_items, "core",
3728 parsed_items.lcorelist, 1);
3730 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3735 if (!strcmp(res->list_name, "portlist")) {
3736 nb_item = parse_item_list(res->list_of_items, "port",
3738 parsed_items.portlist, 1);
3740 set_fwd_ports_list(parsed_items.portlist, nb_item);
3746 cmdline_parse_token_string_t cmd_set_list_keyword =
3747 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3749 cmdline_parse_token_string_t cmd_set_list_name =
3750 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3751 "corelist#portlist");
3752 cmdline_parse_token_string_t cmd_set_list_of_items =
3753 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3756 cmdline_parse_inst_t cmd_set_fwd_list = {
3757 .f = cmd_set_list_parsed,
3759 .help_str = "set corelist|portlist <list0[,list1]*>",
3761 (void *)&cmd_set_list_keyword,
3762 (void *)&cmd_set_list_name,
3763 (void *)&cmd_set_list_of_items,
3768 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3770 struct cmd_setmask_result {
3771 cmdline_fixed_string_t set;
3772 cmdline_fixed_string_t mask;
3776 static void cmd_set_mask_parsed(void *parsed_result,
3777 __rte_unused struct cmdline *cl,
3778 __rte_unused void *data)
3780 struct cmd_setmask_result *res = parsed_result;
3782 if (test_done == 0) {
3783 printf("Please stop forwarding first\n");
3786 if (!strcmp(res->mask, "coremask")) {
3787 set_fwd_lcores_mask(res->hexavalue);
3789 } else if (!strcmp(res->mask, "portmask")) {
3790 set_fwd_ports_mask(res->hexavalue);
3795 cmdline_parse_token_string_t cmd_setmask_set =
3796 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3797 cmdline_parse_token_string_t cmd_setmask_mask =
3798 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3799 "coremask#portmask");
3800 cmdline_parse_token_num_t cmd_setmask_value =
3801 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3803 cmdline_parse_inst_t cmd_set_fwd_mask = {
3804 .f = cmd_set_mask_parsed,
3806 .help_str = "set coremask|portmask <hexadecimal value>",
3808 (void *)&cmd_setmask_set,
3809 (void *)&cmd_setmask_mask,
3810 (void *)&cmd_setmask_value,
3816 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3818 struct cmd_set_result {
3819 cmdline_fixed_string_t set;
3820 cmdline_fixed_string_t what;
3824 static void cmd_set_parsed(void *parsed_result,
3825 __rte_unused struct cmdline *cl,
3826 __rte_unused void *data)
3828 struct cmd_set_result *res = parsed_result;
3829 if (!strcmp(res->what, "nbport")) {
3830 set_fwd_ports_number(res->value);
3832 } else if (!strcmp(res->what, "nbcore")) {
3833 set_fwd_lcores_number(res->value);
3835 } else if (!strcmp(res->what, "burst"))
3836 set_nb_pkt_per_burst(res->value);
3837 else if (!strcmp(res->what, "verbose"))
3838 set_verbose_level(res->value);
3841 cmdline_parse_token_string_t cmd_set_set =
3842 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3843 cmdline_parse_token_string_t cmd_set_what =
3844 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3845 "nbport#nbcore#burst#verbose");
3846 cmdline_parse_token_num_t cmd_set_value =
3847 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3849 cmdline_parse_inst_t cmd_set_numbers = {
3850 .f = cmd_set_parsed,
3852 .help_str = "set nbport|nbcore|burst|verbose <value>",
3854 (void *)&cmd_set_set,
3855 (void *)&cmd_set_what,
3856 (void *)&cmd_set_value,
3861 /* *** SET LOG LEVEL CONFIGURATION *** */
3863 struct cmd_set_log_result {
3864 cmdline_fixed_string_t set;
3865 cmdline_fixed_string_t log;
3866 cmdline_fixed_string_t type;
3871 cmd_set_log_parsed(void *parsed_result,
3872 __rte_unused struct cmdline *cl,
3873 __rte_unused void *data)
3875 struct cmd_set_log_result *res;
3878 res = parsed_result;
3879 if (!strcmp(res->type, "global"))
3880 rte_log_set_global_level(res->level);
3882 ret = rte_log_set_level_regexp(res->type, res->level);
3884 printf("Unable to set log level\n");
3888 cmdline_parse_token_string_t cmd_set_log_set =
3889 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3890 cmdline_parse_token_string_t cmd_set_log_log =
3891 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3892 cmdline_parse_token_string_t cmd_set_log_type =
3893 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3894 cmdline_parse_token_num_t cmd_set_log_level =
3895 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3897 cmdline_parse_inst_t cmd_set_log = {
3898 .f = cmd_set_log_parsed,
3900 .help_str = "set log global|<type> <level>",
3902 (void *)&cmd_set_log_set,
3903 (void *)&cmd_set_log_log,
3904 (void *)&cmd_set_log_type,
3905 (void *)&cmd_set_log_level,
3910 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3912 struct cmd_set_txpkts_result {
3913 cmdline_fixed_string_t cmd_keyword;
3914 cmdline_fixed_string_t txpkts;
3915 cmdline_fixed_string_t seg_lengths;
3919 cmd_set_txpkts_parsed(void *parsed_result,
3920 __rte_unused struct cmdline *cl,
3921 __rte_unused void *data)
3923 struct cmd_set_txpkts_result *res;
3924 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3925 unsigned int nb_segs;
3927 res = parsed_result;
3928 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3929 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3931 set_tx_pkt_segments(seg_lengths, nb_segs);
3934 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3935 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3936 cmd_keyword, "set");
3937 cmdline_parse_token_string_t cmd_set_txpkts_name =
3938 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3940 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3941 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3944 cmdline_parse_inst_t cmd_set_txpkts = {
3945 .f = cmd_set_txpkts_parsed,
3947 .help_str = "set txpkts <len0[,len1]*>",
3949 (void *)&cmd_set_txpkts_keyword,
3950 (void *)&cmd_set_txpkts_name,
3951 (void *)&cmd_set_txpkts_lengths,
3956 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3958 struct cmd_set_txsplit_result {
3959 cmdline_fixed_string_t cmd_keyword;
3960 cmdline_fixed_string_t txsplit;
3961 cmdline_fixed_string_t mode;
3965 cmd_set_txsplit_parsed(void *parsed_result,
3966 __rte_unused struct cmdline *cl,
3967 __rte_unused void *data)
3969 struct cmd_set_txsplit_result *res;
3971 res = parsed_result;
3972 set_tx_pkt_split(res->mode);
3975 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3976 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3977 cmd_keyword, "set");
3978 cmdline_parse_token_string_t cmd_set_txsplit_name =
3979 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3980 txsplit, "txsplit");
3981 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3982 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3985 cmdline_parse_inst_t cmd_set_txsplit = {
3986 .f = cmd_set_txsplit_parsed,
3988 .help_str = "set txsplit on|off|rand",
3990 (void *)&cmd_set_txsplit_keyword,
3991 (void *)&cmd_set_txsplit_name,
3992 (void *)&cmd_set_txsplit_mode,
3997 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
3999 struct cmd_set_txtimes_result {
4000 cmdline_fixed_string_t cmd_keyword;
4001 cmdline_fixed_string_t txtimes;
4002 cmdline_fixed_string_t tx_times;
4006 cmd_set_txtimes_parsed(void *parsed_result,
4007 __rte_unused struct cmdline *cl,
4008 __rte_unused void *data)
4010 struct cmd_set_txtimes_result *res;
4011 unsigned int tx_times[2] = {0, 0};
4012 unsigned int n_times;
4014 res = parsed_result;
4015 n_times = parse_item_list(res->tx_times, "tx times",
4018 set_tx_pkt_times(tx_times);
4021 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4022 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4023 cmd_keyword, "set");
4024 cmdline_parse_token_string_t cmd_set_txtimes_name =
4025 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4026 txtimes, "txtimes");
4027 cmdline_parse_token_string_t cmd_set_txtimes_value =
4028 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4031 cmdline_parse_inst_t cmd_set_txtimes = {
4032 .f = cmd_set_txtimes_parsed,
4034 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4036 (void *)&cmd_set_txtimes_keyword,
4037 (void *)&cmd_set_txtimes_name,
4038 (void *)&cmd_set_txtimes_value,
4043 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4044 struct cmd_rx_vlan_filter_all_result {
4045 cmdline_fixed_string_t rx_vlan;
4046 cmdline_fixed_string_t what;
4047 cmdline_fixed_string_t all;
4052 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4053 __rte_unused struct cmdline *cl,
4054 __rte_unused void *data)
4056 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4058 if (!strcmp(res->what, "add"))
4059 rx_vlan_all_filter_set(res->port_id, 1);
4061 rx_vlan_all_filter_set(res->port_id, 0);
4064 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4065 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4066 rx_vlan, "rx_vlan");
4067 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4068 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4070 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4071 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4073 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4074 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4077 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4078 .f = cmd_rx_vlan_filter_all_parsed,
4080 .help_str = "rx_vlan add|rm all <port_id>: "
4081 "Add/Remove all identifiers to/from the set of VLAN "
4082 "identifiers filtered by a port",
4084 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4085 (void *)&cmd_rx_vlan_filter_all_what,
4086 (void *)&cmd_rx_vlan_filter_all_all,
4087 (void *)&cmd_rx_vlan_filter_all_portid,
4092 /* *** VLAN OFFLOAD SET ON A PORT *** */
4093 struct cmd_vlan_offload_result {
4094 cmdline_fixed_string_t vlan;
4095 cmdline_fixed_string_t set;
4096 cmdline_fixed_string_t vlan_type;
4097 cmdline_fixed_string_t what;
4098 cmdline_fixed_string_t on;
4099 cmdline_fixed_string_t port_id;
4103 cmd_vlan_offload_parsed(void *parsed_result,
4104 __rte_unused struct cmdline *cl,
4105 __rte_unused void *data)
4108 struct cmd_vlan_offload_result *res = parsed_result;
4111 portid_t port_id = 0;
4115 len = strnlen(str, STR_TOKEN_SIZE);
4117 /* Get port_id first */
4125 tmp = strtoul(str, NULL, 0);
4126 /* If port_id greater that what portid_t can represent, return */
4127 if(tmp >= RTE_MAX_ETHPORTS)
4129 port_id = (portid_t)tmp;
4131 if (!strcmp(res->on, "on"))
4136 if (!strcmp(res->what, "strip"))
4137 rx_vlan_strip_set(port_id, on);
4138 else if(!strcmp(res->what, "stripq")){
4139 uint16_t queue_id = 0;
4141 /* No queue_id, return */
4143 printf("must specify (port,queue_id)\n");
4146 tmp = strtoul(str + i + 1, NULL, 0);
4147 /* If queue_id greater that what 16-bits can represent, return */
4151 queue_id = (uint16_t)tmp;
4152 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4154 else if (!strcmp(res->what, "filter"))
4155 rx_vlan_filter_set(port_id, on);
4156 else if (!strcmp(res->what, "qinq_strip"))
4157 rx_vlan_qinq_strip_set(port_id, on);
4159 vlan_extend_set(port_id, on);
4164 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4165 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4167 cmdline_parse_token_string_t cmd_vlan_offload_set =
4168 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4170 cmdline_parse_token_string_t cmd_vlan_offload_what =
4171 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4172 what, "strip#filter#qinq_strip#extend#stripq");
4173 cmdline_parse_token_string_t cmd_vlan_offload_on =
4174 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4176 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4177 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4180 cmdline_parse_inst_t cmd_vlan_offload = {
4181 .f = cmd_vlan_offload_parsed,
4183 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4184 "<port_id[,queue_id]>: "
4185 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4187 (void *)&cmd_vlan_offload_vlan,
4188 (void *)&cmd_vlan_offload_set,
4189 (void *)&cmd_vlan_offload_what,
4190 (void *)&cmd_vlan_offload_on,
4191 (void *)&cmd_vlan_offload_portid,
4196 /* *** VLAN TPID SET ON A PORT *** */
4197 struct cmd_vlan_tpid_result {
4198 cmdline_fixed_string_t vlan;
4199 cmdline_fixed_string_t set;
4200 cmdline_fixed_string_t vlan_type;
4201 cmdline_fixed_string_t what;
4207 cmd_vlan_tpid_parsed(void *parsed_result,
4208 __rte_unused struct cmdline *cl,
4209 __rte_unused void *data)
4211 struct cmd_vlan_tpid_result *res = parsed_result;
4212 enum rte_vlan_type vlan_type;
4214 if (!strcmp(res->vlan_type, "inner"))
4215 vlan_type = ETH_VLAN_TYPE_INNER;
4216 else if (!strcmp(res->vlan_type, "outer"))
4217 vlan_type = ETH_VLAN_TYPE_OUTER;
4219 printf("Unknown vlan type\n");
4222 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4225 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4226 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4228 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4229 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4231 cmdline_parse_token_string_t cmd_vlan_type =
4232 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4233 vlan_type, "inner#outer");
4234 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4235 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4237 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4238 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4240 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4241 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4244 cmdline_parse_inst_t cmd_vlan_tpid = {
4245 .f = cmd_vlan_tpid_parsed,
4247 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4248 "Set the VLAN Ether type",
4250 (void *)&cmd_vlan_tpid_vlan,
4251 (void *)&cmd_vlan_tpid_set,
4252 (void *)&cmd_vlan_type,
4253 (void *)&cmd_vlan_tpid_what,
4254 (void *)&cmd_vlan_tpid_tpid,
4255 (void *)&cmd_vlan_tpid_portid,
4260 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4261 struct cmd_rx_vlan_filter_result {
4262 cmdline_fixed_string_t rx_vlan;
4263 cmdline_fixed_string_t what;
4269 cmd_rx_vlan_filter_parsed(void *parsed_result,
4270 __rte_unused struct cmdline *cl,
4271 __rte_unused void *data)
4273 struct cmd_rx_vlan_filter_result *res = parsed_result;
4275 if (!strcmp(res->what, "add"))
4276 rx_vft_set(res->port_id, res->vlan_id, 1);
4278 rx_vft_set(res->port_id, res->vlan_id, 0);
4281 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4282 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4283 rx_vlan, "rx_vlan");
4284 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4285 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4287 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4288 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4290 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4291 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4294 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4295 .f = cmd_rx_vlan_filter_parsed,
4297 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4298 "Add/Remove a VLAN identifier to/from the set of VLAN "
4299 "identifiers filtered by a port",
4301 (void *)&cmd_rx_vlan_filter_rx_vlan,
4302 (void *)&cmd_rx_vlan_filter_what,
4303 (void *)&cmd_rx_vlan_filter_vlanid,
4304 (void *)&cmd_rx_vlan_filter_portid,
4309 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4310 struct cmd_tx_vlan_set_result {
4311 cmdline_fixed_string_t tx_vlan;
4312 cmdline_fixed_string_t set;
4318 cmd_tx_vlan_set_parsed(void *parsed_result,
4319 __rte_unused struct cmdline *cl,
4320 __rte_unused void *data)
4322 struct cmd_tx_vlan_set_result *res = parsed_result;
4324 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4327 if (!port_is_stopped(res->port_id)) {
4328 printf("Please stop port %d first\n", res->port_id);
4332 tx_vlan_set(res->port_id, res->vlan_id);
4334 cmd_reconfig_device_queue(res->port_id, 1, 1);
4337 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4338 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4339 tx_vlan, "tx_vlan");
4340 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4341 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4343 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4344 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4346 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4347 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4350 cmdline_parse_inst_t cmd_tx_vlan_set = {
4351 .f = cmd_tx_vlan_set_parsed,
4353 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4354 "Enable hardware insertion of a single VLAN header "
4355 "with a given TAG Identifier in packets sent on a port",
4357 (void *)&cmd_tx_vlan_set_tx_vlan,
4358 (void *)&cmd_tx_vlan_set_set,
4359 (void *)&cmd_tx_vlan_set_portid,
4360 (void *)&cmd_tx_vlan_set_vlanid,
4365 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4366 struct cmd_tx_vlan_set_qinq_result {
4367 cmdline_fixed_string_t tx_vlan;
4368 cmdline_fixed_string_t set;
4371 uint16_t vlan_id_outer;
4375 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4376 __rte_unused struct cmdline *cl,
4377 __rte_unused void *data)
4379 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4381 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4384 if (!port_is_stopped(res->port_id)) {
4385 printf("Please stop port %d first\n", res->port_id);
4389 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4391 cmd_reconfig_device_queue(res->port_id, 1, 1);
4394 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4395 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4396 tx_vlan, "tx_vlan");
4397 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4398 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4400 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4401 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4403 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4404 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4406 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4407 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4408 vlan_id_outer, UINT16);
4410 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4411 .f = cmd_tx_vlan_set_qinq_parsed,
4413 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4414 "Enable hardware insertion of double VLAN header "
4415 "with given TAG Identifiers in packets sent on a port",
4417 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4418 (void *)&cmd_tx_vlan_set_qinq_set,
4419 (void *)&cmd_tx_vlan_set_qinq_portid,
4420 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4421 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4426 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4427 struct cmd_tx_vlan_set_pvid_result {
4428 cmdline_fixed_string_t tx_vlan;
4429 cmdline_fixed_string_t set;
4430 cmdline_fixed_string_t pvid;
4433 cmdline_fixed_string_t mode;
4437 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4438 __rte_unused struct cmdline *cl,
4439 __rte_unused void *data)
4441 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4443 if (strcmp(res->mode, "on") == 0)
4444 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4446 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4449 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4450 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4451 tx_vlan, "tx_vlan");
4452 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4453 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4455 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4456 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4458 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4459 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4461 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4462 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4464 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4465 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4468 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4469 .f = cmd_tx_vlan_set_pvid_parsed,
4471 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4473 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4474 (void *)&cmd_tx_vlan_set_pvid_set,
4475 (void *)&cmd_tx_vlan_set_pvid_pvid,
4476 (void *)&cmd_tx_vlan_set_pvid_port_id,
4477 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4478 (void *)&cmd_tx_vlan_set_pvid_mode,
4483 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4484 struct cmd_tx_vlan_reset_result {
4485 cmdline_fixed_string_t tx_vlan;
4486 cmdline_fixed_string_t reset;
4491 cmd_tx_vlan_reset_parsed(void *parsed_result,
4492 __rte_unused struct cmdline *cl,
4493 __rte_unused void *data)
4495 struct cmd_tx_vlan_reset_result *res = parsed_result;
4497 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4500 if (!port_is_stopped(res->port_id)) {
4501 printf("Please stop port %d first\n", res->port_id);
4505 tx_vlan_reset(res->port_id);
4507 cmd_reconfig_device_queue(res->port_id, 1, 1);
4510 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4511 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4512 tx_vlan, "tx_vlan");
4513 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4514 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4516 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4517 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4520 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4521 .f = cmd_tx_vlan_reset_parsed,
4523 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4524 "VLAN header in packets sent on a port",
4526 (void *)&cmd_tx_vlan_reset_tx_vlan,
4527 (void *)&cmd_tx_vlan_reset_reset,
4528 (void *)&cmd_tx_vlan_reset_portid,
4534 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4535 struct cmd_csum_result {
4536 cmdline_fixed_string_t csum;
4537 cmdline_fixed_string_t mode;
4538 cmdline_fixed_string_t proto;
4539 cmdline_fixed_string_t hwsw;
4544 csum_show(int port_id)
4546 struct rte_eth_dev_info dev_info;
4547 uint64_t tx_offloads;
4550 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4551 printf("Parse tunnel is %s\n",
4552 (ports[port_id].parse_tunnel) ? "on" : "off");
4553 printf("IP checksum offload is %s\n",
4554 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4555 printf("UDP checksum offload is %s\n",
4556 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4557 printf("TCP checksum offload is %s\n",
4558 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4559 printf("SCTP checksum offload is %s\n",
4560 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4561 printf("Outer-Ip checksum offload is %s\n",
4562 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4563 printf("Outer-Udp checksum offload is %s\n",
4564 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4566 /* display warnings if configuration is not supported by the NIC */
4567 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4571 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4572 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4573 printf("Warning: hardware IP checksum enabled but not "
4574 "supported by port %d\n", port_id);
4576 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4577 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4578 printf("Warning: hardware UDP checksum enabled but not "
4579 "supported by port %d\n", port_id);
4581 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4582 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4583 printf("Warning: hardware TCP checksum enabled but not "
4584 "supported by port %d\n", port_id);
4586 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4587 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4588 printf("Warning: hardware SCTP checksum enabled but not "
4589 "supported by port %d\n", port_id);
4591 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4592 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4593 printf("Warning: hardware outer IP checksum enabled but not "
4594 "supported by port %d\n", port_id);
4596 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4597 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4599 printf("Warning: hardware outer UDP checksum enabled but not "
4600 "supported by port %d\n", port_id);
4605 cmd_config_queue_tx_offloads(struct rte_port *port)
4609 /* Apply queue tx offloads configuration */
4610 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4611 port->tx_conf[k].offloads =
4612 port->dev_conf.txmode.offloads;
4616 cmd_csum_parsed(void *parsed_result,
4617 __rte_unused struct cmdline *cl,
4618 __rte_unused void *data)
4620 struct cmd_csum_result *res = parsed_result;
4622 uint64_t csum_offloads = 0;
4623 struct rte_eth_dev_info dev_info;
4626 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4627 printf("invalid port %d\n", res->port_id);
4630 if (!port_is_stopped(res->port_id)) {
4631 printf("Please stop port %d first\n", res->port_id);
4635 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4639 if (!strcmp(res->mode, "set")) {
4641 if (!strcmp(res->hwsw, "hw"))
4644 if (!strcmp(res->proto, "ip")) {
4645 if (hw == 0 || (dev_info.tx_offload_capa &
4646 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4647 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4649 printf("IP checksum offload is not supported "
4650 "by port %u\n", res->port_id);
4652 } else if (!strcmp(res->proto, "udp")) {
4653 if (hw == 0 || (dev_info.tx_offload_capa &
4654 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4655 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4657 printf("UDP checksum offload is not supported "
4658 "by port %u\n", res->port_id);
4660 } else if (!strcmp(res->proto, "tcp")) {
4661 if (hw == 0 || (dev_info.tx_offload_capa &
4662 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4663 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4665 printf("TCP checksum offload is not supported "
4666 "by port %u\n", res->port_id);
4668 } else if (!strcmp(res->proto, "sctp")) {
4669 if (hw == 0 || (dev_info.tx_offload_capa &
4670 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4671 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4673 printf("SCTP checksum offload is not supported "
4674 "by port %u\n", res->port_id);
4676 } else if (!strcmp(res->proto, "outer-ip")) {
4677 if (hw == 0 || (dev_info.tx_offload_capa &
4678 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4680 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4682 printf("Outer IP checksum offload is not "
4683 "supported by port %u\n", res->port_id);
4685 } else if (!strcmp(res->proto, "outer-udp")) {
4686 if (hw == 0 || (dev_info.tx_offload_capa &
4687 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4689 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4691 printf("Outer UDP checksum offload is not "
4692 "supported by port %u\n", res->port_id);
4697 ports[res->port_id].dev_conf.txmode.offloads |=
4700 ports[res->port_id].dev_conf.txmode.offloads &=
4703 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4705 csum_show(res->port_id);
4707 cmd_reconfig_device_queue(res->port_id, 1, 1);
4710 cmdline_parse_token_string_t cmd_csum_csum =
4711 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4713 cmdline_parse_token_string_t cmd_csum_mode =
4714 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4716 cmdline_parse_token_string_t cmd_csum_proto =
4717 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4718 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4719 cmdline_parse_token_string_t cmd_csum_hwsw =
4720 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4722 cmdline_parse_token_num_t cmd_csum_portid =
4723 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4726 cmdline_parse_inst_t cmd_csum_set = {
4727 .f = cmd_csum_parsed,
4729 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4730 "Enable/Disable hardware calculation of L3/L4 checksum when "
4731 "using csum forward engine",
4733 (void *)&cmd_csum_csum,
4734 (void *)&cmd_csum_mode,
4735 (void *)&cmd_csum_proto,
4736 (void *)&cmd_csum_hwsw,
4737 (void *)&cmd_csum_portid,
4742 cmdline_parse_token_string_t cmd_csum_mode_show =
4743 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4746 cmdline_parse_inst_t cmd_csum_show = {
4747 .f = cmd_csum_parsed,
4749 .help_str = "csum show <port_id>: Show checksum offload configuration",
4751 (void *)&cmd_csum_csum,
4752 (void *)&cmd_csum_mode_show,
4753 (void *)&cmd_csum_portid,
4758 /* Enable/disable tunnel parsing */
4759 struct cmd_csum_tunnel_result {
4760 cmdline_fixed_string_t csum;
4761 cmdline_fixed_string_t parse;
4762 cmdline_fixed_string_t onoff;
4767 cmd_csum_tunnel_parsed(void *parsed_result,
4768 __rte_unused struct cmdline *cl,
4769 __rte_unused void *data)
4771 struct cmd_csum_tunnel_result *res = parsed_result;
4773 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4776 if (!strcmp(res->onoff, "on"))
4777 ports[res->port_id].parse_tunnel = 1;
4779 ports[res->port_id].parse_tunnel = 0;
4781 csum_show(res->port_id);
4784 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4785 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4787 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4788 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4789 parse, "parse-tunnel");
4790 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4791 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4793 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4794 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4797 cmdline_parse_inst_t cmd_csum_tunnel = {
4798 .f = cmd_csum_tunnel_parsed,
4800 .help_str = "csum parse-tunnel on|off <port_id>: "
4801 "Enable/Disable parsing of tunnels for csum engine",
4803 (void *)&cmd_csum_tunnel_csum,
4804 (void *)&cmd_csum_tunnel_parse,
4805 (void *)&cmd_csum_tunnel_onoff,
4806 (void *)&cmd_csum_tunnel_portid,
4811 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4812 struct cmd_tso_set_result {
4813 cmdline_fixed_string_t tso;
4814 cmdline_fixed_string_t mode;
4820 cmd_tso_set_parsed(void *parsed_result,
4821 __rte_unused struct cmdline *cl,
4822 __rte_unused void *data)
4824 struct cmd_tso_set_result *res = parsed_result;
4825 struct rte_eth_dev_info dev_info;
4828 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4830 if (!port_is_stopped(res->port_id)) {
4831 printf("Please stop port %d first\n", res->port_id);
4835 if (!strcmp(res->mode, "set"))
4836 ports[res->port_id].tso_segsz = res->tso_segsz;
4838 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4842 if ((ports[res->port_id].tso_segsz != 0) &&
4843 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4844 printf("Error: TSO is not supported by port %d\n",
4849 if (ports[res->port_id].tso_segsz == 0) {
4850 ports[res->port_id].dev_conf.txmode.offloads &=
4851 ~DEV_TX_OFFLOAD_TCP_TSO;
4852 printf("TSO for non-tunneled packets is disabled\n");
4854 ports[res->port_id].dev_conf.txmode.offloads |=
4855 DEV_TX_OFFLOAD_TCP_TSO;
4856 printf("TSO segment size for non-tunneled packets is %d\n",
4857 ports[res->port_id].tso_segsz);
4859 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4861 /* display warnings if configuration is not supported by the NIC */
4862 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4866 if ((ports[res->port_id].tso_segsz != 0) &&
4867 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4868 printf("Warning: TSO enabled but not "
4869 "supported by port %d\n", res->port_id);
4872 cmd_reconfig_device_queue(res->port_id, 1, 1);
4875 cmdline_parse_token_string_t cmd_tso_set_tso =
4876 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4878 cmdline_parse_token_string_t cmd_tso_set_mode =
4879 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4881 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4882 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4884 cmdline_parse_token_num_t cmd_tso_set_portid =
4885 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4888 cmdline_parse_inst_t cmd_tso_set = {
4889 .f = cmd_tso_set_parsed,
4891 .help_str = "tso set <tso_segsz> <port_id>: "
4892 "Set TSO segment size of non-tunneled packets for csum engine "
4895 (void *)&cmd_tso_set_tso,
4896 (void *)&cmd_tso_set_mode,
4897 (void *)&cmd_tso_set_tso_segsz,
4898 (void *)&cmd_tso_set_portid,
4903 cmdline_parse_token_string_t cmd_tso_show_mode =
4904 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4908 cmdline_parse_inst_t cmd_tso_show = {
4909 .f = cmd_tso_set_parsed,
4911 .help_str = "tso show <port_id>: "
4912 "Show TSO segment size of non-tunneled packets for csum engine",
4914 (void *)&cmd_tso_set_tso,
4915 (void *)&cmd_tso_show_mode,
4916 (void *)&cmd_tso_set_portid,
4921 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4922 struct cmd_tunnel_tso_set_result {
4923 cmdline_fixed_string_t tso;
4924 cmdline_fixed_string_t mode;
4929 static struct rte_eth_dev_info
4930 check_tunnel_tso_nic_support(portid_t port_id)
4932 struct rte_eth_dev_info dev_info;
4934 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4937 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4938 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4939 "not enabled for port %d\n", port_id);
4940 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4941 printf("Warning: GRE TUNNEL TSO not supported therefore "
4942 "not enabled for port %d\n", port_id);
4943 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4944 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4945 "not enabled for port %d\n", port_id);
4946 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4947 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4948 "not enabled for port %d\n", port_id);
4949 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4950 printf("Warning: IP TUNNEL TSO not supported therefore "
4951 "not enabled for port %d\n", port_id);
4952 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4953 printf("Warning: UDP TUNNEL TSO not supported therefore "
4954 "not enabled for port %d\n", port_id);
4959 cmd_tunnel_tso_set_parsed(void *parsed_result,
4960 __rte_unused struct cmdline *cl,
4961 __rte_unused void *data)
4963 struct cmd_tunnel_tso_set_result *res = parsed_result;
4964 struct rte_eth_dev_info dev_info;
4966 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4968 if (!port_is_stopped(res->port_id)) {
4969 printf("Please stop port %d first\n", res->port_id);
4973 if (!strcmp(res->mode, "set"))
4974 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4976 dev_info = check_tunnel_tso_nic_support(res->port_id);
4977 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4978 ports[res->port_id].dev_conf.txmode.offloads &=
4979 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4980 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4981 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4982 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4983 DEV_TX_OFFLOAD_IP_TNL_TSO |
4984 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4985 printf("TSO for tunneled packets is disabled\n");
4987 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4988 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4989 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4990 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4991 DEV_TX_OFFLOAD_IP_TNL_TSO |
4992 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4994 ports[res->port_id].dev_conf.txmode.offloads |=
4995 (tso_offloads & dev_info.tx_offload_capa);
4996 printf("TSO segment size for tunneled packets is %d\n",
4997 ports[res->port_id].tunnel_tso_segsz);
4999 /* Below conditions are needed to make it work:
5000 * (1) tunnel TSO is supported by the NIC;
5001 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5003 * (3) for tunneled pkts with outer L3 of IPv4,
5004 * "csum set outer-ip" must be set to hw, because after tso,
5005 * total_len of outer IP header is changed, and the checksum
5006 * of outer IP header calculated by sw should be wrong; that
5007 * is not necessary for IPv6 tunneled pkts because there's no
5008 * checksum in IP header anymore.
5011 if (!ports[res->port_id].parse_tunnel)
5012 printf("Warning: csum parse_tunnel must be set "
5013 "so that tunneled packets are recognized\n");
5014 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5015 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5016 printf("Warning: csum set outer-ip must be set to hw "
5017 "if outer L3 is IPv4; not necessary for IPv6\n");
5020 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5021 cmd_reconfig_device_queue(res->port_id, 1, 1);
5024 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5025 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5027 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5028 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5030 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5031 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5033 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5034 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5037 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5038 .f = cmd_tunnel_tso_set_parsed,
5040 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5041 "Set TSO segment size of tunneled packets for csum engine "
5044 (void *)&cmd_tunnel_tso_set_tso,
5045 (void *)&cmd_tunnel_tso_set_mode,
5046 (void *)&cmd_tunnel_tso_set_tso_segsz,
5047 (void *)&cmd_tunnel_tso_set_portid,
5052 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5053 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5057 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5058 .f = cmd_tunnel_tso_set_parsed,
5060 .help_str = "tunnel_tso show <port_id> "
5061 "Show TSO segment size of tunneled packets for csum engine",
5063 (void *)&cmd_tunnel_tso_set_tso,
5064 (void *)&cmd_tunnel_tso_show_mode,
5065 (void *)&cmd_tunnel_tso_set_portid,
5070 /* *** SET GRO FOR A PORT *** */
5071 struct cmd_gro_enable_result {
5072 cmdline_fixed_string_t cmd_set;
5073 cmdline_fixed_string_t cmd_port;
5074 cmdline_fixed_string_t cmd_keyword;
5075 cmdline_fixed_string_t cmd_onoff;
5080 cmd_gro_enable_parsed(void *parsed_result,
5081 __rte_unused struct cmdline *cl,
5082 __rte_unused void *data)
5084 struct cmd_gro_enable_result *res;
5086 res = parsed_result;
5087 if (!strcmp(res->cmd_keyword, "gro"))
5088 setup_gro(res->cmd_onoff, res->cmd_pid);
5091 cmdline_parse_token_string_t cmd_gro_enable_set =
5092 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5094 cmdline_parse_token_string_t cmd_gro_enable_port =
5095 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5096 cmd_keyword, "port");
5097 cmdline_parse_token_num_t cmd_gro_enable_pid =
5098 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5100 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5101 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5102 cmd_keyword, "gro");
5103 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5104 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5105 cmd_onoff, "on#off");
5107 cmdline_parse_inst_t cmd_gro_enable = {
5108 .f = cmd_gro_enable_parsed,
5110 .help_str = "set port <port_id> gro on|off",
5112 (void *)&cmd_gro_enable_set,
5113 (void *)&cmd_gro_enable_port,
5114 (void *)&cmd_gro_enable_pid,
5115 (void *)&cmd_gro_enable_keyword,
5116 (void *)&cmd_gro_enable_onoff,
5121 /* *** DISPLAY GRO CONFIGURATION *** */
5122 struct cmd_gro_show_result {
5123 cmdline_fixed_string_t cmd_show;
5124 cmdline_fixed_string_t cmd_port;
5125 cmdline_fixed_string_t cmd_keyword;
5130 cmd_gro_show_parsed(void *parsed_result,
5131 __rte_unused struct cmdline *cl,
5132 __rte_unused void *data)
5134 struct cmd_gro_show_result *res;
5136 res = parsed_result;
5137 if (!strcmp(res->cmd_keyword, "gro"))
5138 show_gro(res->cmd_pid);
5141 cmdline_parse_token_string_t cmd_gro_show_show =
5142 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5144 cmdline_parse_token_string_t cmd_gro_show_port =
5145 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5147 cmdline_parse_token_num_t cmd_gro_show_pid =
5148 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5150 cmdline_parse_token_string_t cmd_gro_show_keyword =
5151 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5152 cmd_keyword, "gro");
5154 cmdline_parse_inst_t cmd_gro_show = {
5155 .f = cmd_gro_show_parsed,
5157 .help_str = "show port <port_id> gro",
5159 (void *)&cmd_gro_show_show,
5160 (void *)&cmd_gro_show_port,
5161 (void *)&cmd_gro_show_pid,
5162 (void *)&cmd_gro_show_keyword,
5167 /* *** SET FLUSH CYCLES FOR GRO *** */
5168 struct cmd_gro_flush_result {
5169 cmdline_fixed_string_t cmd_set;
5170 cmdline_fixed_string_t cmd_keyword;
5171 cmdline_fixed_string_t cmd_flush;
5176 cmd_gro_flush_parsed(void *parsed_result,
5177 __rte_unused struct cmdline *cl,
5178 __rte_unused void *data)
5180 struct cmd_gro_flush_result *res;
5182 res = parsed_result;
5183 if ((!strcmp(res->cmd_keyword, "gro")) &&
5184 (!strcmp(res->cmd_flush, "flush")))
5185 setup_gro_flush_cycles(res->cmd_cycles);
5188 cmdline_parse_token_string_t cmd_gro_flush_set =
5189 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5191 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5192 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5193 cmd_keyword, "gro");
5194 cmdline_parse_token_string_t cmd_gro_flush_flush =
5195 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5196 cmd_flush, "flush");
5197 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5198 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5201 cmdline_parse_inst_t cmd_gro_flush = {
5202 .f = cmd_gro_flush_parsed,
5204 .help_str = "set gro flush <cycles>",
5206 (void *)&cmd_gro_flush_set,
5207 (void *)&cmd_gro_flush_keyword,
5208 (void *)&cmd_gro_flush_flush,
5209 (void *)&cmd_gro_flush_cycles,
5214 /* *** ENABLE/DISABLE GSO *** */
5215 struct cmd_gso_enable_result {
5216 cmdline_fixed_string_t cmd_set;
5217 cmdline_fixed_string_t cmd_port;
5218 cmdline_fixed_string_t cmd_keyword;
5219 cmdline_fixed_string_t cmd_mode;
5224 cmd_gso_enable_parsed(void *parsed_result,
5225 __rte_unused struct cmdline *cl,
5226 __rte_unused void *data)
5228 struct cmd_gso_enable_result *res;
5230 res = parsed_result;
5231 if (!strcmp(res->cmd_keyword, "gso"))
5232 setup_gso(res->cmd_mode, res->cmd_pid);
5235 cmdline_parse_token_string_t cmd_gso_enable_set =
5236 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5238 cmdline_parse_token_string_t cmd_gso_enable_port =
5239 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5241 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5242 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5243 cmd_keyword, "gso");
5244 cmdline_parse_token_string_t cmd_gso_enable_mode =
5245 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5246 cmd_mode, "on#off");
5247 cmdline_parse_token_num_t cmd_gso_enable_pid =
5248 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5251 cmdline_parse_inst_t cmd_gso_enable = {
5252 .f = cmd_gso_enable_parsed,
5254 .help_str = "set port <port_id> gso on|off",
5256 (void *)&cmd_gso_enable_set,
5257 (void *)&cmd_gso_enable_port,
5258 (void *)&cmd_gso_enable_pid,
5259 (void *)&cmd_gso_enable_keyword,
5260 (void *)&cmd_gso_enable_mode,
5265 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5266 struct cmd_gso_size_result {
5267 cmdline_fixed_string_t cmd_set;
5268 cmdline_fixed_string_t cmd_keyword;
5269 cmdline_fixed_string_t cmd_segsz;
5274 cmd_gso_size_parsed(void *parsed_result,
5275 __rte_unused struct cmdline *cl,
5276 __rte_unused void *data)
5278 struct cmd_gso_size_result *res = parsed_result;
5280 if (test_done == 0) {
5281 printf("Before setting GSO segsz, please first"
5282 " stop forwarding\n");
5286 if (!strcmp(res->cmd_keyword, "gso") &&
5287 !strcmp(res->cmd_segsz, "segsz")) {
5288 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5289 printf("gso_size should be larger than %zu."
5290 " Please input a legal value\n",
5291 RTE_GSO_SEG_SIZE_MIN);
5293 gso_max_segment_size = res->cmd_size;
5297 cmdline_parse_token_string_t cmd_gso_size_set =
5298 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5300 cmdline_parse_token_string_t cmd_gso_size_keyword =
5301 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5302 cmd_keyword, "gso");
5303 cmdline_parse_token_string_t cmd_gso_size_segsz =
5304 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5305 cmd_segsz, "segsz");
5306 cmdline_parse_token_num_t cmd_gso_size_size =
5307 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5310 cmdline_parse_inst_t cmd_gso_size = {
5311 .f = cmd_gso_size_parsed,
5313 .help_str = "set gso segsz <length>",
5315 (void *)&cmd_gso_size_set,
5316 (void *)&cmd_gso_size_keyword,
5317 (void *)&cmd_gso_size_segsz,
5318 (void *)&cmd_gso_size_size,
5323 /* *** SHOW GSO CONFIGURATION *** */
5324 struct cmd_gso_show_result {
5325 cmdline_fixed_string_t cmd_show;
5326 cmdline_fixed_string_t cmd_port;
5327 cmdline_fixed_string_t cmd_keyword;
5332 cmd_gso_show_parsed(void *parsed_result,
5333 __rte_unused struct cmdline *cl,
5334 __rte_unused void *data)
5336 struct cmd_gso_show_result *res = parsed_result;
5338 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5339 printf("invalid port id %u\n", res->cmd_pid);
5342 if (!strcmp(res->cmd_keyword, "gso")) {
5343 if (gso_ports[res->cmd_pid].enable) {
5344 printf("Max GSO'd packet size: %uB\n"
5345 "Supported GSO types: TCP/IPv4, "
5346 "UDP/IPv4, VxLAN with inner "
5347 "TCP/IPv4 packet, GRE with inner "
5348 "TCP/IPv4 packet\n",
5349 gso_max_segment_size);
5351 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5355 cmdline_parse_token_string_t cmd_gso_show_show =
5356 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5358 cmdline_parse_token_string_t cmd_gso_show_port =
5359 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5361 cmdline_parse_token_string_t cmd_gso_show_keyword =
5362 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5363 cmd_keyword, "gso");
5364 cmdline_parse_token_num_t cmd_gso_show_pid =
5365 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5368 cmdline_parse_inst_t cmd_gso_show = {
5369 .f = cmd_gso_show_parsed,
5371 .help_str = "show port <port_id> gso",
5373 (void *)&cmd_gso_show_show,
5374 (void *)&cmd_gso_show_port,
5375 (void *)&cmd_gso_show_pid,
5376 (void *)&cmd_gso_show_keyword,
5381 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5382 struct cmd_set_flush_rx {
5383 cmdline_fixed_string_t set;
5384 cmdline_fixed_string_t flush_rx;
5385 cmdline_fixed_string_t mode;
5389 cmd_set_flush_rx_parsed(void *parsed_result,
5390 __rte_unused struct cmdline *cl,
5391 __rte_unused void *data)
5393 struct cmd_set_flush_rx *res = parsed_result;
5394 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5397 cmdline_parse_token_string_t cmd_setflushrx_set =
5398 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5400 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5401 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5402 flush_rx, "flush_rx");
5403 cmdline_parse_token_string_t cmd_setflushrx_mode =
5404 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5408 cmdline_parse_inst_t cmd_set_flush_rx = {
5409 .f = cmd_set_flush_rx_parsed,
5410 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5413 (void *)&cmd_setflushrx_set,
5414 (void *)&cmd_setflushrx_flush_rx,
5415 (void *)&cmd_setflushrx_mode,
5420 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5421 struct cmd_set_link_check {
5422 cmdline_fixed_string_t set;
5423 cmdline_fixed_string_t link_check;
5424 cmdline_fixed_string_t mode;
5428 cmd_set_link_check_parsed(void *parsed_result,
5429 __rte_unused struct cmdline *cl,
5430 __rte_unused void *data)
5432 struct cmd_set_link_check *res = parsed_result;
5433 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5436 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5437 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5439 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5440 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5441 link_check, "link_check");
5442 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5443 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5447 cmdline_parse_inst_t cmd_set_link_check = {
5448 .f = cmd_set_link_check_parsed,
5449 .help_str = "set link_check on|off: Enable/Disable link status check "
5450 "when starting/stopping a port",
5453 (void *)&cmd_setlinkcheck_set,
5454 (void *)&cmd_setlinkcheck_link_check,
5455 (void *)&cmd_setlinkcheck_mode,
5460 /* *** SET NIC BYPASS MODE *** */
5461 struct cmd_set_bypass_mode_result {
5462 cmdline_fixed_string_t set;
5463 cmdline_fixed_string_t bypass;
5464 cmdline_fixed_string_t mode;
5465 cmdline_fixed_string_t value;
5470 cmd_set_bypass_mode_parsed(void *parsed_result,
5471 __rte_unused struct cmdline *cl,
5472 __rte_unused void *data)
5474 struct cmd_set_bypass_mode_result *res = parsed_result;
5475 portid_t port_id = res->port_id;
5476 int32_t rc = -EINVAL;
5478 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5479 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5481 if (!strcmp(res->value, "bypass"))
5482 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5483 else if (!strcmp(res->value, "isolate"))
5484 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5486 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5488 /* Set the bypass mode for the relevant port. */
5489 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5492 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5495 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5496 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5498 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5499 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5501 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5502 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5504 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5505 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5506 value, "normal#bypass#isolate");
5507 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5508 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5511 cmdline_parse_inst_t cmd_set_bypass_mode = {
5512 .f = cmd_set_bypass_mode_parsed,
5513 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5514 "Set the NIC bypass mode for port_id",
5517 (void *)&cmd_setbypass_mode_set,
5518 (void *)&cmd_setbypass_mode_bypass,
5519 (void *)&cmd_setbypass_mode_mode,
5520 (void *)&cmd_setbypass_mode_value,
5521 (void *)&cmd_setbypass_mode_port,
5526 /* *** SET NIC BYPASS EVENT *** */
5527 struct cmd_set_bypass_event_result {
5528 cmdline_fixed_string_t set;
5529 cmdline_fixed_string_t bypass;
5530 cmdline_fixed_string_t event;
5531 cmdline_fixed_string_t event_value;
5532 cmdline_fixed_string_t mode;
5533 cmdline_fixed_string_t mode_value;
5538 cmd_set_bypass_event_parsed(void *parsed_result,
5539 __rte_unused struct cmdline *cl,
5540 __rte_unused void *data)
5542 int32_t rc = -EINVAL;
5543 struct cmd_set_bypass_event_result *res = parsed_result;
5544 portid_t port_id = res->port_id;
5546 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5547 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5548 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5550 if (!strcmp(res->event_value, "timeout"))
5551 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5552 else if (!strcmp(res->event_value, "os_on"))
5553 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5554 else if (!strcmp(res->event_value, "os_off"))
5555 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5556 else if (!strcmp(res->event_value, "power_on"))
5557 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5558 else if (!strcmp(res->event_value, "power_off"))
5559 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5561 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5563 if (!strcmp(res->mode_value, "bypass"))
5564 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5565 else if (!strcmp(res->mode_value, "isolate"))
5566 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5568 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5570 /* Set the watchdog timeout. */
5571 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5574 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5575 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5579 printf("Failed to set timeout value %u "
5580 "for port %d, errto code: %d.\n",
5581 bypass_timeout, port_id, rc);
5585 /* Set the bypass event to transition to bypass mode. */
5586 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5591 printf("\t Failed to set bypass event for port = %d.\n",
5595 cmdline_parse_token_string_t cmd_setbypass_event_set =
5596 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5598 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5599 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5601 cmdline_parse_token_string_t cmd_setbypass_event_event =
5602 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5604 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5605 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5606 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5607 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5608 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5610 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5611 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5612 mode_value, "normal#bypass#isolate");
5613 cmdline_parse_token_num_t cmd_setbypass_event_port =
5614 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5617 cmdline_parse_inst_t cmd_set_bypass_event = {
5618 .f = cmd_set_bypass_event_parsed,
5619 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5620 "power_off mode normal|bypass|isolate <port_id>: "
5621 "Set the NIC bypass event mode for port_id",
5624 (void *)&cmd_setbypass_event_set,
5625 (void *)&cmd_setbypass_event_bypass,
5626 (void *)&cmd_setbypass_event_event,
5627 (void *)&cmd_setbypass_event_event_value,
5628 (void *)&cmd_setbypass_event_mode,
5629 (void *)&cmd_setbypass_event_mode_value,
5630 (void *)&cmd_setbypass_event_port,
5636 /* *** SET NIC BYPASS TIMEOUT *** */
5637 struct cmd_set_bypass_timeout_result {
5638 cmdline_fixed_string_t set;
5639 cmdline_fixed_string_t bypass;
5640 cmdline_fixed_string_t timeout;
5641 cmdline_fixed_string_t value;
5645 cmd_set_bypass_timeout_parsed(void *parsed_result,
5646 __rte_unused struct cmdline *cl,
5647 __rte_unused void *data)
5649 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5651 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5652 if (!strcmp(res->value, "1.5"))
5653 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5654 else if (!strcmp(res->value, "2"))
5655 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5656 else if (!strcmp(res->value, "3"))
5657 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5658 else if (!strcmp(res->value, "4"))
5659 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5660 else if (!strcmp(res->value, "8"))
5661 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5662 else if (!strcmp(res->value, "16"))
5663 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5664 else if (!strcmp(res->value, "32"))
5665 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5667 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5671 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5672 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5674 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5675 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5677 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5678 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5679 timeout, "timeout");
5680 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5681 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5682 value, "0#1.5#2#3#4#8#16#32");
5684 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5685 .f = cmd_set_bypass_timeout_parsed,
5686 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5687 "Set the NIC bypass watchdog timeout in seconds",
5690 (void *)&cmd_setbypass_timeout_set,
5691 (void *)&cmd_setbypass_timeout_bypass,
5692 (void *)&cmd_setbypass_timeout_timeout,
5693 (void *)&cmd_setbypass_timeout_value,
5698 /* *** SHOW NIC BYPASS MODE *** */
5699 struct cmd_show_bypass_config_result {
5700 cmdline_fixed_string_t show;
5701 cmdline_fixed_string_t bypass;
5702 cmdline_fixed_string_t config;
5707 cmd_show_bypass_config_parsed(void *parsed_result,
5708 __rte_unused struct cmdline *cl,
5709 __rte_unused void *data)
5711 struct cmd_show_bypass_config_result *res = parsed_result;
5712 portid_t port_id = res->port_id;
5714 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5715 uint32_t event_mode;
5716 uint32_t bypass_mode;
5717 uint32_t timeout = bypass_timeout;
5720 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5721 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5722 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5723 {"UNKNOWN", "normal", "bypass", "isolate"};
5724 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5732 /* Display the bypass mode.*/
5733 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5734 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5738 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5739 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5741 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5744 /* Display the bypass timeout.*/
5745 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5746 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5748 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5750 /* Display the bypass events and associated modes. */
5751 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5753 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5754 printf("\tFailed to get bypass mode for event = %s\n",
5757 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5758 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5760 printf("\tbypass event: %-16s = %s\n", events[i],
5766 printf("\tFailed to get bypass configuration for port = %d\n",
5770 cmdline_parse_token_string_t cmd_showbypass_config_show =
5771 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5773 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5774 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5776 cmdline_parse_token_string_t cmd_showbypass_config_config =
5777 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5779 cmdline_parse_token_num_t cmd_showbypass_config_port =
5780 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5783 cmdline_parse_inst_t cmd_show_bypass_config = {
5784 .f = cmd_show_bypass_config_parsed,
5785 .help_str = "show bypass config <port_id>: "
5786 "Show the NIC bypass config for port_id",
5789 (void *)&cmd_showbypass_config_show,
5790 (void *)&cmd_showbypass_config_bypass,
5791 (void *)&cmd_showbypass_config_config,
5792 (void *)&cmd_showbypass_config_port,
5797 #ifdef RTE_LIBRTE_PMD_BOND
5798 /* *** SET BONDING MODE *** */
5799 struct cmd_set_bonding_mode_result {
5800 cmdline_fixed_string_t set;
5801 cmdline_fixed_string_t bonding;
5802 cmdline_fixed_string_t mode;
5807 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5808 __rte_unused struct cmdline *cl,
5809 __rte_unused void *data)
5811 struct cmd_set_bonding_mode_result *res = parsed_result;
5812 portid_t port_id = res->port_id;
5814 /* Set the bonding mode for the relevant port. */
5815 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5816 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5819 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5820 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5822 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5823 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5824 bonding, "bonding");
5825 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5826 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5828 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5829 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5831 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5832 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5835 cmdline_parse_inst_t cmd_set_bonding_mode = {
5836 .f = cmd_set_bonding_mode_parsed,
5837 .help_str = "set bonding mode <mode_value> <port_id>: "
5838 "Set the bonding mode for port_id",
5841 (void *) &cmd_setbonding_mode_set,
5842 (void *) &cmd_setbonding_mode_bonding,
5843 (void *) &cmd_setbonding_mode_mode,
5844 (void *) &cmd_setbonding_mode_value,
5845 (void *) &cmd_setbonding_mode_port,
5850 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5851 struct cmd_set_bonding_lacp_dedicated_queues_result {
5852 cmdline_fixed_string_t set;
5853 cmdline_fixed_string_t bonding;
5854 cmdline_fixed_string_t lacp;
5855 cmdline_fixed_string_t dedicated_queues;
5857 cmdline_fixed_string_t mode;
5860 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5861 __rte_unused struct cmdline *cl,
5862 __rte_unused void *data)
5864 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5865 portid_t port_id = res->port_id;
5866 struct rte_port *port;
5868 port = &ports[port_id];
5870 /** Check if the port is not started **/
5871 if (port->port_status != RTE_PORT_STOPPED) {
5872 printf("Please stop port %d first\n", port_id);
5876 if (!strcmp(res->mode, "enable")) {
5877 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5878 printf("Dedicate queues for LACP control packets"
5881 printf("Enabling dedicate queues for LACP control "
5882 "packets on port %d failed\n", port_id);
5883 } else if (!strcmp(res->mode, "disable")) {
5884 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5885 printf("Dedicated queues for LACP control packets "
5888 printf("Disabling dedicated queues for LACP control "
5889 "traffic on port %d failed\n", port_id);
5893 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5894 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5896 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5897 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5898 bonding, "bonding");
5899 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5900 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5902 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5903 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5904 dedicated_queues, "dedicated_queues");
5905 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5906 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5908 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5909 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5910 mode, "enable#disable");
5912 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5913 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5914 .help_str = "set bonding lacp dedicated_queues <port_id> "
5916 "Enable/disable dedicated queues for LACP control traffic for port_id",
5919 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5920 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5921 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5922 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5923 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5924 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5929 /* *** SET BALANCE XMIT POLICY *** */
5930 struct cmd_set_bonding_balance_xmit_policy_result {
5931 cmdline_fixed_string_t set;
5932 cmdline_fixed_string_t bonding;
5933 cmdline_fixed_string_t balance_xmit_policy;
5935 cmdline_fixed_string_t policy;
5938 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5939 __rte_unused struct cmdline *cl,
5940 __rte_unused void *data)
5942 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5943 portid_t port_id = res->port_id;
5946 if (!strcmp(res->policy, "l2")) {
5947 policy = BALANCE_XMIT_POLICY_LAYER2;
5948 } else if (!strcmp(res->policy, "l23")) {
5949 policy = BALANCE_XMIT_POLICY_LAYER23;
5950 } else if (!strcmp(res->policy, "l34")) {
5951 policy = BALANCE_XMIT_POLICY_LAYER34;
5953 printf("\t Invalid xmit policy selection");
5957 /* Set the bonding mode for the relevant port. */
5958 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5959 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5964 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5965 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5967 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5968 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5969 bonding, "bonding");
5970 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5971 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5972 balance_xmit_policy, "balance_xmit_policy");
5973 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5974 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5976 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5977 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5978 policy, "l2#l23#l34");
5980 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5981 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5982 .help_str = "set bonding balance_xmit_policy <port_id> "
5984 "Set the bonding balance_xmit_policy for port_id",
5987 (void *)&cmd_setbonding_balance_xmit_policy_set,
5988 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5989 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5990 (void *)&cmd_setbonding_balance_xmit_policy_port,
5991 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5996 /* *** SHOW NIC BONDING CONFIGURATION *** */
5997 struct cmd_show_bonding_config_result {
5998 cmdline_fixed_string_t show;
5999 cmdline_fixed_string_t bonding;
6000 cmdline_fixed_string_t config;
6004 static void cmd_show_bonding_config_parsed(void *parsed_result,
6005 __rte_unused struct cmdline *cl,
6006 __rte_unused void *data)
6008 struct cmd_show_bonding_config_result *res = parsed_result;
6009 int bonding_mode, agg_mode;
6010 portid_t slaves[RTE_MAX_ETHPORTS];
6011 int num_slaves, num_active_slaves;
6014 portid_t port_id = res->port_id;
6016 /* Display the bonding mode.*/
6017 bonding_mode = rte_eth_bond_mode_get(port_id);
6018 if (bonding_mode < 0) {
6019 printf("\tFailed to get bonding mode for port = %d\n", port_id);
6022 printf("\tBonding mode: %d\n", bonding_mode);
6024 if (bonding_mode == BONDING_MODE_BALANCE) {
6025 int balance_xmit_policy;
6027 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6028 if (balance_xmit_policy < 0) {
6029 printf("\tFailed to get balance xmit policy for port = %d\n",
6033 printf("\tBalance Xmit Policy: ");
6035 switch (balance_xmit_policy) {
6036 case BALANCE_XMIT_POLICY_LAYER2:
6037 printf("BALANCE_XMIT_POLICY_LAYER2");
6039 case BALANCE_XMIT_POLICY_LAYER23:
6040 printf("BALANCE_XMIT_POLICY_LAYER23");
6042 case BALANCE_XMIT_POLICY_LAYER34:
6043 printf("BALANCE_XMIT_POLICY_LAYER34");
6050 if (bonding_mode == BONDING_MODE_8023AD) {
6051 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6052 printf("\tIEEE802.3AD Aggregator Mode: ");
6055 printf("bandwidth");
6067 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6069 if (num_slaves < 0) {
6070 printf("\tFailed to get slave list for port = %d\n", port_id);
6073 if (num_slaves > 0) {
6074 printf("\tSlaves (%d): [", num_slaves);
6075 for (i = 0; i < num_slaves - 1; i++)
6076 printf("%d ", slaves[i]);
6078 printf("%d]\n", slaves[num_slaves - 1]);
6080 printf("\tSlaves: []\n");
6084 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6087 if (num_active_slaves < 0) {
6088 printf("\tFailed to get active slave list for port = %d\n", port_id);
6091 if (num_active_slaves > 0) {
6092 printf("\tActive Slaves (%d): [", num_active_slaves);
6093 for (i = 0; i < num_active_slaves - 1; i++)
6094 printf("%d ", slaves[i]);
6096 printf("%d]\n", slaves[num_active_slaves - 1]);
6099 printf("\tActive Slaves: []\n");
6103 primary_id = rte_eth_bond_primary_get(port_id);
6104 if (primary_id < 0) {
6105 printf("\tFailed to get primary slave for port = %d\n", port_id);
6108 printf("\tPrimary: [%d]\n", primary_id);
6112 cmdline_parse_token_string_t cmd_showbonding_config_show =
6113 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6115 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6116 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6117 bonding, "bonding");
6118 cmdline_parse_token_string_t cmd_showbonding_config_config =
6119 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6121 cmdline_parse_token_num_t cmd_showbonding_config_port =
6122 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6125 cmdline_parse_inst_t cmd_show_bonding_config = {
6126 .f = cmd_show_bonding_config_parsed,
6127 .help_str = "show bonding config <port_id>: "
6128 "Show the bonding config for port_id",
6131 (void *)&cmd_showbonding_config_show,
6132 (void *)&cmd_showbonding_config_bonding,
6133 (void *)&cmd_showbonding_config_config,
6134 (void *)&cmd_showbonding_config_port,
6139 /* *** SET BONDING PRIMARY *** */
6140 struct cmd_set_bonding_primary_result {
6141 cmdline_fixed_string_t set;
6142 cmdline_fixed_string_t bonding;
6143 cmdline_fixed_string_t primary;
6148 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6149 __rte_unused struct cmdline *cl,
6150 __rte_unused void *data)
6152 struct cmd_set_bonding_primary_result *res = parsed_result;
6153 portid_t master_port_id = res->port_id;
6154 portid_t slave_port_id = res->slave_id;
6156 /* Set the primary slave for a bonded device. */
6157 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6158 printf("\t Failed to set primary slave for port = %d.\n",
6165 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6166 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6168 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6169 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6170 bonding, "bonding");
6171 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6172 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6173 primary, "primary");
6174 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6175 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6177 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6178 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6181 cmdline_parse_inst_t cmd_set_bonding_primary = {
6182 .f = cmd_set_bonding_primary_parsed,
6183 .help_str = "set bonding primary <slave_id> <port_id>: "
6184 "Set the primary slave for port_id",
6187 (void *)&cmd_setbonding_primary_set,
6188 (void *)&cmd_setbonding_primary_bonding,
6189 (void *)&cmd_setbonding_primary_primary,
6190 (void *)&cmd_setbonding_primary_slave,
6191 (void *)&cmd_setbonding_primary_port,
6196 /* *** ADD SLAVE *** */
6197 struct cmd_add_bonding_slave_result {
6198 cmdline_fixed_string_t add;
6199 cmdline_fixed_string_t bonding;
6200 cmdline_fixed_string_t slave;
6205 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6206 __rte_unused struct cmdline *cl,
6207 __rte_unused void *data)
6209 struct cmd_add_bonding_slave_result *res = parsed_result;
6210 portid_t master_port_id = res->port_id;
6211 portid_t slave_port_id = res->slave_id;
6213 /* add the slave for a bonded device. */
6214 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6215 printf("\t Failed to add slave %d to master port = %d.\n",
6216 slave_port_id, master_port_id);
6220 set_port_slave_flag(slave_port_id);
6223 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6224 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6226 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6227 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6228 bonding, "bonding");
6229 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6230 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6232 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6233 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6235 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6236 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6239 cmdline_parse_inst_t cmd_add_bonding_slave = {
6240 .f = cmd_add_bonding_slave_parsed,
6241 .help_str = "add bonding slave <slave_id> <port_id>: "
6242 "Add a slave device to a bonded device",
6245 (void *)&cmd_addbonding_slave_add,
6246 (void *)&cmd_addbonding_slave_bonding,
6247 (void *)&cmd_addbonding_slave_slave,
6248 (void *)&cmd_addbonding_slave_slaveid,
6249 (void *)&cmd_addbonding_slave_port,
6254 /* *** REMOVE SLAVE *** */
6255 struct cmd_remove_bonding_slave_result {
6256 cmdline_fixed_string_t remove;
6257 cmdline_fixed_string_t bonding;
6258 cmdline_fixed_string_t slave;
6263 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6264 __rte_unused struct cmdline *cl,
6265 __rte_unused void *data)
6267 struct cmd_remove_bonding_slave_result *res = parsed_result;
6268 portid_t master_port_id = res->port_id;
6269 portid_t slave_port_id = res->slave_id;
6271 /* remove the slave from a bonded device. */
6272 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6273 printf("\t Failed to remove slave %d from master port = %d.\n",
6274 slave_port_id, master_port_id);
6278 clear_port_slave_flag(slave_port_id);
6281 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6282 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6284 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6285 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6286 bonding, "bonding");
6287 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6288 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6290 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6291 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6293 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6294 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6297 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6298 .f = cmd_remove_bonding_slave_parsed,
6299 .help_str = "remove bonding slave <slave_id> <port_id>: "
6300 "Remove a slave device from a bonded device",
6303 (void *)&cmd_removebonding_slave_remove,
6304 (void *)&cmd_removebonding_slave_bonding,
6305 (void *)&cmd_removebonding_slave_slave,
6306 (void *)&cmd_removebonding_slave_slaveid,
6307 (void *)&cmd_removebonding_slave_port,
6312 /* *** CREATE BONDED DEVICE *** */
6313 struct cmd_create_bonded_device_result {
6314 cmdline_fixed_string_t create;
6315 cmdline_fixed_string_t bonded;
6316 cmdline_fixed_string_t device;
6321 static int bond_dev_num = 0;
6323 static void cmd_create_bonded_device_parsed(void *parsed_result,
6324 __rte_unused struct cmdline *cl,
6325 __rte_unused void *data)
6327 struct cmd_create_bonded_device_result *res = parsed_result;
6328 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6332 if (test_done == 0) {
6333 printf("Please stop forwarding first\n");
6337 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6340 /* Create a new bonded device. */
6341 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6343 printf("\t Failed to create bonded device.\n");
6346 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6349 /* Update number of ports */
6350 nb_ports = rte_eth_dev_count_avail();
6351 reconfig(port_id, res->socket);
6352 ret = rte_eth_promiscuous_enable(port_id);
6354 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6355 port_id, rte_strerror(-ret));
6357 ports[port_id].need_setup = 0;
6358 ports[port_id].port_status = RTE_PORT_STOPPED;
6363 cmdline_parse_token_string_t cmd_createbonded_device_create =
6364 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6366 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6367 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6369 cmdline_parse_token_string_t cmd_createbonded_device_device =
6370 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6372 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6373 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6375 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6376 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6379 cmdline_parse_inst_t cmd_create_bonded_device = {
6380 .f = cmd_create_bonded_device_parsed,
6381 .help_str = "create bonded device <mode> <socket>: "
6382 "Create a new bonded device with specific bonding mode and socket",
6385 (void *)&cmd_createbonded_device_create,
6386 (void *)&cmd_createbonded_device_bonded,
6387 (void *)&cmd_createbonded_device_device,
6388 (void *)&cmd_createbonded_device_mode,
6389 (void *)&cmd_createbonded_device_socket,
6394 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6395 struct cmd_set_bond_mac_addr_result {
6396 cmdline_fixed_string_t set;
6397 cmdline_fixed_string_t bonding;
6398 cmdline_fixed_string_t mac_addr;
6400 struct rte_ether_addr address;
6403 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6404 __rte_unused struct cmdline *cl,
6405 __rte_unused void *data)
6407 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6410 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6413 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6415 /* check the return value and print it if is < 0 */
6417 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6420 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6421 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6422 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6423 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6425 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6426 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6428 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6429 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6431 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6432 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6434 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6435 .f = cmd_set_bond_mac_addr_parsed,
6437 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6439 (void *)&cmd_set_bond_mac_addr_set,
6440 (void *)&cmd_set_bond_mac_addr_bonding,
6441 (void *)&cmd_set_bond_mac_addr_mac,
6442 (void *)&cmd_set_bond_mac_addr_portnum,
6443 (void *)&cmd_set_bond_mac_addr_addr,
6449 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6450 struct cmd_set_bond_mon_period_result {
6451 cmdline_fixed_string_t set;
6452 cmdline_fixed_string_t bonding;
6453 cmdline_fixed_string_t mon_period;
6458 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6459 __rte_unused struct cmdline *cl,
6460 __rte_unused void *data)
6462 struct cmd_set_bond_mon_period_result *res = parsed_result;
6465 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6467 /* check the return value and print it if is < 0 */
6469 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6472 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6473 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6475 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6476 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6477 bonding, "bonding");
6478 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6479 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6480 mon_period, "mon_period");
6481 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6482 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6484 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6485 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6488 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6489 .f = cmd_set_bond_mon_period_parsed,
6491 .help_str = "set bonding mon_period <port_id> <period_ms>",
6493 (void *)&cmd_set_bond_mon_period_set,
6494 (void *)&cmd_set_bond_mon_period_bonding,
6495 (void *)&cmd_set_bond_mon_period_mon_period,
6496 (void *)&cmd_set_bond_mon_period_portnum,
6497 (void *)&cmd_set_bond_mon_period_period_ms,
6504 struct cmd_set_bonding_agg_mode_policy_result {
6505 cmdline_fixed_string_t set;
6506 cmdline_fixed_string_t bonding;
6507 cmdline_fixed_string_t agg_mode;
6509 cmdline_fixed_string_t policy;
6514 cmd_set_bonding_agg_mode(void *parsed_result,
6515 __rte_unused struct cmdline *cl,
6516 __rte_unused void *data)
6518 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6519 uint8_t policy = AGG_BANDWIDTH;
6521 if (!strcmp(res->policy, "bandwidth"))
6522 policy = AGG_BANDWIDTH;
6523 else if (!strcmp(res->policy, "stable"))
6524 policy = AGG_STABLE;
6525 else if (!strcmp(res->policy, "count"))
6528 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6532 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6533 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6535 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6536 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6537 bonding, "bonding");
6539 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6540 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6541 agg_mode, "agg_mode");
6543 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6544 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6547 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6548 TOKEN_STRING_INITIALIZER(
6549 struct cmd_set_bonding_balance_xmit_policy_result,
6550 policy, "stable#bandwidth#count");
6552 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6553 .f = cmd_set_bonding_agg_mode,
6555 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6557 (void *)&cmd_set_bonding_agg_mode_set,
6558 (void *)&cmd_set_bonding_agg_mode_bonding,
6559 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6560 (void *)&cmd_set_bonding_agg_mode_portnum,
6561 (void *)&cmd_set_bonding_agg_mode_policy_string,
6567 #endif /* RTE_LIBRTE_PMD_BOND */
6569 /* *** SET FORWARDING MODE *** */
6570 struct cmd_set_fwd_mode_result {
6571 cmdline_fixed_string_t set;
6572 cmdline_fixed_string_t fwd;
6573 cmdline_fixed_string_t mode;
6576 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6577 __rte_unused struct cmdline *cl,
6578 __rte_unused void *data)
6580 struct cmd_set_fwd_mode_result *res = parsed_result;
6583 set_pkt_forwarding_mode(res->mode);
6586 cmdline_parse_token_string_t cmd_setfwd_set =
6587 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6588 cmdline_parse_token_string_t cmd_setfwd_fwd =
6589 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6590 cmdline_parse_token_string_t cmd_setfwd_mode =
6591 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6592 "" /* defined at init */);
6594 cmdline_parse_inst_t cmd_set_fwd_mode = {
6595 .f = cmd_set_fwd_mode_parsed,
6597 .help_str = NULL, /* defined at init */
6599 (void *)&cmd_setfwd_set,
6600 (void *)&cmd_setfwd_fwd,
6601 (void *)&cmd_setfwd_mode,
6606 static void cmd_set_fwd_mode_init(void)
6609 static char token[128];
6610 static char help[256];
6611 cmdline_parse_token_string_t *token_struct;
6613 modes = list_pkt_forwarding_modes();
6614 snprintf(help, sizeof(help), "set fwd %s: "
6615 "Set packet forwarding mode", modes);
6616 cmd_set_fwd_mode.help_str = help;
6618 /* string token separator is # */
6619 for (c = token; *modes != '\0'; modes++)
6624 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6625 token_struct->string_data.str = token;
6628 /* *** SET RETRY FORWARDING MODE *** */
6629 struct cmd_set_fwd_retry_mode_result {
6630 cmdline_fixed_string_t set;
6631 cmdline_fixed_string_t fwd;
6632 cmdline_fixed_string_t mode;
6633 cmdline_fixed_string_t retry;
6636 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6637 __rte_unused struct cmdline *cl,
6638 __rte_unused void *data)
6640 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6643 set_pkt_forwarding_mode(res->mode);
6646 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6647 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6649 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6650 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6652 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6653 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6655 "" /* defined at init */);
6656 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6657 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6660 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6661 .f = cmd_set_fwd_retry_mode_parsed,
6663 .help_str = NULL, /* defined at init */
6665 (void *)&cmd_setfwd_retry_set,
6666 (void *)&cmd_setfwd_retry_fwd,
6667 (void *)&cmd_setfwd_retry_mode,
6668 (void *)&cmd_setfwd_retry_retry,
6673 static void cmd_set_fwd_retry_mode_init(void)
6676 static char token[128];
6677 static char help[256];
6678 cmdline_parse_token_string_t *token_struct;
6680 modes = list_pkt_forwarding_retry_modes();
6681 snprintf(help, sizeof(help), "set fwd %s retry: "
6682 "Set packet forwarding mode with retry", modes);
6683 cmd_set_fwd_retry_mode.help_str = help;
6685 /* string token separator is # */
6686 for (c = token; *modes != '\0'; modes++)
6691 token_struct = (cmdline_parse_token_string_t *)
6692 cmd_set_fwd_retry_mode.tokens[2];
6693 token_struct->string_data.str = token;
6696 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6697 struct cmd_set_burst_tx_retry_result {
6698 cmdline_fixed_string_t set;
6699 cmdline_fixed_string_t burst;
6700 cmdline_fixed_string_t tx;
6701 cmdline_fixed_string_t delay;
6703 cmdline_fixed_string_t retry;
6707 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6708 __rte_unused struct cmdline *cl,
6709 __rte_unused void *data)
6711 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6713 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6714 && !strcmp(res->tx, "tx")) {
6715 if (!strcmp(res->delay, "delay"))
6716 burst_tx_delay_time = res->time;
6717 if (!strcmp(res->retry, "retry"))
6718 burst_tx_retry_num = res->retry_num;
6723 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6724 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6725 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6726 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6728 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6729 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6730 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6731 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6732 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6733 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6734 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6735 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6736 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6737 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6739 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6740 .f = cmd_set_burst_tx_retry_parsed,
6741 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6743 (void *)&cmd_set_burst_tx_retry_set,
6744 (void *)&cmd_set_burst_tx_retry_burst,
6745 (void *)&cmd_set_burst_tx_retry_tx,
6746 (void *)&cmd_set_burst_tx_retry_delay,
6747 (void *)&cmd_set_burst_tx_retry_time,
6748 (void *)&cmd_set_burst_tx_retry_retry,
6749 (void *)&cmd_set_burst_tx_retry_retry_num,
6754 /* *** SET PROMISC MODE *** */
6755 struct cmd_set_promisc_mode_result {
6756 cmdline_fixed_string_t set;
6757 cmdline_fixed_string_t promisc;
6758 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6759 uint16_t port_num; /* valid if "allports" argument == 0 */
6760 cmdline_fixed_string_t mode;
6763 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6764 __rte_unused struct cmdline *cl,
6767 struct cmd_set_promisc_mode_result *res = parsed_result;
6771 if (!strcmp(res->mode, "on"))
6778 RTE_ETH_FOREACH_DEV(i)
6779 eth_set_promisc_mode(i, enable);
6781 eth_set_promisc_mode(res->port_num, enable);
6785 cmdline_parse_token_string_t cmd_setpromisc_set =
6786 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6787 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6788 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6790 cmdline_parse_token_string_t cmd_setpromisc_portall =
6791 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6793 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6794 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6796 cmdline_parse_token_string_t cmd_setpromisc_mode =
6797 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6800 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6801 .f = cmd_set_promisc_mode_parsed,
6803 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6805 (void *)&cmd_setpromisc_set,
6806 (void *)&cmd_setpromisc_promisc,
6807 (void *)&cmd_setpromisc_portall,
6808 (void *)&cmd_setpromisc_mode,
6813 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6814 .f = cmd_set_promisc_mode_parsed,
6816 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6818 (void *)&cmd_setpromisc_set,
6819 (void *)&cmd_setpromisc_promisc,
6820 (void *)&cmd_setpromisc_portnum,
6821 (void *)&cmd_setpromisc_mode,
6826 /* *** SET ALLMULTI MODE *** */
6827 struct cmd_set_allmulti_mode_result {
6828 cmdline_fixed_string_t set;
6829 cmdline_fixed_string_t allmulti;
6830 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6831 uint16_t port_num; /* valid if "allports" argument == 0 */
6832 cmdline_fixed_string_t mode;
6835 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6836 __rte_unused struct cmdline *cl,
6839 struct cmd_set_allmulti_mode_result *res = parsed_result;
6843 if (!strcmp(res->mode, "on"))
6850 RTE_ETH_FOREACH_DEV(i) {
6851 eth_set_allmulticast_mode(i, enable);
6855 eth_set_allmulticast_mode(res->port_num, enable);
6859 cmdline_parse_token_string_t cmd_setallmulti_set =
6860 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6861 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6862 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6864 cmdline_parse_token_string_t cmd_setallmulti_portall =
6865 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6867 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6868 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6870 cmdline_parse_token_string_t cmd_setallmulti_mode =
6871 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6874 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6875 .f = cmd_set_allmulti_mode_parsed,
6877 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6879 (void *)&cmd_setallmulti_set,
6880 (void *)&cmd_setallmulti_allmulti,
6881 (void *)&cmd_setallmulti_portall,
6882 (void *)&cmd_setallmulti_mode,
6887 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6888 .f = cmd_set_allmulti_mode_parsed,
6890 .help_str = "set allmulti <port_id> on|off: "
6891 "Set allmulti mode on port_id",
6893 (void *)&cmd_setallmulti_set,
6894 (void *)&cmd_setallmulti_allmulti,
6895 (void *)&cmd_setallmulti_portnum,
6896 (void *)&cmd_setallmulti_mode,
6901 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6902 struct cmd_link_flow_ctrl_set_result {
6903 cmdline_fixed_string_t set;
6904 cmdline_fixed_string_t flow_ctrl;
6905 cmdline_fixed_string_t rx;
6906 cmdline_fixed_string_t rx_lfc_mode;
6907 cmdline_fixed_string_t tx;
6908 cmdline_fixed_string_t tx_lfc_mode;
6909 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6910 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6911 cmdline_fixed_string_t autoneg_str;
6912 cmdline_fixed_string_t autoneg;
6913 cmdline_fixed_string_t hw_str;
6914 uint32_t high_water;
6915 cmdline_fixed_string_t lw_str;
6917 cmdline_fixed_string_t pt_str;
6918 uint16_t pause_time;
6919 cmdline_fixed_string_t xon_str;
6924 cmdline_parse_token_string_t cmd_lfc_set_set =
6925 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6927 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6928 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6929 flow_ctrl, "flow_ctrl");
6930 cmdline_parse_token_string_t cmd_lfc_set_rx =
6931 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6933 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6934 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6935 rx_lfc_mode, "on#off");
6936 cmdline_parse_token_string_t cmd_lfc_set_tx =
6937 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6939 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6940 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6941 tx_lfc_mode, "on#off");
6942 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6943 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6944 hw_str, "high_water");
6945 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6946 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6947 high_water, UINT32);
6948 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6949 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6950 lw_str, "low_water");
6951 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6952 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6954 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6955 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6956 pt_str, "pause_time");
6957 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6958 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6959 pause_time, UINT16);
6960 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6961 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6962 xon_str, "send_xon");
6963 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6964 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6966 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6967 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6968 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6969 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6970 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6971 mac_ctrl_frame_fwd_mode, "on#off");
6972 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6973 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6974 autoneg_str, "autoneg");
6975 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6976 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6978 cmdline_parse_token_num_t cmd_lfc_set_portid =
6979 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6982 /* forward declaration */
6984 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6987 cmdline_parse_inst_t cmd_link_flow_control_set = {
6988 .f = cmd_link_flow_ctrl_set_parsed,
6990 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6991 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6992 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6994 (void *)&cmd_lfc_set_set,
6995 (void *)&cmd_lfc_set_flow_ctrl,
6996 (void *)&cmd_lfc_set_rx,
6997 (void *)&cmd_lfc_set_rx_mode,
6998 (void *)&cmd_lfc_set_tx,
6999 (void *)&cmd_lfc_set_tx_mode,
7000 (void *)&cmd_lfc_set_high_water,
7001 (void *)&cmd_lfc_set_low_water,
7002 (void *)&cmd_lfc_set_pause_time,
7003 (void *)&cmd_lfc_set_send_xon,
7004 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7005 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7006 (void *)&cmd_lfc_set_autoneg_str,
7007 (void *)&cmd_lfc_set_autoneg,
7008 (void *)&cmd_lfc_set_portid,
7013 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7014 .f = cmd_link_flow_ctrl_set_parsed,
7015 .data = (void *)&cmd_link_flow_control_set_rx,
7016 .help_str = "set flow_ctrl rx on|off <port_id>: "
7017 "Change rx flow control parameter",
7019 (void *)&cmd_lfc_set_set,
7020 (void *)&cmd_lfc_set_flow_ctrl,
7021 (void *)&cmd_lfc_set_rx,
7022 (void *)&cmd_lfc_set_rx_mode,
7023 (void *)&cmd_lfc_set_portid,
7028 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7029 .f = cmd_link_flow_ctrl_set_parsed,
7030 .data = (void *)&cmd_link_flow_control_set_tx,
7031 .help_str = "set flow_ctrl tx on|off <port_id>: "
7032 "Change tx flow control parameter",
7034 (void *)&cmd_lfc_set_set,
7035 (void *)&cmd_lfc_set_flow_ctrl,
7036 (void *)&cmd_lfc_set_tx,
7037 (void *)&cmd_lfc_set_tx_mode,
7038 (void *)&cmd_lfc_set_portid,
7043 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7044 .f = cmd_link_flow_ctrl_set_parsed,
7045 .data = (void *)&cmd_link_flow_control_set_hw,
7046 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7047 "Change high water flow control parameter",
7049 (void *)&cmd_lfc_set_set,
7050 (void *)&cmd_lfc_set_flow_ctrl,
7051 (void *)&cmd_lfc_set_high_water_str,
7052 (void *)&cmd_lfc_set_high_water,
7053 (void *)&cmd_lfc_set_portid,
7058 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7059 .f = cmd_link_flow_ctrl_set_parsed,
7060 .data = (void *)&cmd_link_flow_control_set_lw,
7061 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7062 "Change low water flow control parameter",
7064 (void *)&cmd_lfc_set_set,
7065 (void *)&cmd_lfc_set_flow_ctrl,
7066 (void *)&cmd_lfc_set_low_water_str,
7067 (void *)&cmd_lfc_set_low_water,
7068 (void *)&cmd_lfc_set_portid,
7073 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7074 .f = cmd_link_flow_ctrl_set_parsed,
7075 .data = (void *)&cmd_link_flow_control_set_pt,
7076 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7077 "Change pause time flow control parameter",
7079 (void *)&cmd_lfc_set_set,
7080 (void *)&cmd_lfc_set_flow_ctrl,
7081 (void *)&cmd_lfc_set_pause_time_str,
7082 (void *)&cmd_lfc_set_pause_time,
7083 (void *)&cmd_lfc_set_portid,
7088 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7089 .f = cmd_link_flow_ctrl_set_parsed,
7090 .data = (void *)&cmd_link_flow_control_set_xon,
7091 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7092 "Change send_xon flow control parameter",
7094 (void *)&cmd_lfc_set_set,
7095 (void *)&cmd_lfc_set_flow_ctrl,
7096 (void *)&cmd_lfc_set_send_xon_str,
7097 (void *)&cmd_lfc_set_send_xon,
7098 (void *)&cmd_lfc_set_portid,
7103 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7104 .f = cmd_link_flow_ctrl_set_parsed,
7105 .data = (void *)&cmd_link_flow_control_set_macfwd,
7106 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7107 "Change mac ctrl fwd flow control parameter",
7109 (void *)&cmd_lfc_set_set,
7110 (void *)&cmd_lfc_set_flow_ctrl,
7111 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7112 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7113 (void *)&cmd_lfc_set_portid,
7118 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7119 .f = cmd_link_flow_ctrl_set_parsed,
7120 .data = (void *)&cmd_link_flow_control_set_autoneg,
7121 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7122 "Change autoneg flow control parameter",
7124 (void *)&cmd_lfc_set_set,
7125 (void *)&cmd_lfc_set_flow_ctrl,
7126 (void *)&cmd_lfc_set_autoneg_str,
7127 (void *)&cmd_lfc_set_autoneg,
7128 (void *)&cmd_lfc_set_portid,
7134 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7135 __rte_unused struct cmdline *cl,
7138 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7139 cmdline_parse_inst_t *cmd = data;
7140 struct rte_eth_fc_conf fc_conf;
7146 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7147 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7148 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7149 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7151 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7152 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7155 /* Partial command line, retrieve current configuration */
7157 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7159 printf("cannot get current flow ctrl parameters, return"
7160 "code = %d\n", ret);
7164 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7165 (fc_conf.mode == RTE_FC_FULL))
7167 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7168 (fc_conf.mode == RTE_FC_FULL))
7172 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7173 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7175 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7176 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7178 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7180 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7181 fc_conf.high_water = res->high_water;
7183 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7184 fc_conf.low_water = res->low_water;
7186 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7187 fc_conf.pause_time = res->pause_time;
7189 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7190 fc_conf.send_xon = res->send_xon;
7192 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7193 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7194 fc_conf.mac_ctrl_frame_fwd = 1;
7196 fc_conf.mac_ctrl_frame_fwd = 0;
7199 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7200 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7202 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7204 printf("bad flow contrl parameter, return code = %d \n", ret);
7207 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7208 struct cmd_priority_flow_ctrl_set_result {
7209 cmdline_fixed_string_t set;
7210 cmdline_fixed_string_t pfc_ctrl;
7211 cmdline_fixed_string_t rx;
7212 cmdline_fixed_string_t rx_pfc_mode;
7213 cmdline_fixed_string_t tx;
7214 cmdline_fixed_string_t tx_pfc_mode;
7215 uint32_t high_water;
7217 uint16_t pause_time;
7223 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7224 __rte_unused struct cmdline *cl,
7225 __rte_unused void *data)
7227 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7228 struct rte_eth_pfc_conf pfc_conf;
7229 int rx_fc_enable, tx_fc_enable;
7233 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7234 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7235 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7236 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7238 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7239 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7242 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7243 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7244 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7245 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7246 pfc_conf.fc.high_water = res->high_water;
7247 pfc_conf.fc.low_water = res->low_water;
7248 pfc_conf.fc.pause_time = res->pause_time;
7249 pfc_conf.priority = res->priority;
7251 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7253 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7256 cmdline_parse_token_string_t cmd_pfc_set_set =
7257 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7259 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7260 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7261 pfc_ctrl, "pfc_ctrl");
7262 cmdline_parse_token_string_t cmd_pfc_set_rx =
7263 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7265 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7266 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7267 rx_pfc_mode, "on#off");
7268 cmdline_parse_token_string_t cmd_pfc_set_tx =
7269 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7271 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7272 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7273 tx_pfc_mode, "on#off");
7274 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7275 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7276 high_water, UINT32);
7277 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7278 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7280 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7281 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7282 pause_time, UINT16);
7283 cmdline_parse_token_num_t cmd_pfc_set_priority =
7284 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7286 cmdline_parse_token_num_t cmd_pfc_set_portid =
7287 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7290 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7291 .f = cmd_priority_flow_ctrl_set_parsed,
7293 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7294 "<pause_time> <priority> <port_id>: "
7295 "Configure the Ethernet priority flow control",
7297 (void *)&cmd_pfc_set_set,
7298 (void *)&cmd_pfc_set_flow_ctrl,
7299 (void *)&cmd_pfc_set_rx,
7300 (void *)&cmd_pfc_set_rx_mode,
7301 (void *)&cmd_pfc_set_tx,
7302 (void *)&cmd_pfc_set_tx_mode,
7303 (void *)&cmd_pfc_set_high_water,
7304 (void *)&cmd_pfc_set_low_water,
7305 (void *)&cmd_pfc_set_pause_time,
7306 (void *)&cmd_pfc_set_priority,
7307 (void *)&cmd_pfc_set_portid,
7312 /* *** RESET CONFIGURATION *** */
7313 struct cmd_reset_result {
7314 cmdline_fixed_string_t reset;
7315 cmdline_fixed_string_t def;
7318 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7320 __rte_unused void *data)
7322 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7323 set_def_fwd_config();
7326 cmdline_parse_token_string_t cmd_reset_set =
7327 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7328 cmdline_parse_token_string_t cmd_reset_def =
7329 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7332 cmdline_parse_inst_t cmd_reset = {
7333 .f = cmd_reset_parsed,
7335 .help_str = "set default: Reset default forwarding configuration",
7337 (void *)&cmd_reset_set,
7338 (void *)&cmd_reset_def,
7343 /* *** START FORWARDING *** */
7344 struct cmd_start_result {
7345 cmdline_fixed_string_t start;
7348 cmdline_parse_token_string_t cmd_start_start =
7349 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7351 static void cmd_start_parsed(__rte_unused void *parsed_result,
7352 __rte_unused struct cmdline *cl,
7353 __rte_unused void *data)
7355 start_packet_forwarding(0);
7358 cmdline_parse_inst_t cmd_start = {
7359 .f = cmd_start_parsed,
7361 .help_str = "start: Start packet forwarding",
7363 (void *)&cmd_start_start,
7368 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7369 struct cmd_start_tx_first_result {
7370 cmdline_fixed_string_t start;
7371 cmdline_fixed_string_t tx_first;
7375 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7376 __rte_unused struct cmdline *cl,
7377 __rte_unused void *data)
7379 start_packet_forwarding(1);
7382 cmdline_parse_token_string_t cmd_start_tx_first_start =
7383 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7385 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7386 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7387 tx_first, "tx_first");
7389 cmdline_parse_inst_t cmd_start_tx_first = {
7390 .f = cmd_start_tx_first_parsed,
7392 .help_str = "start tx_first: Start packet forwarding, "
7393 "after sending 1 burst of packets",
7395 (void *)&cmd_start_tx_first_start,
7396 (void *)&cmd_start_tx_first_tx_first,
7401 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7402 struct cmd_start_tx_first_n_result {
7403 cmdline_fixed_string_t start;
7404 cmdline_fixed_string_t tx_first;
7409 cmd_start_tx_first_n_parsed(void *parsed_result,
7410 __rte_unused struct cmdline *cl,
7411 __rte_unused void *data)
7413 struct cmd_start_tx_first_n_result *res = parsed_result;
7415 start_packet_forwarding(res->tx_num);
7418 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7419 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7421 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7422 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7423 tx_first, "tx_first");
7424 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7425 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7428 cmdline_parse_inst_t cmd_start_tx_first_n = {
7429 .f = cmd_start_tx_first_n_parsed,
7431 .help_str = "start tx_first <num>: "
7432 "packet forwarding, after sending <num> bursts of packets",
7434 (void *)&cmd_start_tx_first_n_start,
7435 (void *)&cmd_start_tx_first_n_tx_first,
7436 (void *)&cmd_start_tx_first_n_tx_num,
7441 /* *** SET LINK UP *** */
7442 struct cmd_set_link_up_result {
7443 cmdline_fixed_string_t set;
7444 cmdline_fixed_string_t link_up;
7445 cmdline_fixed_string_t port;
7449 cmdline_parse_token_string_t cmd_set_link_up_set =
7450 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7451 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7452 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7454 cmdline_parse_token_string_t cmd_set_link_up_port =
7455 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7456 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7457 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7459 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7460 __rte_unused struct cmdline *cl,
7461 __rte_unused void *data)
7463 struct cmd_set_link_up_result *res = parsed_result;
7464 dev_set_link_up(res->port_id);
7467 cmdline_parse_inst_t cmd_set_link_up = {
7468 .f = cmd_set_link_up_parsed,
7470 .help_str = "set link-up port <port id>",
7472 (void *)&cmd_set_link_up_set,
7473 (void *)&cmd_set_link_up_link_up,
7474 (void *)&cmd_set_link_up_port,
7475 (void *)&cmd_set_link_up_port_id,
7480 /* *** SET LINK DOWN *** */
7481 struct cmd_set_link_down_result {
7482 cmdline_fixed_string_t set;
7483 cmdline_fixed_string_t link_down;
7484 cmdline_fixed_string_t port;
7488 cmdline_parse_token_string_t cmd_set_link_down_set =
7489 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7490 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7491 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7493 cmdline_parse_token_string_t cmd_set_link_down_port =
7494 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7495 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7496 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7498 static void cmd_set_link_down_parsed(
7499 __rte_unused void *parsed_result,
7500 __rte_unused struct cmdline *cl,
7501 __rte_unused void *data)
7503 struct cmd_set_link_down_result *res = parsed_result;
7504 dev_set_link_down(res->port_id);
7507 cmdline_parse_inst_t cmd_set_link_down = {
7508 .f = cmd_set_link_down_parsed,
7510 .help_str = "set link-down port <port id>",
7512 (void *)&cmd_set_link_down_set,
7513 (void *)&cmd_set_link_down_link_down,
7514 (void *)&cmd_set_link_down_port,
7515 (void *)&cmd_set_link_down_port_id,
7520 /* *** SHOW CFG *** */
7521 struct cmd_showcfg_result {
7522 cmdline_fixed_string_t show;
7523 cmdline_fixed_string_t cfg;
7524 cmdline_fixed_string_t what;
7527 static void cmd_showcfg_parsed(void *parsed_result,
7528 __rte_unused struct cmdline *cl,
7529 __rte_unused void *data)
7531 struct cmd_showcfg_result *res = parsed_result;
7532 if (!strcmp(res->what, "rxtx"))
7533 rxtx_config_display();
7534 else if (!strcmp(res->what, "cores"))
7535 fwd_lcores_config_display();
7536 else if (!strcmp(res->what, "fwd"))
7537 pkt_fwd_config_display(&cur_fwd_config);
7538 else if (!strcmp(res->what, "txpkts"))
7539 show_tx_pkt_segments();
7540 else if (!strcmp(res->what, "txtimes"))
7541 show_tx_pkt_times();
7544 cmdline_parse_token_string_t cmd_showcfg_show =
7545 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7546 cmdline_parse_token_string_t cmd_showcfg_port =
7547 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7548 cmdline_parse_token_string_t cmd_showcfg_what =
7549 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7550 "rxtx#cores#fwd#txpkts#txtimes");
7552 cmdline_parse_inst_t cmd_showcfg = {
7553 .f = cmd_showcfg_parsed,
7555 .help_str = "show config rxtx|cores|fwd|txpkts|txtimes",
7557 (void *)&cmd_showcfg_show,
7558 (void *)&cmd_showcfg_port,
7559 (void *)&cmd_showcfg_what,
7564 /* *** SHOW ALL PORT INFO *** */
7565 struct cmd_showportall_result {
7566 cmdline_fixed_string_t show;
7567 cmdline_fixed_string_t port;
7568 cmdline_fixed_string_t what;
7569 cmdline_fixed_string_t all;
7572 static void cmd_showportall_parsed(void *parsed_result,
7573 __rte_unused struct cmdline *cl,
7574 __rte_unused void *data)
7578 struct cmd_showportall_result *res = parsed_result;
7579 if (!strcmp(res->show, "clear")) {
7580 if (!strcmp(res->what, "stats"))
7581 RTE_ETH_FOREACH_DEV(i)
7583 else if (!strcmp(res->what, "xstats"))
7584 RTE_ETH_FOREACH_DEV(i)
7585 nic_xstats_clear(i);
7586 } else if (!strcmp(res->what, "info"))
7587 RTE_ETH_FOREACH_DEV(i)
7588 port_infos_display(i);
7589 else if (!strcmp(res->what, "summary")) {
7590 port_summary_header_display();
7591 RTE_ETH_FOREACH_DEV(i)
7592 port_summary_display(i);
7594 else if (!strcmp(res->what, "stats"))
7595 RTE_ETH_FOREACH_DEV(i)
7596 nic_stats_display(i);
7597 else if (!strcmp(res->what, "xstats"))
7598 RTE_ETH_FOREACH_DEV(i)
7599 nic_xstats_display(i);
7600 else if (!strcmp(res->what, "fdir"))
7601 RTE_ETH_FOREACH_DEV(i)
7603 else if (!strcmp(res->what, "stat_qmap"))
7604 RTE_ETH_FOREACH_DEV(i)
7605 nic_stats_mapping_display(i);
7606 else if (!strcmp(res->what, "dcb_tc"))
7607 RTE_ETH_FOREACH_DEV(i)
7608 port_dcb_info_display(i);
7609 else if (!strcmp(res->what, "cap"))
7610 RTE_ETH_FOREACH_DEV(i)
7611 port_offload_cap_display(i);
7614 cmdline_parse_token_string_t cmd_showportall_show =
7615 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7617 cmdline_parse_token_string_t cmd_showportall_port =
7618 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7619 cmdline_parse_token_string_t cmd_showportall_what =
7620 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7621 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7622 cmdline_parse_token_string_t cmd_showportall_all =
7623 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7624 cmdline_parse_inst_t cmd_showportall = {
7625 .f = cmd_showportall_parsed,
7627 .help_str = "show|clear port "
7628 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7630 (void *)&cmd_showportall_show,
7631 (void *)&cmd_showportall_port,
7632 (void *)&cmd_showportall_what,
7633 (void *)&cmd_showportall_all,
7638 /* *** SHOW PORT INFO *** */
7639 struct cmd_showport_result {
7640 cmdline_fixed_string_t show;
7641 cmdline_fixed_string_t port;
7642 cmdline_fixed_string_t what;
7646 static void cmd_showport_parsed(void *parsed_result,
7647 __rte_unused struct cmdline *cl,
7648 __rte_unused void *data)
7650 struct cmd_showport_result *res = parsed_result;
7651 if (!strcmp(res->show, "clear")) {
7652 if (!strcmp(res->what, "stats"))
7653 nic_stats_clear(res->portnum);
7654 else if (!strcmp(res->what, "xstats"))
7655 nic_xstats_clear(res->portnum);
7656 } else if (!strcmp(res->what, "info"))
7657 port_infos_display(res->portnum);
7658 else if (!strcmp(res->what, "summary")) {
7659 port_summary_header_display();
7660 port_summary_display(res->portnum);
7662 else if (!strcmp(res->what, "stats"))
7663 nic_stats_display(res->portnum);
7664 else if (!strcmp(res->what, "xstats"))
7665 nic_xstats_display(res->portnum);
7666 else if (!strcmp(res->what, "fdir"))
7667 fdir_get_infos(res->portnum);
7668 else if (!strcmp(res->what, "stat_qmap"))
7669 nic_stats_mapping_display(res->portnum);
7670 else if (!strcmp(res->what, "dcb_tc"))
7671 port_dcb_info_display(res->portnum);
7672 else if (!strcmp(res->what, "cap"))
7673 port_offload_cap_display(res->portnum);
7676 cmdline_parse_token_string_t cmd_showport_show =
7677 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7679 cmdline_parse_token_string_t cmd_showport_port =
7680 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7681 cmdline_parse_token_string_t cmd_showport_what =
7682 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7683 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7684 cmdline_parse_token_num_t cmd_showport_portnum =
7685 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7687 cmdline_parse_inst_t cmd_showport = {
7688 .f = cmd_showport_parsed,
7690 .help_str = "show|clear port "
7691 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7694 (void *)&cmd_showport_show,
7695 (void *)&cmd_showport_port,
7696 (void *)&cmd_showport_what,
7697 (void *)&cmd_showport_portnum,
7702 /* *** SHOW DEVICE INFO *** */
7703 struct cmd_showdevice_result {
7704 cmdline_fixed_string_t show;
7705 cmdline_fixed_string_t device;
7706 cmdline_fixed_string_t what;
7707 cmdline_fixed_string_t identifier;
7710 static void cmd_showdevice_parsed(void *parsed_result,
7711 __rte_unused struct cmdline *cl,
7712 __rte_unused void *data)
7714 struct cmd_showdevice_result *res = parsed_result;
7715 if (!strcmp(res->what, "info")) {
7716 if (!strcmp(res->identifier, "all"))
7717 device_infos_display(NULL);
7719 device_infos_display(res->identifier);
7723 cmdline_parse_token_string_t cmd_showdevice_show =
7724 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7726 cmdline_parse_token_string_t cmd_showdevice_device =
7727 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7728 cmdline_parse_token_string_t cmd_showdevice_what =
7729 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7731 cmdline_parse_token_string_t cmd_showdevice_identifier =
7732 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7735 cmdline_parse_inst_t cmd_showdevice = {
7736 .f = cmd_showdevice_parsed,
7738 .help_str = "show device info <identifier>|all",
7740 (void *)&cmd_showdevice_show,
7741 (void *)&cmd_showdevice_device,
7742 (void *)&cmd_showdevice_what,
7743 (void *)&cmd_showdevice_identifier,
7748 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7749 struct cmd_showeeprom_result {
7750 cmdline_fixed_string_t show;
7751 cmdline_fixed_string_t port;
7753 cmdline_fixed_string_t type;
7756 static void cmd_showeeprom_parsed(void *parsed_result,
7757 __rte_unused struct cmdline *cl,
7758 __rte_unused void *data)
7760 struct cmd_showeeprom_result *res = parsed_result;
7762 if (!strcmp(res->type, "eeprom"))
7763 port_eeprom_display(res->portnum);
7764 else if (!strcmp(res->type, "module_eeprom"))
7765 port_module_eeprom_display(res->portnum);
7767 printf("Unknown argument\n");
7770 cmdline_parse_token_string_t cmd_showeeprom_show =
7771 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7772 cmdline_parse_token_string_t cmd_showeeprom_port =
7773 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7774 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7775 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum, UINT16);
7776 cmdline_parse_token_string_t cmd_showeeprom_type =
7777 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7779 cmdline_parse_inst_t cmd_showeeprom = {
7780 .f = cmd_showeeprom_parsed,
7782 .help_str = "show port <port_id> module_eeprom|eeprom",
7784 (void *)&cmd_showeeprom_show,
7785 (void *)&cmd_showeeprom_port,
7786 (void *)&cmd_showeeprom_portnum,
7787 (void *)&cmd_showeeprom_type,
7792 /* *** SHOW QUEUE INFO *** */
7793 struct cmd_showqueue_result {
7794 cmdline_fixed_string_t show;
7795 cmdline_fixed_string_t type;
7796 cmdline_fixed_string_t what;
7802 cmd_showqueue_parsed(void *parsed_result,
7803 __rte_unused struct cmdline *cl,
7804 __rte_unused void *data)
7806 struct cmd_showqueue_result *res = parsed_result;
7808 if (!strcmp(res->type, "rxq"))
7809 rx_queue_infos_display(res->portnum, res->queuenum);
7810 else if (!strcmp(res->type, "txq"))
7811 tx_queue_infos_display(res->portnum, res->queuenum);
7814 cmdline_parse_token_string_t cmd_showqueue_show =
7815 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7816 cmdline_parse_token_string_t cmd_showqueue_type =
7817 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7818 cmdline_parse_token_string_t cmd_showqueue_what =
7819 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7820 cmdline_parse_token_num_t cmd_showqueue_portnum =
7821 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7822 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7823 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7825 cmdline_parse_inst_t cmd_showqueue = {
7826 .f = cmd_showqueue_parsed,
7828 .help_str = "show rxq|txq info <port_id> <queue_id>",
7830 (void *)&cmd_showqueue_show,
7831 (void *)&cmd_showqueue_type,
7832 (void *)&cmd_showqueue_what,
7833 (void *)&cmd_showqueue_portnum,
7834 (void *)&cmd_showqueue_queuenum,
7839 /* show/clear fwd engine statistics */
7841 cmdline_fixed_string_t action;
7842 cmdline_fixed_string_t fwd;
7843 cmdline_fixed_string_t stats;
7844 cmdline_fixed_string_t all;
7847 cmdline_parse_token_string_t cmd_fwd_action =
7848 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7849 cmdline_parse_token_string_t cmd_fwd_fwd =
7850 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7851 cmdline_parse_token_string_t cmd_fwd_stats =
7852 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7853 cmdline_parse_token_string_t cmd_fwd_all =
7854 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7857 cmd_showfwdall_parsed(void *parsed_result,
7858 __rte_unused struct cmdline *cl,
7859 __rte_unused void *data)
7861 struct fwd_result *res = parsed_result;
7863 if (!strcmp(res->action, "show"))
7864 fwd_stats_display();
7869 static cmdline_parse_inst_t cmd_showfwdall = {
7870 .f = cmd_showfwdall_parsed,
7872 .help_str = "show|clear fwd stats all",
7874 (void *)&cmd_fwd_action,
7875 (void *)&cmd_fwd_fwd,
7876 (void *)&cmd_fwd_stats,
7877 (void *)&cmd_fwd_all,
7882 /* *** READ PORT REGISTER *** */
7883 struct cmd_read_reg_result {
7884 cmdline_fixed_string_t read;
7885 cmdline_fixed_string_t reg;
7891 cmd_read_reg_parsed(void *parsed_result,
7892 __rte_unused struct cmdline *cl,
7893 __rte_unused void *data)
7895 struct cmd_read_reg_result *res = parsed_result;
7896 port_reg_display(res->port_id, res->reg_off);
7899 cmdline_parse_token_string_t cmd_read_reg_read =
7900 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7901 cmdline_parse_token_string_t cmd_read_reg_reg =
7902 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7903 cmdline_parse_token_num_t cmd_read_reg_port_id =
7904 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7905 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7906 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7908 cmdline_parse_inst_t cmd_read_reg = {
7909 .f = cmd_read_reg_parsed,
7911 .help_str = "read reg <port_id> <reg_off>",
7913 (void *)&cmd_read_reg_read,
7914 (void *)&cmd_read_reg_reg,
7915 (void *)&cmd_read_reg_port_id,
7916 (void *)&cmd_read_reg_reg_off,
7921 /* *** READ PORT REGISTER BIT FIELD *** */
7922 struct cmd_read_reg_bit_field_result {
7923 cmdline_fixed_string_t read;
7924 cmdline_fixed_string_t regfield;
7932 cmd_read_reg_bit_field_parsed(void *parsed_result,
7933 __rte_unused struct cmdline *cl,
7934 __rte_unused void *data)
7936 struct cmd_read_reg_bit_field_result *res = parsed_result;
7937 port_reg_bit_field_display(res->port_id, res->reg_off,
7938 res->bit1_pos, res->bit2_pos);
7941 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7942 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7944 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7945 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7946 regfield, "regfield");
7947 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7948 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7950 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7951 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7953 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7954 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7956 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7957 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7960 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7961 .f = cmd_read_reg_bit_field_parsed,
7963 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7964 "Read register bit field between bit_x and bit_y included",
7966 (void *)&cmd_read_reg_bit_field_read,
7967 (void *)&cmd_read_reg_bit_field_regfield,
7968 (void *)&cmd_read_reg_bit_field_port_id,
7969 (void *)&cmd_read_reg_bit_field_reg_off,
7970 (void *)&cmd_read_reg_bit_field_bit1_pos,
7971 (void *)&cmd_read_reg_bit_field_bit2_pos,
7976 /* *** READ PORT REGISTER BIT *** */
7977 struct cmd_read_reg_bit_result {
7978 cmdline_fixed_string_t read;
7979 cmdline_fixed_string_t regbit;
7986 cmd_read_reg_bit_parsed(void *parsed_result,
7987 __rte_unused struct cmdline *cl,
7988 __rte_unused void *data)
7990 struct cmd_read_reg_bit_result *res = parsed_result;
7991 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7994 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7995 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7996 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7997 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7999 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8000 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
8001 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8002 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
8003 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8004 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
8006 cmdline_parse_inst_t cmd_read_reg_bit = {
8007 .f = cmd_read_reg_bit_parsed,
8009 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8011 (void *)&cmd_read_reg_bit_read,
8012 (void *)&cmd_read_reg_bit_regbit,
8013 (void *)&cmd_read_reg_bit_port_id,
8014 (void *)&cmd_read_reg_bit_reg_off,
8015 (void *)&cmd_read_reg_bit_bit_pos,
8020 /* *** WRITE PORT REGISTER *** */
8021 struct cmd_write_reg_result {
8022 cmdline_fixed_string_t write;
8023 cmdline_fixed_string_t reg;
8030 cmd_write_reg_parsed(void *parsed_result,
8031 __rte_unused struct cmdline *cl,
8032 __rte_unused void *data)
8034 struct cmd_write_reg_result *res = parsed_result;
8035 port_reg_set(res->port_id, res->reg_off, res->value);
8038 cmdline_parse_token_string_t cmd_write_reg_write =
8039 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8040 cmdline_parse_token_string_t cmd_write_reg_reg =
8041 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8042 cmdline_parse_token_num_t cmd_write_reg_port_id =
8043 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
8044 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8045 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
8046 cmdline_parse_token_num_t cmd_write_reg_value =
8047 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
8049 cmdline_parse_inst_t cmd_write_reg = {
8050 .f = cmd_write_reg_parsed,
8052 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8054 (void *)&cmd_write_reg_write,
8055 (void *)&cmd_write_reg_reg,
8056 (void *)&cmd_write_reg_port_id,
8057 (void *)&cmd_write_reg_reg_off,
8058 (void *)&cmd_write_reg_value,
8063 /* *** WRITE PORT REGISTER BIT FIELD *** */
8064 struct cmd_write_reg_bit_field_result {
8065 cmdline_fixed_string_t write;
8066 cmdline_fixed_string_t regfield;
8075 cmd_write_reg_bit_field_parsed(void *parsed_result,
8076 __rte_unused struct cmdline *cl,
8077 __rte_unused void *data)
8079 struct cmd_write_reg_bit_field_result *res = parsed_result;
8080 port_reg_bit_field_set(res->port_id, res->reg_off,
8081 res->bit1_pos, res->bit2_pos, res->value);
8084 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8085 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8087 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8088 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8089 regfield, "regfield");
8090 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8091 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8093 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8094 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8096 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8097 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8099 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8100 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8102 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8103 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8106 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8107 .f = cmd_write_reg_bit_field_parsed,
8109 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8111 "Set register bit field between bit_x and bit_y included",
8113 (void *)&cmd_write_reg_bit_field_write,
8114 (void *)&cmd_write_reg_bit_field_regfield,
8115 (void *)&cmd_write_reg_bit_field_port_id,
8116 (void *)&cmd_write_reg_bit_field_reg_off,
8117 (void *)&cmd_write_reg_bit_field_bit1_pos,
8118 (void *)&cmd_write_reg_bit_field_bit2_pos,
8119 (void *)&cmd_write_reg_bit_field_value,
8124 /* *** WRITE PORT REGISTER BIT *** */
8125 struct cmd_write_reg_bit_result {
8126 cmdline_fixed_string_t write;
8127 cmdline_fixed_string_t regbit;
8135 cmd_write_reg_bit_parsed(void *parsed_result,
8136 __rte_unused struct cmdline *cl,
8137 __rte_unused void *data)
8139 struct cmd_write_reg_bit_result *res = parsed_result;
8140 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8143 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8144 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8146 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8147 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8149 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8150 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
8151 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8152 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
8153 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8154 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
8155 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8156 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
8158 cmdline_parse_inst_t cmd_write_reg_bit = {
8159 .f = cmd_write_reg_bit_parsed,
8161 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8164 (void *)&cmd_write_reg_bit_write,
8165 (void *)&cmd_write_reg_bit_regbit,
8166 (void *)&cmd_write_reg_bit_port_id,
8167 (void *)&cmd_write_reg_bit_reg_off,
8168 (void *)&cmd_write_reg_bit_bit_pos,
8169 (void *)&cmd_write_reg_bit_value,
8174 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8175 struct cmd_read_rxd_txd_result {
8176 cmdline_fixed_string_t read;
8177 cmdline_fixed_string_t rxd_txd;
8184 cmd_read_rxd_txd_parsed(void *parsed_result,
8185 __rte_unused struct cmdline *cl,
8186 __rte_unused void *data)
8188 struct cmd_read_rxd_txd_result *res = parsed_result;
8190 if (!strcmp(res->rxd_txd, "rxd"))
8191 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8192 else if (!strcmp(res->rxd_txd, "txd"))
8193 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8196 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8197 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8198 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8199 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8201 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8202 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8203 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8204 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8205 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8206 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8208 cmdline_parse_inst_t cmd_read_rxd_txd = {
8209 .f = cmd_read_rxd_txd_parsed,
8211 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8213 (void *)&cmd_read_rxd_txd_read,
8214 (void *)&cmd_read_rxd_txd_rxd_txd,
8215 (void *)&cmd_read_rxd_txd_port_id,
8216 (void *)&cmd_read_rxd_txd_queue_id,
8217 (void *)&cmd_read_rxd_txd_desc_id,
8223 struct cmd_quit_result {
8224 cmdline_fixed_string_t quit;
8227 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8229 __rte_unused void *data)
8234 cmdline_parse_token_string_t cmd_quit_quit =
8235 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8237 cmdline_parse_inst_t cmd_quit = {
8238 .f = cmd_quit_parsed,
8240 .help_str = "quit: Exit application",
8242 (void *)&cmd_quit_quit,
8247 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8248 struct cmd_mac_addr_result {
8249 cmdline_fixed_string_t mac_addr_cmd;
8250 cmdline_fixed_string_t what;
8252 struct rte_ether_addr address;
8255 static void cmd_mac_addr_parsed(void *parsed_result,
8256 __rte_unused struct cmdline *cl,
8257 __rte_unused void *data)
8259 struct cmd_mac_addr_result *res = parsed_result;
8262 if (strcmp(res->what, "add") == 0)
8263 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8264 else if (strcmp(res->what, "set") == 0)
8265 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8268 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8270 /* check the return value and print it if is < 0 */
8272 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8276 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8277 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8279 cmdline_parse_token_string_t cmd_mac_addr_what =
8280 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8282 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8283 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8285 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8286 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8288 cmdline_parse_inst_t cmd_mac_addr = {
8289 .f = cmd_mac_addr_parsed,
8291 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8292 "Add/Remove/Set MAC address on port_id",
8294 (void *)&cmd_mac_addr_cmd,
8295 (void *)&cmd_mac_addr_what,
8296 (void *)&cmd_mac_addr_portnum,
8297 (void *)&cmd_mac_addr_addr,
8302 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8303 struct cmd_eth_peer_result {
8304 cmdline_fixed_string_t set;
8305 cmdline_fixed_string_t eth_peer;
8307 cmdline_fixed_string_t peer_addr;
8310 static void cmd_set_eth_peer_parsed(void *parsed_result,
8311 __rte_unused struct cmdline *cl,
8312 __rte_unused void *data)
8314 struct cmd_eth_peer_result *res = parsed_result;
8316 if (test_done == 0) {
8317 printf("Please stop forwarding first\n");
8320 if (!strcmp(res->eth_peer, "eth-peer")) {
8321 set_fwd_eth_peer(res->port_id, res->peer_addr);
8325 cmdline_parse_token_string_t cmd_eth_peer_set =
8326 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8327 cmdline_parse_token_string_t cmd_eth_peer =
8328 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8329 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8330 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8331 cmdline_parse_token_string_t cmd_eth_peer_addr =
8332 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8334 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8335 .f = cmd_set_eth_peer_parsed,
8337 .help_str = "set eth-peer <port_id> <peer_mac>",
8339 (void *)&cmd_eth_peer_set,
8340 (void *)&cmd_eth_peer,
8341 (void *)&cmd_eth_peer_port_id,
8342 (void *)&cmd_eth_peer_addr,
8347 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8348 struct cmd_set_qmap_result {
8349 cmdline_fixed_string_t set;
8350 cmdline_fixed_string_t qmap;
8351 cmdline_fixed_string_t what;
8358 cmd_set_qmap_parsed(void *parsed_result,
8359 __rte_unused struct cmdline *cl,
8360 __rte_unused void *data)
8362 struct cmd_set_qmap_result *res = parsed_result;
8363 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8365 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8368 cmdline_parse_token_string_t cmd_setqmap_set =
8369 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8371 cmdline_parse_token_string_t cmd_setqmap_qmap =
8372 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8374 cmdline_parse_token_string_t cmd_setqmap_what =
8375 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8377 cmdline_parse_token_num_t cmd_setqmap_portid =
8378 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8380 cmdline_parse_token_num_t cmd_setqmap_queueid =
8381 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8383 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8384 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8387 cmdline_parse_inst_t cmd_set_qmap = {
8388 .f = cmd_set_qmap_parsed,
8390 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8391 "Set statistics mapping value on tx|rx queue_id of port_id",
8393 (void *)&cmd_setqmap_set,
8394 (void *)&cmd_setqmap_qmap,
8395 (void *)&cmd_setqmap_what,
8396 (void *)&cmd_setqmap_portid,
8397 (void *)&cmd_setqmap_queueid,
8398 (void *)&cmd_setqmap_mapvalue,
8403 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8404 struct cmd_set_xstats_hide_zero_result {
8405 cmdline_fixed_string_t keyword;
8406 cmdline_fixed_string_t name;
8407 cmdline_fixed_string_t on_off;
8411 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8412 __rte_unused struct cmdline *cl,
8413 __rte_unused void *data)
8415 struct cmd_set_xstats_hide_zero_result *res;
8416 uint16_t on_off = 0;
8418 res = parsed_result;
8419 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8420 set_xstats_hide_zero(on_off);
8423 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8424 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8426 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8427 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8428 name, "xstats-hide-zero");
8429 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8430 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8433 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8434 .f = cmd_set_xstats_hide_zero_parsed,
8436 .help_str = "set xstats-hide-zero on|off",
8438 (void *)&cmd_set_xstats_hide_zero_keyword,
8439 (void *)&cmd_set_xstats_hide_zero_name,
8440 (void *)&cmd_set_xstats_hide_zero_on_off,
8445 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8446 struct cmd_set_record_core_cycles_result {
8447 cmdline_fixed_string_t keyword;
8448 cmdline_fixed_string_t name;
8449 cmdline_fixed_string_t on_off;
8453 cmd_set_record_core_cycles_parsed(void *parsed_result,
8454 __rte_unused struct cmdline *cl,
8455 __rte_unused void *data)
8457 struct cmd_set_record_core_cycles_result *res;
8458 uint16_t on_off = 0;
8460 res = parsed_result;
8461 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8462 set_record_core_cycles(on_off);
8465 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8466 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8468 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8469 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8470 name, "record-core-cycles");
8471 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8472 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8475 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8476 .f = cmd_set_record_core_cycles_parsed,
8478 .help_str = "set record-core-cycles on|off",
8480 (void *)&cmd_set_record_core_cycles_keyword,
8481 (void *)&cmd_set_record_core_cycles_name,
8482 (void *)&cmd_set_record_core_cycles_on_off,
8487 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8488 struct cmd_set_record_burst_stats_result {
8489 cmdline_fixed_string_t keyword;
8490 cmdline_fixed_string_t name;
8491 cmdline_fixed_string_t on_off;
8495 cmd_set_record_burst_stats_parsed(void *parsed_result,
8496 __rte_unused struct cmdline *cl,
8497 __rte_unused void *data)
8499 struct cmd_set_record_burst_stats_result *res;
8500 uint16_t on_off = 0;
8502 res = parsed_result;
8503 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8504 set_record_burst_stats(on_off);
8507 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8508 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8510 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8511 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8512 name, "record-burst-stats");
8513 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8514 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8517 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8518 .f = cmd_set_record_burst_stats_parsed,
8520 .help_str = "set record-burst-stats on|off",
8522 (void *)&cmd_set_record_burst_stats_keyword,
8523 (void *)&cmd_set_record_burst_stats_name,
8524 (void *)&cmd_set_record_burst_stats_on_off,
8529 /* *** CONFIGURE UNICAST HASH TABLE *** */
8530 struct cmd_set_uc_hash_table {
8531 cmdline_fixed_string_t set;
8532 cmdline_fixed_string_t port;
8534 cmdline_fixed_string_t what;
8535 struct rte_ether_addr address;
8536 cmdline_fixed_string_t mode;
8540 cmd_set_uc_hash_parsed(void *parsed_result,
8541 __rte_unused struct cmdline *cl,
8542 __rte_unused void *data)
8545 struct cmd_set_uc_hash_table *res = parsed_result;
8547 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8549 if (strcmp(res->what, "uta") == 0)
8550 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8551 &res->address,(uint8_t)is_on);
8553 printf("bad unicast hash table parameter, return code = %d \n", ret);
8557 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8558 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8560 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8561 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8563 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8564 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8566 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8567 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8569 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8570 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8572 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8573 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8576 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8577 .f = cmd_set_uc_hash_parsed,
8579 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8581 (void *)&cmd_set_uc_hash_set,
8582 (void *)&cmd_set_uc_hash_port,
8583 (void *)&cmd_set_uc_hash_portid,
8584 (void *)&cmd_set_uc_hash_what,
8585 (void *)&cmd_set_uc_hash_mac,
8586 (void *)&cmd_set_uc_hash_mode,
8591 struct cmd_set_uc_all_hash_table {
8592 cmdline_fixed_string_t set;
8593 cmdline_fixed_string_t port;
8595 cmdline_fixed_string_t what;
8596 cmdline_fixed_string_t value;
8597 cmdline_fixed_string_t mode;
8601 cmd_set_uc_all_hash_parsed(void *parsed_result,
8602 __rte_unused struct cmdline *cl,
8603 __rte_unused void *data)
8606 struct cmd_set_uc_all_hash_table *res = parsed_result;
8608 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8610 if ((strcmp(res->what, "uta") == 0) &&
8611 (strcmp(res->value, "all") == 0))
8612 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8614 printf("bad unicast hash table parameter,"
8615 "return code = %d \n", ret);
8618 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8619 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8621 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8622 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8624 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8625 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8627 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8628 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8630 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8631 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8633 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8634 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8637 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8638 .f = cmd_set_uc_all_hash_parsed,
8640 .help_str = "set port <port_id> uta all on|off",
8642 (void *)&cmd_set_uc_all_hash_set,
8643 (void *)&cmd_set_uc_all_hash_port,
8644 (void *)&cmd_set_uc_all_hash_portid,
8645 (void *)&cmd_set_uc_all_hash_what,
8646 (void *)&cmd_set_uc_all_hash_value,
8647 (void *)&cmd_set_uc_all_hash_mode,
8652 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8653 struct cmd_set_vf_macvlan_filter {
8654 cmdline_fixed_string_t set;
8655 cmdline_fixed_string_t port;
8657 cmdline_fixed_string_t vf;
8659 struct rte_ether_addr address;
8660 cmdline_fixed_string_t filter_type;
8661 cmdline_fixed_string_t mode;
8665 cmd_set_vf_macvlan_parsed(void *parsed_result,
8666 __rte_unused struct cmdline *cl,
8667 __rte_unused void *data)
8670 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8671 struct rte_eth_mac_filter filter;
8673 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8675 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8677 /* set VF MAC filter */
8681 filter.dst_id = res->vf_id;
8683 if (!strcmp(res->filter_type, "exact-mac"))
8684 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8685 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8686 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8687 else if (!strcmp(res->filter_type, "hashmac"))
8688 filter.filter_type = RTE_MAC_HASH_MATCH;
8689 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8690 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8692 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8695 ret = rte_eth_dev_filter_ctrl(res->port_id,
8696 RTE_ETH_FILTER_MACVLAN,
8700 ret = rte_eth_dev_filter_ctrl(res->port_id,
8701 RTE_ETH_FILTER_MACVLAN,
8702 RTE_ETH_FILTER_DELETE,
8706 printf("bad set MAC hash parameter, return code = %d\n", ret);
8710 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8711 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8713 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8714 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8716 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8717 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8719 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8720 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8722 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8723 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8725 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8726 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8728 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8729 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8730 filter_type, "exact-mac#exact-mac-vlan"
8731 "#hashmac#hashmac-vlan");
8732 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8733 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8736 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8737 .f = cmd_set_vf_macvlan_parsed,
8739 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8740 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8741 "Exact match rule: exact match of MAC or MAC and VLAN; "
8742 "hash match rule: hash match of MAC and exact match of VLAN",
8744 (void *)&cmd_set_vf_macvlan_set,
8745 (void *)&cmd_set_vf_macvlan_port,
8746 (void *)&cmd_set_vf_macvlan_portid,
8747 (void *)&cmd_set_vf_macvlan_vf,
8748 (void *)&cmd_set_vf_macvlan_vf_id,
8749 (void *)&cmd_set_vf_macvlan_mac,
8750 (void *)&cmd_set_vf_macvlan_filter_type,
8751 (void *)&cmd_set_vf_macvlan_mode,
8756 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8757 struct cmd_set_vf_traffic {
8758 cmdline_fixed_string_t set;
8759 cmdline_fixed_string_t port;
8761 cmdline_fixed_string_t vf;
8763 cmdline_fixed_string_t what;
8764 cmdline_fixed_string_t mode;
8768 cmd_set_vf_traffic_parsed(void *parsed_result,
8769 __rte_unused struct cmdline *cl,
8770 __rte_unused void *data)
8772 struct cmd_set_vf_traffic *res = parsed_result;
8773 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8774 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8776 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8779 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8780 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8782 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8783 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8785 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8786 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8788 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8789 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8791 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8792 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8794 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8795 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8797 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8798 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8801 cmdline_parse_inst_t cmd_set_vf_traffic = {
8802 .f = cmd_set_vf_traffic_parsed,
8804 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8806 (void *)&cmd_setvf_traffic_set,
8807 (void *)&cmd_setvf_traffic_port,
8808 (void *)&cmd_setvf_traffic_portid,
8809 (void *)&cmd_setvf_traffic_vf,
8810 (void *)&cmd_setvf_traffic_vfid,
8811 (void *)&cmd_setvf_traffic_what,
8812 (void *)&cmd_setvf_traffic_mode,
8817 /* *** CONFIGURE VF RECEIVE MODE *** */
8818 struct cmd_set_vf_rxmode {
8819 cmdline_fixed_string_t set;
8820 cmdline_fixed_string_t port;
8822 cmdline_fixed_string_t vf;
8824 cmdline_fixed_string_t what;
8825 cmdline_fixed_string_t mode;
8826 cmdline_fixed_string_t on;
8830 cmd_set_vf_rxmode_parsed(void *parsed_result,
8831 __rte_unused struct cmdline *cl,
8832 __rte_unused void *data)
8835 uint16_t vf_rxmode = 0;
8836 struct cmd_set_vf_rxmode *res = parsed_result;
8838 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8839 if (!strcmp(res->what,"rxmode")) {
8840 if (!strcmp(res->mode, "AUPE"))
8841 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8842 else if (!strcmp(res->mode, "ROPE"))
8843 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8844 else if (!strcmp(res->mode, "BAM"))
8845 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8846 else if (!strncmp(res->mode, "MPE",3))
8847 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8850 RTE_SET_USED(is_on);
8852 #ifdef RTE_LIBRTE_IXGBE_PMD
8853 if (ret == -ENOTSUP)
8854 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8855 vf_rxmode, (uint8_t)is_on);
8857 #ifdef RTE_LIBRTE_BNXT_PMD
8858 if (ret == -ENOTSUP)
8859 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8860 vf_rxmode, (uint8_t)is_on);
8863 printf("bad VF receive mode parameter, return code = %d \n",
8867 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8868 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8870 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8871 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8873 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8874 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8876 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8877 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8879 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8880 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8882 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8883 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8885 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8886 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8887 mode, "AUPE#ROPE#BAM#MPE");
8888 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8889 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8892 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8893 .f = cmd_set_vf_rxmode_parsed,
8895 .help_str = "set port <port_id> vf <vf_id> rxmode "
8896 "AUPE|ROPE|BAM|MPE on|off",
8898 (void *)&cmd_set_vf_rxmode_set,
8899 (void *)&cmd_set_vf_rxmode_port,
8900 (void *)&cmd_set_vf_rxmode_portid,
8901 (void *)&cmd_set_vf_rxmode_vf,
8902 (void *)&cmd_set_vf_rxmode_vfid,
8903 (void *)&cmd_set_vf_rxmode_what,
8904 (void *)&cmd_set_vf_rxmode_mode,
8905 (void *)&cmd_set_vf_rxmode_on,
8910 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8911 struct cmd_vf_mac_addr_result {
8912 cmdline_fixed_string_t mac_addr_cmd;
8913 cmdline_fixed_string_t what;
8914 cmdline_fixed_string_t port;
8916 cmdline_fixed_string_t vf;
8918 struct rte_ether_addr address;
8921 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8922 __rte_unused struct cmdline *cl,
8923 __rte_unused void *data)
8925 struct cmd_vf_mac_addr_result *res = parsed_result;
8928 if (strcmp(res->what, "add") != 0)
8931 #ifdef RTE_LIBRTE_I40E_PMD
8932 if (ret == -ENOTSUP)
8933 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8936 #ifdef RTE_LIBRTE_BNXT_PMD
8937 if (ret == -ENOTSUP)
8938 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8943 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8947 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8948 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8949 mac_addr_cmd,"mac_addr");
8950 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8951 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8953 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8954 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8956 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8957 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8959 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8960 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8962 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8963 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8965 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8966 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8969 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8970 .f = cmd_vf_mac_addr_parsed,
8972 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8973 "Add MAC address filtering for a VF on port_id",
8975 (void *)&cmd_vf_mac_addr_cmd,
8976 (void *)&cmd_vf_mac_addr_what,
8977 (void *)&cmd_vf_mac_addr_port,
8978 (void *)&cmd_vf_mac_addr_portnum,
8979 (void *)&cmd_vf_mac_addr_vf,
8980 (void *)&cmd_vf_mac_addr_vfnum,
8981 (void *)&cmd_vf_mac_addr_addr,
8986 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8987 struct cmd_vf_rx_vlan_filter {
8988 cmdline_fixed_string_t rx_vlan;
8989 cmdline_fixed_string_t what;
8991 cmdline_fixed_string_t port;
8993 cmdline_fixed_string_t vf;
8998 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8999 __rte_unused struct cmdline *cl,
9000 __rte_unused void *data)
9002 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9005 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9007 #ifdef RTE_LIBRTE_IXGBE_PMD
9008 if (ret == -ENOTSUP)
9009 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9010 res->vlan_id, res->vf_mask, is_add);
9012 #ifdef RTE_LIBRTE_I40E_PMD
9013 if (ret == -ENOTSUP)
9014 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9015 res->vlan_id, res->vf_mask, is_add);
9017 #ifdef RTE_LIBRTE_BNXT_PMD
9018 if (ret == -ENOTSUP)
9019 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9020 res->vlan_id, res->vf_mask, is_add);
9027 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
9028 res->vlan_id, res->vf_mask);
9031 printf("invalid port_id %d\n", res->port_id);
9034 printf("function not implemented or supported\n");
9037 printf("programming error: (%s)\n", strerror(-ret));
9041 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9042 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9043 rx_vlan, "rx_vlan");
9044 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9045 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9047 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9048 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9050 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9051 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9053 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9054 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9056 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9057 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9059 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9060 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9063 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9064 .f = cmd_vf_rx_vlan_filter_parsed,
9066 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9067 "(vf_mask = hexadecimal VF mask)",
9069 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9070 (void *)&cmd_vf_rx_vlan_filter_what,
9071 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9072 (void *)&cmd_vf_rx_vlan_filter_port,
9073 (void *)&cmd_vf_rx_vlan_filter_portid,
9074 (void *)&cmd_vf_rx_vlan_filter_vf,
9075 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9080 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9081 struct cmd_queue_rate_limit_result {
9082 cmdline_fixed_string_t set;
9083 cmdline_fixed_string_t port;
9085 cmdline_fixed_string_t queue;
9087 cmdline_fixed_string_t rate;
9091 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9092 __rte_unused struct cmdline *cl,
9093 __rte_unused void *data)
9095 struct cmd_queue_rate_limit_result *res = parsed_result;
9098 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9099 && (strcmp(res->queue, "queue") == 0)
9100 && (strcmp(res->rate, "rate") == 0))
9101 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9104 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
9108 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9109 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9111 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9112 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9114 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9115 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9117 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9118 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9120 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9121 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9123 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9124 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9126 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9127 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9130 cmdline_parse_inst_t cmd_queue_rate_limit = {
9131 .f = cmd_queue_rate_limit_parsed,
9133 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9134 "Set rate limit for a queue on port_id",
9136 (void *)&cmd_queue_rate_limit_set,
9137 (void *)&cmd_queue_rate_limit_port,
9138 (void *)&cmd_queue_rate_limit_portnum,
9139 (void *)&cmd_queue_rate_limit_queue,
9140 (void *)&cmd_queue_rate_limit_queuenum,
9141 (void *)&cmd_queue_rate_limit_rate,
9142 (void *)&cmd_queue_rate_limit_ratenum,
9147 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9148 struct cmd_vf_rate_limit_result {
9149 cmdline_fixed_string_t set;
9150 cmdline_fixed_string_t port;
9152 cmdline_fixed_string_t vf;
9154 cmdline_fixed_string_t rate;
9156 cmdline_fixed_string_t q_msk;
9160 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9161 __rte_unused struct cmdline *cl,
9162 __rte_unused void *data)
9164 struct cmd_vf_rate_limit_result *res = parsed_result;
9167 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9168 && (strcmp(res->vf, "vf") == 0)
9169 && (strcmp(res->rate, "rate") == 0)
9170 && (strcmp(res->q_msk, "queue_mask") == 0))
9171 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9172 res->rate_num, res->q_msk_val);
9174 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9178 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9179 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9181 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9182 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9184 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9185 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9187 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9188 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9190 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9191 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9193 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9194 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9196 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9197 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9199 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9200 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9201 q_msk, "queue_mask");
9202 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9203 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9206 cmdline_parse_inst_t cmd_vf_rate_limit = {
9207 .f = cmd_vf_rate_limit_parsed,
9209 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9210 "queue_mask <queue_mask_value>: "
9211 "Set rate limit for queues of VF on port_id",
9213 (void *)&cmd_vf_rate_limit_set,
9214 (void *)&cmd_vf_rate_limit_port,
9215 (void *)&cmd_vf_rate_limit_portnum,
9216 (void *)&cmd_vf_rate_limit_vf,
9217 (void *)&cmd_vf_rate_limit_vfnum,
9218 (void *)&cmd_vf_rate_limit_rate,
9219 (void *)&cmd_vf_rate_limit_ratenum,
9220 (void *)&cmd_vf_rate_limit_q_msk,
9221 (void *)&cmd_vf_rate_limit_q_msk_val,
9226 /* *** ADD TUNNEL FILTER OF A PORT *** */
9227 struct cmd_tunnel_filter_result {
9228 cmdline_fixed_string_t cmd;
9229 cmdline_fixed_string_t what;
9231 struct rte_ether_addr outer_mac;
9232 struct rte_ether_addr inner_mac;
9233 cmdline_ipaddr_t ip_value;
9234 uint16_t inner_vlan;
9235 cmdline_fixed_string_t tunnel_type;
9236 cmdline_fixed_string_t filter_type;
9242 cmd_tunnel_filter_parsed(void *parsed_result,
9243 __rte_unused struct cmdline *cl,
9244 __rte_unused void *data)
9246 struct cmd_tunnel_filter_result *res = parsed_result;
9247 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
9250 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
9252 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
9253 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
9254 tunnel_filter_conf.inner_vlan = res->inner_vlan;
9256 if (res->ip_value.family == AF_INET) {
9257 tunnel_filter_conf.ip_addr.ipv4_addr =
9258 res->ip_value.addr.ipv4.s_addr;
9259 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
9261 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
9262 &(res->ip_value.addr.ipv6),
9263 sizeof(struct in6_addr));
9264 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
9267 if (!strcmp(res->filter_type, "imac-ivlan"))
9268 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
9269 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
9270 tunnel_filter_conf.filter_type =
9271 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
9272 else if (!strcmp(res->filter_type, "imac-tenid"))
9273 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
9274 else if (!strcmp(res->filter_type, "imac"))
9275 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
9276 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
9277 tunnel_filter_conf.filter_type =
9278 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
9279 else if (!strcmp(res->filter_type, "oip"))
9280 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9281 else if (!strcmp(res->filter_type, "iip"))
9282 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9284 printf("The filter type is not supported");
9288 if (!strcmp(res->tunnel_type, "vxlan"))
9289 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9290 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9291 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9292 else if (!strcmp(res->tunnel_type, "nvgre"))
9293 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9294 else if (!strcmp(res->tunnel_type, "ipingre"))
9295 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9297 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9301 tunnel_filter_conf.tenant_id = res->tenant_id;
9302 tunnel_filter_conf.queue_id = res->queue_num;
9303 if (!strcmp(res->what, "add"))
9304 ret = rte_eth_dev_filter_ctrl(res->port_id,
9305 RTE_ETH_FILTER_TUNNEL,
9307 &tunnel_filter_conf);
9309 ret = rte_eth_dev_filter_ctrl(res->port_id,
9310 RTE_ETH_FILTER_TUNNEL,
9311 RTE_ETH_FILTER_DELETE,
9312 &tunnel_filter_conf);
9314 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9318 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9319 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9320 cmd, "tunnel_filter");
9321 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9322 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9324 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9325 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9327 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9328 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9330 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9331 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9333 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9334 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9335 inner_vlan, UINT16);
9336 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9337 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9339 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9340 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9341 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9343 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9344 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9345 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9346 "imac#omac-imac-tenid");
9347 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9348 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9350 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9351 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9354 cmdline_parse_inst_t cmd_tunnel_filter = {
9355 .f = cmd_tunnel_filter_parsed,
9357 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9358 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9359 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9360 "<queue_id>: Add/Rm tunnel filter of a port",
9362 (void *)&cmd_tunnel_filter_cmd,
9363 (void *)&cmd_tunnel_filter_what,
9364 (void *)&cmd_tunnel_filter_port_id,
9365 (void *)&cmd_tunnel_filter_outer_mac,
9366 (void *)&cmd_tunnel_filter_inner_mac,
9367 (void *)&cmd_tunnel_filter_ip_value,
9368 (void *)&cmd_tunnel_filter_innner_vlan,
9369 (void *)&cmd_tunnel_filter_tunnel_type,
9370 (void *)&cmd_tunnel_filter_filter_type,
9371 (void *)&cmd_tunnel_filter_tenant_id,
9372 (void *)&cmd_tunnel_filter_queue_num,
9377 /* *** CONFIGURE TUNNEL UDP PORT *** */
9378 struct cmd_tunnel_udp_config {
9379 cmdline_fixed_string_t cmd;
9380 cmdline_fixed_string_t what;
9386 cmd_tunnel_udp_config_parsed(void *parsed_result,
9387 __rte_unused struct cmdline *cl,
9388 __rte_unused void *data)
9390 struct cmd_tunnel_udp_config *res = parsed_result;
9391 struct rte_eth_udp_tunnel tunnel_udp;
9394 tunnel_udp.udp_port = res->udp_port;
9396 if (!strcmp(res->cmd, "rx_vxlan_port"))
9397 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9399 if (!strcmp(res->what, "add"))
9400 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9403 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9407 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9410 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9411 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9412 cmd, "rx_vxlan_port");
9413 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9414 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9416 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9417 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9419 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9420 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9423 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9424 .f = cmd_tunnel_udp_config_parsed,
9426 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9427 "Add/Remove a tunneling UDP port filter",
9429 (void *)&cmd_tunnel_udp_config_cmd,
9430 (void *)&cmd_tunnel_udp_config_what,
9431 (void *)&cmd_tunnel_udp_config_udp_port,
9432 (void *)&cmd_tunnel_udp_config_port_id,
9437 struct cmd_config_tunnel_udp_port {
9438 cmdline_fixed_string_t port;
9439 cmdline_fixed_string_t config;
9441 cmdline_fixed_string_t udp_tunnel_port;
9442 cmdline_fixed_string_t action;
9443 cmdline_fixed_string_t tunnel_type;
9448 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9449 __rte_unused struct cmdline *cl,
9450 __rte_unused void *data)
9452 struct cmd_config_tunnel_udp_port *res = parsed_result;
9453 struct rte_eth_udp_tunnel tunnel_udp;
9456 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9459 tunnel_udp.udp_port = res->udp_port;
9461 if (!strcmp(res->tunnel_type, "vxlan")) {
9462 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9463 } else if (!strcmp(res->tunnel_type, "geneve")) {
9464 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9465 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9466 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9468 printf("Invalid tunnel type\n");
9472 if (!strcmp(res->action, "add"))
9473 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9476 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9480 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9483 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9484 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9486 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9487 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9489 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9490 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9492 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9493 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9496 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9497 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9499 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9500 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9501 "vxlan#geneve#vxlan-gpe");
9502 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9503 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9506 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9507 .f = cmd_cfg_tunnel_udp_port_parsed,
9509 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9511 (void *)&cmd_config_tunnel_udp_port_port,
9512 (void *)&cmd_config_tunnel_udp_port_config,
9513 (void *)&cmd_config_tunnel_udp_port_port_id,
9514 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9515 (void *)&cmd_config_tunnel_udp_port_action,
9516 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9517 (void *)&cmd_config_tunnel_udp_port_value,
9522 /* *** GLOBAL CONFIG *** */
9523 struct cmd_global_config_result {
9524 cmdline_fixed_string_t cmd;
9526 cmdline_fixed_string_t cfg_type;
9531 cmd_global_config_parsed(void *parsed_result,
9532 __rte_unused struct cmdline *cl,
9533 __rte_unused void *data)
9535 struct cmd_global_config_result *res = parsed_result;
9536 struct rte_eth_global_cfg conf;
9539 memset(&conf, 0, sizeof(conf));
9540 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9541 conf.cfg.gre_key_len = res->len;
9542 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9543 RTE_ETH_FILTER_SET, &conf);
9544 #ifdef RTE_LIBRTE_I40E_PMD
9545 if (ret == -ENOTSUP)
9546 ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len);
9549 printf("Global config error\n");
9552 cmdline_parse_token_string_t cmd_global_config_cmd =
9553 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9555 cmdline_parse_token_num_t cmd_global_config_port_id =
9556 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9558 cmdline_parse_token_string_t cmd_global_config_type =
9559 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9560 cfg_type, "gre-key-len");
9561 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9562 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9565 cmdline_parse_inst_t cmd_global_config = {
9566 .f = cmd_global_config_parsed,
9567 .data = (void *)NULL,
9568 .help_str = "global_config <port_id> gre-key-len <key_len>",
9570 (void *)&cmd_global_config_cmd,
9571 (void *)&cmd_global_config_port_id,
9572 (void *)&cmd_global_config_type,
9573 (void *)&cmd_global_config_gre_key_len,
9578 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9579 struct cmd_set_mirror_mask_result {
9580 cmdline_fixed_string_t set;
9581 cmdline_fixed_string_t port;
9583 cmdline_fixed_string_t mirror;
9585 cmdline_fixed_string_t what;
9586 cmdline_fixed_string_t value;
9587 cmdline_fixed_string_t dstpool;
9589 cmdline_fixed_string_t on;
9592 cmdline_parse_token_string_t cmd_mirror_mask_set =
9593 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9595 cmdline_parse_token_string_t cmd_mirror_mask_port =
9596 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9598 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9599 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9601 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9602 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9603 mirror, "mirror-rule");
9604 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9605 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9607 cmdline_parse_token_string_t cmd_mirror_mask_what =
9608 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9609 what, "pool-mirror-up#pool-mirror-down"
9611 cmdline_parse_token_string_t cmd_mirror_mask_value =
9612 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9614 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9615 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9616 dstpool, "dst-pool");
9617 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9618 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9620 cmdline_parse_token_string_t cmd_mirror_mask_on =
9621 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9625 cmd_set_mirror_mask_parsed(void *parsed_result,
9626 __rte_unused struct cmdline *cl,
9627 __rte_unused void *data)
9630 struct cmd_set_mirror_mask_result *res = parsed_result;
9631 struct rte_eth_mirror_conf mr_conf;
9633 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9635 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9637 mr_conf.dst_pool = res->dstpool_id;
9639 if (!strcmp(res->what, "pool-mirror-up")) {
9640 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9641 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9642 } else if (!strcmp(res->what, "pool-mirror-down")) {
9643 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9644 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9645 } else if (!strcmp(res->what, "vlan-mirror")) {
9646 mr_conf.rule_type = ETH_MIRROR_VLAN;
9647 nb_item = parse_item_list(res->value, "vlan",
9648 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9652 for (i = 0; i < nb_item; i++) {
9653 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9654 printf("Invalid vlan_id: must be < 4096\n");
9658 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9659 mr_conf.vlan.vlan_mask |= 1ULL << i;
9663 if (!strcmp(res->on, "on"))
9664 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9667 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9670 printf("mirror rule add error: (%s)\n", strerror(-ret));
9673 cmdline_parse_inst_t cmd_set_mirror_mask = {
9674 .f = cmd_set_mirror_mask_parsed,
9676 .help_str = "set port <port_id> mirror-rule <rule_id> "
9677 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9678 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9680 (void *)&cmd_mirror_mask_set,
9681 (void *)&cmd_mirror_mask_port,
9682 (void *)&cmd_mirror_mask_portid,
9683 (void *)&cmd_mirror_mask_mirror,
9684 (void *)&cmd_mirror_mask_ruleid,
9685 (void *)&cmd_mirror_mask_what,
9686 (void *)&cmd_mirror_mask_value,
9687 (void *)&cmd_mirror_mask_dstpool,
9688 (void *)&cmd_mirror_mask_poolid,
9689 (void *)&cmd_mirror_mask_on,
9694 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9695 struct cmd_set_mirror_link_result {
9696 cmdline_fixed_string_t set;
9697 cmdline_fixed_string_t port;
9699 cmdline_fixed_string_t mirror;
9701 cmdline_fixed_string_t what;
9702 cmdline_fixed_string_t dstpool;
9704 cmdline_fixed_string_t on;
9707 cmdline_parse_token_string_t cmd_mirror_link_set =
9708 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9710 cmdline_parse_token_string_t cmd_mirror_link_port =
9711 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9713 cmdline_parse_token_num_t cmd_mirror_link_portid =
9714 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9716 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9717 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9718 mirror, "mirror-rule");
9719 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9720 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9722 cmdline_parse_token_string_t cmd_mirror_link_what =
9723 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9724 what, "uplink-mirror#downlink-mirror");
9725 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9726 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9727 dstpool, "dst-pool");
9728 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9729 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9731 cmdline_parse_token_string_t cmd_mirror_link_on =
9732 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9736 cmd_set_mirror_link_parsed(void *parsed_result,
9737 __rte_unused struct cmdline *cl,
9738 __rte_unused void *data)
9741 struct cmd_set_mirror_link_result *res = parsed_result;
9742 struct rte_eth_mirror_conf mr_conf;
9744 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9745 if (!strcmp(res->what, "uplink-mirror"))
9746 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9748 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9750 mr_conf.dst_pool = res->dstpool_id;
9752 if (!strcmp(res->on, "on"))
9753 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9756 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9759 /* check the return value and print it if is < 0 */
9761 printf("mirror rule add error: (%s)\n", strerror(-ret));
9765 cmdline_parse_inst_t cmd_set_mirror_link = {
9766 .f = cmd_set_mirror_link_parsed,
9768 .help_str = "set port <port_id> mirror-rule <rule_id> "
9769 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9771 (void *)&cmd_mirror_link_set,
9772 (void *)&cmd_mirror_link_port,
9773 (void *)&cmd_mirror_link_portid,
9774 (void *)&cmd_mirror_link_mirror,
9775 (void *)&cmd_mirror_link_ruleid,
9776 (void *)&cmd_mirror_link_what,
9777 (void *)&cmd_mirror_link_dstpool,
9778 (void *)&cmd_mirror_link_poolid,
9779 (void *)&cmd_mirror_link_on,
9784 /* *** RESET VM MIRROR RULE *** */
9785 struct cmd_rm_mirror_rule_result {
9786 cmdline_fixed_string_t reset;
9787 cmdline_fixed_string_t port;
9789 cmdline_fixed_string_t mirror;
9793 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9794 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9796 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9797 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9799 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9800 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9802 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9803 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9804 mirror, "mirror-rule");
9805 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9806 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9810 cmd_reset_mirror_rule_parsed(void *parsed_result,
9811 __rte_unused struct cmdline *cl,
9812 __rte_unused void *data)
9815 struct cmd_set_mirror_link_result *res = parsed_result;
9817 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9819 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9822 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9823 .f = cmd_reset_mirror_rule_parsed,
9825 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9827 (void *)&cmd_rm_mirror_rule_reset,
9828 (void *)&cmd_rm_mirror_rule_port,
9829 (void *)&cmd_rm_mirror_rule_portid,
9830 (void *)&cmd_rm_mirror_rule_mirror,
9831 (void *)&cmd_rm_mirror_rule_ruleid,
9836 /* ******************************************************************************** */
9838 struct cmd_dump_result {
9839 cmdline_fixed_string_t dump;
9843 dump_struct_sizes(void)
9845 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9846 DUMP_SIZE(struct rte_mbuf);
9847 DUMP_SIZE(struct rte_mempool);
9848 DUMP_SIZE(struct rte_ring);
9853 /* Dump the socket memory statistics on console */
9855 dump_socket_mem(FILE *f)
9857 struct rte_malloc_socket_stats socket_stats;
9862 unsigned int n_alloc = 0;
9863 unsigned int n_free = 0;
9864 static size_t last_allocs;
9865 static size_t last_total;
9868 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9869 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9870 !socket_stats.heap_totalsz_bytes)
9872 total += socket_stats.heap_totalsz_bytes;
9873 alloc += socket_stats.heap_allocsz_bytes;
9874 free += socket_stats.heap_freesz_bytes;
9875 n_alloc += socket_stats.alloc_count;
9876 n_free += socket_stats.free_count;
9878 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9880 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9881 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9882 (double)socket_stats.heap_allocsz_bytes * 100 /
9883 (double)socket_stats.heap_totalsz_bytes,
9884 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9885 socket_stats.alloc_count,
9886 socket_stats.free_count);
9889 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9890 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9891 (double)alloc * 100 / (double)total,
9892 (double)free / (1024 * 1024),
9895 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9896 ((double)total - (double)last_total) / (1024 * 1024),
9897 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9898 last_allocs = alloc;
9902 static void cmd_dump_parsed(void *parsed_result,
9903 __rte_unused struct cmdline *cl,
9904 __rte_unused void *data)
9906 struct cmd_dump_result *res = parsed_result;
9908 if (!strcmp(res->dump, "dump_physmem"))
9909 rte_dump_physmem_layout(stdout);
9910 else if (!strcmp(res->dump, "dump_socket_mem"))
9911 dump_socket_mem(stdout);
9912 else if (!strcmp(res->dump, "dump_memzone"))
9913 rte_memzone_dump(stdout);
9914 else if (!strcmp(res->dump, "dump_struct_sizes"))
9915 dump_struct_sizes();
9916 else if (!strcmp(res->dump, "dump_ring"))
9917 rte_ring_list_dump(stdout);
9918 else if (!strcmp(res->dump, "dump_mempool"))
9919 rte_mempool_list_dump(stdout);
9920 else if (!strcmp(res->dump, "dump_devargs"))
9921 rte_devargs_dump(stdout);
9922 else if (!strcmp(res->dump, "dump_log_types"))
9923 rte_log_dump(stdout);
9926 cmdline_parse_token_string_t cmd_dump_dump =
9927 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9931 "dump_struct_sizes#"
9937 cmdline_parse_inst_t cmd_dump = {
9938 .f = cmd_dump_parsed, /* function to call */
9939 .data = NULL, /* 2nd arg of func */
9940 .help_str = "Dump status",
9941 .tokens = { /* token list, NULL terminated */
9942 (void *)&cmd_dump_dump,
9947 /* ******************************************************************************** */
9949 struct cmd_dump_one_result {
9950 cmdline_fixed_string_t dump;
9951 cmdline_fixed_string_t name;
9954 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9955 __rte_unused void *data)
9957 struct cmd_dump_one_result *res = parsed_result;
9959 if (!strcmp(res->dump, "dump_ring")) {
9961 r = rte_ring_lookup(res->name);
9963 cmdline_printf(cl, "Cannot find ring\n");
9966 rte_ring_dump(stdout, r);
9967 } else if (!strcmp(res->dump, "dump_mempool")) {
9968 struct rte_mempool *mp;
9969 mp = rte_mempool_lookup(res->name);
9971 cmdline_printf(cl, "Cannot find mempool\n");
9974 rte_mempool_dump(stdout, mp);
9978 cmdline_parse_token_string_t cmd_dump_one_dump =
9979 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9980 "dump_ring#dump_mempool");
9982 cmdline_parse_token_string_t cmd_dump_one_name =
9983 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9985 cmdline_parse_inst_t cmd_dump_one = {
9986 .f = cmd_dump_one_parsed, /* function to call */
9987 .data = NULL, /* 2nd arg of func */
9988 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9989 .tokens = { /* token list, NULL terminated */
9990 (void *)&cmd_dump_one_dump,
9991 (void *)&cmd_dump_one_name,
9996 /* *** Add/Del syn filter *** */
9997 struct cmd_syn_filter_result {
9998 cmdline_fixed_string_t filter;
10000 cmdline_fixed_string_t ops;
10001 cmdline_fixed_string_t priority;
10002 cmdline_fixed_string_t high;
10003 cmdline_fixed_string_t queue;
10008 cmd_syn_filter_parsed(void *parsed_result,
10009 __rte_unused struct cmdline *cl,
10010 __rte_unused void *data)
10012 struct cmd_syn_filter_result *res = parsed_result;
10013 struct rte_eth_syn_filter syn_filter;
10016 ret = rte_eth_dev_filter_supported(res->port_id,
10017 RTE_ETH_FILTER_SYN);
10019 printf("syn filter is not supported on port %u.\n",
10024 memset(&syn_filter, 0, sizeof(syn_filter));
10026 if (!strcmp(res->ops, "add")) {
10027 if (!strcmp(res->high, "high"))
10028 syn_filter.hig_pri = 1;
10030 syn_filter.hig_pri = 0;
10032 syn_filter.queue = res->queue_id;
10033 ret = rte_eth_dev_filter_ctrl(res->port_id,
10034 RTE_ETH_FILTER_SYN,
10035 RTE_ETH_FILTER_ADD,
10038 ret = rte_eth_dev_filter_ctrl(res->port_id,
10039 RTE_ETH_FILTER_SYN,
10040 RTE_ETH_FILTER_DELETE,
10044 printf("syn filter programming error: (%s)\n",
10048 cmdline_parse_token_string_t cmd_syn_filter_filter =
10049 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10050 filter, "syn_filter");
10051 cmdline_parse_token_num_t cmd_syn_filter_port_id =
10052 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
10054 cmdline_parse_token_string_t cmd_syn_filter_ops =
10055 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10057 cmdline_parse_token_string_t cmd_syn_filter_priority =
10058 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10059 priority, "priority");
10060 cmdline_parse_token_string_t cmd_syn_filter_high =
10061 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10063 cmdline_parse_token_string_t cmd_syn_filter_queue =
10064 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10066 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
10067 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
10070 cmdline_parse_inst_t cmd_syn_filter = {
10071 .f = cmd_syn_filter_parsed,
10073 .help_str = "syn_filter <port_id> add|del priority high|low queue "
10074 "<queue_id>: Add/Delete syn filter",
10076 (void *)&cmd_syn_filter_filter,
10077 (void *)&cmd_syn_filter_port_id,
10078 (void *)&cmd_syn_filter_ops,
10079 (void *)&cmd_syn_filter_priority,
10080 (void *)&cmd_syn_filter_high,
10081 (void *)&cmd_syn_filter_queue,
10082 (void *)&cmd_syn_filter_queue_id,
10087 /* *** queue region set *** */
10088 struct cmd_queue_region_result {
10089 cmdline_fixed_string_t set;
10090 cmdline_fixed_string_t port;
10092 cmdline_fixed_string_t cmd;
10093 cmdline_fixed_string_t region;
10095 cmdline_fixed_string_t queue_start_index;
10097 cmdline_fixed_string_t queue_num;
10098 uint8_t queue_num_value;
10102 cmd_queue_region_parsed(void *parsed_result,
10103 __rte_unused struct cmdline *cl,
10104 __rte_unused void *data)
10106 struct cmd_queue_region_result *res = parsed_result;
10107 int ret = -ENOTSUP;
10108 #ifdef RTE_LIBRTE_I40E_PMD
10109 struct rte_pmd_i40e_queue_region_conf region_conf;
10110 enum rte_pmd_i40e_queue_region_op op_type;
10113 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10116 #ifdef RTE_LIBRTE_I40E_PMD
10117 memset(®ion_conf, 0, sizeof(region_conf));
10118 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
10119 region_conf.region_id = res->region_id;
10120 region_conf.queue_num = res->queue_num_value;
10121 region_conf.queue_start_index = res->queue_id;
10123 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10124 op_type, ®ion_conf);
10131 printf("function not implemented or supported\n");
10134 printf("queue region config error: (%s)\n", strerror(-ret));
10138 cmdline_parse_token_string_t cmd_queue_region_set =
10139 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10141 cmdline_parse_token_string_t cmd_queue_region_port =
10142 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10143 cmdline_parse_token_num_t cmd_queue_region_port_id =
10144 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10146 cmdline_parse_token_string_t cmd_queue_region_cmd =
10147 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10148 cmd, "queue-region");
10149 cmdline_parse_token_string_t cmd_queue_region_id =
10150 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10151 region, "region_id");
10152 cmdline_parse_token_num_t cmd_queue_region_index =
10153 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10155 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10156 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10157 queue_start_index, "queue_start_index");
10158 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10159 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10161 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10162 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10163 queue_num, "queue_num");
10164 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10165 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10166 queue_num_value, UINT8);
10168 cmdline_parse_inst_t cmd_queue_region = {
10169 .f = cmd_queue_region_parsed,
10171 .help_str = "set port <port_id> queue-region region_id <value> "
10172 "queue_start_index <value> queue_num <value>: Set a queue region",
10174 (void *)&cmd_queue_region_set,
10175 (void *)&cmd_queue_region_port,
10176 (void *)&cmd_queue_region_port_id,
10177 (void *)&cmd_queue_region_cmd,
10178 (void *)&cmd_queue_region_id,
10179 (void *)&cmd_queue_region_index,
10180 (void *)&cmd_queue_region_queue_start_index,
10181 (void *)&cmd_queue_region_queue_id,
10182 (void *)&cmd_queue_region_queue_num,
10183 (void *)&cmd_queue_region_queue_num_value,
10188 /* *** queue region and flowtype set *** */
10189 struct cmd_region_flowtype_result {
10190 cmdline_fixed_string_t set;
10191 cmdline_fixed_string_t port;
10193 cmdline_fixed_string_t cmd;
10194 cmdline_fixed_string_t region;
10196 cmdline_fixed_string_t flowtype;
10197 uint8_t flowtype_id;
10201 cmd_region_flowtype_parsed(void *parsed_result,
10202 __rte_unused struct cmdline *cl,
10203 __rte_unused void *data)
10205 struct cmd_region_flowtype_result *res = parsed_result;
10206 int ret = -ENOTSUP;
10207 #ifdef RTE_LIBRTE_I40E_PMD
10208 struct rte_pmd_i40e_queue_region_conf region_conf;
10209 enum rte_pmd_i40e_queue_region_op op_type;
10212 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10215 #ifdef RTE_LIBRTE_I40E_PMD
10216 memset(®ion_conf, 0, sizeof(region_conf));
10218 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10219 region_conf.region_id = res->region_id;
10220 region_conf.hw_flowtype = res->flowtype_id;
10222 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10223 op_type, ®ion_conf);
10230 printf("function not implemented or supported\n");
10233 printf("region flowtype config error: (%s)\n", strerror(-ret));
10237 cmdline_parse_token_string_t cmd_region_flowtype_set =
10238 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10240 cmdline_parse_token_string_t cmd_region_flowtype_port =
10241 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10243 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10244 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10246 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10247 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10248 cmd, "queue-region");
10249 cmdline_parse_token_string_t cmd_region_flowtype_index =
10250 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10251 region, "region_id");
10252 cmdline_parse_token_num_t cmd_region_flowtype_id =
10253 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10255 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10256 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10257 flowtype, "flowtype");
10258 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10259 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10260 flowtype_id, UINT8);
10261 cmdline_parse_inst_t cmd_region_flowtype = {
10262 .f = cmd_region_flowtype_parsed,
10264 .help_str = "set port <port_id> queue-region region_id <value> "
10265 "flowtype <value>: Set a flowtype region index",
10267 (void *)&cmd_region_flowtype_set,
10268 (void *)&cmd_region_flowtype_port,
10269 (void *)&cmd_region_flowtype_port_index,
10270 (void *)&cmd_region_flowtype_cmd,
10271 (void *)&cmd_region_flowtype_index,
10272 (void *)&cmd_region_flowtype_id,
10273 (void *)&cmd_region_flowtype_flow_index,
10274 (void *)&cmd_region_flowtype_flow_id,
10279 /* *** User Priority (UP) to queue region (region_id) set *** */
10280 struct cmd_user_priority_region_result {
10281 cmdline_fixed_string_t set;
10282 cmdline_fixed_string_t port;
10284 cmdline_fixed_string_t cmd;
10285 cmdline_fixed_string_t user_priority;
10286 uint8_t user_priority_id;
10287 cmdline_fixed_string_t region;
10292 cmd_user_priority_region_parsed(void *parsed_result,
10293 __rte_unused struct cmdline *cl,
10294 __rte_unused void *data)
10296 struct cmd_user_priority_region_result *res = parsed_result;
10297 int ret = -ENOTSUP;
10298 #ifdef RTE_LIBRTE_I40E_PMD
10299 struct rte_pmd_i40e_queue_region_conf region_conf;
10300 enum rte_pmd_i40e_queue_region_op op_type;
10303 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10306 #ifdef RTE_LIBRTE_I40E_PMD
10307 memset(®ion_conf, 0, sizeof(region_conf));
10308 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10309 region_conf.user_priority = res->user_priority_id;
10310 region_conf.region_id = res->region_id;
10312 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10313 op_type, ®ion_conf);
10320 printf("function not implemented or supported\n");
10323 printf("user_priority region config error: (%s)\n",
10328 cmdline_parse_token_string_t cmd_user_priority_region_set =
10329 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10331 cmdline_parse_token_string_t cmd_user_priority_region_port =
10332 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10334 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10335 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10337 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10338 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10339 cmd, "queue-region");
10340 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10341 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10342 user_priority, "UP");
10343 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10344 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10345 user_priority_id, UINT8);
10346 cmdline_parse_token_string_t cmd_user_priority_region_region =
10347 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10348 region, "region_id");
10349 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10350 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10353 cmdline_parse_inst_t cmd_user_priority_region = {
10354 .f = cmd_user_priority_region_parsed,
10356 .help_str = "set port <port_id> queue-region UP <value> "
10357 "region_id <value>: Set the mapping of User Priority (UP) "
10358 "to queue region (region_id) ",
10360 (void *)&cmd_user_priority_region_set,
10361 (void *)&cmd_user_priority_region_port,
10362 (void *)&cmd_user_priority_region_port_index,
10363 (void *)&cmd_user_priority_region_cmd,
10364 (void *)&cmd_user_priority_region_UP,
10365 (void *)&cmd_user_priority_region_UP_id,
10366 (void *)&cmd_user_priority_region_region,
10367 (void *)&cmd_user_priority_region_region_id,
10372 /* *** flush all queue region related configuration *** */
10373 struct cmd_flush_queue_region_result {
10374 cmdline_fixed_string_t set;
10375 cmdline_fixed_string_t port;
10377 cmdline_fixed_string_t cmd;
10378 cmdline_fixed_string_t flush;
10379 cmdline_fixed_string_t what;
10383 cmd_flush_queue_region_parsed(void *parsed_result,
10384 __rte_unused struct cmdline *cl,
10385 __rte_unused void *data)
10387 struct cmd_flush_queue_region_result *res = parsed_result;
10388 int ret = -ENOTSUP;
10389 #ifdef RTE_LIBRTE_I40E_PMD
10390 struct rte_pmd_i40e_queue_region_conf region_conf;
10391 enum rte_pmd_i40e_queue_region_op op_type;
10394 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10397 #ifdef RTE_LIBRTE_I40E_PMD
10398 memset(®ion_conf, 0, sizeof(region_conf));
10400 if (strcmp(res->what, "on") == 0)
10401 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10403 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10405 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10406 op_type, ®ion_conf);
10413 printf("function not implemented or supported\n");
10416 printf("queue region config flush error: (%s)\n",
10421 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10422 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10424 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10425 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10427 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10428 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10430 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10431 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10432 cmd, "queue-region");
10433 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10434 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10436 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10437 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10440 cmdline_parse_inst_t cmd_flush_queue_region = {
10441 .f = cmd_flush_queue_region_parsed,
10443 .help_str = "set port <port_id> queue-region flush on|off"
10444 ": flush all queue region related configuration",
10446 (void *)&cmd_flush_queue_region_set,
10447 (void *)&cmd_flush_queue_region_port,
10448 (void *)&cmd_flush_queue_region_port_index,
10449 (void *)&cmd_flush_queue_region_cmd,
10450 (void *)&cmd_flush_queue_region_flush,
10451 (void *)&cmd_flush_queue_region_what,
10456 /* *** get all queue region related configuration info *** */
10457 struct cmd_show_queue_region_info {
10458 cmdline_fixed_string_t show;
10459 cmdline_fixed_string_t port;
10461 cmdline_fixed_string_t cmd;
10465 cmd_show_queue_region_info_parsed(void *parsed_result,
10466 __rte_unused struct cmdline *cl,
10467 __rte_unused void *data)
10469 struct cmd_show_queue_region_info *res = parsed_result;
10470 int ret = -ENOTSUP;
10471 #ifdef RTE_LIBRTE_I40E_PMD
10472 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10473 enum rte_pmd_i40e_queue_region_op op_type;
10476 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10479 #ifdef RTE_LIBRTE_I40E_PMD
10480 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10482 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10484 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10485 op_type, &rte_pmd_regions);
10487 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10494 printf("function not implemented or supported\n");
10497 printf("queue region config info show error: (%s)\n",
10502 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10503 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10505 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10506 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10508 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10509 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10511 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10512 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10513 cmd, "queue-region");
10515 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10516 .f = cmd_show_queue_region_info_parsed,
10518 .help_str = "show port <port_id> queue-region"
10519 ": show all queue region related configuration info",
10521 (void *)&cmd_show_queue_region_info_get,
10522 (void *)&cmd_show_queue_region_info_port,
10523 (void *)&cmd_show_queue_region_info_port_index,
10524 (void *)&cmd_show_queue_region_info_cmd,
10529 /* *** ADD/REMOVE A 2tuple FILTER *** */
10530 struct cmd_2tuple_filter_result {
10531 cmdline_fixed_string_t filter;
10533 cmdline_fixed_string_t ops;
10534 cmdline_fixed_string_t dst_port;
10535 uint16_t dst_port_value;
10536 cmdline_fixed_string_t protocol;
10537 uint8_t protocol_value;
10538 cmdline_fixed_string_t mask;
10539 uint8_t mask_value;
10540 cmdline_fixed_string_t tcp_flags;
10541 uint8_t tcp_flags_value;
10542 cmdline_fixed_string_t priority;
10543 uint8_t priority_value;
10544 cmdline_fixed_string_t queue;
10549 cmd_2tuple_filter_parsed(void *parsed_result,
10550 __rte_unused struct cmdline *cl,
10551 __rte_unused void *data)
10553 struct rte_eth_ntuple_filter filter;
10554 struct cmd_2tuple_filter_result *res = parsed_result;
10557 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10559 printf("ntuple filter is not supported on port %u.\n",
10564 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10566 filter.flags = RTE_2TUPLE_FLAGS;
10567 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10568 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10569 filter.proto = res->protocol_value;
10570 filter.priority = res->priority_value;
10571 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10572 printf("nonzero tcp_flags is only meaningful"
10573 " when protocol is TCP.\n");
10576 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10577 printf("invalid TCP flags.\n");
10581 if (res->tcp_flags_value != 0) {
10582 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10583 filter.tcp_flags = res->tcp_flags_value;
10586 /* need convert to big endian. */
10587 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10588 filter.queue = res->queue_id;
10590 if (!strcmp(res->ops, "add"))
10591 ret = rte_eth_dev_filter_ctrl(res->port_id,
10592 RTE_ETH_FILTER_NTUPLE,
10593 RTE_ETH_FILTER_ADD,
10596 ret = rte_eth_dev_filter_ctrl(res->port_id,
10597 RTE_ETH_FILTER_NTUPLE,
10598 RTE_ETH_FILTER_DELETE,
10601 printf("2tuple filter programming error: (%s)\n",
10606 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10607 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10608 filter, "2tuple_filter");
10609 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10610 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10612 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10613 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10615 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10616 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10617 dst_port, "dst_port");
10618 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10619 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10620 dst_port_value, UINT16);
10621 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10622 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10623 protocol, "protocol");
10624 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10625 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10626 protocol_value, UINT8);
10627 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10628 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10630 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10631 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10633 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10634 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10635 tcp_flags, "tcp_flags");
10636 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10637 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10638 tcp_flags_value, UINT8);
10639 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10640 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10641 priority, "priority");
10642 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10643 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10644 priority_value, UINT8);
10645 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10646 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10648 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10649 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10652 cmdline_parse_inst_t cmd_2tuple_filter = {
10653 .f = cmd_2tuple_filter_parsed,
10655 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10656 "<value> mask <value> tcp_flags <value> priority <value> queue "
10657 "<queue_id>: Add a 2tuple filter",
10659 (void *)&cmd_2tuple_filter_filter,
10660 (void *)&cmd_2tuple_filter_port_id,
10661 (void *)&cmd_2tuple_filter_ops,
10662 (void *)&cmd_2tuple_filter_dst_port,
10663 (void *)&cmd_2tuple_filter_dst_port_value,
10664 (void *)&cmd_2tuple_filter_protocol,
10665 (void *)&cmd_2tuple_filter_protocol_value,
10666 (void *)&cmd_2tuple_filter_mask,
10667 (void *)&cmd_2tuple_filter_mask_value,
10668 (void *)&cmd_2tuple_filter_tcp_flags,
10669 (void *)&cmd_2tuple_filter_tcp_flags_value,
10670 (void *)&cmd_2tuple_filter_priority,
10671 (void *)&cmd_2tuple_filter_priority_value,
10672 (void *)&cmd_2tuple_filter_queue,
10673 (void *)&cmd_2tuple_filter_queue_id,
10678 /* *** ADD/REMOVE A 5tuple FILTER *** */
10679 struct cmd_5tuple_filter_result {
10680 cmdline_fixed_string_t filter;
10682 cmdline_fixed_string_t ops;
10683 cmdline_fixed_string_t dst_ip;
10684 cmdline_ipaddr_t dst_ip_value;
10685 cmdline_fixed_string_t src_ip;
10686 cmdline_ipaddr_t src_ip_value;
10687 cmdline_fixed_string_t dst_port;
10688 uint16_t dst_port_value;
10689 cmdline_fixed_string_t src_port;
10690 uint16_t src_port_value;
10691 cmdline_fixed_string_t protocol;
10692 uint8_t protocol_value;
10693 cmdline_fixed_string_t mask;
10694 uint8_t mask_value;
10695 cmdline_fixed_string_t tcp_flags;
10696 uint8_t tcp_flags_value;
10697 cmdline_fixed_string_t priority;
10698 uint8_t priority_value;
10699 cmdline_fixed_string_t queue;
10704 cmd_5tuple_filter_parsed(void *parsed_result,
10705 __rte_unused struct cmdline *cl,
10706 __rte_unused void *data)
10708 struct rte_eth_ntuple_filter filter;
10709 struct cmd_5tuple_filter_result *res = parsed_result;
10712 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10714 printf("ntuple filter is not supported on port %u.\n",
10719 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10721 filter.flags = RTE_5TUPLE_FLAGS;
10722 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10723 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10724 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10725 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10726 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10727 filter.proto = res->protocol_value;
10728 filter.priority = res->priority_value;
10729 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10730 printf("nonzero tcp_flags is only meaningful"
10731 " when protocol is TCP.\n");
10734 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10735 printf("invalid TCP flags.\n");
10739 if (res->tcp_flags_value != 0) {
10740 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10741 filter.tcp_flags = res->tcp_flags_value;
10744 if (res->dst_ip_value.family == AF_INET)
10745 /* no need to convert, already big endian. */
10746 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10748 if (filter.dst_ip_mask == 0) {
10749 printf("can not support ipv6 involved compare.\n");
10755 if (res->src_ip_value.family == AF_INET)
10756 /* no need to convert, already big endian. */
10757 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10759 if (filter.src_ip_mask == 0) {
10760 printf("can not support ipv6 involved compare.\n");
10765 /* need convert to big endian. */
10766 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10767 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10768 filter.queue = res->queue_id;
10770 if (!strcmp(res->ops, "add"))
10771 ret = rte_eth_dev_filter_ctrl(res->port_id,
10772 RTE_ETH_FILTER_NTUPLE,
10773 RTE_ETH_FILTER_ADD,
10776 ret = rte_eth_dev_filter_ctrl(res->port_id,
10777 RTE_ETH_FILTER_NTUPLE,
10778 RTE_ETH_FILTER_DELETE,
10781 printf("5tuple filter programming error: (%s)\n",
10785 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10786 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10787 filter, "5tuple_filter");
10788 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10789 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10791 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10792 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10794 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10795 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10797 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10798 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10800 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10801 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10803 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10804 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10806 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10807 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10808 dst_port, "dst_port");
10809 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10810 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10811 dst_port_value, UINT16);
10812 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10813 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10814 src_port, "src_port");
10815 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10816 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10817 src_port_value, UINT16);
10818 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10819 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10820 protocol, "protocol");
10821 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10822 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10823 protocol_value, UINT8);
10824 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10825 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10827 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10828 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10830 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10831 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10832 tcp_flags, "tcp_flags");
10833 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10834 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10835 tcp_flags_value, UINT8);
10836 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10837 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10838 priority, "priority");
10839 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10840 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10841 priority_value, UINT8);
10842 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10843 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10845 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10846 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10849 cmdline_parse_inst_t cmd_5tuple_filter = {
10850 .f = cmd_5tuple_filter_parsed,
10852 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10853 "src_ip <value> dst_port <value> src_port <value> "
10854 "protocol <value> mask <value> tcp_flags <value> "
10855 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10857 (void *)&cmd_5tuple_filter_filter,
10858 (void *)&cmd_5tuple_filter_port_id,
10859 (void *)&cmd_5tuple_filter_ops,
10860 (void *)&cmd_5tuple_filter_dst_ip,
10861 (void *)&cmd_5tuple_filter_dst_ip_value,
10862 (void *)&cmd_5tuple_filter_src_ip,
10863 (void *)&cmd_5tuple_filter_src_ip_value,
10864 (void *)&cmd_5tuple_filter_dst_port,
10865 (void *)&cmd_5tuple_filter_dst_port_value,
10866 (void *)&cmd_5tuple_filter_src_port,
10867 (void *)&cmd_5tuple_filter_src_port_value,
10868 (void *)&cmd_5tuple_filter_protocol,
10869 (void *)&cmd_5tuple_filter_protocol_value,
10870 (void *)&cmd_5tuple_filter_mask,
10871 (void *)&cmd_5tuple_filter_mask_value,
10872 (void *)&cmd_5tuple_filter_tcp_flags,
10873 (void *)&cmd_5tuple_filter_tcp_flags_value,
10874 (void *)&cmd_5tuple_filter_priority,
10875 (void *)&cmd_5tuple_filter_priority_value,
10876 (void *)&cmd_5tuple_filter_queue,
10877 (void *)&cmd_5tuple_filter_queue_id,
10882 /* *** ADD/REMOVE A flex FILTER *** */
10883 struct cmd_flex_filter_result {
10884 cmdline_fixed_string_t filter;
10885 cmdline_fixed_string_t ops;
10887 cmdline_fixed_string_t len;
10889 cmdline_fixed_string_t bytes;
10890 cmdline_fixed_string_t bytes_value;
10891 cmdline_fixed_string_t mask;
10892 cmdline_fixed_string_t mask_value;
10893 cmdline_fixed_string_t priority;
10894 uint8_t priority_value;
10895 cmdline_fixed_string_t queue;
10899 static int xdigit2val(unsigned char c)
10904 else if (isupper(c))
10905 val = c - 'A' + 10;
10907 val = c - 'a' + 10;
10912 cmd_flex_filter_parsed(void *parsed_result,
10913 __rte_unused struct cmdline *cl,
10914 __rte_unused void *data)
10917 struct rte_eth_flex_filter filter;
10918 struct cmd_flex_filter_result *res = parsed_result;
10919 char *bytes_ptr, *mask_ptr;
10920 uint16_t len, i, j = 0;
10925 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10926 printf("the len exceed the max length 128\n");
10929 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10930 filter.len = res->len_value;
10931 filter.priority = res->priority_value;
10932 filter.queue = res->queue_id;
10933 bytes_ptr = res->bytes_value;
10934 mask_ptr = res->mask_value;
10936 /* translate bytes string to array. */
10937 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10938 (bytes_ptr[1] == 'X')))
10940 len = strnlen(bytes_ptr, res->len_value * 2);
10941 if (len == 0 || (len % 8 != 0)) {
10942 printf("please check len and bytes input\n");
10945 for (i = 0; i < len; i++) {
10947 if (isxdigit(c) == 0) {
10948 /* invalid characters. */
10949 printf("invalid input\n");
10952 val = xdigit2val(c);
10955 filter.bytes[j] = byte;
10956 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10963 /* translate mask string to uint8_t array. */
10964 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10965 (mask_ptr[1] == 'X')))
10967 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10969 printf("invalid input\n");
10974 for (i = 0; i < len; i++) {
10976 if (isxdigit(c) == 0) {
10977 /* invalid characters. */
10978 printf("invalid input\n");
10981 val = xdigit2val(c);
10984 filter.mask[j] = byte;
10985 printf("mask[%d]:%02x ", j, filter.mask[j]);
10993 if (!strcmp(res->ops, "add"))
10994 ret = rte_eth_dev_filter_ctrl(res->port_id,
10995 RTE_ETH_FILTER_FLEXIBLE,
10996 RTE_ETH_FILTER_ADD,
10999 ret = rte_eth_dev_filter_ctrl(res->port_id,
11000 RTE_ETH_FILTER_FLEXIBLE,
11001 RTE_ETH_FILTER_DELETE,
11005 printf("flex filter setting error: (%s)\n", strerror(-ret));
11008 cmdline_parse_token_string_t cmd_flex_filter_filter =
11009 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11010 filter, "flex_filter");
11011 cmdline_parse_token_num_t cmd_flex_filter_port_id =
11012 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11014 cmdline_parse_token_string_t cmd_flex_filter_ops =
11015 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11017 cmdline_parse_token_string_t cmd_flex_filter_len =
11018 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11020 cmdline_parse_token_num_t cmd_flex_filter_len_value =
11021 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11023 cmdline_parse_token_string_t cmd_flex_filter_bytes =
11024 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11026 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
11027 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11028 bytes_value, NULL);
11029 cmdline_parse_token_string_t cmd_flex_filter_mask =
11030 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11032 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
11033 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11035 cmdline_parse_token_string_t cmd_flex_filter_priority =
11036 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11037 priority, "priority");
11038 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
11039 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11040 priority_value, UINT8);
11041 cmdline_parse_token_string_t cmd_flex_filter_queue =
11042 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11044 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
11045 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11047 cmdline_parse_inst_t cmd_flex_filter = {
11048 .f = cmd_flex_filter_parsed,
11050 .help_str = "flex_filter <port_id> add|del len <value> bytes "
11051 "<value> mask <value> priority <value> queue <queue_id>: "
11052 "Add/Del a flex filter",
11054 (void *)&cmd_flex_filter_filter,
11055 (void *)&cmd_flex_filter_port_id,
11056 (void *)&cmd_flex_filter_ops,
11057 (void *)&cmd_flex_filter_len,
11058 (void *)&cmd_flex_filter_len_value,
11059 (void *)&cmd_flex_filter_bytes,
11060 (void *)&cmd_flex_filter_bytes_value,
11061 (void *)&cmd_flex_filter_mask,
11062 (void *)&cmd_flex_filter_mask_value,
11063 (void *)&cmd_flex_filter_priority,
11064 (void *)&cmd_flex_filter_priority_value,
11065 (void *)&cmd_flex_filter_queue,
11066 (void *)&cmd_flex_filter_queue_id,
11071 /* *** Filters Control *** */
11073 /* *** deal with ethertype filter *** */
11074 struct cmd_ethertype_filter_result {
11075 cmdline_fixed_string_t filter;
11077 cmdline_fixed_string_t ops;
11078 cmdline_fixed_string_t mac;
11079 struct rte_ether_addr mac_addr;
11080 cmdline_fixed_string_t ethertype;
11081 uint16_t ethertype_value;
11082 cmdline_fixed_string_t drop;
11083 cmdline_fixed_string_t queue;
11087 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
11088 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11089 filter, "ethertype_filter");
11090 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
11091 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
11093 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
11094 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11096 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
11097 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11098 mac, "mac_addr#mac_ignr");
11099 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
11100 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
11102 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
11103 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11104 ethertype, "ethertype");
11105 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
11106 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
11107 ethertype_value, UINT16);
11108 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
11109 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11111 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
11112 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11114 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
11115 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
11119 cmd_ethertype_filter_parsed(void *parsed_result,
11120 __rte_unused struct cmdline *cl,
11121 __rte_unused void *data)
11123 struct cmd_ethertype_filter_result *res = parsed_result;
11124 struct rte_eth_ethertype_filter filter;
11127 ret = rte_eth_dev_filter_supported(res->port_id,
11128 RTE_ETH_FILTER_ETHERTYPE);
11130 printf("ethertype filter is not supported on port %u.\n",
11135 memset(&filter, 0, sizeof(filter));
11136 if (!strcmp(res->mac, "mac_addr")) {
11137 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
11138 rte_memcpy(&filter.mac_addr, &res->mac_addr,
11139 sizeof(struct rte_ether_addr));
11141 if (!strcmp(res->drop, "drop"))
11142 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
11143 filter.ether_type = res->ethertype_value;
11144 filter.queue = res->queue_id;
11146 if (!strcmp(res->ops, "add"))
11147 ret = rte_eth_dev_filter_ctrl(res->port_id,
11148 RTE_ETH_FILTER_ETHERTYPE,
11149 RTE_ETH_FILTER_ADD,
11152 ret = rte_eth_dev_filter_ctrl(res->port_id,
11153 RTE_ETH_FILTER_ETHERTYPE,
11154 RTE_ETH_FILTER_DELETE,
11157 printf("ethertype filter programming error: (%s)\n",
11161 cmdline_parse_inst_t cmd_ethertype_filter = {
11162 .f = cmd_ethertype_filter_parsed,
11164 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
11165 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
11166 "Add or delete an ethertype filter entry",
11168 (void *)&cmd_ethertype_filter_filter,
11169 (void *)&cmd_ethertype_filter_port_id,
11170 (void *)&cmd_ethertype_filter_ops,
11171 (void *)&cmd_ethertype_filter_mac,
11172 (void *)&cmd_ethertype_filter_mac_addr,
11173 (void *)&cmd_ethertype_filter_ethertype,
11174 (void *)&cmd_ethertype_filter_ethertype_value,
11175 (void *)&cmd_ethertype_filter_drop,
11176 (void *)&cmd_ethertype_filter_queue,
11177 (void *)&cmd_ethertype_filter_queue_id,
11182 /* *** deal with flow director filter *** */
11183 struct cmd_flow_director_result {
11184 cmdline_fixed_string_t flow_director_filter;
11186 cmdline_fixed_string_t mode;
11187 cmdline_fixed_string_t mode_value;
11188 cmdline_fixed_string_t ops;
11189 cmdline_fixed_string_t flow;
11190 cmdline_fixed_string_t flow_type;
11191 cmdline_fixed_string_t ether;
11192 uint16_t ether_type;
11193 cmdline_fixed_string_t src;
11194 cmdline_ipaddr_t ip_src;
11196 cmdline_fixed_string_t dst;
11197 cmdline_ipaddr_t ip_dst;
11199 cmdline_fixed_string_t verify_tag;
11200 uint32_t verify_tag_value;
11201 cmdline_fixed_string_t tos;
11203 cmdline_fixed_string_t proto;
11204 uint8_t proto_value;
11205 cmdline_fixed_string_t ttl;
11207 cmdline_fixed_string_t vlan;
11208 uint16_t vlan_value;
11209 cmdline_fixed_string_t flexbytes;
11210 cmdline_fixed_string_t flexbytes_value;
11211 cmdline_fixed_string_t pf_vf;
11212 cmdline_fixed_string_t drop;
11213 cmdline_fixed_string_t queue;
11215 cmdline_fixed_string_t fd_id;
11216 uint32_t fd_id_value;
11217 cmdline_fixed_string_t mac;
11218 struct rte_ether_addr mac_addr;
11219 cmdline_fixed_string_t tunnel;
11220 cmdline_fixed_string_t tunnel_type;
11221 cmdline_fixed_string_t tunnel_id;
11222 uint32_t tunnel_id_value;
11223 cmdline_fixed_string_t packet;
11228 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
11231 const char *p, *p0 = q_arg;
11233 unsigned long int_fld;
11234 char *str_fld[max_num];
11239 p = strchr(p0, '(');
11243 p0 = strchr(p, ')');
11248 if (size >= sizeof(s))
11251 snprintf(s, sizeof(s), "%.*s", size, p);
11252 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11253 if (ret < 0 || ret > max_num)
11255 for (i = 0; i < ret; i++) {
11257 int_fld = strtoul(str_fld[i], &end, 0);
11258 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
11260 flexbytes[i] = (uint8_t)int_fld;
11266 str2flowtype(char *string)
11269 static const struct {
11272 } flowtype_str[] = {
11273 {"raw", RTE_ETH_FLOW_RAW},
11274 {"ipv4", RTE_ETH_FLOW_IPV4},
11275 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11276 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11277 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11278 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11279 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11280 {"ipv6", RTE_ETH_FLOW_IPV6},
11281 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11282 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11283 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11284 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11285 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11286 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11289 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
11290 if (!strcmp(flowtype_str[i].str, string))
11291 return flowtype_str[i].type;
11294 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
11295 return (uint16_t)atoi(string);
11297 return RTE_ETH_FLOW_UNKNOWN;
11300 static enum rte_eth_fdir_tunnel_type
11301 str2fdir_tunneltype(char *string)
11305 static const struct {
11307 enum rte_eth_fdir_tunnel_type type;
11308 } tunneltype_str[] = {
11309 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
11310 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
11313 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
11314 if (!strcmp(tunneltype_str[i].str, string))
11315 return tunneltype_str[i].type;
11317 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
11320 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
11322 if ((ip_addr).family == AF_INET) \
11323 (ip) = (ip_addr).addr.ipv4.s_addr; \
11325 printf("invalid parameter.\n"); \
11330 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
11332 if ((ip_addr).family == AF_INET6) \
11333 rte_memcpy(&(ip), \
11334 &((ip_addr).addr.ipv6), \
11335 sizeof(struct in6_addr)); \
11337 printf("invalid parameter.\n"); \
11343 cmd_flow_director_filter_parsed(void *parsed_result,
11344 __rte_unused struct cmdline *cl,
11345 __rte_unused void *data)
11347 struct cmd_flow_director_result *res = parsed_result;
11348 struct rte_eth_fdir_filter entry;
11349 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11351 unsigned long vf_id;
11354 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11356 printf("flow director is not supported on port %u.\n",
11360 memset(flexbytes, 0, sizeof(flexbytes));
11361 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11363 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11364 if (strcmp(res->mode_value, "MAC-VLAN")) {
11365 printf("Please set mode to MAC-VLAN.\n");
11368 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11369 if (strcmp(res->mode_value, "Tunnel")) {
11370 printf("Please set mode to Tunnel.\n");
11374 if (!strcmp(res->mode_value, "raw")) {
11375 #ifdef RTE_LIBRTE_I40E_PMD
11376 struct rte_pmd_i40e_flow_type_mapping
11377 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11378 struct rte_pmd_i40e_pkt_template_conf conf;
11379 uint16_t flow_type = str2flowtype(res->flow_type);
11380 uint16_t i, port = res->port_id;
11383 memset(&conf, 0, sizeof(conf));
11385 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11386 printf("Invalid flow type specified.\n");
11389 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11393 if (mapping[flow_type].pctype == 0ULL) {
11394 printf("Invalid flow type specified.\n");
11397 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11398 if (mapping[flow_type].pctype & (1ULL << i)) {
11399 conf.input.pctype = i;
11404 conf.input.packet = open_file(res->filepath,
11405 &conf.input.length);
11406 if (!conf.input.packet)
11408 if (!strcmp(res->drop, "drop"))
11409 conf.action.behavior =
11410 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11412 conf.action.behavior =
11413 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11414 conf.action.report_status =
11415 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11416 conf.action.rx_queue = res->queue_id;
11417 conf.soft_id = res->fd_id_value;
11418 add = strcmp(res->ops, "del") ? 1 : 0;
11419 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11423 printf("flow director config error: (%s)\n",
11425 close_file(conf.input.packet);
11428 } else if (strcmp(res->mode_value, "IP")) {
11429 printf("Please set mode to IP or raw.\n");
11432 entry.input.flow_type = str2flowtype(res->flow_type);
11435 ret = parse_flexbytes(res->flexbytes_value,
11437 RTE_ETH_FDIR_MAX_FLEXLEN);
11439 printf("error: Cannot parse flexbytes input.\n");
11443 switch (entry.input.flow_type) {
11444 case RTE_ETH_FLOW_FRAG_IPV4:
11445 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11446 entry.input.flow.ip4_flow.proto = res->proto_value;
11448 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11449 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11450 IPV4_ADDR_TO_UINT(res->ip_dst,
11451 entry.input.flow.ip4_flow.dst_ip);
11452 IPV4_ADDR_TO_UINT(res->ip_src,
11453 entry.input.flow.ip4_flow.src_ip);
11454 entry.input.flow.ip4_flow.tos = res->tos_value;
11455 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11456 /* need convert to big endian. */
11457 entry.input.flow.udp4_flow.dst_port =
11458 rte_cpu_to_be_16(res->port_dst);
11459 entry.input.flow.udp4_flow.src_port =
11460 rte_cpu_to_be_16(res->port_src);
11462 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11463 IPV4_ADDR_TO_UINT(res->ip_dst,
11464 entry.input.flow.sctp4_flow.ip.dst_ip);
11465 IPV4_ADDR_TO_UINT(res->ip_src,
11466 entry.input.flow.sctp4_flow.ip.src_ip);
11467 entry.input.flow.ip4_flow.tos = res->tos_value;
11468 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11469 /* need convert to big endian. */
11470 entry.input.flow.sctp4_flow.dst_port =
11471 rte_cpu_to_be_16(res->port_dst);
11472 entry.input.flow.sctp4_flow.src_port =
11473 rte_cpu_to_be_16(res->port_src);
11474 entry.input.flow.sctp4_flow.verify_tag =
11475 rte_cpu_to_be_32(res->verify_tag_value);
11477 case RTE_ETH_FLOW_FRAG_IPV6:
11478 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11479 entry.input.flow.ipv6_flow.proto = res->proto_value;
11481 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11482 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11483 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11484 entry.input.flow.ipv6_flow.dst_ip);
11485 IPV6_ADDR_TO_ARRAY(res->ip_src,
11486 entry.input.flow.ipv6_flow.src_ip);
11487 entry.input.flow.ipv6_flow.tc = res->tos_value;
11488 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11489 /* need convert to big endian. */
11490 entry.input.flow.udp6_flow.dst_port =
11491 rte_cpu_to_be_16(res->port_dst);
11492 entry.input.flow.udp6_flow.src_port =
11493 rte_cpu_to_be_16(res->port_src);
11495 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11496 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11497 entry.input.flow.sctp6_flow.ip.dst_ip);
11498 IPV6_ADDR_TO_ARRAY(res->ip_src,
11499 entry.input.flow.sctp6_flow.ip.src_ip);
11500 entry.input.flow.ipv6_flow.tc = res->tos_value;
11501 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11502 /* need convert to big endian. */
11503 entry.input.flow.sctp6_flow.dst_port =
11504 rte_cpu_to_be_16(res->port_dst);
11505 entry.input.flow.sctp6_flow.src_port =
11506 rte_cpu_to_be_16(res->port_src);
11507 entry.input.flow.sctp6_flow.verify_tag =
11508 rte_cpu_to_be_32(res->verify_tag_value);
11510 case RTE_ETH_FLOW_L2_PAYLOAD:
11511 entry.input.flow.l2_flow.ether_type =
11512 rte_cpu_to_be_16(res->ether_type);
11518 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11519 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11521 sizeof(struct rte_ether_addr));
11523 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11524 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11526 sizeof(struct rte_ether_addr));
11527 entry.input.flow.tunnel_flow.tunnel_type =
11528 str2fdir_tunneltype(res->tunnel_type);
11529 entry.input.flow.tunnel_flow.tunnel_id =
11530 rte_cpu_to_be_32(res->tunnel_id_value);
11533 rte_memcpy(entry.input.flow_ext.flexbytes,
11535 RTE_ETH_FDIR_MAX_FLEXLEN);
11537 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11539 entry.action.flex_off = 0; /*use 0 by default */
11540 if (!strcmp(res->drop, "drop"))
11541 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11543 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11545 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11546 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11547 if (!strcmp(res->pf_vf, "pf"))
11548 entry.input.flow_ext.is_vf = 0;
11549 else if (!strncmp(res->pf_vf, "vf", 2)) {
11550 struct rte_eth_dev_info dev_info;
11552 ret = eth_dev_info_get_print_err(res->port_id,
11558 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11559 if (errno != 0 || *end != '\0' ||
11560 vf_id >= dev_info.max_vfs) {
11561 printf("invalid parameter %s.\n", res->pf_vf);
11564 entry.input.flow_ext.is_vf = 1;
11565 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11567 printf("invalid parameter %s.\n", res->pf_vf);
11572 /* set to report FD ID by default */
11573 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11574 entry.action.rx_queue = res->queue_id;
11575 entry.soft_id = res->fd_id_value;
11576 if (!strcmp(res->ops, "add"))
11577 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11578 RTE_ETH_FILTER_ADD, &entry);
11579 else if (!strcmp(res->ops, "del"))
11580 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11581 RTE_ETH_FILTER_DELETE, &entry);
11583 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11584 RTE_ETH_FILTER_UPDATE, &entry);
11586 printf("flow director programming error: (%s)\n",
11590 cmdline_parse_token_string_t cmd_flow_director_filter =
11591 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11592 flow_director_filter, "flow_director_filter");
11593 cmdline_parse_token_num_t cmd_flow_director_port_id =
11594 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11596 cmdline_parse_token_string_t cmd_flow_director_ops =
11597 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11598 ops, "add#del#update");
11599 cmdline_parse_token_string_t cmd_flow_director_flow =
11600 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11602 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11603 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11605 cmdline_parse_token_string_t cmd_flow_director_ether =
11606 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11608 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11609 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11610 ether_type, UINT16);
11611 cmdline_parse_token_string_t cmd_flow_director_src =
11612 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11614 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11615 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11617 cmdline_parse_token_num_t cmd_flow_director_port_src =
11618 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11620 cmdline_parse_token_string_t cmd_flow_director_dst =
11621 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11623 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11624 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11626 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11627 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11629 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11630 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11631 verify_tag, "verify_tag");
11632 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11633 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11634 verify_tag_value, UINT32);
11635 cmdline_parse_token_string_t cmd_flow_director_tos =
11636 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11638 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11639 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11641 cmdline_parse_token_string_t cmd_flow_director_proto =
11642 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11644 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11645 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11646 proto_value, UINT8);
11647 cmdline_parse_token_string_t cmd_flow_director_ttl =
11648 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11650 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11651 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11653 cmdline_parse_token_string_t cmd_flow_director_vlan =
11654 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11656 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11657 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11658 vlan_value, UINT16);
11659 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11660 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11661 flexbytes, "flexbytes");
11662 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11663 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11664 flexbytes_value, NULL);
11665 cmdline_parse_token_string_t cmd_flow_director_drop =
11666 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11668 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11669 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11671 cmdline_parse_token_string_t cmd_flow_director_queue =
11672 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11674 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11675 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11677 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11678 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11680 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11681 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11682 fd_id_value, UINT32);
11684 cmdline_parse_token_string_t cmd_flow_director_mode =
11685 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11687 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11688 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11690 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11691 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11692 mode_value, "MAC-VLAN");
11693 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11694 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11695 mode_value, "Tunnel");
11696 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11697 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11698 mode_value, "raw");
11699 cmdline_parse_token_string_t cmd_flow_director_mac =
11700 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11702 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11703 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11705 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11706 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11708 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11709 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11710 tunnel_type, "NVGRE#VxLAN");
11711 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11712 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11713 tunnel_id, "tunnel-id");
11714 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11715 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11716 tunnel_id_value, UINT32);
11717 cmdline_parse_token_string_t cmd_flow_director_packet =
11718 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11720 cmdline_parse_token_string_t cmd_flow_director_filepath =
11721 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11724 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11725 .f = cmd_flow_director_filter_parsed,
11727 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11728 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11729 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11730 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11731 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11732 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11733 "fd_id <fd_id_value>: "
11734 "Add or delete an ip flow director entry on NIC",
11736 (void *)&cmd_flow_director_filter,
11737 (void *)&cmd_flow_director_port_id,
11738 (void *)&cmd_flow_director_mode,
11739 (void *)&cmd_flow_director_mode_ip,
11740 (void *)&cmd_flow_director_ops,
11741 (void *)&cmd_flow_director_flow,
11742 (void *)&cmd_flow_director_flow_type,
11743 (void *)&cmd_flow_director_src,
11744 (void *)&cmd_flow_director_ip_src,
11745 (void *)&cmd_flow_director_dst,
11746 (void *)&cmd_flow_director_ip_dst,
11747 (void *)&cmd_flow_director_tos,
11748 (void *)&cmd_flow_director_tos_value,
11749 (void *)&cmd_flow_director_proto,
11750 (void *)&cmd_flow_director_proto_value,
11751 (void *)&cmd_flow_director_ttl,
11752 (void *)&cmd_flow_director_ttl_value,
11753 (void *)&cmd_flow_director_vlan,
11754 (void *)&cmd_flow_director_vlan_value,
11755 (void *)&cmd_flow_director_flexbytes,
11756 (void *)&cmd_flow_director_flexbytes_value,
11757 (void *)&cmd_flow_director_drop,
11758 (void *)&cmd_flow_director_pf_vf,
11759 (void *)&cmd_flow_director_queue,
11760 (void *)&cmd_flow_director_queue_id,
11761 (void *)&cmd_flow_director_fd_id,
11762 (void *)&cmd_flow_director_fd_id_value,
11767 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11768 .f = cmd_flow_director_filter_parsed,
11770 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11771 "director entry on NIC",
11773 (void *)&cmd_flow_director_filter,
11774 (void *)&cmd_flow_director_port_id,
11775 (void *)&cmd_flow_director_mode,
11776 (void *)&cmd_flow_director_mode_ip,
11777 (void *)&cmd_flow_director_ops,
11778 (void *)&cmd_flow_director_flow,
11779 (void *)&cmd_flow_director_flow_type,
11780 (void *)&cmd_flow_director_src,
11781 (void *)&cmd_flow_director_ip_src,
11782 (void *)&cmd_flow_director_port_src,
11783 (void *)&cmd_flow_director_dst,
11784 (void *)&cmd_flow_director_ip_dst,
11785 (void *)&cmd_flow_director_port_dst,
11786 (void *)&cmd_flow_director_tos,
11787 (void *)&cmd_flow_director_tos_value,
11788 (void *)&cmd_flow_director_ttl,
11789 (void *)&cmd_flow_director_ttl_value,
11790 (void *)&cmd_flow_director_vlan,
11791 (void *)&cmd_flow_director_vlan_value,
11792 (void *)&cmd_flow_director_flexbytes,
11793 (void *)&cmd_flow_director_flexbytes_value,
11794 (void *)&cmd_flow_director_drop,
11795 (void *)&cmd_flow_director_pf_vf,
11796 (void *)&cmd_flow_director_queue,
11797 (void *)&cmd_flow_director_queue_id,
11798 (void *)&cmd_flow_director_fd_id,
11799 (void *)&cmd_flow_director_fd_id_value,
11804 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11805 .f = cmd_flow_director_filter_parsed,
11807 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11808 "director entry on NIC",
11810 (void *)&cmd_flow_director_filter,
11811 (void *)&cmd_flow_director_port_id,
11812 (void *)&cmd_flow_director_mode,
11813 (void *)&cmd_flow_director_mode_ip,
11814 (void *)&cmd_flow_director_ops,
11815 (void *)&cmd_flow_director_flow,
11816 (void *)&cmd_flow_director_flow_type,
11817 (void *)&cmd_flow_director_src,
11818 (void *)&cmd_flow_director_ip_src,
11819 (void *)&cmd_flow_director_port_src,
11820 (void *)&cmd_flow_director_dst,
11821 (void *)&cmd_flow_director_ip_dst,
11822 (void *)&cmd_flow_director_port_dst,
11823 (void *)&cmd_flow_director_verify_tag,
11824 (void *)&cmd_flow_director_verify_tag_value,
11825 (void *)&cmd_flow_director_tos,
11826 (void *)&cmd_flow_director_tos_value,
11827 (void *)&cmd_flow_director_ttl,
11828 (void *)&cmd_flow_director_ttl_value,
11829 (void *)&cmd_flow_director_vlan,
11830 (void *)&cmd_flow_director_vlan_value,
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_l2_flow_director = {
11844 .f = cmd_flow_director_filter_parsed,
11846 .help_str = "flow_director_filter ... : Add or delete a L2 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_ip,
11853 (void *)&cmd_flow_director_ops,
11854 (void *)&cmd_flow_director_flow,
11855 (void *)&cmd_flow_director_flow_type,
11856 (void *)&cmd_flow_director_ether,
11857 (void *)&cmd_flow_director_ether_type,
11858 (void *)&cmd_flow_director_flexbytes,
11859 (void *)&cmd_flow_director_flexbytes_value,
11860 (void *)&cmd_flow_director_drop,
11861 (void *)&cmd_flow_director_pf_vf,
11862 (void *)&cmd_flow_director_queue,
11863 (void *)&cmd_flow_director_queue_id,
11864 (void *)&cmd_flow_director_fd_id,
11865 (void *)&cmd_flow_director_fd_id_value,
11870 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11871 .f = cmd_flow_director_filter_parsed,
11873 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11874 "director entry on NIC",
11876 (void *)&cmd_flow_director_filter,
11877 (void *)&cmd_flow_director_port_id,
11878 (void *)&cmd_flow_director_mode,
11879 (void *)&cmd_flow_director_mode_mac_vlan,
11880 (void *)&cmd_flow_director_ops,
11881 (void *)&cmd_flow_director_mac,
11882 (void *)&cmd_flow_director_mac_addr,
11883 (void *)&cmd_flow_director_vlan,
11884 (void *)&cmd_flow_director_vlan_value,
11885 (void *)&cmd_flow_director_flexbytes,
11886 (void *)&cmd_flow_director_flexbytes_value,
11887 (void *)&cmd_flow_director_drop,
11888 (void *)&cmd_flow_director_queue,
11889 (void *)&cmd_flow_director_queue_id,
11890 (void *)&cmd_flow_director_fd_id,
11891 (void *)&cmd_flow_director_fd_id_value,
11896 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11897 .f = cmd_flow_director_filter_parsed,
11899 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11900 "director entry on NIC",
11902 (void *)&cmd_flow_director_filter,
11903 (void *)&cmd_flow_director_port_id,
11904 (void *)&cmd_flow_director_mode,
11905 (void *)&cmd_flow_director_mode_tunnel,
11906 (void *)&cmd_flow_director_ops,
11907 (void *)&cmd_flow_director_mac,
11908 (void *)&cmd_flow_director_mac_addr,
11909 (void *)&cmd_flow_director_vlan,
11910 (void *)&cmd_flow_director_vlan_value,
11911 (void *)&cmd_flow_director_tunnel,
11912 (void *)&cmd_flow_director_tunnel_type,
11913 (void *)&cmd_flow_director_tunnel_id,
11914 (void *)&cmd_flow_director_tunnel_id_value,
11915 (void *)&cmd_flow_director_flexbytes,
11916 (void *)&cmd_flow_director_flexbytes_value,
11917 (void *)&cmd_flow_director_drop,
11918 (void *)&cmd_flow_director_queue,
11919 (void *)&cmd_flow_director_queue_id,
11920 (void *)&cmd_flow_director_fd_id,
11921 (void *)&cmd_flow_director_fd_id_value,
11926 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11927 .f = cmd_flow_director_filter_parsed,
11929 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11930 "director entry on NIC",
11932 (void *)&cmd_flow_director_filter,
11933 (void *)&cmd_flow_director_port_id,
11934 (void *)&cmd_flow_director_mode,
11935 (void *)&cmd_flow_director_mode_raw,
11936 (void *)&cmd_flow_director_ops,
11937 (void *)&cmd_flow_director_flow,
11938 (void *)&cmd_flow_director_flow_type,
11939 (void *)&cmd_flow_director_drop,
11940 (void *)&cmd_flow_director_queue,
11941 (void *)&cmd_flow_director_queue_id,
11942 (void *)&cmd_flow_director_fd_id,
11943 (void *)&cmd_flow_director_fd_id_value,
11944 (void *)&cmd_flow_director_packet,
11945 (void *)&cmd_flow_director_filepath,
11950 struct cmd_flush_flow_director_result {
11951 cmdline_fixed_string_t flush_flow_director;
11955 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11956 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11957 flush_flow_director, "flush_flow_director");
11958 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11959 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11963 cmd_flush_flow_director_parsed(void *parsed_result,
11964 __rte_unused struct cmdline *cl,
11965 __rte_unused void *data)
11967 struct cmd_flow_director_result *res = parsed_result;
11970 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11972 printf("flow director is not supported on port %u.\n",
11977 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11978 RTE_ETH_FILTER_FLUSH, NULL);
11980 printf("flow director table flushing error: (%s)\n",
11984 cmdline_parse_inst_t cmd_flush_flow_director = {
11985 .f = cmd_flush_flow_director_parsed,
11987 .help_str = "flush_flow_director <port_id>: "
11988 "Flush all flow director entries of a device on NIC",
11990 (void *)&cmd_flush_flow_director_flush,
11991 (void *)&cmd_flush_flow_director_port_id,
11996 /* *** deal with flow director mask *** */
11997 struct cmd_flow_director_mask_result {
11998 cmdline_fixed_string_t flow_director_mask;
12000 cmdline_fixed_string_t mode;
12001 cmdline_fixed_string_t mode_value;
12002 cmdline_fixed_string_t vlan;
12003 uint16_t vlan_mask;
12004 cmdline_fixed_string_t src_mask;
12005 cmdline_ipaddr_t ipv4_src;
12006 cmdline_ipaddr_t ipv6_src;
12008 cmdline_fixed_string_t dst_mask;
12009 cmdline_ipaddr_t ipv4_dst;
12010 cmdline_ipaddr_t ipv6_dst;
12012 cmdline_fixed_string_t mac;
12013 uint8_t mac_addr_byte_mask;
12014 cmdline_fixed_string_t tunnel_id;
12015 uint32_t tunnel_id_mask;
12016 cmdline_fixed_string_t tunnel_type;
12017 uint8_t tunnel_type_mask;
12021 cmd_flow_director_mask_parsed(void *parsed_result,
12022 __rte_unused struct cmdline *cl,
12023 __rte_unused void *data)
12025 struct cmd_flow_director_mask_result *res = parsed_result;
12026 struct rte_eth_fdir_masks *mask;
12027 struct rte_port *port;
12029 port = &ports[res->port_id];
12030 /** Check if the port is not started **/
12031 if (port->port_status != RTE_PORT_STOPPED) {
12032 printf("Please stop port %d first\n", res->port_id);
12036 mask = &port->dev_conf.fdir_conf.mask;
12038 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
12039 if (strcmp(res->mode_value, "MAC-VLAN")) {
12040 printf("Please set mode to MAC-VLAN.\n");
12044 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
12045 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
12046 if (strcmp(res->mode_value, "Tunnel")) {
12047 printf("Please set mode to Tunnel.\n");
12051 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
12052 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
12053 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
12054 mask->tunnel_type_mask = res->tunnel_type_mask;
12056 if (strcmp(res->mode_value, "IP")) {
12057 printf("Please set mode to IP.\n");
12061 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
12062 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
12063 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
12064 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
12065 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
12066 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
12067 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
12070 cmd_reconfig_device_queue(res->port_id, 1, 1);
12073 cmdline_parse_token_string_t cmd_flow_director_mask =
12074 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12075 flow_director_mask, "flow_director_mask");
12076 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
12077 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12079 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
12080 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12082 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
12083 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12084 vlan_mask, UINT16);
12085 cmdline_parse_token_string_t cmd_flow_director_mask_src =
12086 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12087 src_mask, "src_mask");
12088 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
12089 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12091 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
12092 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12094 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
12095 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12097 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
12098 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12099 dst_mask, "dst_mask");
12100 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
12101 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12103 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
12104 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12106 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
12107 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12110 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
12111 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12113 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
12114 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12116 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
12117 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12118 mode_value, "MAC-VLAN");
12119 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
12120 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12121 mode_value, "Tunnel");
12122 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
12123 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12125 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
12126 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12127 mac_addr_byte_mask, UINT8);
12128 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
12129 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12130 tunnel_type, "tunnel-type");
12131 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
12132 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12133 tunnel_type_mask, UINT8);
12134 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
12135 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12136 tunnel_id, "tunnel-id");
12137 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
12138 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12139 tunnel_id_mask, UINT32);
12141 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
12142 .f = cmd_flow_director_mask_parsed,
12144 .help_str = "flow_director_mask ... : "
12145 "Set IP mode flow director's mask on NIC",
12147 (void *)&cmd_flow_director_mask,
12148 (void *)&cmd_flow_director_mask_port_id,
12149 (void *)&cmd_flow_director_mask_mode,
12150 (void *)&cmd_flow_director_mask_mode_ip,
12151 (void *)&cmd_flow_director_mask_vlan,
12152 (void *)&cmd_flow_director_mask_vlan_value,
12153 (void *)&cmd_flow_director_mask_src,
12154 (void *)&cmd_flow_director_mask_ipv4_src,
12155 (void *)&cmd_flow_director_mask_ipv6_src,
12156 (void *)&cmd_flow_director_mask_port_src,
12157 (void *)&cmd_flow_director_mask_dst,
12158 (void *)&cmd_flow_director_mask_ipv4_dst,
12159 (void *)&cmd_flow_director_mask_ipv6_dst,
12160 (void *)&cmd_flow_director_mask_port_dst,
12165 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
12166 .f = cmd_flow_director_mask_parsed,
12168 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
12169 "flow director's mask on NIC",
12171 (void *)&cmd_flow_director_mask,
12172 (void *)&cmd_flow_director_mask_port_id,
12173 (void *)&cmd_flow_director_mask_mode,
12174 (void *)&cmd_flow_director_mask_mode_mac_vlan,
12175 (void *)&cmd_flow_director_mask_vlan,
12176 (void *)&cmd_flow_director_mask_vlan_value,
12181 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
12182 .f = cmd_flow_director_mask_parsed,
12184 .help_str = "flow_director_mask ... : Set tunnel mode "
12185 "flow director's mask on NIC",
12187 (void *)&cmd_flow_director_mask,
12188 (void *)&cmd_flow_director_mask_port_id,
12189 (void *)&cmd_flow_director_mask_mode,
12190 (void *)&cmd_flow_director_mask_mode_tunnel,
12191 (void *)&cmd_flow_director_mask_vlan,
12192 (void *)&cmd_flow_director_mask_vlan_value,
12193 (void *)&cmd_flow_director_mask_mac,
12194 (void *)&cmd_flow_director_mask_mac_value,
12195 (void *)&cmd_flow_director_mask_tunnel_type,
12196 (void *)&cmd_flow_director_mask_tunnel_type_value,
12197 (void *)&cmd_flow_director_mask_tunnel_id,
12198 (void *)&cmd_flow_director_mask_tunnel_id_value,
12203 /* *** deal with flow director mask on flexible payload *** */
12204 struct cmd_flow_director_flex_mask_result {
12205 cmdline_fixed_string_t flow_director_flexmask;
12207 cmdline_fixed_string_t flow;
12208 cmdline_fixed_string_t flow_type;
12209 cmdline_fixed_string_t mask;
12213 cmd_flow_director_flex_mask_parsed(void *parsed_result,
12214 __rte_unused struct cmdline *cl,
12215 __rte_unused void *data)
12217 struct cmd_flow_director_flex_mask_result *res = parsed_result;
12218 struct rte_eth_fdir_info fdir_info;
12219 struct rte_eth_fdir_flex_mask flex_mask;
12220 struct rte_port *port;
12221 uint64_t flow_type_mask;
12225 port = &ports[res->port_id];
12226 /** Check if the port is not started **/
12227 if (port->port_status != RTE_PORT_STOPPED) {
12228 printf("Please stop port %d first\n", res->port_id);
12232 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
12233 ret = parse_flexbytes(res->mask,
12235 RTE_ETH_FDIR_MAX_FLEXLEN);
12237 printf("error: Cannot parse mask input.\n");
12241 memset(&fdir_info, 0, sizeof(fdir_info));
12242 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12243 RTE_ETH_FILTER_INFO, &fdir_info);
12245 printf("Cannot get FDir filter info\n");
12249 if (!strcmp(res->flow_type, "none")) {
12250 /* means don't specify the flow type */
12251 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
12252 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
12253 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
12254 0, sizeof(struct rte_eth_fdir_flex_mask));
12255 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
12256 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
12258 sizeof(struct rte_eth_fdir_flex_mask));
12259 cmd_reconfig_device_queue(res->port_id, 1, 1);
12262 flow_type_mask = fdir_info.flow_types_mask[0];
12263 if (!strcmp(res->flow_type, "all")) {
12264 if (!flow_type_mask) {
12265 printf("No flow type supported\n");
12268 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
12269 if (flow_type_mask & (1ULL << i)) {
12270 flex_mask.flow_type = i;
12271 fdir_set_flex_mask(res->port_id, &flex_mask);
12274 cmd_reconfig_device_queue(res->port_id, 1, 1);
12277 flex_mask.flow_type = str2flowtype(res->flow_type);
12278 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
12279 printf("Flow type %s not supported on port %d\n",
12280 res->flow_type, res->port_id);
12283 fdir_set_flex_mask(res->port_id, &flex_mask);
12284 cmd_reconfig_device_queue(res->port_id, 1, 1);
12287 cmdline_parse_token_string_t cmd_flow_director_flexmask =
12288 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12289 flow_director_flexmask,
12290 "flow_director_flex_mask");
12291 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
12292 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12294 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
12295 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12297 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
12298 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12299 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
12300 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
12301 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
12302 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12305 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
12306 .f = cmd_flow_director_flex_mask_parsed,
12308 .help_str = "flow_director_flex_mask ... : "
12309 "Set flow director's flex mask on NIC",
12311 (void *)&cmd_flow_director_flexmask,
12312 (void *)&cmd_flow_director_flexmask_port_id,
12313 (void *)&cmd_flow_director_flexmask_flow,
12314 (void *)&cmd_flow_director_flexmask_flow_type,
12315 (void *)&cmd_flow_director_flexmask_mask,
12320 /* *** deal with flow director flexible payload configuration *** */
12321 struct cmd_flow_director_flexpayload_result {
12322 cmdline_fixed_string_t flow_director_flexpayload;
12324 cmdline_fixed_string_t payload_layer;
12325 cmdline_fixed_string_t payload_cfg;
12329 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
12332 const char *p, *p0 = q_arg;
12334 unsigned long int_fld;
12335 char *str_fld[max_num];
12340 p = strchr(p0, '(');
12344 p0 = strchr(p, ')');
12349 if (size >= sizeof(s))
12352 snprintf(s, sizeof(s), "%.*s", size, p);
12353 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12354 if (ret < 0 || ret > max_num)
12356 for (i = 0; i < ret; i++) {
12358 int_fld = strtoul(str_fld[i], &end, 0);
12359 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12361 offsets[i] = (uint16_t)int_fld;
12367 cmd_flow_director_flxpld_parsed(void *parsed_result,
12368 __rte_unused struct cmdline *cl,
12369 __rte_unused void *data)
12371 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12372 struct rte_eth_flex_payload_cfg flex_cfg;
12373 struct rte_port *port;
12376 port = &ports[res->port_id];
12377 /** Check if the port is not started **/
12378 if (port->port_status != RTE_PORT_STOPPED) {
12379 printf("Please stop port %d first\n", res->port_id);
12383 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12385 if (!strcmp(res->payload_layer, "raw"))
12386 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12387 else if (!strcmp(res->payload_layer, "l2"))
12388 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12389 else if (!strcmp(res->payload_layer, "l3"))
12390 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12391 else if (!strcmp(res->payload_layer, "l4"))
12392 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12394 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12395 RTE_ETH_FDIR_MAX_FLEXLEN);
12397 printf("error: Cannot parse flex payload input.\n");
12401 fdir_set_flex_payload(res->port_id, &flex_cfg);
12402 cmd_reconfig_device_queue(res->port_id, 1, 1);
12405 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12406 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12407 flow_director_flexpayload,
12408 "flow_director_flex_payload");
12409 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12410 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12412 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12413 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12414 payload_layer, "raw#l2#l3#l4");
12415 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12416 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12417 payload_cfg, NULL);
12419 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12420 .f = cmd_flow_director_flxpld_parsed,
12422 .help_str = "flow_director_flexpayload ... : "
12423 "Set flow director's flex payload on NIC",
12425 (void *)&cmd_flow_director_flexpayload,
12426 (void *)&cmd_flow_director_flexpayload_port_id,
12427 (void *)&cmd_flow_director_flexpayload_payload_layer,
12428 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12433 /* Generic flow interface command. */
12434 extern cmdline_parse_inst_t cmd_flow;
12436 /* *** Classification Filters Control *** */
12437 /* *** Get symmetric hash enable per port *** */
12438 struct cmd_get_sym_hash_ena_per_port_result {
12439 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12444 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12445 __rte_unused struct cmdline *cl,
12446 __rte_unused void *data)
12448 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12449 struct rte_eth_hash_filter_info info;
12452 if (rte_eth_dev_filter_supported(res->port_id,
12453 RTE_ETH_FILTER_HASH) < 0) {
12454 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12459 memset(&info, 0, sizeof(info));
12460 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12461 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12462 RTE_ETH_FILTER_GET, &info);
12465 printf("Cannot get symmetric hash enable per port "
12466 "on port %u\n", res->port_id);
12470 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12471 "enabled" : "disabled", res->port_id);
12474 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12475 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12476 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12477 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12478 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12481 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12482 .f = cmd_get_sym_hash_per_port_parsed,
12484 .help_str = "get_sym_hash_ena_per_port <port_id>",
12486 (void *)&cmd_get_sym_hash_ena_per_port_all,
12487 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12492 /* *** Set symmetric hash enable per port *** */
12493 struct cmd_set_sym_hash_ena_per_port_result {
12494 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12495 cmdline_fixed_string_t enable;
12500 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12501 __rte_unused struct cmdline *cl,
12502 __rte_unused void *data)
12504 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12505 struct rte_eth_hash_filter_info info;
12508 if (rte_eth_dev_filter_supported(res->port_id,
12509 RTE_ETH_FILTER_HASH) < 0) {
12510 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12515 memset(&info, 0, sizeof(info));
12516 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12517 if (!strcmp(res->enable, "enable"))
12518 info.info.enable = 1;
12519 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12520 RTE_ETH_FILTER_SET, &info);
12522 printf("Cannot set symmetric hash enable per port on "
12523 "port %u\n", res->port_id);
12526 printf("Symmetric hash has been set to %s on port %u\n",
12527 res->enable, res->port_id);
12530 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12531 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12532 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12533 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12534 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12536 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12537 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12538 enable, "enable#disable");
12540 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12541 .f = cmd_set_sym_hash_per_port_parsed,
12543 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12545 (void *)&cmd_set_sym_hash_ena_per_port_all,
12546 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12547 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12552 /* Get global config of hash function */
12553 struct cmd_get_hash_global_config_result {
12554 cmdline_fixed_string_t get_hash_global_config;
12559 flowtype_to_str(uint16_t ftype)
12565 } ftype_table[] = {
12566 {"ipv4", RTE_ETH_FLOW_IPV4},
12567 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12568 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12569 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12570 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12571 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12572 {"ipv6", RTE_ETH_FLOW_IPV6},
12573 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12574 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12575 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12576 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12577 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12578 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12579 {"port", RTE_ETH_FLOW_PORT},
12580 {"vxlan", RTE_ETH_FLOW_VXLAN},
12581 {"geneve", RTE_ETH_FLOW_GENEVE},
12582 {"nvgre", RTE_ETH_FLOW_NVGRE},
12583 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12586 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12587 if (ftype_table[i].ftype == ftype)
12588 return ftype_table[i].str;
12595 cmd_get_hash_global_config_parsed(void *parsed_result,
12596 __rte_unused struct cmdline *cl,
12597 __rte_unused void *data)
12599 struct cmd_get_hash_global_config_result *res = parsed_result;
12600 struct rte_eth_hash_filter_info info;
12601 uint32_t idx, offset;
12606 if (rte_eth_dev_filter_supported(res->port_id,
12607 RTE_ETH_FILTER_HASH) < 0) {
12608 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12613 memset(&info, 0, sizeof(info));
12614 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12615 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12616 RTE_ETH_FILTER_GET, &info);
12618 printf("Cannot get hash global configurations by port %d\n",
12623 switch (info.info.global_conf.hash_func) {
12624 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12625 printf("Hash function is Toeplitz\n");
12627 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12628 printf("Hash function is Simple XOR\n");
12630 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12631 printf("Hash function is Symmetric Toeplitz\n");
12634 printf("Unknown hash function\n");
12638 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12639 idx = i / UINT64_BIT;
12640 offset = i % UINT64_BIT;
12641 if (!(info.info.global_conf.valid_bit_mask[idx] &
12644 str = flowtype_to_str(i);
12647 printf("Symmetric hash is %s globally for flow type %s "
12649 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12650 (1ULL << offset)) ? "enabled" : "disabled"), str,
12655 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12656 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12657 get_hash_global_config, "get_hash_global_config");
12658 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12659 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12662 cmdline_parse_inst_t cmd_get_hash_global_config = {
12663 .f = cmd_get_hash_global_config_parsed,
12665 .help_str = "get_hash_global_config <port_id>",
12667 (void *)&cmd_get_hash_global_config_all,
12668 (void *)&cmd_get_hash_global_config_port_id,
12673 /* Set global config of hash function */
12674 struct cmd_set_hash_global_config_result {
12675 cmdline_fixed_string_t set_hash_global_config;
12677 cmdline_fixed_string_t hash_func;
12678 cmdline_fixed_string_t flow_type;
12679 cmdline_fixed_string_t enable;
12683 cmd_set_hash_global_config_parsed(void *parsed_result,
12684 __rte_unused struct cmdline *cl,
12685 __rte_unused void *data)
12687 struct cmd_set_hash_global_config_result *res = parsed_result;
12688 struct rte_eth_hash_filter_info info;
12689 uint32_t ftype, idx, offset;
12692 if (rte_eth_dev_filter_supported(res->port_id,
12693 RTE_ETH_FILTER_HASH) < 0) {
12694 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12698 memset(&info, 0, sizeof(info));
12699 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12700 if (!strcmp(res->hash_func, "toeplitz"))
12701 info.info.global_conf.hash_func =
12702 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12703 else if (!strcmp(res->hash_func, "simple_xor"))
12704 info.info.global_conf.hash_func =
12705 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12706 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12707 info.info.global_conf.hash_func =
12708 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12709 else if (!strcmp(res->hash_func, "default"))
12710 info.info.global_conf.hash_func =
12711 RTE_ETH_HASH_FUNCTION_DEFAULT;
12713 ftype = str2flowtype(res->flow_type);
12714 idx = ftype / UINT64_BIT;
12715 offset = ftype % UINT64_BIT;
12716 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12717 if (!strcmp(res->enable, "enable"))
12718 info.info.global_conf.sym_hash_enable_mask[idx] |=
12720 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12721 RTE_ETH_FILTER_SET, &info);
12723 printf("Cannot set global hash configurations by port %d\n",
12726 printf("Global hash configurations have been set "
12727 "successfully by port %d\n", res->port_id);
12730 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12731 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12732 set_hash_global_config, "set_hash_global_config");
12733 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12734 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12736 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12737 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12738 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12739 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12740 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12742 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12743 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12744 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12745 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12746 enable, "enable#disable");
12748 cmdline_parse_inst_t cmd_set_hash_global_config = {
12749 .f = cmd_set_hash_global_config_parsed,
12751 .help_str = "set_hash_global_config <port_id> "
12752 "toeplitz|simple_xor|symmetric_toeplitz|default "
12753 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12754 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12755 "l2_payload enable|disable",
12757 (void *)&cmd_set_hash_global_config_all,
12758 (void *)&cmd_set_hash_global_config_port_id,
12759 (void *)&cmd_set_hash_global_config_hash_func,
12760 (void *)&cmd_set_hash_global_config_flow_type,
12761 (void *)&cmd_set_hash_global_config_enable,
12766 /* Set hash input set */
12767 struct cmd_set_hash_input_set_result {
12768 cmdline_fixed_string_t set_hash_input_set;
12770 cmdline_fixed_string_t flow_type;
12771 cmdline_fixed_string_t inset_field;
12772 cmdline_fixed_string_t select;
12775 static enum rte_eth_input_set_field
12776 str2inset(char *string)
12780 static const struct {
12782 enum rte_eth_input_set_field inset;
12783 } inset_table[] = {
12784 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12785 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12786 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12787 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12788 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12789 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12790 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12791 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12792 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12793 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12794 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12795 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12796 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12797 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12798 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12799 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12800 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12801 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12802 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12803 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12804 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12805 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12806 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12807 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12808 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12809 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12810 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12811 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12812 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12813 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12814 {"none", RTE_ETH_INPUT_SET_NONE},
12817 for (i = 0; i < RTE_DIM(inset_table); i++) {
12818 if (!strcmp(string, inset_table[i].str))
12819 return inset_table[i].inset;
12822 return RTE_ETH_INPUT_SET_UNKNOWN;
12826 cmd_set_hash_input_set_parsed(void *parsed_result,
12827 __rte_unused struct cmdline *cl,
12828 __rte_unused void *data)
12830 struct cmd_set_hash_input_set_result *res = parsed_result;
12831 struct rte_eth_hash_filter_info info;
12833 memset(&info, 0, sizeof(info));
12834 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12835 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12836 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12837 info.info.input_set_conf.inset_size = 1;
12838 if (!strcmp(res->select, "select"))
12839 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12840 else if (!strcmp(res->select, "add"))
12841 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12842 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12843 RTE_ETH_FILTER_SET, &info);
12846 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12847 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12848 set_hash_input_set, "set_hash_input_set");
12849 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12850 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12852 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12853 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12855 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12856 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12858 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12859 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12860 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12861 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12862 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12864 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12865 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12866 select, "select#add");
12868 cmdline_parse_inst_t cmd_set_hash_input_set = {
12869 .f = cmd_set_hash_input_set_parsed,
12871 .help_str = "set_hash_input_set <port_id> "
12872 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12873 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12874 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12875 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12876 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12877 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12878 "fld-7th|fld-8th|none select|add",
12880 (void *)&cmd_set_hash_input_set_cmd,
12881 (void *)&cmd_set_hash_input_set_port_id,
12882 (void *)&cmd_set_hash_input_set_flow_type,
12883 (void *)&cmd_set_hash_input_set_field,
12884 (void *)&cmd_set_hash_input_set_select,
12889 /* Set flow director input set */
12890 struct cmd_set_fdir_input_set_result {
12891 cmdline_fixed_string_t set_fdir_input_set;
12893 cmdline_fixed_string_t flow_type;
12894 cmdline_fixed_string_t inset_field;
12895 cmdline_fixed_string_t select;
12899 cmd_set_fdir_input_set_parsed(void *parsed_result,
12900 __rte_unused struct cmdline *cl,
12901 __rte_unused void *data)
12903 struct cmd_set_fdir_input_set_result *res = parsed_result;
12904 struct rte_eth_fdir_filter_info info;
12906 memset(&info, 0, sizeof(info));
12907 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12908 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12909 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12910 info.info.input_set_conf.inset_size = 1;
12911 if (!strcmp(res->select, "select"))
12912 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12913 else if (!strcmp(res->select, "add"))
12914 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12915 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12916 RTE_ETH_FILTER_SET, &info);
12919 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12920 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12921 set_fdir_input_set, "set_fdir_input_set");
12922 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12923 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12925 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12926 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12928 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12929 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12930 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12931 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12933 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12934 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12935 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12936 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12937 "sctp-veri-tag#none");
12938 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12939 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12940 select, "select#add");
12942 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12943 .f = cmd_set_fdir_input_set_parsed,
12945 .help_str = "set_fdir_input_set <port_id> "
12946 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12947 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12948 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12949 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12950 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12951 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12952 "sctp-veri-tag|none select|add",
12954 (void *)&cmd_set_fdir_input_set_cmd,
12955 (void *)&cmd_set_fdir_input_set_port_id,
12956 (void *)&cmd_set_fdir_input_set_flow_type,
12957 (void *)&cmd_set_fdir_input_set_field,
12958 (void *)&cmd_set_fdir_input_set_select,
12963 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12964 struct cmd_mcast_addr_result {
12965 cmdline_fixed_string_t mcast_addr_cmd;
12966 cmdline_fixed_string_t what;
12968 struct rte_ether_addr mc_addr;
12971 static void cmd_mcast_addr_parsed(void *parsed_result,
12972 __rte_unused struct cmdline *cl,
12973 __rte_unused void *data)
12975 struct cmd_mcast_addr_result *res = parsed_result;
12977 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12978 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12979 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12980 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12981 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12984 if (strcmp(res->what, "add") == 0)
12985 mcast_addr_add(res->port_num, &res->mc_addr);
12987 mcast_addr_remove(res->port_num, &res->mc_addr);
12990 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12991 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12992 mcast_addr_cmd, "mcast_addr");
12993 cmdline_parse_token_string_t cmd_mcast_addr_what =
12994 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12996 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12997 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12998 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12999 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
13001 cmdline_parse_inst_t cmd_mcast_addr = {
13002 .f = cmd_mcast_addr_parsed,
13004 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
13005 "Add/Remove multicast MAC address on port_id",
13007 (void *)&cmd_mcast_addr_cmd,
13008 (void *)&cmd_mcast_addr_what,
13009 (void *)&cmd_mcast_addr_portnum,
13010 (void *)&cmd_mcast_addr_addr,
13015 /* l2 tunnel config
13016 * only support E-tag now.
13019 /* Ether type config */
13020 struct cmd_config_l2_tunnel_eth_type_result {
13021 cmdline_fixed_string_t port;
13022 cmdline_fixed_string_t config;
13023 cmdline_fixed_string_t all;
13025 cmdline_fixed_string_t l2_tunnel;
13026 cmdline_fixed_string_t l2_tunnel_type;
13027 cmdline_fixed_string_t eth_type;
13028 uint16_t eth_type_val;
13031 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
13032 TOKEN_STRING_INITIALIZER
13033 (struct cmd_config_l2_tunnel_eth_type_result,
13035 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
13036 TOKEN_STRING_INITIALIZER
13037 (struct cmd_config_l2_tunnel_eth_type_result,
13039 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
13040 TOKEN_STRING_INITIALIZER
13041 (struct cmd_config_l2_tunnel_eth_type_result,
13043 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
13044 TOKEN_NUM_INITIALIZER
13045 (struct cmd_config_l2_tunnel_eth_type_result,
13047 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
13048 TOKEN_STRING_INITIALIZER
13049 (struct cmd_config_l2_tunnel_eth_type_result,
13050 l2_tunnel, "l2-tunnel");
13051 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
13052 TOKEN_STRING_INITIALIZER
13053 (struct cmd_config_l2_tunnel_eth_type_result,
13054 l2_tunnel_type, "E-tag");
13055 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
13056 TOKEN_STRING_INITIALIZER
13057 (struct cmd_config_l2_tunnel_eth_type_result,
13058 eth_type, "ether-type");
13059 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
13060 TOKEN_NUM_INITIALIZER
13061 (struct cmd_config_l2_tunnel_eth_type_result,
13062 eth_type_val, UINT16);
13064 static enum rte_eth_tunnel_type
13065 str2fdir_l2_tunnel_type(char *string)
13069 static const struct {
13071 enum rte_eth_tunnel_type type;
13072 } l2_tunnel_type_str[] = {
13073 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
13076 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
13077 if (!strcmp(l2_tunnel_type_str[i].str, string))
13078 return l2_tunnel_type_str[i].type;
13080 return RTE_TUNNEL_TYPE_NONE;
13083 /* ether type config for all ports */
13085 cmd_config_l2_tunnel_eth_type_all_parsed
13086 (void *parsed_result,
13087 __rte_unused struct cmdline *cl,
13088 __rte_unused void *data)
13090 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
13091 struct rte_eth_l2_tunnel_conf entry;
13094 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13095 entry.ether_type = res->eth_type_val;
13097 RTE_ETH_FOREACH_DEV(pid) {
13098 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
13102 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
13103 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
13105 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
13107 (void *)&cmd_config_l2_tunnel_eth_type_port,
13108 (void *)&cmd_config_l2_tunnel_eth_type_config,
13109 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
13110 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
13111 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
13112 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
13113 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
13118 /* ether type config for a specific port */
13120 cmd_config_l2_tunnel_eth_type_specific_parsed(
13121 void *parsed_result,
13122 __rte_unused struct cmdline *cl,
13123 __rte_unused void *data)
13125 struct cmd_config_l2_tunnel_eth_type_result *res =
13127 struct rte_eth_l2_tunnel_conf entry;
13129 if (port_id_is_invalid(res->id, ENABLED_WARN))
13132 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13133 entry.ether_type = res->eth_type_val;
13135 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
13138 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
13139 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
13141 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
13143 (void *)&cmd_config_l2_tunnel_eth_type_port,
13144 (void *)&cmd_config_l2_tunnel_eth_type_config,
13145 (void *)&cmd_config_l2_tunnel_eth_type_id,
13146 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
13147 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
13148 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
13149 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
13154 /* Enable/disable l2 tunnel */
13155 struct cmd_config_l2_tunnel_en_dis_result {
13156 cmdline_fixed_string_t port;
13157 cmdline_fixed_string_t config;
13158 cmdline_fixed_string_t all;
13160 cmdline_fixed_string_t l2_tunnel;
13161 cmdline_fixed_string_t l2_tunnel_type;
13162 cmdline_fixed_string_t en_dis;
13165 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
13166 TOKEN_STRING_INITIALIZER
13167 (struct cmd_config_l2_tunnel_en_dis_result,
13169 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
13170 TOKEN_STRING_INITIALIZER
13171 (struct cmd_config_l2_tunnel_en_dis_result,
13173 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
13174 TOKEN_STRING_INITIALIZER
13175 (struct cmd_config_l2_tunnel_en_dis_result,
13177 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
13178 TOKEN_NUM_INITIALIZER
13179 (struct cmd_config_l2_tunnel_en_dis_result,
13181 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
13182 TOKEN_STRING_INITIALIZER
13183 (struct cmd_config_l2_tunnel_en_dis_result,
13184 l2_tunnel, "l2-tunnel");
13185 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
13186 TOKEN_STRING_INITIALIZER
13187 (struct cmd_config_l2_tunnel_en_dis_result,
13188 l2_tunnel_type, "E-tag");
13189 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
13190 TOKEN_STRING_INITIALIZER
13191 (struct cmd_config_l2_tunnel_en_dis_result,
13192 en_dis, "enable#disable");
13194 /* enable/disable l2 tunnel for all ports */
13196 cmd_config_l2_tunnel_en_dis_all_parsed(
13197 void *parsed_result,
13198 __rte_unused struct cmdline *cl,
13199 __rte_unused void *data)
13201 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
13202 struct rte_eth_l2_tunnel_conf entry;
13206 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13208 if (!strcmp("enable", res->en_dis))
13213 RTE_ETH_FOREACH_DEV(pid) {
13214 rte_eth_dev_l2_tunnel_offload_set(pid,
13216 ETH_L2_TUNNEL_ENABLE_MASK,
13221 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
13222 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
13224 .help_str = "port config all l2-tunnel E-tag enable|disable",
13226 (void *)&cmd_config_l2_tunnel_en_dis_port,
13227 (void *)&cmd_config_l2_tunnel_en_dis_config,
13228 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
13229 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13230 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13231 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13236 /* enable/disable l2 tunnel for a port */
13238 cmd_config_l2_tunnel_en_dis_specific_parsed(
13239 void *parsed_result,
13240 __rte_unused struct cmdline *cl,
13241 __rte_unused void *data)
13243 struct cmd_config_l2_tunnel_en_dis_result *res =
13245 struct rte_eth_l2_tunnel_conf entry;
13247 if (port_id_is_invalid(res->id, ENABLED_WARN))
13250 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13252 if (!strcmp("enable", res->en_dis))
13253 rte_eth_dev_l2_tunnel_offload_set(res->id,
13255 ETH_L2_TUNNEL_ENABLE_MASK,
13258 rte_eth_dev_l2_tunnel_offload_set(res->id,
13260 ETH_L2_TUNNEL_ENABLE_MASK,
13264 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
13265 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
13267 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
13269 (void *)&cmd_config_l2_tunnel_en_dis_port,
13270 (void *)&cmd_config_l2_tunnel_en_dis_config,
13271 (void *)&cmd_config_l2_tunnel_en_dis_id,
13272 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13273 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13274 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13279 /* E-tag configuration */
13281 /* Common result structure for all E-tag configuration */
13282 struct cmd_config_e_tag_result {
13283 cmdline_fixed_string_t e_tag;
13284 cmdline_fixed_string_t set;
13285 cmdline_fixed_string_t insertion;
13286 cmdline_fixed_string_t stripping;
13287 cmdline_fixed_string_t forwarding;
13288 cmdline_fixed_string_t filter;
13289 cmdline_fixed_string_t add;
13290 cmdline_fixed_string_t del;
13291 cmdline_fixed_string_t on;
13292 cmdline_fixed_string_t off;
13293 cmdline_fixed_string_t on_off;
13294 cmdline_fixed_string_t port_tag_id;
13295 uint32_t port_tag_id_val;
13296 cmdline_fixed_string_t e_tag_id;
13297 uint16_t e_tag_id_val;
13298 cmdline_fixed_string_t dst_pool;
13299 uint8_t dst_pool_val;
13300 cmdline_fixed_string_t port;
13302 cmdline_fixed_string_t vf;
13306 /* Common CLI fields for all E-tag configuration */
13307 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
13308 TOKEN_STRING_INITIALIZER
13309 (struct cmd_config_e_tag_result,
13311 cmdline_parse_token_string_t cmd_config_e_tag_set =
13312 TOKEN_STRING_INITIALIZER
13313 (struct cmd_config_e_tag_result,
13315 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
13316 TOKEN_STRING_INITIALIZER
13317 (struct cmd_config_e_tag_result,
13318 insertion, "insertion");
13319 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
13320 TOKEN_STRING_INITIALIZER
13321 (struct cmd_config_e_tag_result,
13322 stripping, "stripping");
13323 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
13324 TOKEN_STRING_INITIALIZER
13325 (struct cmd_config_e_tag_result,
13326 forwarding, "forwarding");
13327 cmdline_parse_token_string_t cmd_config_e_tag_filter =
13328 TOKEN_STRING_INITIALIZER
13329 (struct cmd_config_e_tag_result,
13331 cmdline_parse_token_string_t cmd_config_e_tag_add =
13332 TOKEN_STRING_INITIALIZER
13333 (struct cmd_config_e_tag_result,
13335 cmdline_parse_token_string_t cmd_config_e_tag_del =
13336 TOKEN_STRING_INITIALIZER
13337 (struct cmd_config_e_tag_result,
13339 cmdline_parse_token_string_t cmd_config_e_tag_on =
13340 TOKEN_STRING_INITIALIZER
13341 (struct cmd_config_e_tag_result,
13343 cmdline_parse_token_string_t cmd_config_e_tag_off =
13344 TOKEN_STRING_INITIALIZER
13345 (struct cmd_config_e_tag_result,
13347 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13348 TOKEN_STRING_INITIALIZER
13349 (struct cmd_config_e_tag_result,
13351 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13352 TOKEN_STRING_INITIALIZER
13353 (struct cmd_config_e_tag_result,
13354 port_tag_id, "port-tag-id");
13355 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13356 TOKEN_NUM_INITIALIZER
13357 (struct cmd_config_e_tag_result,
13358 port_tag_id_val, UINT32);
13359 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13360 TOKEN_STRING_INITIALIZER
13361 (struct cmd_config_e_tag_result,
13362 e_tag_id, "e-tag-id");
13363 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13364 TOKEN_NUM_INITIALIZER
13365 (struct cmd_config_e_tag_result,
13366 e_tag_id_val, UINT16);
13367 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13368 TOKEN_STRING_INITIALIZER
13369 (struct cmd_config_e_tag_result,
13370 dst_pool, "dst-pool");
13371 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13372 TOKEN_NUM_INITIALIZER
13373 (struct cmd_config_e_tag_result,
13374 dst_pool_val, UINT8);
13375 cmdline_parse_token_string_t cmd_config_e_tag_port =
13376 TOKEN_STRING_INITIALIZER
13377 (struct cmd_config_e_tag_result,
13379 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13380 TOKEN_NUM_INITIALIZER
13381 (struct cmd_config_e_tag_result,
13383 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13384 TOKEN_STRING_INITIALIZER
13385 (struct cmd_config_e_tag_result,
13387 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13388 TOKEN_NUM_INITIALIZER
13389 (struct cmd_config_e_tag_result,
13392 /* E-tag insertion configuration */
13394 cmd_config_e_tag_insertion_en_parsed(
13395 void *parsed_result,
13396 __rte_unused struct cmdline *cl,
13397 __rte_unused void *data)
13399 struct cmd_config_e_tag_result *res =
13401 struct rte_eth_l2_tunnel_conf entry;
13403 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13406 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13407 entry.tunnel_id = res->port_tag_id_val;
13408 entry.vf_id = res->vf_id;
13409 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13411 ETH_L2_TUNNEL_INSERTION_MASK,
13416 cmd_config_e_tag_insertion_dis_parsed(
13417 void *parsed_result,
13418 __rte_unused struct cmdline *cl,
13419 __rte_unused void *data)
13421 struct cmd_config_e_tag_result *res =
13423 struct rte_eth_l2_tunnel_conf entry;
13425 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13428 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13429 entry.vf_id = res->vf_id;
13431 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13433 ETH_L2_TUNNEL_INSERTION_MASK,
13437 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13438 .f = cmd_config_e_tag_insertion_en_parsed,
13440 .help_str = "E-tag ... : E-tag insertion enable",
13442 (void *)&cmd_config_e_tag_e_tag,
13443 (void *)&cmd_config_e_tag_set,
13444 (void *)&cmd_config_e_tag_insertion,
13445 (void *)&cmd_config_e_tag_on,
13446 (void *)&cmd_config_e_tag_port_tag_id,
13447 (void *)&cmd_config_e_tag_port_tag_id_val,
13448 (void *)&cmd_config_e_tag_port,
13449 (void *)&cmd_config_e_tag_port_id,
13450 (void *)&cmd_config_e_tag_vf,
13451 (void *)&cmd_config_e_tag_vf_id,
13456 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13457 .f = cmd_config_e_tag_insertion_dis_parsed,
13459 .help_str = "E-tag ... : E-tag insertion disable",
13461 (void *)&cmd_config_e_tag_e_tag,
13462 (void *)&cmd_config_e_tag_set,
13463 (void *)&cmd_config_e_tag_insertion,
13464 (void *)&cmd_config_e_tag_off,
13465 (void *)&cmd_config_e_tag_port,
13466 (void *)&cmd_config_e_tag_port_id,
13467 (void *)&cmd_config_e_tag_vf,
13468 (void *)&cmd_config_e_tag_vf_id,
13473 /* E-tag stripping configuration */
13475 cmd_config_e_tag_stripping_parsed(
13476 void *parsed_result,
13477 __rte_unused struct cmdline *cl,
13478 __rte_unused void *data)
13480 struct cmd_config_e_tag_result *res =
13482 struct rte_eth_l2_tunnel_conf entry;
13484 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13487 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13489 if (!strcmp(res->on_off, "on"))
13490 rte_eth_dev_l2_tunnel_offload_set
13493 ETH_L2_TUNNEL_STRIPPING_MASK,
13496 rte_eth_dev_l2_tunnel_offload_set
13499 ETH_L2_TUNNEL_STRIPPING_MASK,
13503 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13504 .f = cmd_config_e_tag_stripping_parsed,
13506 .help_str = "E-tag ... : E-tag stripping enable/disable",
13508 (void *)&cmd_config_e_tag_e_tag,
13509 (void *)&cmd_config_e_tag_set,
13510 (void *)&cmd_config_e_tag_stripping,
13511 (void *)&cmd_config_e_tag_on_off,
13512 (void *)&cmd_config_e_tag_port,
13513 (void *)&cmd_config_e_tag_port_id,
13518 /* E-tag forwarding configuration */
13520 cmd_config_e_tag_forwarding_parsed(
13521 void *parsed_result,
13522 __rte_unused struct cmdline *cl,
13523 __rte_unused void *data)
13525 struct cmd_config_e_tag_result *res = parsed_result;
13526 struct rte_eth_l2_tunnel_conf entry;
13528 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13531 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13533 if (!strcmp(res->on_off, "on"))
13534 rte_eth_dev_l2_tunnel_offload_set
13537 ETH_L2_TUNNEL_FORWARDING_MASK,
13540 rte_eth_dev_l2_tunnel_offload_set
13543 ETH_L2_TUNNEL_FORWARDING_MASK,
13547 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13548 .f = cmd_config_e_tag_forwarding_parsed,
13550 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13552 (void *)&cmd_config_e_tag_e_tag,
13553 (void *)&cmd_config_e_tag_set,
13554 (void *)&cmd_config_e_tag_forwarding,
13555 (void *)&cmd_config_e_tag_on_off,
13556 (void *)&cmd_config_e_tag_port,
13557 (void *)&cmd_config_e_tag_port_id,
13562 /* E-tag filter configuration */
13564 cmd_config_e_tag_filter_add_parsed(
13565 void *parsed_result,
13566 __rte_unused struct cmdline *cl,
13567 __rte_unused void *data)
13569 struct cmd_config_e_tag_result *res = parsed_result;
13570 struct rte_eth_l2_tunnel_conf entry;
13573 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13576 if (res->e_tag_id_val > 0x3fff) {
13577 printf("e-tag-id must be equal or less than 0x3fff.\n");
13581 ret = rte_eth_dev_filter_supported(res->port_id,
13582 RTE_ETH_FILTER_L2_TUNNEL);
13584 printf("E-tag filter is not supported on port %u.\n",
13589 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13590 entry.tunnel_id = res->e_tag_id_val;
13591 entry.pool = res->dst_pool_val;
13593 ret = rte_eth_dev_filter_ctrl(res->port_id,
13594 RTE_ETH_FILTER_L2_TUNNEL,
13595 RTE_ETH_FILTER_ADD,
13598 printf("E-tag filter programming error: (%s)\n",
13602 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13603 .f = cmd_config_e_tag_filter_add_parsed,
13605 .help_str = "E-tag ... : E-tag filter add",
13607 (void *)&cmd_config_e_tag_e_tag,
13608 (void *)&cmd_config_e_tag_set,
13609 (void *)&cmd_config_e_tag_filter,
13610 (void *)&cmd_config_e_tag_add,
13611 (void *)&cmd_config_e_tag_e_tag_id,
13612 (void *)&cmd_config_e_tag_e_tag_id_val,
13613 (void *)&cmd_config_e_tag_dst_pool,
13614 (void *)&cmd_config_e_tag_dst_pool_val,
13615 (void *)&cmd_config_e_tag_port,
13616 (void *)&cmd_config_e_tag_port_id,
13622 cmd_config_e_tag_filter_del_parsed(
13623 void *parsed_result,
13624 __rte_unused struct cmdline *cl,
13625 __rte_unused void *data)
13627 struct cmd_config_e_tag_result *res = parsed_result;
13628 struct rte_eth_l2_tunnel_conf entry;
13631 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13634 if (res->e_tag_id_val > 0x3fff) {
13635 printf("e-tag-id must be less than 0x3fff.\n");
13639 ret = rte_eth_dev_filter_supported(res->port_id,
13640 RTE_ETH_FILTER_L2_TUNNEL);
13642 printf("E-tag filter is not supported on port %u.\n",
13647 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13648 entry.tunnel_id = res->e_tag_id_val;
13650 ret = rte_eth_dev_filter_ctrl(res->port_id,
13651 RTE_ETH_FILTER_L2_TUNNEL,
13652 RTE_ETH_FILTER_DELETE,
13655 printf("E-tag filter programming error: (%s)\n",
13659 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13660 .f = cmd_config_e_tag_filter_del_parsed,
13662 .help_str = "E-tag ... : E-tag filter delete",
13664 (void *)&cmd_config_e_tag_e_tag,
13665 (void *)&cmd_config_e_tag_set,
13666 (void *)&cmd_config_e_tag_filter,
13667 (void *)&cmd_config_e_tag_del,
13668 (void *)&cmd_config_e_tag_e_tag_id,
13669 (void *)&cmd_config_e_tag_e_tag_id_val,
13670 (void *)&cmd_config_e_tag_port,
13671 (void *)&cmd_config_e_tag_port_id,
13676 /* vf vlan anti spoof configuration */
13678 /* Common result structure for vf vlan anti spoof */
13679 struct cmd_vf_vlan_anti_spoof_result {
13680 cmdline_fixed_string_t set;
13681 cmdline_fixed_string_t vf;
13682 cmdline_fixed_string_t vlan;
13683 cmdline_fixed_string_t antispoof;
13686 cmdline_fixed_string_t on_off;
13689 /* Common CLI fields for vf vlan anti spoof enable disable */
13690 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13691 TOKEN_STRING_INITIALIZER
13692 (struct cmd_vf_vlan_anti_spoof_result,
13694 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13695 TOKEN_STRING_INITIALIZER
13696 (struct cmd_vf_vlan_anti_spoof_result,
13698 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13699 TOKEN_STRING_INITIALIZER
13700 (struct cmd_vf_vlan_anti_spoof_result,
13702 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13703 TOKEN_STRING_INITIALIZER
13704 (struct cmd_vf_vlan_anti_spoof_result,
13705 antispoof, "antispoof");
13706 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13707 TOKEN_NUM_INITIALIZER
13708 (struct cmd_vf_vlan_anti_spoof_result,
13710 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13711 TOKEN_NUM_INITIALIZER
13712 (struct cmd_vf_vlan_anti_spoof_result,
13714 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13715 TOKEN_STRING_INITIALIZER
13716 (struct cmd_vf_vlan_anti_spoof_result,
13720 cmd_set_vf_vlan_anti_spoof_parsed(
13721 void *parsed_result,
13722 __rte_unused struct cmdline *cl,
13723 __rte_unused void *data)
13725 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13726 int ret = -ENOTSUP;
13728 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13730 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13733 #ifdef RTE_LIBRTE_IXGBE_PMD
13734 if (ret == -ENOTSUP)
13735 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13736 res->vf_id, is_on);
13738 #ifdef RTE_LIBRTE_I40E_PMD
13739 if (ret == -ENOTSUP)
13740 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13741 res->vf_id, is_on);
13743 #ifdef RTE_LIBRTE_BNXT_PMD
13744 if (ret == -ENOTSUP)
13745 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13746 res->vf_id, is_on);
13753 printf("invalid vf_id %d\n", res->vf_id);
13756 printf("invalid port_id %d\n", res->port_id);
13759 printf("function not implemented\n");
13762 printf("programming error: (%s)\n", strerror(-ret));
13766 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13767 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13769 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13771 (void *)&cmd_vf_vlan_anti_spoof_set,
13772 (void *)&cmd_vf_vlan_anti_spoof_vf,
13773 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13774 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13775 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13776 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13777 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13782 /* vf mac anti spoof configuration */
13784 /* Common result structure for vf mac anti spoof */
13785 struct cmd_vf_mac_anti_spoof_result {
13786 cmdline_fixed_string_t set;
13787 cmdline_fixed_string_t vf;
13788 cmdline_fixed_string_t mac;
13789 cmdline_fixed_string_t antispoof;
13792 cmdline_fixed_string_t on_off;
13795 /* Common CLI fields for vf mac anti spoof enable disable */
13796 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13797 TOKEN_STRING_INITIALIZER
13798 (struct cmd_vf_mac_anti_spoof_result,
13800 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13801 TOKEN_STRING_INITIALIZER
13802 (struct cmd_vf_mac_anti_spoof_result,
13804 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13805 TOKEN_STRING_INITIALIZER
13806 (struct cmd_vf_mac_anti_spoof_result,
13808 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13809 TOKEN_STRING_INITIALIZER
13810 (struct cmd_vf_mac_anti_spoof_result,
13811 antispoof, "antispoof");
13812 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13813 TOKEN_NUM_INITIALIZER
13814 (struct cmd_vf_mac_anti_spoof_result,
13816 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13817 TOKEN_NUM_INITIALIZER
13818 (struct cmd_vf_mac_anti_spoof_result,
13820 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13821 TOKEN_STRING_INITIALIZER
13822 (struct cmd_vf_mac_anti_spoof_result,
13826 cmd_set_vf_mac_anti_spoof_parsed(
13827 void *parsed_result,
13828 __rte_unused struct cmdline *cl,
13829 __rte_unused void *data)
13831 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13832 int ret = -ENOTSUP;
13834 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13836 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13839 #ifdef RTE_LIBRTE_IXGBE_PMD
13840 if (ret == -ENOTSUP)
13841 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13842 res->vf_id, is_on);
13844 #ifdef RTE_LIBRTE_I40E_PMD
13845 if (ret == -ENOTSUP)
13846 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13847 res->vf_id, is_on);
13849 #ifdef RTE_LIBRTE_BNXT_PMD
13850 if (ret == -ENOTSUP)
13851 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13852 res->vf_id, is_on);
13859 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13862 printf("invalid port_id %d\n", res->port_id);
13865 printf("function not implemented\n");
13868 printf("programming error: (%s)\n", strerror(-ret));
13872 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13873 .f = cmd_set_vf_mac_anti_spoof_parsed,
13875 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13877 (void *)&cmd_vf_mac_anti_spoof_set,
13878 (void *)&cmd_vf_mac_anti_spoof_vf,
13879 (void *)&cmd_vf_mac_anti_spoof_mac,
13880 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13881 (void *)&cmd_vf_mac_anti_spoof_port_id,
13882 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13883 (void *)&cmd_vf_mac_anti_spoof_on_off,
13888 /* vf vlan strip queue configuration */
13890 /* Common result structure for vf mac anti spoof */
13891 struct cmd_vf_vlan_stripq_result {
13892 cmdline_fixed_string_t set;
13893 cmdline_fixed_string_t vf;
13894 cmdline_fixed_string_t vlan;
13895 cmdline_fixed_string_t stripq;
13898 cmdline_fixed_string_t on_off;
13901 /* Common CLI fields for vf vlan strip enable disable */
13902 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13903 TOKEN_STRING_INITIALIZER
13904 (struct cmd_vf_vlan_stripq_result,
13906 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13907 TOKEN_STRING_INITIALIZER
13908 (struct cmd_vf_vlan_stripq_result,
13910 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13911 TOKEN_STRING_INITIALIZER
13912 (struct cmd_vf_vlan_stripq_result,
13914 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13915 TOKEN_STRING_INITIALIZER
13916 (struct cmd_vf_vlan_stripq_result,
13918 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13919 TOKEN_NUM_INITIALIZER
13920 (struct cmd_vf_vlan_stripq_result,
13922 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13923 TOKEN_NUM_INITIALIZER
13924 (struct cmd_vf_vlan_stripq_result,
13926 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13927 TOKEN_STRING_INITIALIZER
13928 (struct cmd_vf_vlan_stripq_result,
13932 cmd_set_vf_vlan_stripq_parsed(
13933 void *parsed_result,
13934 __rte_unused struct cmdline *cl,
13935 __rte_unused void *data)
13937 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13938 int ret = -ENOTSUP;
13940 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13942 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13945 #ifdef RTE_LIBRTE_IXGBE_PMD
13946 if (ret == -ENOTSUP)
13947 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13948 res->vf_id, is_on);
13950 #ifdef RTE_LIBRTE_I40E_PMD
13951 if (ret == -ENOTSUP)
13952 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13953 res->vf_id, is_on);
13955 #ifdef RTE_LIBRTE_BNXT_PMD
13956 if (ret == -ENOTSUP)
13957 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13958 res->vf_id, is_on);
13965 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13968 printf("invalid port_id %d\n", res->port_id);
13971 printf("function not implemented\n");
13974 printf("programming error: (%s)\n", strerror(-ret));
13978 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13979 .f = cmd_set_vf_vlan_stripq_parsed,
13981 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13983 (void *)&cmd_vf_vlan_stripq_set,
13984 (void *)&cmd_vf_vlan_stripq_vf,
13985 (void *)&cmd_vf_vlan_stripq_vlan,
13986 (void *)&cmd_vf_vlan_stripq_stripq,
13987 (void *)&cmd_vf_vlan_stripq_port_id,
13988 (void *)&cmd_vf_vlan_stripq_vf_id,
13989 (void *)&cmd_vf_vlan_stripq_on_off,
13994 /* vf vlan insert configuration */
13996 /* Common result structure for vf vlan insert */
13997 struct cmd_vf_vlan_insert_result {
13998 cmdline_fixed_string_t set;
13999 cmdline_fixed_string_t vf;
14000 cmdline_fixed_string_t vlan;
14001 cmdline_fixed_string_t insert;
14007 /* Common CLI fields for vf vlan insert enable disable */
14008 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
14009 TOKEN_STRING_INITIALIZER
14010 (struct cmd_vf_vlan_insert_result,
14012 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
14013 TOKEN_STRING_INITIALIZER
14014 (struct cmd_vf_vlan_insert_result,
14016 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
14017 TOKEN_STRING_INITIALIZER
14018 (struct cmd_vf_vlan_insert_result,
14020 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
14021 TOKEN_STRING_INITIALIZER
14022 (struct cmd_vf_vlan_insert_result,
14024 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
14025 TOKEN_NUM_INITIALIZER
14026 (struct cmd_vf_vlan_insert_result,
14028 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
14029 TOKEN_NUM_INITIALIZER
14030 (struct cmd_vf_vlan_insert_result,
14032 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
14033 TOKEN_NUM_INITIALIZER
14034 (struct cmd_vf_vlan_insert_result,
14038 cmd_set_vf_vlan_insert_parsed(
14039 void *parsed_result,
14040 __rte_unused struct cmdline *cl,
14041 __rte_unused void *data)
14043 struct cmd_vf_vlan_insert_result *res = parsed_result;
14044 int ret = -ENOTSUP;
14046 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14049 #ifdef RTE_LIBRTE_IXGBE_PMD
14050 if (ret == -ENOTSUP)
14051 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
14054 #ifdef RTE_LIBRTE_I40E_PMD
14055 if (ret == -ENOTSUP)
14056 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
14059 #ifdef RTE_LIBRTE_BNXT_PMD
14060 if (ret == -ENOTSUP)
14061 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
14069 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
14072 printf("invalid port_id %d\n", res->port_id);
14075 printf("function not implemented\n");
14078 printf("programming error: (%s)\n", strerror(-ret));
14082 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
14083 .f = cmd_set_vf_vlan_insert_parsed,
14085 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
14087 (void *)&cmd_vf_vlan_insert_set,
14088 (void *)&cmd_vf_vlan_insert_vf,
14089 (void *)&cmd_vf_vlan_insert_vlan,
14090 (void *)&cmd_vf_vlan_insert_insert,
14091 (void *)&cmd_vf_vlan_insert_port_id,
14092 (void *)&cmd_vf_vlan_insert_vf_id,
14093 (void *)&cmd_vf_vlan_insert_vlan_id,
14098 /* tx loopback configuration */
14100 /* Common result structure for tx loopback */
14101 struct cmd_tx_loopback_result {
14102 cmdline_fixed_string_t set;
14103 cmdline_fixed_string_t tx;
14104 cmdline_fixed_string_t loopback;
14106 cmdline_fixed_string_t on_off;
14109 /* Common CLI fields for tx loopback enable disable */
14110 cmdline_parse_token_string_t cmd_tx_loopback_set =
14111 TOKEN_STRING_INITIALIZER
14112 (struct cmd_tx_loopback_result,
14114 cmdline_parse_token_string_t cmd_tx_loopback_tx =
14115 TOKEN_STRING_INITIALIZER
14116 (struct cmd_tx_loopback_result,
14118 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
14119 TOKEN_STRING_INITIALIZER
14120 (struct cmd_tx_loopback_result,
14121 loopback, "loopback");
14122 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
14123 TOKEN_NUM_INITIALIZER
14124 (struct cmd_tx_loopback_result,
14126 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
14127 TOKEN_STRING_INITIALIZER
14128 (struct cmd_tx_loopback_result,
14132 cmd_set_tx_loopback_parsed(
14133 void *parsed_result,
14134 __rte_unused struct cmdline *cl,
14135 __rte_unused void *data)
14137 struct cmd_tx_loopback_result *res = parsed_result;
14138 int ret = -ENOTSUP;
14140 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14142 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14145 #ifdef RTE_LIBRTE_IXGBE_PMD
14146 if (ret == -ENOTSUP)
14147 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
14149 #ifdef RTE_LIBRTE_I40E_PMD
14150 if (ret == -ENOTSUP)
14151 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
14153 #ifdef RTE_LIBRTE_BNXT_PMD
14154 if (ret == -ENOTSUP)
14155 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
14157 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
14158 if (ret == -ENOTSUP)
14159 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
14166 printf("invalid is_on %d\n", is_on);
14169 printf("invalid port_id %d\n", res->port_id);
14172 printf("function not implemented\n");
14175 printf("programming error: (%s)\n", strerror(-ret));
14179 cmdline_parse_inst_t cmd_set_tx_loopback = {
14180 .f = cmd_set_tx_loopback_parsed,
14182 .help_str = "set tx loopback <port_id> on|off",
14184 (void *)&cmd_tx_loopback_set,
14185 (void *)&cmd_tx_loopback_tx,
14186 (void *)&cmd_tx_loopback_loopback,
14187 (void *)&cmd_tx_loopback_port_id,
14188 (void *)&cmd_tx_loopback_on_off,
14193 /* all queues drop enable configuration */
14195 /* Common result structure for all queues drop enable */
14196 struct cmd_all_queues_drop_en_result {
14197 cmdline_fixed_string_t set;
14198 cmdline_fixed_string_t all;
14199 cmdline_fixed_string_t queues;
14200 cmdline_fixed_string_t drop;
14202 cmdline_fixed_string_t on_off;
14205 /* Common CLI fields for tx loopback enable disable */
14206 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
14207 TOKEN_STRING_INITIALIZER
14208 (struct cmd_all_queues_drop_en_result,
14210 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
14211 TOKEN_STRING_INITIALIZER
14212 (struct cmd_all_queues_drop_en_result,
14214 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
14215 TOKEN_STRING_INITIALIZER
14216 (struct cmd_all_queues_drop_en_result,
14218 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
14219 TOKEN_STRING_INITIALIZER
14220 (struct cmd_all_queues_drop_en_result,
14222 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
14223 TOKEN_NUM_INITIALIZER
14224 (struct cmd_all_queues_drop_en_result,
14226 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
14227 TOKEN_STRING_INITIALIZER
14228 (struct cmd_all_queues_drop_en_result,
14232 cmd_set_all_queues_drop_en_parsed(
14233 void *parsed_result,
14234 __rte_unused struct cmdline *cl,
14235 __rte_unused void *data)
14237 struct cmd_all_queues_drop_en_result *res = parsed_result;
14238 int ret = -ENOTSUP;
14239 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14241 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14244 #ifdef RTE_LIBRTE_IXGBE_PMD
14245 if (ret == -ENOTSUP)
14246 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
14248 #ifdef RTE_LIBRTE_BNXT_PMD
14249 if (ret == -ENOTSUP)
14250 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
14256 printf("invalid is_on %d\n", is_on);
14259 printf("invalid port_id %d\n", res->port_id);
14262 printf("function not implemented\n");
14265 printf("programming error: (%s)\n", strerror(-ret));
14269 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
14270 .f = cmd_set_all_queues_drop_en_parsed,
14272 .help_str = "set all queues drop <port_id> on|off",
14274 (void *)&cmd_all_queues_drop_en_set,
14275 (void *)&cmd_all_queues_drop_en_all,
14276 (void *)&cmd_all_queues_drop_en_queues,
14277 (void *)&cmd_all_queues_drop_en_drop,
14278 (void *)&cmd_all_queues_drop_en_port_id,
14279 (void *)&cmd_all_queues_drop_en_on_off,
14284 /* vf split drop enable configuration */
14286 /* Common result structure for vf split drop enable */
14287 struct cmd_vf_split_drop_en_result {
14288 cmdline_fixed_string_t set;
14289 cmdline_fixed_string_t vf;
14290 cmdline_fixed_string_t split;
14291 cmdline_fixed_string_t drop;
14294 cmdline_fixed_string_t on_off;
14297 /* Common CLI fields for vf split drop enable disable */
14298 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
14299 TOKEN_STRING_INITIALIZER
14300 (struct cmd_vf_split_drop_en_result,
14302 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
14303 TOKEN_STRING_INITIALIZER
14304 (struct cmd_vf_split_drop_en_result,
14306 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
14307 TOKEN_STRING_INITIALIZER
14308 (struct cmd_vf_split_drop_en_result,
14310 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
14311 TOKEN_STRING_INITIALIZER
14312 (struct cmd_vf_split_drop_en_result,
14314 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
14315 TOKEN_NUM_INITIALIZER
14316 (struct cmd_vf_split_drop_en_result,
14318 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
14319 TOKEN_NUM_INITIALIZER
14320 (struct cmd_vf_split_drop_en_result,
14322 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
14323 TOKEN_STRING_INITIALIZER
14324 (struct cmd_vf_split_drop_en_result,
14328 cmd_set_vf_split_drop_en_parsed(
14329 void *parsed_result,
14330 __rte_unused struct cmdline *cl,
14331 __rte_unused void *data)
14333 struct cmd_vf_split_drop_en_result *res = parsed_result;
14334 int ret = -ENOTSUP;
14335 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14337 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14340 #ifdef RTE_LIBRTE_IXGBE_PMD
14341 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14348 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14351 printf("invalid port_id %d\n", res->port_id);
14354 printf("not supported on port %d\n", res->port_id);
14357 printf("programming error: (%s)\n", strerror(-ret));
14361 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14362 .f = cmd_set_vf_split_drop_en_parsed,
14364 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14366 (void *)&cmd_vf_split_drop_en_set,
14367 (void *)&cmd_vf_split_drop_en_vf,
14368 (void *)&cmd_vf_split_drop_en_split,
14369 (void *)&cmd_vf_split_drop_en_drop,
14370 (void *)&cmd_vf_split_drop_en_port_id,
14371 (void *)&cmd_vf_split_drop_en_vf_id,
14372 (void *)&cmd_vf_split_drop_en_on_off,
14377 /* vf mac address configuration */
14379 /* Common result structure for vf mac address */
14380 struct cmd_set_vf_mac_addr_result {
14381 cmdline_fixed_string_t set;
14382 cmdline_fixed_string_t vf;
14383 cmdline_fixed_string_t mac;
14384 cmdline_fixed_string_t addr;
14387 struct rte_ether_addr mac_addr;
14391 /* Common CLI fields for vf split drop enable disable */
14392 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14393 TOKEN_STRING_INITIALIZER
14394 (struct cmd_set_vf_mac_addr_result,
14396 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14397 TOKEN_STRING_INITIALIZER
14398 (struct cmd_set_vf_mac_addr_result,
14400 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14401 TOKEN_STRING_INITIALIZER
14402 (struct cmd_set_vf_mac_addr_result,
14404 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14405 TOKEN_STRING_INITIALIZER
14406 (struct cmd_set_vf_mac_addr_result,
14408 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14409 TOKEN_NUM_INITIALIZER
14410 (struct cmd_set_vf_mac_addr_result,
14412 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14413 TOKEN_NUM_INITIALIZER
14414 (struct cmd_set_vf_mac_addr_result,
14416 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14417 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14421 cmd_set_vf_mac_addr_parsed(
14422 void *parsed_result,
14423 __rte_unused struct cmdline *cl,
14424 __rte_unused void *data)
14426 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14427 int ret = -ENOTSUP;
14429 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14432 #ifdef RTE_LIBRTE_IXGBE_PMD
14433 if (ret == -ENOTSUP)
14434 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14437 #ifdef RTE_LIBRTE_I40E_PMD
14438 if (ret == -ENOTSUP)
14439 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14442 #ifdef RTE_LIBRTE_BNXT_PMD
14443 if (ret == -ENOTSUP)
14444 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14452 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14455 printf("invalid port_id %d\n", res->port_id);
14458 printf("function not implemented\n");
14461 printf("programming error: (%s)\n", strerror(-ret));
14465 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14466 .f = cmd_set_vf_mac_addr_parsed,
14468 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14470 (void *)&cmd_set_vf_mac_addr_set,
14471 (void *)&cmd_set_vf_mac_addr_vf,
14472 (void *)&cmd_set_vf_mac_addr_mac,
14473 (void *)&cmd_set_vf_mac_addr_addr,
14474 (void *)&cmd_set_vf_mac_addr_port_id,
14475 (void *)&cmd_set_vf_mac_addr_vf_id,
14476 (void *)&cmd_set_vf_mac_addr_mac_addr,
14481 /* MACsec configuration */
14483 /* Common result structure for MACsec offload enable */
14484 struct cmd_macsec_offload_on_result {
14485 cmdline_fixed_string_t set;
14486 cmdline_fixed_string_t macsec;
14487 cmdline_fixed_string_t offload;
14489 cmdline_fixed_string_t on;
14490 cmdline_fixed_string_t encrypt;
14491 cmdline_fixed_string_t en_on_off;
14492 cmdline_fixed_string_t replay_protect;
14493 cmdline_fixed_string_t rp_on_off;
14496 /* Common CLI fields for MACsec offload disable */
14497 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14498 TOKEN_STRING_INITIALIZER
14499 (struct cmd_macsec_offload_on_result,
14501 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14502 TOKEN_STRING_INITIALIZER
14503 (struct cmd_macsec_offload_on_result,
14505 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14506 TOKEN_STRING_INITIALIZER
14507 (struct cmd_macsec_offload_on_result,
14508 offload, "offload");
14509 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14510 TOKEN_NUM_INITIALIZER
14511 (struct cmd_macsec_offload_on_result,
14513 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14514 TOKEN_STRING_INITIALIZER
14515 (struct cmd_macsec_offload_on_result,
14517 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14518 TOKEN_STRING_INITIALIZER
14519 (struct cmd_macsec_offload_on_result,
14520 encrypt, "encrypt");
14521 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14522 TOKEN_STRING_INITIALIZER
14523 (struct cmd_macsec_offload_on_result,
14524 en_on_off, "on#off");
14525 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14526 TOKEN_STRING_INITIALIZER
14527 (struct cmd_macsec_offload_on_result,
14528 replay_protect, "replay-protect");
14529 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14530 TOKEN_STRING_INITIALIZER
14531 (struct cmd_macsec_offload_on_result,
14532 rp_on_off, "on#off");
14535 cmd_set_macsec_offload_on_parsed(
14536 void *parsed_result,
14537 __rte_unused struct cmdline *cl,
14538 __rte_unused void *data)
14540 struct cmd_macsec_offload_on_result *res = parsed_result;
14541 int ret = -ENOTSUP;
14542 portid_t port_id = res->port_id;
14543 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14544 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14545 struct rte_eth_dev_info dev_info;
14547 if (port_id_is_invalid(port_id, ENABLED_WARN))
14549 if (!port_is_stopped(port_id)) {
14550 printf("Please stop port %d first\n", port_id);
14554 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14558 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14559 #ifdef RTE_LIBRTE_IXGBE_PMD
14560 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14568 ports[port_id].dev_conf.txmode.offloads |=
14569 DEV_TX_OFFLOAD_MACSEC_INSERT;
14570 cmd_reconfig_device_queue(port_id, 1, 1);
14573 printf("invalid port_id %d\n", port_id);
14576 printf("not supported on port %d\n", port_id);
14579 printf("programming error: (%s)\n", strerror(-ret));
14583 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14584 .f = cmd_set_macsec_offload_on_parsed,
14586 .help_str = "set macsec offload <port_id> on "
14587 "encrypt on|off replay-protect on|off",
14589 (void *)&cmd_macsec_offload_on_set,
14590 (void *)&cmd_macsec_offload_on_macsec,
14591 (void *)&cmd_macsec_offload_on_offload,
14592 (void *)&cmd_macsec_offload_on_port_id,
14593 (void *)&cmd_macsec_offload_on_on,
14594 (void *)&cmd_macsec_offload_on_encrypt,
14595 (void *)&cmd_macsec_offload_on_en_on_off,
14596 (void *)&cmd_macsec_offload_on_replay_protect,
14597 (void *)&cmd_macsec_offload_on_rp_on_off,
14602 /* Common result structure for MACsec offload disable */
14603 struct cmd_macsec_offload_off_result {
14604 cmdline_fixed_string_t set;
14605 cmdline_fixed_string_t macsec;
14606 cmdline_fixed_string_t offload;
14608 cmdline_fixed_string_t off;
14611 /* Common CLI fields for MACsec offload disable */
14612 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14613 TOKEN_STRING_INITIALIZER
14614 (struct cmd_macsec_offload_off_result,
14616 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14617 TOKEN_STRING_INITIALIZER
14618 (struct cmd_macsec_offload_off_result,
14620 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14621 TOKEN_STRING_INITIALIZER
14622 (struct cmd_macsec_offload_off_result,
14623 offload, "offload");
14624 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14625 TOKEN_NUM_INITIALIZER
14626 (struct cmd_macsec_offload_off_result,
14628 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14629 TOKEN_STRING_INITIALIZER
14630 (struct cmd_macsec_offload_off_result,
14634 cmd_set_macsec_offload_off_parsed(
14635 void *parsed_result,
14636 __rte_unused struct cmdline *cl,
14637 __rte_unused void *data)
14639 struct cmd_macsec_offload_off_result *res = parsed_result;
14640 int ret = -ENOTSUP;
14641 struct rte_eth_dev_info dev_info;
14642 portid_t port_id = res->port_id;
14644 if (port_id_is_invalid(port_id, ENABLED_WARN))
14646 if (!port_is_stopped(port_id)) {
14647 printf("Please stop port %d first\n", port_id);
14651 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14655 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14656 #ifdef RTE_LIBRTE_IXGBE_PMD
14657 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14662 ports[port_id].dev_conf.txmode.offloads &=
14663 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14664 cmd_reconfig_device_queue(port_id, 1, 1);
14667 printf("invalid port_id %d\n", port_id);
14670 printf("not supported on port %d\n", port_id);
14673 printf("programming error: (%s)\n", strerror(-ret));
14677 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14678 .f = cmd_set_macsec_offload_off_parsed,
14680 .help_str = "set macsec offload <port_id> off",
14682 (void *)&cmd_macsec_offload_off_set,
14683 (void *)&cmd_macsec_offload_off_macsec,
14684 (void *)&cmd_macsec_offload_off_offload,
14685 (void *)&cmd_macsec_offload_off_port_id,
14686 (void *)&cmd_macsec_offload_off_off,
14691 /* Common result structure for MACsec secure connection configure */
14692 struct cmd_macsec_sc_result {
14693 cmdline_fixed_string_t set;
14694 cmdline_fixed_string_t macsec;
14695 cmdline_fixed_string_t sc;
14696 cmdline_fixed_string_t tx_rx;
14698 struct rte_ether_addr mac;
14702 /* Common CLI fields for MACsec secure connection configure */
14703 cmdline_parse_token_string_t cmd_macsec_sc_set =
14704 TOKEN_STRING_INITIALIZER
14705 (struct cmd_macsec_sc_result,
14707 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14708 TOKEN_STRING_INITIALIZER
14709 (struct cmd_macsec_sc_result,
14711 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14712 TOKEN_STRING_INITIALIZER
14713 (struct cmd_macsec_sc_result,
14715 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14716 TOKEN_STRING_INITIALIZER
14717 (struct cmd_macsec_sc_result,
14719 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14720 TOKEN_NUM_INITIALIZER
14721 (struct cmd_macsec_sc_result,
14723 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14724 TOKEN_ETHERADDR_INITIALIZER
14725 (struct cmd_macsec_sc_result,
14727 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14728 TOKEN_NUM_INITIALIZER
14729 (struct cmd_macsec_sc_result,
14733 cmd_set_macsec_sc_parsed(
14734 void *parsed_result,
14735 __rte_unused struct cmdline *cl,
14736 __rte_unused void *data)
14738 struct cmd_macsec_sc_result *res = parsed_result;
14739 int ret = -ENOTSUP;
14740 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14742 #ifdef RTE_LIBRTE_IXGBE_PMD
14744 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14745 res->mac.addr_bytes) :
14746 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14747 res->mac.addr_bytes, res->pi);
14749 RTE_SET_USED(is_tx);
14755 printf("invalid port_id %d\n", res->port_id);
14758 printf("not supported on port %d\n", res->port_id);
14761 printf("programming error: (%s)\n", strerror(-ret));
14765 cmdline_parse_inst_t cmd_set_macsec_sc = {
14766 .f = cmd_set_macsec_sc_parsed,
14768 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14770 (void *)&cmd_macsec_sc_set,
14771 (void *)&cmd_macsec_sc_macsec,
14772 (void *)&cmd_macsec_sc_sc,
14773 (void *)&cmd_macsec_sc_tx_rx,
14774 (void *)&cmd_macsec_sc_port_id,
14775 (void *)&cmd_macsec_sc_mac,
14776 (void *)&cmd_macsec_sc_pi,
14781 /* Common result structure for MACsec secure connection configure */
14782 struct cmd_macsec_sa_result {
14783 cmdline_fixed_string_t set;
14784 cmdline_fixed_string_t macsec;
14785 cmdline_fixed_string_t sa;
14786 cmdline_fixed_string_t tx_rx;
14791 cmdline_fixed_string_t key;
14794 /* Common CLI fields for MACsec secure connection configure */
14795 cmdline_parse_token_string_t cmd_macsec_sa_set =
14796 TOKEN_STRING_INITIALIZER
14797 (struct cmd_macsec_sa_result,
14799 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14800 TOKEN_STRING_INITIALIZER
14801 (struct cmd_macsec_sa_result,
14803 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14804 TOKEN_STRING_INITIALIZER
14805 (struct cmd_macsec_sa_result,
14807 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14808 TOKEN_STRING_INITIALIZER
14809 (struct cmd_macsec_sa_result,
14811 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14812 TOKEN_NUM_INITIALIZER
14813 (struct cmd_macsec_sa_result,
14815 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14816 TOKEN_NUM_INITIALIZER
14817 (struct cmd_macsec_sa_result,
14819 cmdline_parse_token_num_t cmd_macsec_sa_an =
14820 TOKEN_NUM_INITIALIZER
14821 (struct cmd_macsec_sa_result,
14823 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14824 TOKEN_NUM_INITIALIZER
14825 (struct cmd_macsec_sa_result,
14827 cmdline_parse_token_string_t cmd_macsec_sa_key =
14828 TOKEN_STRING_INITIALIZER
14829 (struct cmd_macsec_sa_result,
14833 cmd_set_macsec_sa_parsed(
14834 void *parsed_result,
14835 __rte_unused struct cmdline *cl,
14836 __rte_unused void *data)
14838 struct cmd_macsec_sa_result *res = parsed_result;
14839 int ret = -ENOTSUP;
14840 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14841 uint8_t key[16] = { 0 };
14847 key_len = strlen(res->key) / 2;
14851 for (i = 0; i < key_len; i++) {
14852 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14855 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14858 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14861 #ifdef RTE_LIBRTE_IXGBE_PMD
14863 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14864 res->idx, res->an, res->pn, key) :
14865 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14866 res->idx, res->an, res->pn, key);
14868 RTE_SET_USED(is_tx);
14875 printf("invalid idx %d or an %d\n", res->idx, res->an);
14878 printf("invalid port_id %d\n", res->port_id);
14881 printf("not supported on port %d\n", res->port_id);
14884 printf("programming error: (%s)\n", strerror(-ret));
14888 cmdline_parse_inst_t cmd_set_macsec_sa = {
14889 .f = cmd_set_macsec_sa_parsed,
14891 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14893 (void *)&cmd_macsec_sa_set,
14894 (void *)&cmd_macsec_sa_macsec,
14895 (void *)&cmd_macsec_sa_sa,
14896 (void *)&cmd_macsec_sa_tx_rx,
14897 (void *)&cmd_macsec_sa_port_id,
14898 (void *)&cmd_macsec_sa_idx,
14899 (void *)&cmd_macsec_sa_an,
14900 (void *)&cmd_macsec_sa_pn,
14901 (void *)&cmd_macsec_sa_key,
14906 /* VF unicast promiscuous mode configuration */
14908 /* Common result structure for VF unicast promiscuous mode */
14909 struct cmd_vf_promisc_result {
14910 cmdline_fixed_string_t set;
14911 cmdline_fixed_string_t vf;
14912 cmdline_fixed_string_t promisc;
14915 cmdline_fixed_string_t on_off;
14918 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14919 cmdline_parse_token_string_t cmd_vf_promisc_set =
14920 TOKEN_STRING_INITIALIZER
14921 (struct cmd_vf_promisc_result,
14923 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14924 TOKEN_STRING_INITIALIZER
14925 (struct cmd_vf_promisc_result,
14927 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14928 TOKEN_STRING_INITIALIZER
14929 (struct cmd_vf_promisc_result,
14930 promisc, "promisc");
14931 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14932 TOKEN_NUM_INITIALIZER
14933 (struct cmd_vf_promisc_result,
14935 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14936 TOKEN_NUM_INITIALIZER
14937 (struct cmd_vf_promisc_result,
14939 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14940 TOKEN_STRING_INITIALIZER
14941 (struct cmd_vf_promisc_result,
14945 cmd_set_vf_promisc_parsed(
14946 void *parsed_result,
14947 __rte_unused struct cmdline *cl,
14948 __rte_unused void *data)
14950 struct cmd_vf_promisc_result *res = parsed_result;
14951 int ret = -ENOTSUP;
14953 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14955 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14958 #ifdef RTE_LIBRTE_I40E_PMD
14959 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14960 res->vf_id, is_on);
14967 printf("invalid vf_id %d\n", res->vf_id);
14970 printf("invalid port_id %d\n", res->port_id);
14973 printf("function not implemented\n");
14976 printf("programming error: (%s)\n", strerror(-ret));
14980 cmdline_parse_inst_t cmd_set_vf_promisc = {
14981 .f = cmd_set_vf_promisc_parsed,
14983 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14984 "Set unicast promiscuous mode for a VF from the PF",
14986 (void *)&cmd_vf_promisc_set,
14987 (void *)&cmd_vf_promisc_vf,
14988 (void *)&cmd_vf_promisc_promisc,
14989 (void *)&cmd_vf_promisc_port_id,
14990 (void *)&cmd_vf_promisc_vf_id,
14991 (void *)&cmd_vf_promisc_on_off,
14996 /* VF multicast promiscuous mode configuration */
14998 /* Common result structure for VF multicast promiscuous mode */
14999 struct cmd_vf_allmulti_result {
15000 cmdline_fixed_string_t set;
15001 cmdline_fixed_string_t vf;
15002 cmdline_fixed_string_t allmulti;
15005 cmdline_fixed_string_t on_off;
15008 /* Common CLI fields for VF multicast promiscuous mode enable disable */
15009 cmdline_parse_token_string_t cmd_vf_allmulti_set =
15010 TOKEN_STRING_INITIALIZER
15011 (struct cmd_vf_allmulti_result,
15013 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
15014 TOKEN_STRING_INITIALIZER
15015 (struct cmd_vf_allmulti_result,
15017 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
15018 TOKEN_STRING_INITIALIZER
15019 (struct cmd_vf_allmulti_result,
15020 allmulti, "allmulti");
15021 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
15022 TOKEN_NUM_INITIALIZER
15023 (struct cmd_vf_allmulti_result,
15025 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
15026 TOKEN_NUM_INITIALIZER
15027 (struct cmd_vf_allmulti_result,
15029 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
15030 TOKEN_STRING_INITIALIZER
15031 (struct cmd_vf_allmulti_result,
15035 cmd_set_vf_allmulti_parsed(
15036 void *parsed_result,
15037 __rte_unused struct cmdline *cl,
15038 __rte_unused void *data)
15040 struct cmd_vf_allmulti_result *res = parsed_result;
15041 int ret = -ENOTSUP;
15043 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15045 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15048 #ifdef RTE_LIBRTE_I40E_PMD
15049 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
15050 res->vf_id, is_on);
15057 printf("invalid vf_id %d\n", res->vf_id);
15060 printf("invalid port_id %d\n", res->port_id);
15063 printf("function not implemented\n");
15066 printf("programming error: (%s)\n", strerror(-ret));
15070 cmdline_parse_inst_t cmd_set_vf_allmulti = {
15071 .f = cmd_set_vf_allmulti_parsed,
15073 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
15074 "Set multicast promiscuous mode for a VF from the PF",
15076 (void *)&cmd_vf_allmulti_set,
15077 (void *)&cmd_vf_allmulti_vf,
15078 (void *)&cmd_vf_allmulti_allmulti,
15079 (void *)&cmd_vf_allmulti_port_id,
15080 (void *)&cmd_vf_allmulti_vf_id,
15081 (void *)&cmd_vf_allmulti_on_off,
15086 /* vf broadcast mode configuration */
15088 /* Common result structure for vf broadcast */
15089 struct cmd_set_vf_broadcast_result {
15090 cmdline_fixed_string_t set;
15091 cmdline_fixed_string_t vf;
15092 cmdline_fixed_string_t broadcast;
15095 cmdline_fixed_string_t on_off;
15098 /* Common CLI fields for vf broadcast enable disable */
15099 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
15100 TOKEN_STRING_INITIALIZER
15101 (struct cmd_set_vf_broadcast_result,
15103 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
15104 TOKEN_STRING_INITIALIZER
15105 (struct cmd_set_vf_broadcast_result,
15107 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
15108 TOKEN_STRING_INITIALIZER
15109 (struct cmd_set_vf_broadcast_result,
15110 broadcast, "broadcast");
15111 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
15112 TOKEN_NUM_INITIALIZER
15113 (struct cmd_set_vf_broadcast_result,
15115 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
15116 TOKEN_NUM_INITIALIZER
15117 (struct cmd_set_vf_broadcast_result,
15119 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
15120 TOKEN_STRING_INITIALIZER
15121 (struct cmd_set_vf_broadcast_result,
15125 cmd_set_vf_broadcast_parsed(
15126 void *parsed_result,
15127 __rte_unused struct cmdline *cl,
15128 __rte_unused void *data)
15130 struct cmd_set_vf_broadcast_result *res = parsed_result;
15131 int ret = -ENOTSUP;
15133 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15135 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15138 #ifdef RTE_LIBRTE_I40E_PMD
15139 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
15140 res->vf_id, is_on);
15147 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15150 printf("invalid port_id %d\n", res->port_id);
15153 printf("function not implemented\n");
15156 printf("programming error: (%s)\n", strerror(-ret));
15160 cmdline_parse_inst_t cmd_set_vf_broadcast = {
15161 .f = cmd_set_vf_broadcast_parsed,
15163 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
15165 (void *)&cmd_set_vf_broadcast_set,
15166 (void *)&cmd_set_vf_broadcast_vf,
15167 (void *)&cmd_set_vf_broadcast_broadcast,
15168 (void *)&cmd_set_vf_broadcast_port_id,
15169 (void *)&cmd_set_vf_broadcast_vf_id,
15170 (void *)&cmd_set_vf_broadcast_on_off,
15175 /* vf vlan tag configuration */
15177 /* Common result structure for vf vlan tag */
15178 struct cmd_set_vf_vlan_tag_result {
15179 cmdline_fixed_string_t set;
15180 cmdline_fixed_string_t vf;
15181 cmdline_fixed_string_t vlan;
15182 cmdline_fixed_string_t tag;
15185 cmdline_fixed_string_t on_off;
15188 /* Common CLI fields for vf vlan tag enable disable */
15189 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
15190 TOKEN_STRING_INITIALIZER
15191 (struct cmd_set_vf_vlan_tag_result,
15193 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
15194 TOKEN_STRING_INITIALIZER
15195 (struct cmd_set_vf_vlan_tag_result,
15197 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
15198 TOKEN_STRING_INITIALIZER
15199 (struct cmd_set_vf_vlan_tag_result,
15201 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
15202 TOKEN_STRING_INITIALIZER
15203 (struct cmd_set_vf_vlan_tag_result,
15205 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
15206 TOKEN_NUM_INITIALIZER
15207 (struct cmd_set_vf_vlan_tag_result,
15209 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
15210 TOKEN_NUM_INITIALIZER
15211 (struct cmd_set_vf_vlan_tag_result,
15213 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
15214 TOKEN_STRING_INITIALIZER
15215 (struct cmd_set_vf_vlan_tag_result,
15219 cmd_set_vf_vlan_tag_parsed(
15220 void *parsed_result,
15221 __rte_unused struct cmdline *cl,
15222 __rte_unused void *data)
15224 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
15225 int ret = -ENOTSUP;
15227 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15229 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15232 #ifdef RTE_LIBRTE_I40E_PMD
15233 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
15234 res->vf_id, is_on);
15241 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15244 printf("invalid port_id %d\n", res->port_id);
15247 printf("function not implemented\n");
15250 printf("programming error: (%s)\n", strerror(-ret));
15254 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
15255 .f = cmd_set_vf_vlan_tag_parsed,
15257 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
15259 (void *)&cmd_set_vf_vlan_tag_set,
15260 (void *)&cmd_set_vf_vlan_tag_vf,
15261 (void *)&cmd_set_vf_vlan_tag_vlan,
15262 (void *)&cmd_set_vf_vlan_tag_tag,
15263 (void *)&cmd_set_vf_vlan_tag_port_id,
15264 (void *)&cmd_set_vf_vlan_tag_vf_id,
15265 (void *)&cmd_set_vf_vlan_tag_on_off,
15270 /* Common definition of VF and TC TX bandwidth configuration */
15271 struct cmd_vf_tc_bw_result {
15272 cmdline_fixed_string_t set;
15273 cmdline_fixed_string_t vf;
15274 cmdline_fixed_string_t tc;
15275 cmdline_fixed_string_t tx;
15276 cmdline_fixed_string_t min_bw;
15277 cmdline_fixed_string_t max_bw;
15278 cmdline_fixed_string_t strict_link_prio;
15283 cmdline_fixed_string_t bw_list;
15287 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
15288 TOKEN_STRING_INITIALIZER
15289 (struct cmd_vf_tc_bw_result,
15291 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
15292 TOKEN_STRING_INITIALIZER
15293 (struct cmd_vf_tc_bw_result,
15295 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
15296 TOKEN_STRING_INITIALIZER
15297 (struct cmd_vf_tc_bw_result,
15299 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
15300 TOKEN_STRING_INITIALIZER
15301 (struct cmd_vf_tc_bw_result,
15303 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
15304 TOKEN_STRING_INITIALIZER
15305 (struct cmd_vf_tc_bw_result,
15306 strict_link_prio, "strict-link-priority");
15307 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
15308 TOKEN_STRING_INITIALIZER
15309 (struct cmd_vf_tc_bw_result,
15310 min_bw, "min-bandwidth");
15311 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
15312 TOKEN_STRING_INITIALIZER
15313 (struct cmd_vf_tc_bw_result,
15314 max_bw, "max-bandwidth");
15315 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
15316 TOKEN_NUM_INITIALIZER
15317 (struct cmd_vf_tc_bw_result,
15319 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
15320 TOKEN_NUM_INITIALIZER
15321 (struct cmd_vf_tc_bw_result,
15323 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
15324 TOKEN_NUM_INITIALIZER
15325 (struct cmd_vf_tc_bw_result,
15327 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
15328 TOKEN_NUM_INITIALIZER
15329 (struct cmd_vf_tc_bw_result,
15331 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
15332 TOKEN_STRING_INITIALIZER
15333 (struct cmd_vf_tc_bw_result,
15335 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
15336 TOKEN_NUM_INITIALIZER
15337 (struct cmd_vf_tc_bw_result,
15340 /* VF max bandwidth setting */
15342 cmd_vf_max_bw_parsed(
15343 void *parsed_result,
15344 __rte_unused struct cmdline *cl,
15345 __rte_unused void *data)
15347 struct cmd_vf_tc_bw_result *res = parsed_result;
15348 int ret = -ENOTSUP;
15350 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15353 #ifdef RTE_LIBRTE_I40E_PMD
15354 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15355 res->vf_id, res->bw);
15362 printf("invalid vf_id %d or bandwidth %d\n",
15363 res->vf_id, res->bw);
15366 printf("invalid port_id %d\n", res->port_id);
15369 printf("function not implemented\n");
15372 printf("programming error: (%s)\n", strerror(-ret));
15376 cmdline_parse_inst_t cmd_vf_max_bw = {
15377 .f = cmd_vf_max_bw_parsed,
15379 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15381 (void *)&cmd_vf_tc_bw_set,
15382 (void *)&cmd_vf_tc_bw_vf,
15383 (void *)&cmd_vf_tc_bw_tx,
15384 (void *)&cmd_vf_tc_bw_max_bw,
15385 (void *)&cmd_vf_tc_bw_port_id,
15386 (void *)&cmd_vf_tc_bw_vf_id,
15387 (void *)&cmd_vf_tc_bw_bw,
15393 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15398 const char *p, *p0 = str;
15405 p = strchr(p0, '(');
15407 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15411 p0 = strchr(p, ')');
15413 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15417 if (size >= sizeof(s)) {
15418 printf("The string size exceeds the internal buffer size\n");
15421 snprintf(s, sizeof(s), "%.*s", size, p);
15422 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15424 printf("Failed to get the bandwidth list. ");
15428 for (i = 0; i < ret; i++)
15429 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15434 /* TC min bandwidth setting */
15436 cmd_vf_tc_min_bw_parsed(
15437 void *parsed_result,
15438 __rte_unused struct cmdline *cl,
15439 __rte_unused void *data)
15441 struct cmd_vf_tc_bw_result *res = parsed_result;
15444 int ret = -ENOTSUP;
15446 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15449 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15453 #ifdef RTE_LIBRTE_I40E_PMD
15454 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15462 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15465 printf("invalid port_id %d\n", res->port_id);
15468 printf("function not implemented\n");
15471 printf("programming error: (%s)\n", strerror(-ret));
15475 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15476 .f = cmd_vf_tc_min_bw_parsed,
15478 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15479 " <bw1, bw2, ...>",
15481 (void *)&cmd_vf_tc_bw_set,
15482 (void *)&cmd_vf_tc_bw_vf,
15483 (void *)&cmd_vf_tc_bw_tc,
15484 (void *)&cmd_vf_tc_bw_tx,
15485 (void *)&cmd_vf_tc_bw_min_bw,
15486 (void *)&cmd_vf_tc_bw_port_id,
15487 (void *)&cmd_vf_tc_bw_vf_id,
15488 (void *)&cmd_vf_tc_bw_bw_list,
15494 cmd_tc_min_bw_parsed(
15495 void *parsed_result,
15496 __rte_unused struct cmdline *cl,
15497 __rte_unused void *data)
15499 struct cmd_vf_tc_bw_result *res = parsed_result;
15500 struct rte_port *port;
15503 int ret = -ENOTSUP;
15505 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15508 port = &ports[res->port_id];
15509 /** Check if the port is not started **/
15510 if (port->port_status != RTE_PORT_STOPPED) {
15511 printf("Please stop port %d first\n", res->port_id);
15515 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15519 #ifdef RTE_LIBRTE_IXGBE_PMD
15520 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15527 printf("invalid bandwidth\n");
15530 printf("invalid port_id %d\n", res->port_id);
15533 printf("function not implemented\n");
15536 printf("programming error: (%s)\n", strerror(-ret));
15540 cmdline_parse_inst_t cmd_tc_min_bw = {
15541 .f = cmd_tc_min_bw_parsed,
15543 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15545 (void *)&cmd_vf_tc_bw_set,
15546 (void *)&cmd_vf_tc_bw_tc,
15547 (void *)&cmd_vf_tc_bw_tx,
15548 (void *)&cmd_vf_tc_bw_min_bw,
15549 (void *)&cmd_vf_tc_bw_port_id,
15550 (void *)&cmd_vf_tc_bw_bw_list,
15555 /* TC max bandwidth setting */
15557 cmd_vf_tc_max_bw_parsed(
15558 void *parsed_result,
15559 __rte_unused struct cmdline *cl,
15560 __rte_unused void *data)
15562 struct cmd_vf_tc_bw_result *res = parsed_result;
15563 int ret = -ENOTSUP;
15565 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15568 #ifdef RTE_LIBRTE_I40E_PMD
15569 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15570 res->tc_no, res->bw);
15577 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15578 res->vf_id, res->tc_no, res->bw);
15581 printf("invalid port_id %d\n", res->port_id);
15584 printf("function not implemented\n");
15587 printf("programming error: (%s)\n", strerror(-ret));
15591 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15592 .f = cmd_vf_tc_max_bw_parsed,
15594 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15597 (void *)&cmd_vf_tc_bw_set,
15598 (void *)&cmd_vf_tc_bw_vf,
15599 (void *)&cmd_vf_tc_bw_tc,
15600 (void *)&cmd_vf_tc_bw_tx,
15601 (void *)&cmd_vf_tc_bw_max_bw,
15602 (void *)&cmd_vf_tc_bw_port_id,
15603 (void *)&cmd_vf_tc_bw_vf_id,
15604 (void *)&cmd_vf_tc_bw_tc_no,
15605 (void *)&cmd_vf_tc_bw_bw,
15610 /** Set VXLAN encapsulation details */
15611 struct cmd_set_vxlan_result {
15612 cmdline_fixed_string_t set;
15613 cmdline_fixed_string_t vxlan;
15614 cmdline_fixed_string_t pos_token;
15615 cmdline_fixed_string_t ip_version;
15616 uint32_t vlan_present:1;
15620 cmdline_ipaddr_t ip_src;
15621 cmdline_ipaddr_t ip_dst;
15625 struct rte_ether_addr eth_src;
15626 struct rte_ether_addr eth_dst;
15629 cmdline_parse_token_string_t cmd_set_vxlan_set =
15630 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15631 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15632 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15633 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15634 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15636 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15637 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15638 "vxlan-with-vlan");
15639 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15640 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15642 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15643 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15645 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15646 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15648 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15649 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15650 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15651 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15653 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15654 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15655 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15656 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15658 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15659 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15660 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15661 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15663 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15664 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15665 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15666 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15668 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15669 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15670 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15671 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15673 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15674 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15675 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15676 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15678 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15679 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15680 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15681 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15683 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15684 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15685 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15686 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15688 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15689 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15690 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15691 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15693 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15694 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15696 static void cmd_set_vxlan_parsed(void *parsed_result,
15697 __rte_unused struct cmdline *cl,
15698 __rte_unused void *data)
15700 struct cmd_set_vxlan_result *res = parsed_result;
15705 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15708 vxlan_encap_conf.select_tos_ttl = 0;
15709 if (strcmp(res->vxlan, "vxlan") == 0)
15710 vxlan_encap_conf.select_vlan = 0;
15711 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15712 vxlan_encap_conf.select_vlan = 1;
15713 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15714 vxlan_encap_conf.select_vlan = 0;
15715 vxlan_encap_conf.select_tos_ttl = 1;
15717 if (strcmp(res->ip_version, "ipv4") == 0)
15718 vxlan_encap_conf.select_ipv4 = 1;
15719 else if (strcmp(res->ip_version, "ipv6") == 0)
15720 vxlan_encap_conf.select_ipv4 = 0;
15723 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15724 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15725 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15726 vxlan_encap_conf.ip_tos = res->tos;
15727 vxlan_encap_conf.ip_ttl = res->ttl;
15728 if (vxlan_encap_conf.select_ipv4) {
15729 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15730 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15732 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15733 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15735 if (vxlan_encap_conf.select_vlan)
15736 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15737 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15738 RTE_ETHER_ADDR_LEN);
15739 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15740 RTE_ETHER_ADDR_LEN);
15743 cmdline_parse_inst_t cmd_set_vxlan = {
15744 .f = cmd_set_vxlan_parsed,
15746 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15747 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15748 " eth-src <eth-src> eth-dst <eth-dst>",
15750 (void *)&cmd_set_vxlan_set,
15751 (void *)&cmd_set_vxlan_vxlan,
15752 (void *)&cmd_set_vxlan_ip_version,
15753 (void *)&cmd_set_vxlan_ip_version_value,
15754 (void *)&cmd_set_vxlan_vni,
15755 (void *)&cmd_set_vxlan_vni_value,
15756 (void *)&cmd_set_vxlan_udp_src,
15757 (void *)&cmd_set_vxlan_udp_src_value,
15758 (void *)&cmd_set_vxlan_udp_dst,
15759 (void *)&cmd_set_vxlan_udp_dst_value,
15760 (void *)&cmd_set_vxlan_ip_src,
15761 (void *)&cmd_set_vxlan_ip_src_value,
15762 (void *)&cmd_set_vxlan_ip_dst,
15763 (void *)&cmd_set_vxlan_ip_dst_value,
15764 (void *)&cmd_set_vxlan_eth_src,
15765 (void *)&cmd_set_vxlan_eth_src_value,
15766 (void *)&cmd_set_vxlan_eth_dst,
15767 (void *)&cmd_set_vxlan_eth_dst_value,
15772 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15773 .f = cmd_set_vxlan_parsed,
15775 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15776 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15777 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15778 " eth-dst <eth-dst>",
15780 (void *)&cmd_set_vxlan_set,
15781 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15782 (void *)&cmd_set_vxlan_ip_version,
15783 (void *)&cmd_set_vxlan_ip_version_value,
15784 (void *)&cmd_set_vxlan_vni,
15785 (void *)&cmd_set_vxlan_vni_value,
15786 (void *)&cmd_set_vxlan_udp_src,
15787 (void *)&cmd_set_vxlan_udp_src_value,
15788 (void *)&cmd_set_vxlan_udp_dst,
15789 (void *)&cmd_set_vxlan_udp_dst_value,
15790 (void *)&cmd_set_vxlan_ip_tos,
15791 (void *)&cmd_set_vxlan_ip_tos_value,
15792 (void *)&cmd_set_vxlan_ip_ttl,
15793 (void *)&cmd_set_vxlan_ip_ttl_value,
15794 (void *)&cmd_set_vxlan_ip_src,
15795 (void *)&cmd_set_vxlan_ip_src_value,
15796 (void *)&cmd_set_vxlan_ip_dst,
15797 (void *)&cmd_set_vxlan_ip_dst_value,
15798 (void *)&cmd_set_vxlan_eth_src,
15799 (void *)&cmd_set_vxlan_eth_src_value,
15800 (void *)&cmd_set_vxlan_eth_dst,
15801 (void *)&cmd_set_vxlan_eth_dst_value,
15806 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15807 .f = cmd_set_vxlan_parsed,
15809 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15810 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15811 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15814 (void *)&cmd_set_vxlan_set,
15815 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15816 (void *)&cmd_set_vxlan_ip_version,
15817 (void *)&cmd_set_vxlan_ip_version_value,
15818 (void *)&cmd_set_vxlan_vni,
15819 (void *)&cmd_set_vxlan_vni_value,
15820 (void *)&cmd_set_vxlan_udp_src,
15821 (void *)&cmd_set_vxlan_udp_src_value,
15822 (void *)&cmd_set_vxlan_udp_dst,
15823 (void *)&cmd_set_vxlan_udp_dst_value,
15824 (void *)&cmd_set_vxlan_ip_src,
15825 (void *)&cmd_set_vxlan_ip_src_value,
15826 (void *)&cmd_set_vxlan_ip_dst,
15827 (void *)&cmd_set_vxlan_ip_dst_value,
15828 (void *)&cmd_set_vxlan_vlan,
15829 (void *)&cmd_set_vxlan_vlan_value,
15830 (void *)&cmd_set_vxlan_eth_src,
15831 (void *)&cmd_set_vxlan_eth_src_value,
15832 (void *)&cmd_set_vxlan_eth_dst,
15833 (void *)&cmd_set_vxlan_eth_dst_value,
15838 /** Set NVGRE encapsulation details */
15839 struct cmd_set_nvgre_result {
15840 cmdline_fixed_string_t set;
15841 cmdline_fixed_string_t nvgre;
15842 cmdline_fixed_string_t pos_token;
15843 cmdline_fixed_string_t ip_version;
15845 cmdline_ipaddr_t ip_src;
15846 cmdline_ipaddr_t ip_dst;
15848 struct rte_ether_addr eth_src;
15849 struct rte_ether_addr eth_dst;
15852 cmdline_parse_token_string_t cmd_set_nvgre_set =
15853 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15854 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15855 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15856 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15857 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15858 "nvgre-with-vlan");
15859 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15860 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15862 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15863 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15865 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15866 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15868 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15869 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15870 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15871 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15873 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15874 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15875 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15876 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15878 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15879 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15880 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15881 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15883 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15884 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15885 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15886 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15888 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15889 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15890 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15891 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15893 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15894 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15896 static void cmd_set_nvgre_parsed(void *parsed_result,
15897 __rte_unused struct cmdline *cl,
15898 __rte_unused void *data)
15900 struct cmd_set_nvgre_result *res = parsed_result;
15902 uint32_t nvgre_tni;
15905 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15908 if (strcmp(res->nvgre, "nvgre") == 0)
15909 nvgre_encap_conf.select_vlan = 0;
15910 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15911 nvgre_encap_conf.select_vlan = 1;
15912 if (strcmp(res->ip_version, "ipv4") == 0)
15913 nvgre_encap_conf.select_ipv4 = 1;
15914 else if (strcmp(res->ip_version, "ipv6") == 0)
15915 nvgre_encap_conf.select_ipv4 = 0;
15918 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15919 if (nvgre_encap_conf.select_ipv4) {
15920 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15921 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15923 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15924 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15926 if (nvgre_encap_conf.select_vlan)
15927 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15928 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15929 RTE_ETHER_ADDR_LEN);
15930 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15931 RTE_ETHER_ADDR_LEN);
15934 cmdline_parse_inst_t cmd_set_nvgre = {
15935 .f = cmd_set_nvgre_parsed,
15937 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15938 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15939 " eth-dst <eth-dst>",
15941 (void *)&cmd_set_nvgre_set,
15942 (void *)&cmd_set_nvgre_nvgre,
15943 (void *)&cmd_set_nvgre_ip_version,
15944 (void *)&cmd_set_nvgre_ip_version_value,
15945 (void *)&cmd_set_nvgre_tni,
15946 (void *)&cmd_set_nvgre_tni_value,
15947 (void *)&cmd_set_nvgre_ip_src,
15948 (void *)&cmd_set_nvgre_ip_src_value,
15949 (void *)&cmd_set_nvgre_ip_dst,
15950 (void *)&cmd_set_nvgre_ip_dst_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 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15960 .f = cmd_set_nvgre_parsed,
15962 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15963 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15964 " eth-src <eth-src> eth-dst <eth-dst>",
15966 (void *)&cmd_set_nvgre_set,
15967 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15968 (void *)&cmd_set_nvgre_ip_version,
15969 (void *)&cmd_set_nvgre_ip_version_value,
15970 (void *)&cmd_set_nvgre_tni,
15971 (void *)&cmd_set_nvgre_tni_value,
15972 (void *)&cmd_set_nvgre_ip_src,
15973 (void *)&cmd_set_nvgre_ip_src_value,
15974 (void *)&cmd_set_nvgre_ip_dst,
15975 (void *)&cmd_set_nvgre_ip_dst_value,
15976 (void *)&cmd_set_nvgre_vlan,
15977 (void *)&cmd_set_nvgre_vlan_value,
15978 (void *)&cmd_set_nvgre_eth_src,
15979 (void *)&cmd_set_nvgre_eth_src_value,
15980 (void *)&cmd_set_nvgre_eth_dst,
15981 (void *)&cmd_set_nvgre_eth_dst_value,
15986 /** Set L2 encapsulation details */
15987 struct cmd_set_l2_encap_result {
15988 cmdline_fixed_string_t set;
15989 cmdline_fixed_string_t l2_encap;
15990 cmdline_fixed_string_t pos_token;
15991 cmdline_fixed_string_t ip_version;
15992 uint32_t vlan_present:1;
15994 struct rte_ether_addr eth_src;
15995 struct rte_ether_addr eth_dst;
15998 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15999 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
16000 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
16001 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
16002 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
16003 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
16004 "l2_encap-with-vlan");
16005 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
16006 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
16008 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
16009 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
16011 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
16012 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
16014 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
16015 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
16016 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
16017 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
16019 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
16020 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
16021 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
16022 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
16024 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
16025 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
16027 static void cmd_set_l2_encap_parsed(void *parsed_result,
16028 __rte_unused struct cmdline *cl,
16029 __rte_unused void *data)
16031 struct cmd_set_l2_encap_result *res = parsed_result;
16033 if (strcmp(res->l2_encap, "l2_encap") == 0)
16034 l2_encap_conf.select_vlan = 0;
16035 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
16036 l2_encap_conf.select_vlan = 1;
16037 if (strcmp(res->ip_version, "ipv4") == 0)
16038 l2_encap_conf.select_ipv4 = 1;
16039 else if (strcmp(res->ip_version, "ipv6") == 0)
16040 l2_encap_conf.select_ipv4 = 0;
16043 if (l2_encap_conf.select_vlan)
16044 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16045 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
16046 RTE_ETHER_ADDR_LEN);
16047 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16048 RTE_ETHER_ADDR_LEN);
16051 cmdline_parse_inst_t cmd_set_l2_encap = {
16052 .f = cmd_set_l2_encap_parsed,
16054 .help_str = "set l2_encap ip-version ipv4|ipv6"
16055 " eth-src <eth-src> eth-dst <eth-dst>",
16057 (void *)&cmd_set_l2_encap_set,
16058 (void *)&cmd_set_l2_encap_l2_encap,
16059 (void *)&cmd_set_l2_encap_ip_version,
16060 (void *)&cmd_set_l2_encap_ip_version_value,
16061 (void *)&cmd_set_l2_encap_eth_src,
16062 (void *)&cmd_set_l2_encap_eth_src_value,
16063 (void *)&cmd_set_l2_encap_eth_dst,
16064 (void *)&cmd_set_l2_encap_eth_dst_value,
16069 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
16070 .f = cmd_set_l2_encap_parsed,
16072 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
16073 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16075 (void *)&cmd_set_l2_encap_set,
16076 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
16077 (void *)&cmd_set_l2_encap_ip_version,
16078 (void *)&cmd_set_l2_encap_ip_version_value,
16079 (void *)&cmd_set_l2_encap_vlan,
16080 (void *)&cmd_set_l2_encap_vlan_value,
16081 (void *)&cmd_set_l2_encap_eth_src,
16082 (void *)&cmd_set_l2_encap_eth_src_value,
16083 (void *)&cmd_set_l2_encap_eth_dst,
16084 (void *)&cmd_set_l2_encap_eth_dst_value,
16089 /** Set L2 decapsulation details */
16090 struct cmd_set_l2_decap_result {
16091 cmdline_fixed_string_t set;
16092 cmdline_fixed_string_t l2_decap;
16093 cmdline_fixed_string_t pos_token;
16094 uint32_t vlan_present:1;
16097 cmdline_parse_token_string_t cmd_set_l2_decap_set =
16098 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
16099 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
16100 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
16102 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
16103 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
16104 "l2_decap-with-vlan");
16106 static void cmd_set_l2_decap_parsed(void *parsed_result,
16107 __rte_unused struct cmdline *cl,
16108 __rte_unused void *data)
16110 struct cmd_set_l2_decap_result *res = parsed_result;
16112 if (strcmp(res->l2_decap, "l2_decap") == 0)
16113 l2_decap_conf.select_vlan = 0;
16114 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
16115 l2_decap_conf.select_vlan = 1;
16118 cmdline_parse_inst_t cmd_set_l2_decap = {
16119 .f = cmd_set_l2_decap_parsed,
16121 .help_str = "set l2_decap",
16123 (void *)&cmd_set_l2_decap_set,
16124 (void *)&cmd_set_l2_decap_l2_decap,
16129 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
16130 .f = cmd_set_l2_decap_parsed,
16132 .help_str = "set l2_decap-with-vlan",
16134 (void *)&cmd_set_l2_decap_set,
16135 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
16140 /** Set MPLSoGRE encapsulation details */
16141 struct cmd_set_mplsogre_encap_result {
16142 cmdline_fixed_string_t set;
16143 cmdline_fixed_string_t mplsogre;
16144 cmdline_fixed_string_t pos_token;
16145 cmdline_fixed_string_t ip_version;
16146 uint32_t vlan_present:1;
16148 cmdline_ipaddr_t ip_src;
16149 cmdline_ipaddr_t ip_dst;
16151 struct rte_ether_addr eth_src;
16152 struct rte_ether_addr eth_dst;
16155 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
16156 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
16158 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
16159 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
16161 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
16162 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16163 mplsogre, "mplsogre_encap-with-vlan");
16164 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
16165 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16166 pos_token, "ip-version");
16167 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
16168 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16169 ip_version, "ipv4#ipv6");
16170 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
16171 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16172 pos_token, "label");
16173 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
16174 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
16176 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
16177 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16178 pos_token, "ip-src");
16179 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
16180 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
16181 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
16182 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16183 pos_token, "ip-dst");
16184 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
16185 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
16186 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
16187 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16188 pos_token, "vlan-tci");
16189 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
16190 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
16192 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
16193 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16194 pos_token, "eth-src");
16195 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
16196 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16198 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
16199 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16200 pos_token, "eth-dst");
16201 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
16202 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16205 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
16206 __rte_unused struct cmdline *cl,
16207 __rte_unused void *data)
16209 struct cmd_set_mplsogre_encap_result *res = parsed_result;
16211 uint32_t mplsogre_label;
16214 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
16217 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
16218 mplsogre_encap_conf.select_vlan = 0;
16219 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
16220 mplsogre_encap_conf.select_vlan = 1;
16221 if (strcmp(res->ip_version, "ipv4") == 0)
16222 mplsogre_encap_conf.select_ipv4 = 1;
16223 else if (strcmp(res->ip_version, "ipv6") == 0)
16224 mplsogre_encap_conf.select_ipv4 = 0;
16227 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
16228 if (mplsogre_encap_conf.select_ipv4) {
16229 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
16230 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
16232 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
16233 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
16235 if (mplsogre_encap_conf.select_vlan)
16236 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16237 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
16238 RTE_ETHER_ADDR_LEN);
16239 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16240 RTE_ETHER_ADDR_LEN);
16243 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
16244 .f = cmd_set_mplsogre_encap_parsed,
16246 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
16247 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
16248 " eth-dst <eth-dst>",
16250 (void *)&cmd_set_mplsogre_encap_set,
16251 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
16252 (void *)&cmd_set_mplsogre_encap_ip_version,
16253 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16254 (void *)&cmd_set_mplsogre_encap_label,
16255 (void *)&cmd_set_mplsogre_encap_label_value,
16256 (void *)&cmd_set_mplsogre_encap_ip_src,
16257 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16258 (void *)&cmd_set_mplsogre_encap_ip_dst,
16259 (void *)&cmd_set_mplsogre_encap_ip_dst_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 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16269 .f = cmd_set_mplsogre_encap_parsed,
16271 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16272 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16273 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16275 (void *)&cmd_set_mplsogre_encap_set,
16276 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16277 (void *)&cmd_set_mplsogre_encap_ip_version,
16278 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16279 (void *)&cmd_set_mplsogre_encap_label,
16280 (void *)&cmd_set_mplsogre_encap_label_value,
16281 (void *)&cmd_set_mplsogre_encap_ip_src,
16282 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16283 (void *)&cmd_set_mplsogre_encap_ip_dst,
16284 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16285 (void *)&cmd_set_mplsogre_encap_vlan,
16286 (void *)&cmd_set_mplsogre_encap_vlan_value,
16287 (void *)&cmd_set_mplsogre_encap_eth_src,
16288 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16289 (void *)&cmd_set_mplsogre_encap_eth_dst,
16290 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16295 /** Set MPLSoGRE decapsulation details */
16296 struct cmd_set_mplsogre_decap_result {
16297 cmdline_fixed_string_t set;
16298 cmdline_fixed_string_t mplsogre;
16299 cmdline_fixed_string_t pos_token;
16300 cmdline_fixed_string_t ip_version;
16301 uint32_t vlan_present:1;
16304 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16305 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16307 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16308 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16310 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16311 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16312 mplsogre, "mplsogre_decap-with-vlan");
16313 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16314 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16315 pos_token, "ip-version");
16316 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16317 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16318 ip_version, "ipv4#ipv6");
16320 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16321 __rte_unused struct cmdline *cl,
16322 __rte_unused void *data)
16324 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16326 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16327 mplsogre_decap_conf.select_vlan = 0;
16328 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16329 mplsogre_decap_conf.select_vlan = 1;
16330 if (strcmp(res->ip_version, "ipv4") == 0)
16331 mplsogre_decap_conf.select_ipv4 = 1;
16332 else if (strcmp(res->ip_version, "ipv6") == 0)
16333 mplsogre_decap_conf.select_ipv4 = 0;
16336 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16337 .f = cmd_set_mplsogre_decap_parsed,
16339 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16341 (void *)&cmd_set_mplsogre_decap_set,
16342 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16343 (void *)&cmd_set_mplsogre_decap_ip_version,
16344 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16349 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16350 .f = cmd_set_mplsogre_decap_parsed,
16352 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16354 (void *)&cmd_set_mplsogre_decap_set,
16355 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16356 (void *)&cmd_set_mplsogre_decap_ip_version,
16357 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16362 /** Set MPLSoUDP encapsulation details */
16363 struct cmd_set_mplsoudp_encap_result {
16364 cmdline_fixed_string_t set;
16365 cmdline_fixed_string_t mplsoudp;
16366 cmdline_fixed_string_t pos_token;
16367 cmdline_fixed_string_t ip_version;
16368 uint32_t vlan_present:1;
16372 cmdline_ipaddr_t ip_src;
16373 cmdline_ipaddr_t ip_dst;
16375 struct rte_ether_addr eth_src;
16376 struct rte_ether_addr eth_dst;
16379 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16380 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16382 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16383 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16385 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16386 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16387 mplsoudp, "mplsoudp_encap-with-vlan");
16388 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16389 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16390 pos_token, "ip-version");
16391 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16392 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16393 ip_version, "ipv4#ipv6");
16394 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16395 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16396 pos_token, "label");
16397 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16398 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16400 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16401 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16402 pos_token, "udp-src");
16403 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16404 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16406 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16407 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16408 pos_token, "udp-dst");
16409 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16410 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16412 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16413 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16414 pos_token, "ip-src");
16415 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16416 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16417 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16418 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16419 pos_token, "ip-dst");
16420 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16421 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16422 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16423 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16424 pos_token, "vlan-tci");
16425 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16426 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16428 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16429 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16430 pos_token, "eth-src");
16431 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16432 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16434 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16435 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16436 pos_token, "eth-dst");
16437 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16438 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16441 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16442 __rte_unused struct cmdline *cl,
16443 __rte_unused void *data)
16445 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16447 uint32_t mplsoudp_label;
16450 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16453 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16454 mplsoudp_encap_conf.select_vlan = 0;
16455 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16456 mplsoudp_encap_conf.select_vlan = 1;
16457 if (strcmp(res->ip_version, "ipv4") == 0)
16458 mplsoudp_encap_conf.select_ipv4 = 1;
16459 else if (strcmp(res->ip_version, "ipv6") == 0)
16460 mplsoudp_encap_conf.select_ipv4 = 0;
16463 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16464 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16465 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16466 if (mplsoudp_encap_conf.select_ipv4) {
16467 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16468 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16470 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16471 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16473 if (mplsoudp_encap_conf.select_vlan)
16474 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16475 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16476 RTE_ETHER_ADDR_LEN);
16477 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16478 RTE_ETHER_ADDR_LEN);
16481 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16482 .f = cmd_set_mplsoudp_encap_parsed,
16484 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16485 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16486 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16488 (void *)&cmd_set_mplsoudp_encap_set,
16489 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16490 (void *)&cmd_set_mplsoudp_encap_ip_version,
16491 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16492 (void *)&cmd_set_mplsoudp_encap_label,
16493 (void *)&cmd_set_mplsoudp_encap_label_value,
16494 (void *)&cmd_set_mplsoudp_encap_udp_src,
16495 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16496 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16497 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16498 (void *)&cmd_set_mplsoudp_encap_ip_src,
16499 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16500 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16501 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16502 (void *)&cmd_set_mplsoudp_encap_eth_src,
16503 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16504 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16505 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16510 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16511 .f = cmd_set_mplsoudp_encap_parsed,
16513 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16514 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16515 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16516 " eth-src <eth-src> eth-dst <eth-dst>",
16518 (void *)&cmd_set_mplsoudp_encap_set,
16519 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16520 (void *)&cmd_set_mplsoudp_encap_ip_version,
16521 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16522 (void *)&cmd_set_mplsoudp_encap_label,
16523 (void *)&cmd_set_mplsoudp_encap_label_value,
16524 (void *)&cmd_set_mplsoudp_encap_udp_src,
16525 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16526 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16527 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16528 (void *)&cmd_set_mplsoudp_encap_ip_src,
16529 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16530 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16531 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16532 (void *)&cmd_set_mplsoudp_encap_vlan,
16533 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16534 (void *)&cmd_set_mplsoudp_encap_eth_src,
16535 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16536 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16537 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16542 /** Set MPLSoUDP decapsulation details */
16543 struct cmd_set_mplsoudp_decap_result {
16544 cmdline_fixed_string_t set;
16545 cmdline_fixed_string_t mplsoudp;
16546 cmdline_fixed_string_t pos_token;
16547 cmdline_fixed_string_t ip_version;
16548 uint32_t vlan_present:1;
16551 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16552 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16554 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16555 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16557 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16558 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16559 mplsoudp, "mplsoudp_decap-with-vlan");
16560 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16561 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16562 pos_token, "ip-version");
16563 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16564 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16565 ip_version, "ipv4#ipv6");
16567 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16568 __rte_unused struct cmdline *cl,
16569 __rte_unused void *data)
16571 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16573 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16574 mplsoudp_decap_conf.select_vlan = 0;
16575 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16576 mplsoudp_decap_conf.select_vlan = 1;
16577 if (strcmp(res->ip_version, "ipv4") == 0)
16578 mplsoudp_decap_conf.select_ipv4 = 1;
16579 else if (strcmp(res->ip_version, "ipv6") == 0)
16580 mplsoudp_decap_conf.select_ipv4 = 0;
16583 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16584 .f = cmd_set_mplsoudp_decap_parsed,
16586 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16588 (void *)&cmd_set_mplsoudp_decap_set,
16589 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16590 (void *)&cmd_set_mplsoudp_decap_ip_version,
16591 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16596 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16597 .f = cmd_set_mplsoudp_decap_parsed,
16599 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16601 (void *)&cmd_set_mplsoudp_decap_set,
16602 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16603 (void *)&cmd_set_mplsoudp_decap_ip_version,
16604 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16609 /* Strict link priority scheduling mode setting */
16611 cmd_strict_link_prio_parsed(
16612 void *parsed_result,
16613 __rte_unused struct cmdline *cl,
16614 __rte_unused void *data)
16616 struct cmd_vf_tc_bw_result *res = parsed_result;
16617 int ret = -ENOTSUP;
16619 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16622 #ifdef RTE_LIBRTE_I40E_PMD
16623 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16630 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16633 printf("invalid port_id %d\n", res->port_id);
16636 printf("function not implemented\n");
16639 printf("programming error: (%s)\n", strerror(-ret));
16643 cmdline_parse_inst_t cmd_strict_link_prio = {
16644 .f = cmd_strict_link_prio_parsed,
16646 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16648 (void *)&cmd_vf_tc_bw_set,
16649 (void *)&cmd_vf_tc_bw_tx,
16650 (void *)&cmd_vf_tc_bw_strict_link_prio,
16651 (void *)&cmd_vf_tc_bw_port_id,
16652 (void *)&cmd_vf_tc_bw_tc_map,
16657 /* Load dynamic device personalization*/
16658 struct cmd_ddp_add_result {
16659 cmdline_fixed_string_t ddp;
16660 cmdline_fixed_string_t add;
16665 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16666 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16667 cmdline_parse_token_string_t cmd_ddp_add_add =
16668 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16669 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16670 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16671 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16672 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16675 cmd_ddp_add_parsed(
16676 void *parsed_result,
16677 __rte_unused struct cmdline *cl,
16678 __rte_unused void *data)
16680 struct cmd_ddp_add_result *res = parsed_result;
16686 int ret = -ENOTSUP;
16688 if (!all_ports_stopped()) {
16689 printf("Please stop all ports first\n");
16693 filepath = strdup(res->filepath);
16694 if (filepath == NULL) {
16695 printf("Failed to allocate memory\n");
16698 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16700 buff = open_file(file_fld[0], &size);
16702 free((void *)filepath);
16706 #ifdef RTE_LIBRTE_I40E_PMD
16707 if (ret == -ENOTSUP)
16708 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16710 RTE_PMD_I40E_PKG_OP_WR_ADD);
16713 if (ret == -EEXIST)
16714 printf("Profile has already existed.\n");
16716 printf("Failed to load profile.\n");
16717 else if (file_num == 2)
16718 save_file(file_fld[1], buff, size);
16721 free((void *)filepath);
16724 cmdline_parse_inst_t cmd_ddp_add = {
16725 .f = cmd_ddp_add_parsed,
16727 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16729 (void *)&cmd_ddp_add_ddp,
16730 (void *)&cmd_ddp_add_add,
16731 (void *)&cmd_ddp_add_port_id,
16732 (void *)&cmd_ddp_add_filepath,
16737 /* Delete dynamic device personalization*/
16738 struct cmd_ddp_del_result {
16739 cmdline_fixed_string_t ddp;
16740 cmdline_fixed_string_t del;
16745 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16746 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16747 cmdline_parse_token_string_t cmd_ddp_del_del =
16748 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16749 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16750 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16751 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16752 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16755 cmd_ddp_del_parsed(
16756 void *parsed_result,
16757 __rte_unused struct cmdline *cl,
16758 __rte_unused void *data)
16760 struct cmd_ddp_del_result *res = parsed_result;
16763 int ret = -ENOTSUP;
16765 if (!all_ports_stopped()) {
16766 printf("Please stop all ports first\n");
16770 buff = open_file(res->filepath, &size);
16774 #ifdef RTE_LIBRTE_I40E_PMD
16775 if (ret == -ENOTSUP)
16776 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16778 RTE_PMD_I40E_PKG_OP_WR_DEL);
16781 if (ret == -EACCES)
16782 printf("Profile does not exist.\n");
16784 printf("Failed to delete profile.\n");
16789 cmdline_parse_inst_t cmd_ddp_del = {
16790 .f = cmd_ddp_del_parsed,
16792 .help_str = "ddp del <port_id> <backup_profile_path>",
16794 (void *)&cmd_ddp_del_ddp,
16795 (void *)&cmd_ddp_del_del,
16796 (void *)&cmd_ddp_del_port_id,
16797 (void *)&cmd_ddp_del_filepath,
16802 /* Get dynamic device personalization profile info */
16803 struct cmd_ddp_info_result {
16804 cmdline_fixed_string_t ddp;
16805 cmdline_fixed_string_t get;
16806 cmdline_fixed_string_t info;
16810 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16811 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16812 cmdline_parse_token_string_t cmd_ddp_info_get =
16813 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16814 cmdline_parse_token_string_t cmd_ddp_info_info =
16815 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16816 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16817 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16820 cmd_ddp_info_parsed(
16821 void *parsed_result,
16822 __rte_unused struct cmdline *cl,
16823 __rte_unused void *data)
16825 struct cmd_ddp_info_result *res = parsed_result;
16828 int ret = -ENOTSUP;
16829 #ifdef RTE_LIBRTE_I40E_PMD
16832 uint32_t buff_size = 0;
16833 struct rte_pmd_i40e_profile_info info;
16834 uint32_t dev_num = 0;
16835 struct rte_pmd_i40e_ddp_device_id *devs;
16836 uint32_t proto_num = 0;
16837 struct rte_pmd_i40e_proto_info *proto = NULL;
16838 uint32_t pctype_num = 0;
16839 struct rte_pmd_i40e_ptype_info *pctype;
16840 uint32_t ptype_num = 0;
16841 struct rte_pmd_i40e_ptype_info *ptype;
16846 pkg = open_file(res->filepath, &pkg_size);
16850 #ifdef RTE_LIBRTE_I40E_PMD
16851 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16852 (uint8_t *)&info, sizeof(info),
16853 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16855 printf("Global Track id: 0x%x\n", info.track_id);
16856 printf("Global Version: %d.%d.%d.%d\n",
16857 info.version.major,
16858 info.version.minor,
16859 info.version.update,
16860 info.version.draft);
16861 printf("Global Package name: %s\n\n", info.name);
16864 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16865 (uint8_t *)&info, sizeof(info),
16866 RTE_PMD_I40E_PKG_INFO_HEADER);
16868 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16869 printf("i40e Profile Version: %d.%d.%d.%d\n",
16870 info.version.major,
16871 info.version.minor,
16872 info.version.update,
16873 info.version.draft);
16874 printf("i40e Profile name: %s\n\n", info.name);
16877 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16878 (uint8_t *)&buff_size, sizeof(buff_size),
16879 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16880 if (!ret && buff_size) {
16881 buff = (uint8_t *)malloc(buff_size);
16883 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16885 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16887 printf("Package Notes:\n%s\n\n", buff);
16892 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16893 (uint8_t *)&dev_num, sizeof(dev_num),
16894 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16895 if (!ret && dev_num) {
16896 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16897 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16899 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16900 (uint8_t *)devs, buff_size,
16901 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16903 printf("List of supported devices:\n");
16904 for (i = 0; i < dev_num; i++) {
16905 printf(" %04X:%04X %04X:%04X\n",
16906 devs[i].vendor_dev_id >> 16,
16907 devs[i].vendor_dev_id & 0xFFFF,
16908 devs[i].sub_vendor_dev_id >> 16,
16909 devs[i].sub_vendor_dev_id & 0xFFFF);
16917 /* get information about protocols and packet types */
16918 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16919 (uint8_t *)&proto_num, sizeof(proto_num),
16920 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16921 if (ret || !proto_num)
16922 goto no_print_return;
16924 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16925 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16927 goto no_print_return;
16929 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16931 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16933 printf("List of used protocols:\n");
16934 for (i = 0; i < proto_num; i++)
16935 printf(" %2u: %s\n", proto[i].proto_id,
16939 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16940 (uint8_t *)&pctype_num, sizeof(pctype_num),
16941 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16942 if (ret || !pctype_num)
16943 goto no_print_pctypes;
16945 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16946 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16948 goto no_print_pctypes;
16950 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16952 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16955 goto no_print_pctypes;
16958 printf("List of defined packet classification types:\n");
16959 for (i = 0; i < pctype_num; i++) {
16960 printf(" %2u:", pctype[i].ptype_id);
16961 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16962 proto_id = pctype[i].protocols[j];
16963 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16964 for (n = 0; n < proto_num; n++) {
16965 if (proto[n].proto_id == proto_id) {
16966 printf(" %s", proto[n].name);
16979 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16981 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16982 if (ret || !ptype_num)
16983 goto no_print_return;
16985 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16986 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16988 goto no_print_return;
16990 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16992 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16995 goto no_print_return;
16997 printf("List of defined packet types:\n");
16998 for (i = 0; i < ptype_num; i++) {
16999 printf(" %2u:", ptype[i].ptype_id);
17000 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
17001 proto_id = ptype[i].protocols[j];
17002 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
17003 for (n = 0; n < proto_num; n++) {
17004 if (proto[n].proto_id == proto_id) {
17005 printf(" %s", proto[n].name);
17021 if (ret == -ENOTSUP)
17022 printf("Function not supported in PMD driver\n");
17026 cmdline_parse_inst_t cmd_ddp_get_info = {
17027 .f = cmd_ddp_info_parsed,
17029 .help_str = "ddp get info <profile_path>",
17031 (void *)&cmd_ddp_info_ddp,
17032 (void *)&cmd_ddp_info_get,
17033 (void *)&cmd_ddp_info_info,
17034 (void *)&cmd_ddp_info_filepath,
17039 /* Get dynamic device personalization profile info list*/
17040 #define PROFILE_INFO_SIZE 48
17041 #define MAX_PROFILE_NUM 16
17043 struct cmd_ddp_get_list_result {
17044 cmdline_fixed_string_t ddp;
17045 cmdline_fixed_string_t get;
17046 cmdline_fixed_string_t list;
17050 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
17051 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
17052 cmdline_parse_token_string_t cmd_ddp_get_list_get =
17053 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
17054 cmdline_parse_token_string_t cmd_ddp_get_list_list =
17055 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
17056 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
17057 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
17060 cmd_ddp_get_list_parsed(
17061 __rte_unused void *parsed_result,
17062 __rte_unused struct cmdline *cl,
17063 __rte_unused void *data)
17065 #ifdef RTE_LIBRTE_I40E_PMD
17066 struct cmd_ddp_get_list_result *res = parsed_result;
17067 struct rte_pmd_i40e_profile_list *p_list;
17068 struct rte_pmd_i40e_profile_info *p_info;
17073 int ret = -ENOTSUP;
17075 #ifdef RTE_LIBRTE_I40E_PMD
17076 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
17077 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
17079 printf("%s: Failed to malloc buffer\n", __func__);
17083 if (ret == -ENOTSUP)
17084 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
17085 (uint8_t *)p_list, size);
17088 p_num = p_list->p_count;
17089 printf("Profile number is: %d\n\n", p_num);
17091 for (i = 0; i < p_num; i++) {
17092 p_info = &p_list->p_info[i];
17093 printf("Profile %d:\n", i);
17094 printf("Track id: 0x%x\n", p_info->track_id);
17095 printf("Version: %d.%d.%d.%d\n",
17096 p_info->version.major,
17097 p_info->version.minor,
17098 p_info->version.update,
17099 p_info->version.draft);
17100 printf("Profile name: %s\n\n", p_info->name);
17108 printf("Failed to get ddp list\n");
17111 cmdline_parse_inst_t cmd_ddp_get_list = {
17112 .f = cmd_ddp_get_list_parsed,
17114 .help_str = "ddp get list <port_id>",
17116 (void *)&cmd_ddp_get_list_ddp,
17117 (void *)&cmd_ddp_get_list_get,
17118 (void *)&cmd_ddp_get_list_list,
17119 (void *)&cmd_ddp_get_list_port_id,
17124 /* Configure input set */
17125 struct cmd_cfg_input_set_result {
17126 cmdline_fixed_string_t port;
17127 cmdline_fixed_string_t cfg;
17129 cmdline_fixed_string_t pctype;
17131 cmdline_fixed_string_t inset_type;
17132 cmdline_fixed_string_t opt;
17133 cmdline_fixed_string_t field;
17138 cmd_cfg_input_set_parsed(
17139 __rte_unused void *parsed_result,
17140 __rte_unused struct cmdline *cl,
17141 __rte_unused void *data)
17143 #ifdef RTE_LIBRTE_I40E_PMD
17144 struct cmd_cfg_input_set_result *res = parsed_result;
17145 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17146 struct rte_pmd_i40e_inset inset;
17148 int ret = -ENOTSUP;
17150 if (!all_ports_stopped()) {
17151 printf("Please stop all ports first\n");
17155 #ifdef RTE_LIBRTE_I40E_PMD
17156 if (!strcmp(res->inset_type, "hash_inset"))
17157 inset_type = INSET_HASH;
17158 else if (!strcmp(res->inset_type, "fdir_inset"))
17159 inset_type = INSET_FDIR;
17160 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17161 inset_type = INSET_FDIR_FLX;
17162 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
17163 &inset, inset_type);
17165 printf("Failed to get input set.\n");
17169 if (!strcmp(res->opt, "get")) {
17170 ret = rte_pmd_i40e_inset_field_get(inset.inset,
17173 printf("Field index %d is enabled.\n", res->field_idx);
17175 printf("Field index %d is disabled.\n", res->field_idx);
17177 } else if (!strcmp(res->opt, "set"))
17178 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
17180 else if (!strcmp(res->opt, "clear"))
17181 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
17184 printf("Failed to configure input set field.\n");
17188 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17189 &inset, inset_type);
17191 printf("Failed to set input set.\n");
17196 if (ret == -ENOTSUP)
17197 printf("Function not supported\n");
17200 cmdline_parse_token_string_t cmd_cfg_input_set_port =
17201 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17203 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
17204 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17206 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
17207 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17209 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
17210 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17212 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
17213 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17215 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
17216 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17218 "hash_inset#fdir_inset#fdir_flx_inset");
17219 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
17220 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17221 opt, "get#set#clear");
17222 cmdline_parse_token_string_t cmd_cfg_input_set_field =
17223 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17225 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
17226 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17229 cmdline_parse_inst_t cmd_cfg_input_set = {
17230 .f = cmd_cfg_input_set_parsed,
17232 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17233 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
17235 (void *)&cmd_cfg_input_set_port,
17236 (void *)&cmd_cfg_input_set_cfg,
17237 (void *)&cmd_cfg_input_set_port_id,
17238 (void *)&cmd_cfg_input_set_pctype,
17239 (void *)&cmd_cfg_input_set_pctype_id,
17240 (void *)&cmd_cfg_input_set_inset_type,
17241 (void *)&cmd_cfg_input_set_opt,
17242 (void *)&cmd_cfg_input_set_field,
17243 (void *)&cmd_cfg_input_set_field_idx,
17248 /* Clear input set */
17249 struct cmd_clear_input_set_result {
17250 cmdline_fixed_string_t port;
17251 cmdline_fixed_string_t cfg;
17253 cmdline_fixed_string_t pctype;
17255 cmdline_fixed_string_t inset_type;
17256 cmdline_fixed_string_t clear;
17257 cmdline_fixed_string_t all;
17261 cmd_clear_input_set_parsed(
17262 __rte_unused void *parsed_result,
17263 __rte_unused struct cmdline *cl,
17264 __rte_unused void *data)
17266 #ifdef RTE_LIBRTE_I40E_PMD
17267 struct cmd_clear_input_set_result *res = parsed_result;
17268 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17269 struct rte_pmd_i40e_inset inset;
17271 int ret = -ENOTSUP;
17273 if (!all_ports_stopped()) {
17274 printf("Please stop all ports first\n");
17278 #ifdef RTE_LIBRTE_I40E_PMD
17279 if (!strcmp(res->inset_type, "hash_inset"))
17280 inset_type = INSET_HASH;
17281 else if (!strcmp(res->inset_type, "fdir_inset"))
17282 inset_type = INSET_FDIR;
17283 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17284 inset_type = INSET_FDIR_FLX;
17286 memset(&inset, 0, sizeof(inset));
17288 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17289 &inset, inset_type);
17291 printf("Failed to clear input set.\n");
17297 if (ret == -ENOTSUP)
17298 printf("Function not supported\n");
17301 cmdline_parse_token_string_t cmd_clear_input_set_port =
17302 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17304 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17305 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17307 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17308 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17310 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17311 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17313 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17314 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17316 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17317 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17319 "hash_inset#fdir_inset#fdir_flx_inset");
17320 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17321 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17323 cmdline_parse_token_string_t cmd_clear_input_set_all =
17324 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17327 cmdline_parse_inst_t cmd_clear_input_set = {
17328 .f = cmd_clear_input_set_parsed,
17330 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17331 "fdir_inset|fdir_flx_inset clear all",
17333 (void *)&cmd_clear_input_set_port,
17334 (void *)&cmd_clear_input_set_cfg,
17335 (void *)&cmd_clear_input_set_port_id,
17336 (void *)&cmd_clear_input_set_pctype,
17337 (void *)&cmd_clear_input_set_pctype_id,
17338 (void *)&cmd_clear_input_set_inset_type,
17339 (void *)&cmd_clear_input_set_clear,
17340 (void *)&cmd_clear_input_set_all,
17345 /* show vf stats */
17347 /* Common result structure for show vf stats */
17348 struct cmd_show_vf_stats_result {
17349 cmdline_fixed_string_t show;
17350 cmdline_fixed_string_t vf;
17351 cmdline_fixed_string_t stats;
17356 /* Common CLI fields show vf stats*/
17357 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17358 TOKEN_STRING_INITIALIZER
17359 (struct cmd_show_vf_stats_result,
17361 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17362 TOKEN_STRING_INITIALIZER
17363 (struct cmd_show_vf_stats_result,
17365 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17366 TOKEN_STRING_INITIALIZER
17367 (struct cmd_show_vf_stats_result,
17369 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17370 TOKEN_NUM_INITIALIZER
17371 (struct cmd_show_vf_stats_result,
17373 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17374 TOKEN_NUM_INITIALIZER
17375 (struct cmd_show_vf_stats_result,
17379 cmd_show_vf_stats_parsed(
17380 void *parsed_result,
17381 __rte_unused struct cmdline *cl,
17382 __rte_unused void *data)
17384 struct cmd_show_vf_stats_result *res = parsed_result;
17385 struct rte_eth_stats stats;
17386 int ret = -ENOTSUP;
17387 static const char *nic_stats_border = "########################";
17389 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17392 memset(&stats, 0, sizeof(stats));
17394 #ifdef RTE_LIBRTE_I40E_PMD
17395 if (ret == -ENOTSUP)
17396 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17400 #ifdef RTE_LIBRTE_BNXT_PMD
17401 if (ret == -ENOTSUP)
17402 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17411 printf("invalid vf_id %d\n", res->vf_id);
17414 printf("invalid port_id %d\n", res->port_id);
17417 printf("function not implemented\n");
17420 printf("programming error: (%s)\n", strerror(-ret));
17423 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17424 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17426 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17428 stats.ipackets, stats.imissed, stats.ibytes);
17429 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17430 printf(" RX-nombuf: %-10"PRIu64"\n",
17432 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17434 stats.opackets, stats.oerrors, stats.obytes);
17436 printf(" %s############################%s\n",
17437 nic_stats_border, nic_stats_border);
17440 cmdline_parse_inst_t cmd_show_vf_stats = {
17441 .f = cmd_show_vf_stats_parsed,
17443 .help_str = "show vf stats <port_id> <vf_id>",
17445 (void *)&cmd_show_vf_stats_show,
17446 (void *)&cmd_show_vf_stats_vf,
17447 (void *)&cmd_show_vf_stats_stats,
17448 (void *)&cmd_show_vf_stats_port_id,
17449 (void *)&cmd_show_vf_stats_vf_id,
17454 /* clear vf stats */
17456 /* Common result structure for clear vf stats */
17457 struct cmd_clear_vf_stats_result {
17458 cmdline_fixed_string_t clear;
17459 cmdline_fixed_string_t vf;
17460 cmdline_fixed_string_t stats;
17465 /* Common CLI fields clear vf stats*/
17466 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17467 TOKEN_STRING_INITIALIZER
17468 (struct cmd_clear_vf_stats_result,
17470 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17471 TOKEN_STRING_INITIALIZER
17472 (struct cmd_clear_vf_stats_result,
17474 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17475 TOKEN_STRING_INITIALIZER
17476 (struct cmd_clear_vf_stats_result,
17478 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17479 TOKEN_NUM_INITIALIZER
17480 (struct cmd_clear_vf_stats_result,
17482 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17483 TOKEN_NUM_INITIALIZER
17484 (struct cmd_clear_vf_stats_result,
17488 cmd_clear_vf_stats_parsed(
17489 void *parsed_result,
17490 __rte_unused struct cmdline *cl,
17491 __rte_unused void *data)
17493 struct cmd_clear_vf_stats_result *res = parsed_result;
17494 int ret = -ENOTSUP;
17496 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17499 #ifdef RTE_LIBRTE_I40E_PMD
17500 if (ret == -ENOTSUP)
17501 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17504 #ifdef RTE_LIBRTE_BNXT_PMD
17505 if (ret == -ENOTSUP)
17506 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17514 printf("invalid vf_id %d\n", res->vf_id);
17517 printf("invalid port_id %d\n", res->port_id);
17520 printf("function not implemented\n");
17523 printf("programming error: (%s)\n", strerror(-ret));
17527 cmdline_parse_inst_t cmd_clear_vf_stats = {
17528 .f = cmd_clear_vf_stats_parsed,
17530 .help_str = "clear vf stats <port_id> <vf_id>",
17532 (void *)&cmd_clear_vf_stats_clear,
17533 (void *)&cmd_clear_vf_stats_vf,
17534 (void *)&cmd_clear_vf_stats_stats,
17535 (void *)&cmd_clear_vf_stats_port_id,
17536 (void *)&cmd_clear_vf_stats_vf_id,
17541 /* port config pctype mapping reset */
17543 /* Common result structure for port config pctype mapping reset */
17544 struct cmd_pctype_mapping_reset_result {
17545 cmdline_fixed_string_t port;
17546 cmdline_fixed_string_t config;
17548 cmdline_fixed_string_t pctype;
17549 cmdline_fixed_string_t mapping;
17550 cmdline_fixed_string_t reset;
17553 /* Common CLI fields for port config pctype mapping reset*/
17554 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17555 TOKEN_STRING_INITIALIZER
17556 (struct cmd_pctype_mapping_reset_result,
17558 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17559 TOKEN_STRING_INITIALIZER
17560 (struct cmd_pctype_mapping_reset_result,
17562 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17563 TOKEN_NUM_INITIALIZER
17564 (struct cmd_pctype_mapping_reset_result,
17566 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17567 TOKEN_STRING_INITIALIZER
17568 (struct cmd_pctype_mapping_reset_result,
17570 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17571 TOKEN_STRING_INITIALIZER
17572 (struct cmd_pctype_mapping_reset_result,
17573 mapping, "mapping");
17574 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17575 TOKEN_STRING_INITIALIZER
17576 (struct cmd_pctype_mapping_reset_result,
17580 cmd_pctype_mapping_reset_parsed(
17581 void *parsed_result,
17582 __rte_unused struct cmdline *cl,
17583 __rte_unused void *data)
17585 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17586 int ret = -ENOTSUP;
17588 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17591 #ifdef RTE_LIBRTE_I40E_PMD
17592 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17599 printf("invalid port_id %d\n", res->port_id);
17602 printf("function not implemented\n");
17605 printf("programming error: (%s)\n", strerror(-ret));
17609 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17610 .f = cmd_pctype_mapping_reset_parsed,
17612 .help_str = "port config <port_id> pctype mapping reset",
17614 (void *)&cmd_pctype_mapping_reset_port,
17615 (void *)&cmd_pctype_mapping_reset_config,
17616 (void *)&cmd_pctype_mapping_reset_port_id,
17617 (void *)&cmd_pctype_mapping_reset_pctype,
17618 (void *)&cmd_pctype_mapping_reset_mapping,
17619 (void *)&cmd_pctype_mapping_reset_reset,
17624 /* show port pctype mapping */
17626 /* Common result structure for show port pctype mapping */
17627 struct cmd_pctype_mapping_get_result {
17628 cmdline_fixed_string_t show;
17629 cmdline_fixed_string_t port;
17631 cmdline_fixed_string_t pctype;
17632 cmdline_fixed_string_t mapping;
17635 /* Common CLI fields for pctype mapping get */
17636 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17637 TOKEN_STRING_INITIALIZER
17638 (struct cmd_pctype_mapping_get_result,
17640 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17641 TOKEN_STRING_INITIALIZER
17642 (struct cmd_pctype_mapping_get_result,
17644 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17645 TOKEN_NUM_INITIALIZER
17646 (struct cmd_pctype_mapping_get_result,
17648 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17649 TOKEN_STRING_INITIALIZER
17650 (struct cmd_pctype_mapping_get_result,
17652 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17653 TOKEN_STRING_INITIALIZER
17654 (struct cmd_pctype_mapping_get_result,
17655 mapping, "mapping");
17658 cmd_pctype_mapping_get_parsed(
17659 void *parsed_result,
17660 __rte_unused struct cmdline *cl,
17661 __rte_unused void *data)
17663 struct cmd_pctype_mapping_get_result *res = parsed_result;
17664 int ret = -ENOTSUP;
17665 #ifdef RTE_LIBRTE_I40E_PMD
17666 struct rte_pmd_i40e_flow_type_mapping
17667 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17668 int i, j, first_pctype;
17671 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17674 #ifdef RTE_LIBRTE_I40E_PMD
17675 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17682 printf("invalid port_id %d\n", res->port_id);
17685 printf("function not implemented\n");
17688 printf("programming error: (%s)\n", strerror(-ret));
17692 #ifdef RTE_LIBRTE_I40E_PMD
17693 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17694 if (mapping[i].pctype != 0ULL) {
17697 printf("pctype: ");
17698 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17699 if (mapping[i].pctype & (1ULL << j)) {
17700 printf(first_pctype ?
17701 "%02d" : ",%02d", j);
17705 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17711 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17712 .f = cmd_pctype_mapping_get_parsed,
17714 .help_str = "show port <port_id> pctype mapping",
17716 (void *)&cmd_pctype_mapping_get_show,
17717 (void *)&cmd_pctype_mapping_get_port,
17718 (void *)&cmd_pctype_mapping_get_port_id,
17719 (void *)&cmd_pctype_mapping_get_pctype,
17720 (void *)&cmd_pctype_mapping_get_mapping,
17725 /* port config pctype mapping update */
17727 /* Common result structure for port config pctype mapping update */
17728 struct cmd_pctype_mapping_update_result {
17729 cmdline_fixed_string_t port;
17730 cmdline_fixed_string_t config;
17732 cmdline_fixed_string_t pctype;
17733 cmdline_fixed_string_t mapping;
17734 cmdline_fixed_string_t update;
17735 cmdline_fixed_string_t pctype_list;
17736 uint16_t flow_type;
17739 /* Common CLI fields for pctype mapping update*/
17740 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17741 TOKEN_STRING_INITIALIZER
17742 (struct cmd_pctype_mapping_update_result,
17744 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17745 TOKEN_STRING_INITIALIZER
17746 (struct cmd_pctype_mapping_update_result,
17748 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17749 TOKEN_NUM_INITIALIZER
17750 (struct cmd_pctype_mapping_update_result,
17752 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17753 TOKEN_STRING_INITIALIZER
17754 (struct cmd_pctype_mapping_update_result,
17756 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17757 TOKEN_STRING_INITIALIZER
17758 (struct cmd_pctype_mapping_update_result,
17759 mapping, "mapping");
17760 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17761 TOKEN_STRING_INITIALIZER
17762 (struct cmd_pctype_mapping_update_result,
17764 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17765 TOKEN_STRING_INITIALIZER
17766 (struct cmd_pctype_mapping_update_result,
17767 pctype_list, NULL);
17768 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17769 TOKEN_NUM_INITIALIZER
17770 (struct cmd_pctype_mapping_update_result,
17771 flow_type, UINT16);
17774 cmd_pctype_mapping_update_parsed(
17775 void *parsed_result,
17776 __rte_unused struct cmdline *cl,
17777 __rte_unused void *data)
17779 struct cmd_pctype_mapping_update_result *res = parsed_result;
17780 int ret = -ENOTSUP;
17781 #ifdef RTE_LIBRTE_I40E_PMD
17782 struct rte_pmd_i40e_flow_type_mapping mapping;
17784 unsigned int nb_item;
17785 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17788 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17791 #ifdef RTE_LIBRTE_I40E_PMD
17792 nb_item = parse_item_list(res->pctype_list, "pctypes",
17793 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17794 mapping.flow_type = res->flow_type;
17795 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17796 mapping.pctype |= (1ULL << pctype_list[i]);
17797 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17807 printf("invalid pctype or flow type\n");
17810 printf("invalid port_id %d\n", res->port_id);
17813 printf("function not implemented\n");
17816 printf("programming error: (%s)\n", strerror(-ret));
17820 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17821 .f = cmd_pctype_mapping_update_parsed,
17823 .help_str = "port config <port_id> pctype mapping update"
17824 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17826 (void *)&cmd_pctype_mapping_update_port,
17827 (void *)&cmd_pctype_mapping_update_config,
17828 (void *)&cmd_pctype_mapping_update_port_id,
17829 (void *)&cmd_pctype_mapping_update_pctype,
17830 (void *)&cmd_pctype_mapping_update_mapping,
17831 (void *)&cmd_pctype_mapping_update_update,
17832 (void *)&cmd_pctype_mapping_update_pc_type,
17833 (void *)&cmd_pctype_mapping_update_flow_type,
17838 /* ptype mapping get */
17840 /* Common result structure for ptype mapping get */
17841 struct cmd_ptype_mapping_get_result {
17842 cmdline_fixed_string_t ptype;
17843 cmdline_fixed_string_t mapping;
17844 cmdline_fixed_string_t get;
17846 uint8_t valid_only;
17849 /* Common CLI fields for ptype mapping get */
17850 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17851 TOKEN_STRING_INITIALIZER
17852 (struct cmd_ptype_mapping_get_result,
17854 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17855 TOKEN_STRING_INITIALIZER
17856 (struct cmd_ptype_mapping_get_result,
17857 mapping, "mapping");
17858 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17859 TOKEN_STRING_INITIALIZER
17860 (struct cmd_ptype_mapping_get_result,
17862 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17863 TOKEN_NUM_INITIALIZER
17864 (struct cmd_ptype_mapping_get_result,
17866 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17867 TOKEN_NUM_INITIALIZER
17868 (struct cmd_ptype_mapping_get_result,
17869 valid_only, UINT8);
17872 cmd_ptype_mapping_get_parsed(
17873 void *parsed_result,
17874 __rte_unused struct cmdline *cl,
17875 __rte_unused void *data)
17877 struct cmd_ptype_mapping_get_result *res = parsed_result;
17878 int ret = -ENOTSUP;
17879 #ifdef RTE_LIBRTE_I40E_PMD
17880 int max_ptype_num = 256;
17881 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17886 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17889 #ifdef RTE_LIBRTE_I40E_PMD
17890 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17901 printf("invalid port_id %d\n", res->port_id);
17904 printf("function not implemented\n");
17907 printf("programming error: (%s)\n", strerror(-ret));
17910 #ifdef RTE_LIBRTE_I40E_PMD
17912 for (i = 0; i < count; i++)
17913 printf("%3d\t0x%08x\n",
17914 mapping[i].hw_ptype, mapping[i].sw_ptype);
17919 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17920 .f = cmd_ptype_mapping_get_parsed,
17922 .help_str = "ptype mapping get <port_id> <valid_only>",
17924 (void *)&cmd_ptype_mapping_get_ptype,
17925 (void *)&cmd_ptype_mapping_get_mapping,
17926 (void *)&cmd_ptype_mapping_get_get,
17927 (void *)&cmd_ptype_mapping_get_port_id,
17928 (void *)&cmd_ptype_mapping_get_valid_only,
17933 /* ptype mapping replace */
17935 /* Common result structure for ptype mapping replace */
17936 struct cmd_ptype_mapping_replace_result {
17937 cmdline_fixed_string_t ptype;
17938 cmdline_fixed_string_t mapping;
17939 cmdline_fixed_string_t replace;
17946 /* Common CLI fields for ptype mapping replace */
17947 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17948 TOKEN_STRING_INITIALIZER
17949 (struct cmd_ptype_mapping_replace_result,
17951 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17952 TOKEN_STRING_INITIALIZER
17953 (struct cmd_ptype_mapping_replace_result,
17954 mapping, "mapping");
17955 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17956 TOKEN_STRING_INITIALIZER
17957 (struct cmd_ptype_mapping_replace_result,
17958 replace, "replace");
17959 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17960 TOKEN_NUM_INITIALIZER
17961 (struct cmd_ptype_mapping_replace_result,
17963 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17964 TOKEN_NUM_INITIALIZER
17965 (struct cmd_ptype_mapping_replace_result,
17967 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17968 TOKEN_NUM_INITIALIZER
17969 (struct cmd_ptype_mapping_replace_result,
17971 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17972 TOKEN_NUM_INITIALIZER
17973 (struct cmd_ptype_mapping_replace_result,
17977 cmd_ptype_mapping_replace_parsed(
17978 void *parsed_result,
17979 __rte_unused struct cmdline *cl,
17980 __rte_unused void *data)
17982 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17983 int ret = -ENOTSUP;
17985 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17988 #ifdef RTE_LIBRTE_I40E_PMD
17989 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17999 printf("invalid ptype 0x%8x or 0x%8x\n",
18000 res->target, res->pkt_type);
18003 printf("invalid port_id %d\n", res->port_id);
18006 printf("function not implemented\n");
18009 printf("programming error: (%s)\n", strerror(-ret));
18013 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
18014 .f = cmd_ptype_mapping_replace_parsed,
18017 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
18019 (void *)&cmd_ptype_mapping_replace_ptype,
18020 (void *)&cmd_ptype_mapping_replace_mapping,
18021 (void *)&cmd_ptype_mapping_replace_replace,
18022 (void *)&cmd_ptype_mapping_replace_port_id,
18023 (void *)&cmd_ptype_mapping_replace_target,
18024 (void *)&cmd_ptype_mapping_replace_mask,
18025 (void *)&cmd_ptype_mapping_replace_pkt_type,
18030 /* ptype mapping reset */
18032 /* Common result structure for ptype mapping reset */
18033 struct cmd_ptype_mapping_reset_result {
18034 cmdline_fixed_string_t ptype;
18035 cmdline_fixed_string_t mapping;
18036 cmdline_fixed_string_t reset;
18040 /* Common CLI fields for ptype mapping reset*/
18041 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
18042 TOKEN_STRING_INITIALIZER
18043 (struct cmd_ptype_mapping_reset_result,
18045 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
18046 TOKEN_STRING_INITIALIZER
18047 (struct cmd_ptype_mapping_reset_result,
18048 mapping, "mapping");
18049 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
18050 TOKEN_STRING_INITIALIZER
18051 (struct cmd_ptype_mapping_reset_result,
18053 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
18054 TOKEN_NUM_INITIALIZER
18055 (struct cmd_ptype_mapping_reset_result,
18059 cmd_ptype_mapping_reset_parsed(
18060 void *parsed_result,
18061 __rte_unused struct cmdline *cl,
18062 __rte_unused void *data)
18064 struct cmd_ptype_mapping_reset_result *res = parsed_result;
18065 int ret = -ENOTSUP;
18067 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18070 #ifdef RTE_LIBRTE_I40E_PMD
18071 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
18078 printf("invalid port_id %d\n", res->port_id);
18081 printf("function not implemented\n");
18084 printf("programming error: (%s)\n", strerror(-ret));
18088 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
18089 .f = cmd_ptype_mapping_reset_parsed,
18091 .help_str = "ptype mapping reset <port_id>",
18093 (void *)&cmd_ptype_mapping_reset_ptype,
18094 (void *)&cmd_ptype_mapping_reset_mapping,
18095 (void *)&cmd_ptype_mapping_reset_reset,
18096 (void *)&cmd_ptype_mapping_reset_port_id,
18101 /* ptype mapping update */
18103 /* Common result structure for ptype mapping update */
18104 struct cmd_ptype_mapping_update_result {
18105 cmdline_fixed_string_t ptype;
18106 cmdline_fixed_string_t mapping;
18107 cmdline_fixed_string_t reset;
18113 /* Common CLI fields for ptype mapping update*/
18114 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
18115 TOKEN_STRING_INITIALIZER
18116 (struct cmd_ptype_mapping_update_result,
18118 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
18119 TOKEN_STRING_INITIALIZER
18120 (struct cmd_ptype_mapping_update_result,
18121 mapping, "mapping");
18122 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
18123 TOKEN_STRING_INITIALIZER
18124 (struct cmd_ptype_mapping_update_result,
18126 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
18127 TOKEN_NUM_INITIALIZER
18128 (struct cmd_ptype_mapping_update_result,
18130 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
18131 TOKEN_NUM_INITIALIZER
18132 (struct cmd_ptype_mapping_update_result,
18134 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
18135 TOKEN_NUM_INITIALIZER
18136 (struct cmd_ptype_mapping_update_result,
18140 cmd_ptype_mapping_update_parsed(
18141 void *parsed_result,
18142 __rte_unused struct cmdline *cl,
18143 __rte_unused void *data)
18145 struct cmd_ptype_mapping_update_result *res = parsed_result;
18146 int ret = -ENOTSUP;
18147 #ifdef RTE_LIBRTE_I40E_PMD
18148 struct rte_pmd_i40e_ptype_mapping mapping;
18150 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18153 #ifdef RTE_LIBRTE_I40E_PMD
18154 mapping.hw_ptype = res->hw_ptype;
18155 mapping.sw_ptype = res->sw_ptype;
18156 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
18166 printf("invalid ptype 0x%8x\n", res->sw_ptype);
18169 printf("invalid port_id %d\n", res->port_id);
18172 printf("function not implemented\n");
18175 printf("programming error: (%s)\n", strerror(-ret));
18179 cmdline_parse_inst_t cmd_ptype_mapping_update = {
18180 .f = cmd_ptype_mapping_update_parsed,
18182 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
18184 (void *)&cmd_ptype_mapping_update_ptype,
18185 (void *)&cmd_ptype_mapping_update_mapping,
18186 (void *)&cmd_ptype_mapping_update_update,
18187 (void *)&cmd_ptype_mapping_update_port_id,
18188 (void *)&cmd_ptype_mapping_update_hw_ptype,
18189 (void *)&cmd_ptype_mapping_update_sw_ptype,
18194 /* Common result structure for file commands */
18195 struct cmd_cmdfile_result {
18196 cmdline_fixed_string_t load;
18197 cmdline_fixed_string_t filename;
18200 /* Common CLI fields for file commands */
18201 cmdline_parse_token_string_t cmd_load_cmdfile =
18202 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
18203 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
18204 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
18207 cmd_load_from_file_parsed(
18208 void *parsed_result,
18209 __rte_unused struct cmdline *cl,
18210 __rte_unused void *data)
18212 struct cmd_cmdfile_result *res = parsed_result;
18214 cmdline_read_from_file(res->filename);
18217 cmdline_parse_inst_t cmd_load_from_file = {
18218 .f = cmd_load_from_file_parsed,
18220 .help_str = "load <filename>",
18222 (void *)&cmd_load_cmdfile,
18223 (void *)&cmd_load_cmdfile_filename,
18228 /* Get Rx offloads capabilities */
18229 struct cmd_rx_offload_get_capa_result {
18230 cmdline_fixed_string_t show;
18231 cmdline_fixed_string_t port;
18233 cmdline_fixed_string_t rx_offload;
18234 cmdline_fixed_string_t capabilities;
18237 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
18238 TOKEN_STRING_INITIALIZER
18239 (struct cmd_rx_offload_get_capa_result,
18241 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
18242 TOKEN_STRING_INITIALIZER
18243 (struct cmd_rx_offload_get_capa_result,
18245 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
18246 TOKEN_NUM_INITIALIZER
18247 (struct cmd_rx_offload_get_capa_result,
18249 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
18250 TOKEN_STRING_INITIALIZER
18251 (struct cmd_rx_offload_get_capa_result,
18252 rx_offload, "rx_offload");
18253 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
18254 TOKEN_STRING_INITIALIZER
18255 (struct cmd_rx_offload_get_capa_result,
18256 capabilities, "capabilities");
18259 print_rx_offloads(uint64_t offloads)
18261 uint64_t single_offload;
18269 begin = __builtin_ctzll(offloads);
18270 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18272 single_offload = 1ULL << begin;
18273 for (bit = begin; bit < end; bit++) {
18274 if (offloads & single_offload)
18276 rte_eth_dev_rx_offload_name(single_offload));
18277 single_offload <<= 1;
18282 cmd_rx_offload_get_capa_parsed(
18283 void *parsed_result,
18284 __rte_unused struct cmdline *cl,
18285 __rte_unused void *data)
18287 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18288 struct rte_eth_dev_info dev_info;
18289 portid_t port_id = res->port_id;
18290 uint64_t queue_offloads;
18291 uint64_t port_offloads;
18294 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18298 queue_offloads = dev_info.rx_queue_offload_capa;
18299 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18301 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18302 printf(" Per Queue :");
18303 print_rx_offloads(queue_offloads);
18306 printf(" Per Port :");
18307 print_rx_offloads(port_offloads);
18311 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18312 .f = cmd_rx_offload_get_capa_parsed,
18314 .help_str = "show port <port_id> rx_offload capabilities",
18316 (void *)&cmd_rx_offload_get_capa_show,
18317 (void *)&cmd_rx_offload_get_capa_port,
18318 (void *)&cmd_rx_offload_get_capa_port_id,
18319 (void *)&cmd_rx_offload_get_capa_rx_offload,
18320 (void *)&cmd_rx_offload_get_capa_capabilities,
18325 /* Get Rx offloads configuration */
18326 struct cmd_rx_offload_get_configuration_result {
18327 cmdline_fixed_string_t show;
18328 cmdline_fixed_string_t port;
18330 cmdline_fixed_string_t rx_offload;
18331 cmdline_fixed_string_t configuration;
18334 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18335 TOKEN_STRING_INITIALIZER
18336 (struct cmd_rx_offload_get_configuration_result,
18338 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18339 TOKEN_STRING_INITIALIZER
18340 (struct cmd_rx_offload_get_configuration_result,
18342 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18343 TOKEN_NUM_INITIALIZER
18344 (struct cmd_rx_offload_get_configuration_result,
18346 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18347 TOKEN_STRING_INITIALIZER
18348 (struct cmd_rx_offload_get_configuration_result,
18349 rx_offload, "rx_offload");
18350 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18351 TOKEN_STRING_INITIALIZER
18352 (struct cmd_rx_offload_get_configuration_result,
18353 configuration, "configuration");
18356 cmd_rx_offload_get_configuration_parsed(
18357 void *parsed_result,
18358 __rte_unused struct cmdline *cl,
18359 __rte_unused void *data)
18361 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18362 struct rte_eth_dev_info dev_info;
18363 portid_t port_id = res->port_id;
18364 struct rte_port *port = &ports[port_id];
18365 uint64_t port_offloads;
18366 uint64_t queue_offloads;
18367 uint16_t nb_rx_queues;
18371 printf("Rx Offloading Configuration of port %d :\n", port_id);
18373 port_offloads = port->dev_conf.rxmode.offloads;
18375 print_rx_offloads(port_offloads);
18378 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18382 nb_rx_queues = dev_info.nb_rx_queues;
18383 for (q = 0; q < nb_rx_queues; q++) {
18384 queue_offloads = port->rx_conf[q].offloads;
18385 printf(" Queue[%2d] :", q);
18386 print_rx_offloads(queue_offloads);
18392 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18393 .f = cmd_rx_offload_get_configuration_parsed,
18395 .help_str = "show port <port_id> rx_offload configuration",
18397 (void *)&cmd_rx_offload_get_configuration_show,
18398 (void *)&cmd_rx_offload_get_configuration_port,
18399 (void *)&cmd_rx_offload_get_configuration_port_id,
18400 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18401 (void *)&cmd_rx_offload_get_configuration_configuration,
18406 /* Enable/Disable a per port offloading */
18407 struct cmd_config_per_port_rx_offload_result {
18408 cmdline_fixed_string_t port;
18409 cmdline_fixed_string_t config;
18411 cmdline_fixed_string_t rx_offload;
18412 cmdline_fixed_string_t offload;
18413 cmdline_fixed_string_t on_off;
18416 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18417 TOKEN_STRING_INITIALIZER
18418 (struct cmd_config_per_port_rx_offload_result,
18420 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18421 TOKEN_STRING_INITIALIZER
18422 (struct cmd_config_per_port_rx_offload_result,
18424 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18425 TOKEN_NUM_INITIALIZER
18426 (struct cmd_config_per_port_rx_offload_result,
18428 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18429 TOKEN_STRING_INITIALIZER
18430 (struct cmd_config_per_port_rx_offload_result,
18431 rx_offload, "rx_offload");
18432 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18433 TOKEN_STRING_INITIALIZER
18434 (struct cmd_config_per_port_rx_offload_result,
18435 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18436 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18437 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18438 "scatter#buffer_split#timestamp#security#"
18439 "keep_crc#rss_hash");
18440 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18441 TOKEN_STRING_INITIALIZER
18442 (struct cmd_config_per_port_rx_offload_result,
18446 search_rx_offload(const char *name)
18448 uint64_t single_offload;
18449 const char *single_name;
18453 single_offload = 1;
18454 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18455 single_name = rte_eth_dev_rx_offload_name(single_offload);
18456 if (!strcasecmp(single_name, name)) {
18460 single_offload <<= 1;
18464 return single_offload;
18470 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18471 __rte_unused struct cmdline *cl,
18472 __rte_unused void *data)
18474 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18475 portid_t port_id = res->port_id;
18476 struct rte_eth_dev_info dev_info;
18477 struct rte_port *port = &ports[port_id];
18478 uint64_t single_offload;
18479 uint16_t nb_rx_queues;
18483 if (port->port_status != RTE_PORT_STOPPED) {
18484 printf("Error: Can't config offload when Port %d "
18485 "is not stopped\n", port_id);
18489 single_offload = search_rx_offload(res->offload);
18490 if (single_offload == 0) {
18491 printf("Unknown offload name: %s\n", res->offload);
18495 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18499 nb_rx_queues = dev_info.nb_rx_queues;
18500 if (!strcmp(res->on_off, "on")) {
18501 port->dev_conf.rxmode.offloads |= single_offload;
18502 for (q = 0; q < nb_rx_queues; q++)
18503 port->rx_conf[q].offloads |= single_offload;
18505 port->dev_conf.rxmode.offloads &= ~single_offload;
18506 for (q = 0; q < nb_rx_queues; q++)
18507 port->rx_conf[q].offloads &= ~single_offload;
18510 cmd_reconfig_device_queue(port_id, 1, 1);
18513 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18514 .f = cmd_config_per_port_rx_offload_parsed,
18516 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18517 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18518 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18519 "jumbo_frame|scatter|buffer_split|timestamp|security|"
18520 "keep_crc|rss_hash on|off",
18522 (void *)&cmd_config_per_port_rx_offload_result_port,
18523 (void *)&cmd_config_per_port_rx_offload_result_config,
18524 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18525 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18526 (void *)&cmd_config_per_port_rx_offload_result_offload,
18527 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18532 /* Enable/Disable a per queue offloading */
18533 struct cmd_config_per_queue_rx_offload_result {
18534 cmdline_fixed_string_t port;
18536 cmdline_fixed_string_t rxq;
18538 cmdline_fixed_string_t rx_offload;
18539 cmdline_fixed_string_t offload;
18540 cmdline_fixed_string_t on_off;
18543 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18544 TOKEN_STRING_INITIALIZER
18545 (struct cmd_config_per_queue_rx_offload_result,
18547 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18548 TOKEN_NUM_INITIALIZER
18549 (struct cmd_config_per_queue_rx_offload_result,
18551 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18552 TOKEN_STRING_INITIALIZER
18553 (struct cmd_config_per_queue_rx_offload_result,
18555 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18556 TOKEN_NUM_INITIALIZER
18557 (struct cmd_config_per_queue_rx_offload_result,
18559 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18560 TOKEN_STRING_INITIALIZER
18561 (struct cmd_config_per_queue_rx_offload_result,
18562 rx_offload, "rx_offload");
18563 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18564 TOKEN_STRING_INITIALIZER
18565 (struct cmd_config_per_queue_rx_offload_result,
18566 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18567 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18568 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18569 "scatter#buffer_split#timestamp#security#keep_crc");
18570 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18571 TOKEN_STRING_INITIALIZER
18572 (struct cmd_config_per_queue_rx_offload_result,
18576 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18577 __rte_unused struct cmdline *cl,
18578 __rte_unused void *data)
18580 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18581 struct rte_eth_dev_info dev_info;
18582 portid_t port_id = res->port_id;
18583 uint16_t queue_id = res->queue_id;
18584 struct rte_port *port = &ports[port_id];
18585 uint64_t single_offload;
18588 if (port->port_status != RTE_PORT_STOPPED) {
18589 printf("Error: Can't config offload when Port %d "
18590 "is not stopped\n", port_id);
18594 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18598 if (queue_id >= dev_info.nb_rx_queues) {
18599 printf("Error: input queue_id should be 0 ... "
18600 "%d\n", dev_info.nb_rx_queues - 1);
18604 single_offload = search_rx_offload(res->offload);
18605 if (single_offload == 0) {
18606 printf("Unknown offload name: %s\n", res->offload);
18610 if (!strcmp(res->on_off, "on"))
18611 port->rx_conf[queue_id].offloads |= single_offload;
18613 port->rx_conf[queue_id].offloads &= ~single_offload;
18615 cmd_reconfig_device_queue(port_id, 1, 1);
18618 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18619 .f = cmd_config_per_queue_rx_offload_parsed,
18621 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18622 "vlan_strip|ipv4_cksum|"
18623 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18624 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18625 "jumbo_frame|scatter|buffer_split|timestamp|security|"
18628 (void *)&cmd_config_per_queue_rx_offload_result_port,
18629 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18630 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18631 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18632 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18633 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18634 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18639 /* Get Tx offloads capabilities */
18640 struct cmd_tx_offload_get_capa_result {
18641 cmdline_fixed_string_t show;
18642 cmdline_fixed_string_t port;
18644 cmdline_fixed_string_t tx_offload;
18645 cmdline_fixed_string_t capabilities;
18648 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18649 TOKEN_STRING_INITIALIZER
18650 (struct cmd_tx_offload_get_capa_result,
18652 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18653 TOKEN_STRING_INITIALIZER
18654 (struct cmd_tx_offload_get_capa_result,
18656 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18657 TOKEN_NUM_INITIALIZER
18658 (struct cmd_tx_offload_get_capa_result,
18660 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18661 TOKEN_STRING_INITIALIZER
18662 (struct cmd_tx_offload_get_capa_result,
18663 tx_offload, "tx_offload");
18664 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18665 TOKEN_STRING_INITIALIZER
18666 (struct cmd_tx_offload_get_capa_result,
18667 capabilities, "capabilities");
18670 print_tx_offloads(uint64_t offloads)
18672 uint64_t single_offload;
18680 begin = __builtin_ctzll(offloads);
18681 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18683 single_offload = 1ULL << begin;
18684 for (bit = begin; bit < end; bit++) {
18685 if (offloads & single_offload)
18687 rte_eth_dev_tx_offload_name(single_offload));
18688 single_offload <<= 1;
18693 cmd_tx_offload_get_capa_parsed(
18694 void *parsed_result,
18695 __rte_unused struct cmdline *cl,
18696 __rte_unused void *data)
18698 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18699 struct rte_eth_dev_info dev_info;
18700 portid_t port_id = res->port_id;
18701 uint64_t queue_offloads;
18702 uint64_t port_offloads;
18705 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18709 queue_offloads = dev_info.tx_queue_offload_capa;
18710 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18712 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18713 printf(" Per Queue :");
18714 print_tx_offloads(queue_offloads);
18717 printf(" Per Port :");
18718 print_tx_offloads(port_offloads);
18722 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18723 .f = cmd_tx_offload_get_capa_parsed,
18725 .help_str = "show port <port_id> tx_offload capabilities",
18727 (void *)&cmd_tx_offload_get_capa_show,
18728 (void *)&cmd_tx_offload_get_capa_port,
18729 (void *)&cmd_tx_offload_get_capa_port_id,
18730 (void *)&cmd_tx_offload_get_capa_tx_offload,
18731 (void *)&cmd_tx_offload_get_capa_capabilities,
18736 /* Get Tx offloads configuration */
18737 struct cmd_tx_offload_get_configuration_result {
18738 cmdline_fixed_string_t show;
18739 cmdline_fixed_string_t port;
18741 cmdline_fixed_string_t tx_offload;
18742 cmdline_fixed_string_t configuration;
18745 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18746 TOKEN_STRING_INITIALIZER
18747 (struct cmd_tx_offload_get_configuration_result,
18749 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18750 TOKEN_STRING_INITIALIZER
18751 (struct cmd_tx_offload_get_configuration_result,
18753 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18754 TOKEN_NUM_INITIALIZER
18755 (struct cmd_tx_offload_get_configuration_result,
18757 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18758 TOKEN_STRING_INITIALIZER
18759 (struct cmd_tx_offload_get_configuration_result,
18760 tx_offload, "tx_offload");
18761 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18762 TOKEN_STRING_INITIALIZER
18763 (struct cmd_tx_offload_get_configuration_result,
18764 configuration, "configuration");
18767 cmd_tx_offload_get_configuration_parsed(
18768 void *parsed_result,
18769 __rte_unused struct cmdline *cl,
18770 __rte_unused void *data)
18772 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18773 struct rte_eth_dev_info dev_info;
18774 portid_t port_id = res->port_id;
18775 struct rte_port *port = &ports[port_id];
18776 uint64_t port_offloads;
18777 uint64_t queue_offloads;
18778 uint16_t nb_tx_queues;
18782 printf("Tx Offloading Configuration of port %d :\n", port_id);
18784 port_offloads = port->dev_conf.txmode.offloads;
18786 print_tx_offloads(port_offloads);
18789 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18793 nb_tx_queues = dev_info.nb_tx_queues;
18794 for (q = 0; q < nb_tx_queues; q++) {
18795 queue_offloads = port->tx_conf[q].offloads;
18796 printf(" Queue[%2d] :", q);
18797 print_tx_offloads(queue_offloads);
18803 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18804 .f = cmd_tx_offload_get_configuration_parsed,
18806 .help_str = "show port <port_id> tx_offload configuration",
18808 (void *)&cmd_tx_offload_get_configuration_show,
18809 (void *)&cmd_tx_offload_get_configuration_port,
18810 (void *)&cmd_tx_offload_get_configuration_port_id,
18811 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18812 (void *)&cmd_tx_offload_get_configuration_configuration,
18817 /* Enable/Disable a per port offloading */
18818 struct cmd_config_per_port_tx_offload_result {
18819 cmdline_fixed_string_t port;
18820 cmdline_fixed_string_t config;
18822 cmdline_fixed_string_t tx_offload;
18823 cmdline_fixed_string_t offload;
18824 cmdline_fixed_string_t on_off;
18827 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18828 TOKEN_STRING_INITIALIZER
18829 (struct cmd_config_per_port_tx_offload_result,
18831 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18832 TOKEN_STRING_INITIALIZER
18833 (struct cmd_config_per_port_tx_offload_result,
18835 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18836 TOKEN_NUM_INITIALIZER
18837 (struct cmd_config_per_port_tx_offload_result,
18839 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18840 TOKEN_STRING_INITIALIZER
18841 (struct cmd_config_per_port_tx_offload_result,
18842 tx_offload, "tx_offload");
18843 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18844 TOKEN_STRING_INITIALIZER
18845 (struct cmd_config_per_port_tx_offload_result,
18846 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18847 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18848 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18849 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18850 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18851 "send_on_timestamp");
18852 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18853 TOKEN_STRING_INITIALIZER
18854 (struct cmd_config_per_port_tx_offload_result,
18858 search_tx_offload(const char *name)
18860 uint64_t single_offload;
18861 const char *single_name;
18865 single_offload = 1;
18866 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18867 single_name = rte_eth_dev_tx_offload_name(single_offload);
18868 if (single_name == NULL)
18870 if (!strcasecmp(single_name, name)) {
18873 } else if (!strcasecmp(single_name, "UNKNOWN"))
18875 single_offload <<= 1;
18879 return single_offload;
18885 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18886 __rte_unused struct cmdline *cl,
18887 __rte_unused void *data)
18889 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18890 portid_t port_id = res->port_id;
18891 struct rte_eth_dev_info dev_info;
18892 struct rte_port *port = &ports[port_id];
18893 uint64_t single_offload;
18894 uint16_t nb_tx_queues;
18898 if (port->port_status != RTE_PORT_STOPPED) {
18899 printf("Error: Can't config offload when Port %d "
18900 "is not stopped\n", port_id);
18904 single_offload = search_tx_offload(res->offload);
18905 if (single_offload == 0) {
18906 printf("Unknown offload name: %s\n", res->offload);
18910 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18914 nb_tx_queues = dev_info.nb_tx_queues;
18915 if (!strcmp(res->on_off, "on")) {
18916 port->dev_conf.txmode.offloads |= single_offload;
18917 for (q = 0; q < nb_tx_queues; q++)
18918 port->tx_conf[q].offloads |= single_offload;
18920 port->dev_conf.txmode.offloads &= ~single_offload;
18921 for (q = 0; q < nb_tx_queues; q++)
18922 port->tx_conf[q].offloads &= ~single_offload;
18925 cmd_reconfig_device_queue(port_id, 1, 1);
18928 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18929 .f = cmd_config_per_port_tx_offload_parsed,
18931 .help_str = "port config <port_id> tx_offload "
18932 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18933 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18934 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18935 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18936 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18937 "send_on_timestamp on|off",
18939 (void *)&cmd_config_per_port_tx_offload_result_port,
18940 (void *)&cmd_config_per_port_tx_offload_result_config,
18941 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18942 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18943 (void *)&cmd_config_per_port_tx_offload_result_offload,
18944 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18949 /* Enable/Disable a per queue offloading */
18950 struct cmd_config_per_queue_tx_offload_result {
18951 cmdline_fixed_string_t port;
18953 cmdline_fixed_string_t txq;
18955 cmdline_fixed_string_t tx_offload;
18956 cmdline_fixed_string_t offload;
18957 cmdline_fixed_string_t on_off;
18960 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18961 TOKEN_STRING_INITIALIZER
18962 (struct cmd_config_per_queue_tx_offload_result,
18964 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18965 TOKEN_NUM_INITIALIZER
18966 (struct cmd_config_per_queue_tx_offload_result,
18968 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18969 TOKEN_STRING_INITIALIZER
18970 (struct cmd_config_per_queue_tx_offload_result,
18972 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18973 TOKEN_NUM_INITIALIZER
18974 (struct cmd_config_per_queue_tx_offload_result,
18976 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18977 TOKEN_STRING_INITIALIZER
18978 (struct cmd_config_per_queue_tx_offload_result,
18979 tx_offload, "tx_offload");
18980 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18981 TOKEN_STRING_INITIALIZER
18982 (struct cmd_config_per_queue_tx_offload_result,
18983 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18984 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18985 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18986 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18987 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18988 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18989 TOKEN_STRING_INITIALIZER
18990 (struct cmd_config_per_queue_tx_offload_result,
18994 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18995 __rte_unused struct cmdline *cl,
18996 __rte_unused void *data)
18998 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18999 struct rte_eth_dev_info dev_info;
19000 portid_t port_id = res->port_id;
19001 uint16_t queue_id = res->queue_id;
19002 struct rte_port *port = &ports[port_id];
19003 uint64_t single_offload;
19006 if (port->port_status != RTE_PORT_STOPPED) {
19007 printf("Error: Can't config offload when Port %d "
19008 "is not stopped\n", port_id);
19012 ret = eth_dev_info_get_print_err(port_id, &dev_info);
19016 if (queue_id >= dev_info.nb_tx_queues) {
19017 printf("Error: input queue_id should be 0 ... "
19018 "%d\n", dev_info.nb_tx_queues - 1);
19022 single_offload = search_tx_offload(res->offload);
19023 if (single_offload == 0) {
19024 printf("Unknown offload name: %s\n", res->offload);
19028 if (!strcmp(res->on_off, "on"))
19029 port->tx_conf[queue_id].offloads |= single_offload;
19031 port->tx_conf[queue_id].offloads &= ~single_offload;
19033 cmd_reconfig_device_queue(port_id, 1, 1);
19036 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
19037 .f = cmd_config_per_queue_tx_offload_parsed,
19039 .help_str = "port <port_id> txq <queue_id> tx_offload "
19040 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
19041 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
19042 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
19043 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
19044 "mt_lockfree|multi_segs|mbuf_fast_free|security "
19047 (void *)&cmd_config_per_queue_tx_offload_result_port,
19048 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
19049 (void *)&cmd_config_per_queue_tx_offload_result_txq,
19050 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
19051 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
19052 (void *)&cmd_config_per_queue_tx_offload_result_offload,
19053 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
19058 /* *** configure tx_metadata for specific port *** */
19059 struct cmd_config_tx_metadata_specific_result {
19060 cmdline_fixed_string_t port;
19061 cmdline_fixed_string_t keyword;
19063 cmdline_fixed_string_t item;
19068 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
19069 __rte_unused struct cmdline *cl,
19070 __rte_unused void *data)
19072 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
19074 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
19076 ports[res->port_id].tx_metadata = res->value;
19077 /* Add/remove callback to insert valid metadata in every Tx packet. */
19078 if (ports[res->port_id].tx_metadata)
19079 add_tx_md_callback(res->port_id);
19081 remove_tx_md_callback(res->port_id);
19082 rte_flow_dynf_metadata_register();
19085 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
19086 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19088 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
19089 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19090 keyword, "config");
19091 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
19092 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19094 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
19095 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19096 item, "tx_metadata");
19097 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
19098 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19101 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
19102 .f = cmd_config_tx_metadata_specific_parsed,
19104 .help_str = "port config <port_id> tx_metadata <value>",
19106 (void *)&cmd_config_tx_metadata_specific_port,
19107 (void *)&cmd_config_tx_metadata_specific_keyword,
19108 (void *)&cmd_config_tx_metadata_specific_id,
19109 (void *)&cmd_config_tx_metadata_specific_item,
19110 (void *)&cmd_config_tx_metadata_specific_value,
19115 /* *** set dynf *** */
19116 struct cmd_config_tx_dynf_specific_result {
19117 cmdline_fixed_string_t port;
19118 cmdline_fixed_string_t keyword;
19120 cmdline_fixed_string_t item;
19121 cmdline_fixed_string_t name;
19122 cmdline_fixed_string_t value;
19126 cmd_config_dynf_specific_parsed(void *parsed_result,
19127 __rte_unused struct cmdline *cl,
19128 __rte_unused void *data)
19130 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
19131 struct rte_mbuf_dynflag desc_flag;
19133 uint64_t old_port_flags;
19135 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
19137 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
19139 if (strlcpy(desc_flag.name, res->name,
19140 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
19141 printf("Flag name too long\n");
19144 desc_flag.flags = 0;
19145 flag = rte_mbuf_dynflag_register(&desc_flag);
19147 printf("Can't register flag\n");
19150 strcpy(dynf_names[flag], desc_flag.name);
19152 old_port_flags = ports[res->port_id].mbuf_dynf;
19153 if (!strcmp(res->value, "set")) {
19154 ports[res->port_id].mbuf_dynf |= 1UL << flag;
19155 if (old_port_flags == 0)
19156 add_tx_dynf_callback(res->port_id);
19158 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
19159 if (ports[res->port_id].mbuf_dynf == 0)
19160 remove_tx_dynf_callback(res->port_id);
19164 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
19165 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19167 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
19168 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19169 keyword, "config");
19170 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
19171 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19173 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
19174 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19176 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
19177 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19179 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
19180 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19181 value, "set#clear");
19183 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
19184 .f = cmd_config_dynf_specific_parsed,
19186 .help_str = "port config <port id> dynf <name> set|clear",
19188 (void *)&cmd_config_tx_dynf_specific_port,
19189 (void *)&cmd_config_tx_dynf_specific_keyword,
19190 (void *)&cmd_config_tx_dynf_specific_port_id,
19191 (void *)&cmd_config_tx_dynf_specific_item,
19192 (void *)&cmd_config_tx_dynf_specific_name,
19193 (void *)&cmd_config_tx_dynf_specific_value,
19198 /* *** display tx_metadata per port configuration *** */
19199 struct cmd_show_tx_metadata_result {
19200 cmdline_fixed_string_t cmd_show;
19201 cmdline_fixed_string_t cmd_port;
19202 cmdline_fixed_string_t cmd_keyword;
19207 cmd_show_tx_metadata_parsed(void *parsed_result,
19208 __rte_unused struct cmdline *cl,
19209 __rte_unused void *data)
19211 struct cmd_show_tx_metadata_result *res = parsed_result;
19213 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19214 printf("invalid port id %u\n", res->cmd_pid);
19217 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
19218 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
19219 ports[res->cmd_pid].tx_metadata);
19223 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
19224 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19226 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
19227 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19229 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
19230 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
19232 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
19233 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19234 cmd_keyword, "tx_metadata");
19236 cmdline_parse_inst_t cmd_show_tx_metadata = {
19237 .f = cmd_show_tx_metadata_parsed,
19239 .help_str = "show port <port_id> tx_metadata",
19241 (void *)&cmd_show_tx_metadata_show,
19242 (void *)&cmd_show_tx_metadata_port,
19243 (void *)&cmd_show_tx_metadata_pid,
19244 (void *)&cmd_show_tx_metadata_keyword,
19249 /* *** show fec capability per port configuration *** */
19250 struct cmd_show_fec_capability_result {
19251 cmdline_fixed_string_t cmd_show;
19252 cmdline_fixed_string_t cmd_port;
19253 cmdline_fixed_string_t cmd_fec;
19254 cmdline_fixed_string_t cmd_keyword;
19259 cmd_show_fec_capability_parsed(void *parsed_result,
19260 __rte_unused struct cmdline *cl,
19261 __rte_unused void *data)
19263 #define FEC_CAP_NUM 2
19264 struct cmd_show_fec_capability_result *res = parsed_result;
19265 struct rte_eth_fec_capa speed_fec_capa[FEC_CAP_NUM];
19266 unsigned int num = FEC_CAP_NUM;
19267 unsigned int ret_num;
19270 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19271 printf("Invalid port id %u\n", res->cmd_pid);
19275 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
19276 if (ret == -ENOTSUP) {
19277 printf("Function not implemented\n");
19279 } else if (ret < 0) {
19280 printf("Get FEC capability failed\n");
19284 ret_num = (unsigned int)ret;
19285 show_fec_capability(ret_num, speed_fec_capa);
19288 cmdline_parse_token_string_t cmd_show_fec_capability_show =
19289 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19291 cmdline_parse_token_string_t cmd_show_fec_capability_port =
19292 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19294 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
19295 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
19297 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
19298 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19300 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
19301 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19302 cmd_keyword, "capabilities");
19304 cmdline_parse_inst_t cmd_show_capability = {
19305 .f = cmd_show_fec_capability_parsed,
19307 .help_str = "show port <port_id> fec capabilities",
19309 (void *)&cmd_show_fec_capability_show,
19310 (void *)&cmd_show_fec_capability_port,
19311 (void *)&cmd_show_fec_capability_pid,
19312 (void *)&cmd_show_fec_capability_fec,
19313 (void *)&cmd_show_fec_capability_keyword,
19318 /* *** show fec mode per port configuration *** */
19319 struct cmd_show_fec_metadata_result {
19320 cmdline_fixed_string_t cmd_show;
19321 cmdline_fixed_string_t cmd_port;
19322 cmdline_fixed_string_t cmd_keyword;
19327 cmd_show_fec_mode_parsed(void *parsed_result,
19328 __rte_unused struct cmdline *cl,
19329 __rte_unused void *data)
19331 #define FEC_NAME_SIZE 16
19332 struct cmd_show_fec_metadata_result *res = parsed_result;
19334 char buf[FEC_NAME_SIZE];
19337 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19338 printf("Invalid port id %u\n", res->cmd_pid);
19341 ret = rte_eth_fec_get(res->cmd_pid, &mode);
19342 if (ret == -ENOTSUP) {
19343 printf("Function not implemented\n");
19345 } else if (ret < 0) {
19346 printf("Get FEC mode failed\n");
19351 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
19352 strlcpy(buf, "off", sizeof(buf));
19354 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
19355 strlcpy(buf, "auto", sizeof(buf));
19357 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
19358 strlcpy(buf, "baser", sizeof(buf));
19360 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
19361 strlcpy(buf, "rs", sizeof(buf));
19367 printf("%s\n", buf);
19370 cmdline_parse_token_string_t cmd_show_fec_mode_show =
19371 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
19373 cmdline_parse_token_string_t cmd_show_fec_mode_port =
19374 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
19376 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
19377 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
19379 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
19380 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
19381 cmd_keyword, "fec_mode");
19383 cmdline_parse_inst_t cmd_show_fec_mode = {
19384 .f = cmd_show_fec_mode_parsed,
19386 .help_str = "show port <port_id> fec_mode",
19388 (void *)&cmd_show_fec_mode_show,
19389 (void *)&cmd_show_fec_mode_port,
19390 (void *)&cmd_show_fec_mode_pid,
19391 (void *)&cmd_show_fec_mode_keyword,
19396 /* *** set fec mode per port configuration *** */
19397 struct cmd_set_port_fec_mode {
19398 cmdline_fixed_string_t set;
19399 cmdline_fixed_string_t port;
19401 cmdline_fixed_string_t fec_mode;
19402 cmdline_fixed_string_t fec_value;
19405 /* Common CLI fields for set fec mode */
19406 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
19407 TOKEN_STRING_INITIALIZER
19408 (struct cmd_set_port_fec_mode,
19410 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
19411 TOKEN_STRING_INITIALIZER
19412 (struct cmd_set_port_fec_mode,
19414 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
19415 TOKEN_NUM_INITIALIZER
19416 (struct cmd_set_port_fec_mode,
19418 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
19419 TOKEN_STRING_INITIALIZER
19420 (struct cmd_set_port_fec_mode,
19421 fec_mode, "fec_mode");
19422 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
19423 TOKEN_STRING_INITIALIZER
19424 (struct cmd_set_port_fec_mode,
19428 cmd_set_port_fec_mode_parsed(
19429 void *parsed_result,
19430 __rte_unused struct cmdline *cl,
19431 __rte_unused void *data)
19433 struct cmd_set_port_fec_mode *res = parsed_result;
19434 uint16_t port_id = res->port_id;
19438 ret = parse_fec_mode(res->fec_value, &mode);
19440 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
19445 ret = rte_eth_fec_set(port_id, mode);
19446 if (ret == -ENOTSUP) {
19447 printf("Function not implemented\n");
19449 } else if (ret < 0) {
19450 printf("Set FEC mode failed\n");
19455 cmdline_parse_inst_t cmd_set_fec_mode = {
19456 .f = cmd_set_port_fec_mode_parsed,
19458 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
19460 (void *)&cmd_set_port_fec_mode_set,
19461 (void *)&cmd_set_port_fec_mode_port,
19462 (void *)&cmd_set_port_fec_mode_port_id,
19463 (void *)&cmd_set_port_fec_mode_str,
19464 (void *)&cmd_set_port_fec_mode_value,
19469 /* show port supported ptypes */
19471 /* Common result structure for show port ptypes */
19472 struct cmd_show_port_supported_ptypes_result {
19473 cmdline_fixed_string_t show;
19474 cmdline_fixed_string_t port;
19476 cmdline_fixed_string_t ptypes;
19479 /* Common CLI fields for show port ptypes */
19480 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
19481 TOKEN_STRING_INITIALIZER
19482 (struct cmd_show_port_supported_ptypes_result,
19484 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
19485 TOKEN_STRING_INITIALIZER
19486 (struct cmd_show_port_supported_ptypes_result,
19488 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19489 TOKEN_NUM_INITIALIZER
19490 (struct cmd_show_port_supported_ptypes_result,
19492 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19493 TOKEN_STRING_INITIALIZER
19494 (struct cmd_show_port_supported_ptypes_result,
19498 cmd_show_port_supported_ptypes_parsed(
19499 void *parsed_result,
19500 __rte_unused struct cmdline *cl,
19501 __rte_unused void *data)
19503 #define RSVD_PTYPE_MASK 0xf0000000
19504 #define MAX_PTYPES_PER_LAYER 16
19505 #define LTYPE_NAMESIZE 32
19506 #define PTYPE_NAMESIZE 256
19507 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19508 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19509 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19510 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19511 uint16_t port_id = res->port_id;
19514 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19518 while (ptype_mask != RSVD_PTYPE_MASK) {
19520 switch (ptype_mask) {
19521 case RTE_PTYPE_L2_MASK:
19522 strlcpy(ltype, "L2", sizeof(ltype));
19524 case RTE_PTYPE_L3_MASK:
19525 strlcpy(ltype, "L3", sizeof(ltype));
19527 case RTE_PTYPE_L4_MASK:
19528 strlcpy(ltype, "L4", sizeof(ltype));
19530 case RTE_PTYPE_TUNNEL_MASK:
19531 strlcpy(ltype, "Tunnel", sizeof(ltype));
19533 case RTE_PTYPE_INNER_L2_MASK:
19534 strlcpy(ltype, "Inner L2", sizeof(ltype));
19536 case RTE_PTYPE_INNER_L3_MASK:
19537 strlcpy(ltype, "Inner L3", sizeof(ltype));
19539 case RTE_PTYPE_INNER_L4_MASK:
19540 strlcpy(ltype, "Inner L4", sizeof(ltype));
19546 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19547 ptype_mask, ptypes,
19548 MAX_PTYPES_PER_LAYER);
19551 printf("Supported %s ptypes:\n", ltype);
19553 printf("%s ptypes unsupported\n", ltype);
19555 for (i = 0; i < ret; ++i) {
19556 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19557 printf("%s\n", buf);
19564 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19565 .f = cmd_show_port_supported_ptypes_parsed,
19567 .help_str = "show port <port_id> ptypes",
19569 (void *)&cmd_show_port_supported_ptypes_show,
19570 (void *)&cmd_show_port_supported_ptypes_port,
19571 (void *)&cmd_show_port_supported_ptypes_port_id,
19572 (void *)&cmd_show_port_supported_ptypes_ptypes,
19577 /* *** display rx/tx descriptor status *** */
19578 struct cmd_show_rx_tx_desc_status_result {
19579 cmdline_fixed_string_t cmd_show;
19580 cmdline_fixed_string_t cmd_port;
19581 cmdline_fixed_string_t cmd_keyword;
19582 cmdline_fixed_string_t cmd_desc;
19583 cmdline_fixed_string_t cmd_status;
19590 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19591 __rte_unused struct cmdline *cl,
19592 __rte_unused void *data)
19594 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19597 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19598 printf("invalid port id %u\n", res->cmd_pid);
19602 if (!strcmp(res->cmd_keyword, "rxq")) {
19603 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19606 printf("Invalid queueid = %d\n", res->cmd_qid);
19609 if (rc == RTE_ETH_RX_DESC_AVAIL)
19610 printf("Desc status = AVAILABLE\n");
19611 else if (rc == RTE_ETH_RX_DESC_DONE)
19612 printf("Desc status = DONE\n");
19614 printf("Desc status = UNAVAILABLE\n");
19615 } else if (!strcmp(res->cmd_keyword, "txq")) {
19616 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19619 printf("Invalid queueid = %d\n", res->cmd_qid);
19622 if (rc == RTE_ETH_TX_DESC_FULL)
19623 printf("Desc status = FULL\n");
19624 else if (rc == RTE_ETH_TX_DESC_DONE)
19625 printf("Desc status = DONE\n");
19627 printf("Desc status = UNAVAILABLE\n");
19631 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19632 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19634 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19635 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19637 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19638 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19640 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19641 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19642 cmd_keyword, "rxq#txq");
19643 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19644 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19646 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19647 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19649 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19650 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19652 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19653 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19654 cmd_status, "status");
19655 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19656 .f = cmd_show_rx_tx_desc_status_parsed,
19658 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19661 (void *)&cmd_show_rx_tx_desc_status_show,
19662 (void *)&cmd_show_rx_tx_desc_status_port,
19663 (void *)&cmd_show_rx_tx_desc_status_pid,
19664 (void *)&cmd_show_rx_tx_desc_status_keyword,
19665 (void *)&cmd_show_rx_tx_desc_status_qid,
19666 (void *)&cmd_show_rx_tx_desc_status_desc,
19667 (void *)&cmd_show_rx_tx_desc_status_did,
19668 (void *)&cmd_show_rx_tx_desc_status_status,
19673 /* Common result structure for set port ptypes */
19674 struct cmd_set_port_ptypes_result {
19675 cmdline_fixed_string_t set;
19676 cmdline_fixed_string_t port;
19678 cmdline_fixed_string_t ptype_mask;
19682 /* Common CLI fields for set port ptypes */
19683 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19684 TOKEN_STRING_INITIALIZER
19685 (struct cmd_set_port_ptypes_result,
19687 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19688 TOKEN_STRING_INITIALIZER
19689 (struct cmd_set_port_ptypes_result,
19691 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19692 TOKEN_NUM_INITIALIZER
19693 (struct cmd_set_port_ptypes_result,
19695 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19696 TOKEN_STRING_INITIALIZER
19697 (struct cmd_set_port_ptypes_result,
19698 ptype_mask, "ptype_mask");
19699 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19700 TOKEN_NUM_INITIALIZER
19701 (struct cmd_set_port_ptypes_result,
19705 cmd_set_port_ptypes_parsed(
19706 void *parsed_result,
19707 __rte_unused struct cmdline *cl,
19708 __rte_unused void *data)
19710 struct cmd_set_port_ptypes_result *res = parsed_result;
19711 #define PTYPE_NAMESIZE 256
19712 char ptype_name[PTYPE_NAMESIZE];
19713 uint16_t port_id = res->port_id;
19714 uint32_t ptype_mask = res->mask;
19717 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19720 printf("Port %d doesn't support any ptypes.\n", port_id);
19724 uint32_t ptypes[ret];
19726 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19728 printf("Unable to set requested ptypes for Port %d\n", port_id);
19732 printf("Successfully set following ptypes for Port %d\n", port_id);
19733 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19734 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19735 printf("%s\n", ptype_name);
19738 clear_ptypes = false;
19741 cmdline_parse_inst_t cmd_set_port_ptypes = {
19742 .f = cmd_set_port_ptypes_parsed,
19744 .help_str = "set port <port_id> ptype_mask <mask>",
19746 (void *)&cmd_set_port_ptypes_set,
19747 (void *)&cmd_set_port_ptypes_port,
19748 (void *)&cmd_set_port_ptypes_port_id,
19749 (void *)&cmd_set_port_ptypes_mask_str,
19750 (void *)&cmd_set_port_ptypes_mask_u32,
19755 /* *** display mac addresses added to a port *** */
19756 struct cmd_showport_macs_result {
19757 cmdline_fixed_string_t cmd_show;
19758 cmdline_fixed_string_t cmd_port;
19759 cmdline_fixed_string_t cmd_keyword;
19764 cmd_showport_macs_parsed(void *parsed_result,
19765 __rte_unused struct cmdline *cl,
19766 __rte_unused void *data)
19768 struct cmd_showport_macs_result *res = parsed_result;
19770 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19773 if (!strcmp(res->cmd_keyword, "macs"))
19774 show_macs(res->cmd_pid);
19775 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19776 show_mcast_macs(res->cmd_pid);
19779 cmdline_parse_token_string_t cmd_showport_macs_show =
19780 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19782 cmdline_parse_token_string_t cmd_showport_macs_port =
19783 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19785 cmdline_parse_token_num_t cmd_showport_macs_pid =
19786 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19788 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19789 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19790 cmd_keyword, "macs#mcast_macs");
19792 cmdline_parse_inst_t cmd_showport_macs = {
19793 .f = cmd_showport_macs_parsed,
19795 .help_str = "show port <port_id> macs|mcast_macs",
19797 (void *)&cmd_showport_macs_show,
19798 (void *)&cmd_showport_macs_port,
19799 (void *)&cmd_showport_macs_pid,
19800 (void *)&cmd_showport_macs_keyword,
19805 /* ******************************************************************************** */
19807 /* list of instructions */
19808 cmdline_parse_ctx_t main_ctx[] = {
19809 (cmdline_parse_inst_t *)&cmd_help_brief,
19810 (cmdline_parse_inst_t *)&cmd_help_long,
19811 (cmdline_parse_inst_t *)&cmd_quit,
19812 (cmdline_parse_inst_t *)&cmd_load_from_file,
19813 (cmdline_parse_inst_t *)&cmd_showport,
19814 (cmdline_parse_inst_t *)&cmd_showqueue,
19815 (cmdline_parse_inst_t *)&cmd_showeeprom,
19816 (cmdline_parse_inst_t *)&cmd_showportall,
19817 (cmdline_parse_inst_t *)&cmd_showdevice,
19818 (cmdline_parse_inst_t *)&cmd_showcfg,
19819 (cmdline_parse_inst_t *)&cmd_showfwdall,
19820 (cmdline_parse_inst_t *)&cmd_start,
19821 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19822 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19823 (cmdline_parse_inst_t *)&cmd_set_link_up,
19824 (cmdline_parse_inst_t *)&cmd_set_link_down,
19825 (cmdline_parse_inst_t *)&cmd_reset,
19826 (cmdline_parse_inst_t *)&cmd_set_numbers,
19827 (cmdline_parse_inst_t *)&cmd_set_log,
19828 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19829 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19830 (cmdline_parse_inst_t *)&cmd_set_txtimes,
19831 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19832 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19833 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19834 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19835 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19836 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19837 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19838 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19839 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19840 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19841 (cmdline_parse_inst_t *)&cmd_set_link_check,
19842 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19843 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19844 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19845 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19846 #ifdef RTE_LIBRTE_PMD_BOND
19847 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19848 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19849 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19850 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19851 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19852 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19853 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19854 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19855 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19856 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19857 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19859 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19860 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19861 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19862 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19863 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19864 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19865 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19866 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19867 (cmdline_parse_inst_t *)&cmd_csum_set,
19868 (cmdline_parse_inst_t *)&cmd_csum_show,
19869 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19870 (cmdline_parse_inst_t *)&cmd_tso_set,
19871 (cmdline_parse_inst_t *)&cmd_tso_show,
19872 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19873 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19874 (cmdline_parse_inst_t *)&cmd_gro_enable,
19875 (cmdline_parse_inst_t *)&cmd_gro_flush,
19876 (cmdline_parse_inst_t *)&cmd_gro_show,
19877 (cmdline_parse_inst_t *)&cmd_gso_enable,
19878 (cmdline_parse_inst_t *)&cmd_gso_size,
19879 (cmdline_parse_inst_t *)&cmd_gso_show,
19880 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19881 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19882 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19883 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19884 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19885 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19886 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19887 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19888 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19889 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19890 (cmdline_parse_inst_t *)&cmd_config_dcb,
19891 (cmdline_parse_inst_t *)&cmd_read_reg,
19892 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19893 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19894 (cmdline_parse_inst_t *)&cmd_write_reg,
19895 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19896 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19897 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19898 (cmdline_parse_inst_t *)&cmd_stop,
19899 (cmdline_parse_inst_t *)&cmd_mac_addr,
19900 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19901 (cmdline_parse_inst_t *)&cmd_set_qmap,
19902 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19903 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
19904 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
19905 (cmdline_parse_inst_t *)&cmd_operate_port,
19906 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19907 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19908 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19909 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19910 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19911 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19912 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19913 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19914 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19915 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19916 (cmdline_parse_inst_t *)&cmd_config_mtu,
19917 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19918 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19919 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19920 (cmdline_parse_inst_t *)&cmd_config_rss,
19921 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19922 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19923 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19924 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19925 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19926 (cmdline_parse_inst_t *)&cmd_showport_reta,
19927 (cmdline_parse_inst_t *)&cmd_showport_macs,
19928 (cmdline_parse_inst_t *)&cmd_config_burst,
19929 (cmdline_parse_inst_t *)&cmd_config_thresh,
19930 (cmdline_parse_inst_t *)&cmd_config_threshold,
19931 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19932 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19933 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19934 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19935 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19936 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19937 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19938 (cmdline_parse_inst_t *)&cmd_global_config,
19939 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19940 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19941 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19942 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19943 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19944 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19945 (cmdline_parse_inst_t *)&cmd_dump,
19946 (cmdline_parse_inst_t *)&cmd_dump_one,
19947 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19948 (cmdline_parse_inst_t *)&cmd_syn_filter,
19949 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19950 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19951 (cmdline_parse_inst_t *)&cmd_flex_filter,
19952 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19953 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19954 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19955 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19956 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19957 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19958 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19959 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19960 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19961 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19962 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19963 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19964 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19965 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19966 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19967 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19968 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19969 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19970 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19971 (cmdline_parse_inst_t *)&cmd_flow,
19972 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19973 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19974 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19975 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19976 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19977 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19978 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19979 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19980 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19981 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19982 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19983 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19984 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19985 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19986 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19987 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19988 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19989 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19990 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19991 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19992 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19993 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19994 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19995 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19996 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19997 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19998 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19999 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
20000 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
20001 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
20002 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
20003 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
20004 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
20005 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
20006 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
20007 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
20008 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
20009 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
20010 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
20011 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
20012 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
20013 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
20014 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
20015 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
20016 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
20017 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
20018 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
20019 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
20020 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
20021 (cmdline_parse_inst_t *)&cmd_set_vxlan,
20022 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
20023 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
20024 (cmdline_parse_inst_t *)&cmd_set_nvgre,
20025 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
20026 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
20027 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
20028 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
20029 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
20030 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
20031 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
20032 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
20033 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
20034 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
20035 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
20036 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
20037 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
20038 (cmdline_parse_inst_t *)&cmd_ddp_add,
20039 (cmdline_parse_inst_t *)&cmd_ddp_del,
20040 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
20041 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
20042 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
20043 (cmdline_parse_inst_t *)&cmd_clear_input_set,
20044 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
20045 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
20046 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
20047 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
20048 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
20049 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
20050 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
20051 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
20053 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
20054 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
20055 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
20056 (cmdline_parse_inst_t *)&cmd_queue_region,
20057 (cmdline_parse_inst_t *)&cmd_region_flowtype,
20058 (cmdline_parse_inst_t *)&cmd_user_priority_region,
20059 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
20060 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
20061 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
20062 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
20063 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
20064 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
20065 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
20066 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
20067 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
20068 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
20069 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
20070 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
20071 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
20072 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
20073 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
20074 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
20075 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
20076 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
20077 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
20078 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
20079 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
20080 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
20081 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
20082 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
20083 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
20084 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
20085 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
20086 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
20087 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
20088 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
20089 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
20090 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
20091 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
20092 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
20093 #ifdef RTE_LIBRTE_BPF
20094 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
20095 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
20097 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
20098 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
20099 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
20100 (cmdline_parse_inst_t *)&cmd_set_raw,
20101 (cmdline_parse_inst_t *)&cmd_show_set_raw,
20102 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
20103 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
20104 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
20105 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
20106 (cmdline_parse_inst_t *)&cmd_show_capability,
20110 /* read cmdline commands from file */
20112 cmdline_read_from_file(const char *filename)
20114 struct cmdline *cl;
20116 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
20118 printf("Failed to create file based cmdline context: %s\n",
20123 cmdline_interact(cl);
20128 printf("Read CLI commands from %s\n", filename);
20131 /* prompt function, called from main on MASTER lcore */
20135 /* initialize non-constant commands */
20136 cmd_set_fwd_mode_init();
20137 cmd_set_fwd_retry_mode_init();
20139 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
20140 if (testpmd_cl == NULL)
20142 cmdline_interact(testpmd_cl);
20143 cmdline_stdin_exit(testpmd_cl);
20149 if (testpmd_cl != NULL)
20150 cmdline_quit(testpmd_cl);
20154 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
20156 if (id == (portid_t)RTE_PORT_ALL) {
20159 RTE_ETH_FOREACH_DEV(pid) {
20160 /* check if need_reconfig has been set to 1 */
20161 if (ports[pid].need_reconfig == 0)
20162 ports[pid].need_reconfig = dev;
20163 /* check if need_reconfig_queues has been set to 1 */
20164 if (ports[pid].need_reconfig_queues == 0)
20165 ports[pid].need_reconfig_queues = queue;
20167 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
20168 /* check if need_reconfig has been set to 1 */
20169 if (ports[id].need_reconfig == 0)
20170 ports[id].need_reconfig = dev;
20171 /* check if need_reconfig_queues has been set to 1 */
20172 if (ports[id].need_reconfig_queues == 0)
20173 ports[id].need_reconfig_queues = queue;