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|"
887 "scatter|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|"
895 "scatter|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 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1156 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1157 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1158 " Configure the VXLAN encapsulation for flows.\n\n"
1160 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1161 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1162 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1163 " eth-dst (eth-dst)\n"
1164 " Configure the VXLAN encapsulation for flows.\n\n"
1166 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1167 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1168 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1169 " eth-dst (eth-dst)\n"
1170 " Configure the VXLAN encapsulation for flows.\n\n"
1172 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1173 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1175 " Configure the NVGRE encapsulation for flows.\n\n"
1177 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1178 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1179 " eth-src (eth-src) eth-dst (eth-dst)\n"
1180 " Configure the NVGRE encapsulation for flows.\n\n"
1182 "set raw_encap {flow items}\n"
1183 " Configure the encapsulation with raw data.\n\n"
1185 "set raw_decap {flow items}\n"
1186 " Configure the decapsulation with raw data.\n\n"
1191 if (show_all || !strcmp(res->section, "traffic_management")) {
1195 "Traffic Management:\n"
1197 "show port tm cap (port_id)\n"
1198 " Display the port TM capability.\n\n"
1200 "show port tm level cap (port_id) (level_id)\n"
1201 " Display the port TM hierarchical level capability.\n\n"
1203 "show port tm node cap (port_id) (node_id)\n"
1204 " Display the port TM node capability.\n\n"
1206 "show port tm node type (port_id) (node_id)\n"
1207 " Display the port TM node type.\n\n"
1209 "show port tm node stats (port_id) (node_id) (clear)\n"
1210 " Display the port TM node stats.\n\n"
1212 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1213 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1214 " (packet_length_adjust) (packet_mode)\n"
1215 " Add port tm node private shaper profile.\n\n"
1217 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1218 " Delete port tm node private shaper profile.\n\n"
1220 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1221 " (shaper_profile_id)\n"
1222 " Add/update port tm node shared shaper.\n\n"
1224 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1225 " Delete port tm node shared shaper.\n\n"
1227 "set port tm node shaper profile (port_id) (node_id)"
1228 " (shaper_profile_id)\n"
1229 " Set port tm node shaper profile.\n\n"
1231 "add port tm node wred profile (port_id) (wred_profile_id)"
1232 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1233 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1234 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1235 " Add port tm node wred profile.\n\n"
1237 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1238 " Delete port tm node wred profile.\n\n"
1240 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1241 " (priority) (weight) (level_id) (shaper_profile_id)"
1242 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1243 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1244 " Add port tm nonleaf node.\n\n"
1246 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1247 " (priority) (weight) (level_id) (shaper_profile_id)"
1248 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1249 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1250 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1252 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1253 " (priority) (weight) (level_id) (shaper_profile_id)"
1254 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1255 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1256 " Add port tm leaf node.\n\n"
1258 "del port tm node (port_id) (node_id)\n"
1259 " Delete port tm node.\n\n"
1261 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1262 " (priority) (weight)\n"
1263 " Set port tm node parent.\n\n"
1265 "suspend port tm node (port_id) (node_id)"
1266 " Suspend tm node.\n\n"
1268 "resume port tm node (port_id) (node_id)"
1269 " Resume tm node.\n\n"
1271 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1272 " Commit tm hierarchy.\n\n"
1274 "set port tm mark ip_ecn (port) (green) (yellow)"
1276 " Enables/Disables the traffic management marking"
1277 " for IP ECN (Explicit Congestion Notification)"
1278 " packets on a given port\n\n"
1280 "set port tm mark ip_dscp (port) (green) (yellow)"
1282 " Enables/Disables the traffic management marking"
1283 " on the port for IP dscp packets\n\n"
1285 "set port tm mark vlan_dei (port) (green) (yellow)"
1287 " Enables/Disables the traffic management marking"
1288 " on the port for VLAN packets with DEI enabled\n\n"
1292 if (show_all || !strcmp(res->section, "devices")) {
1296 "Device Operations:\n"
1298 "device detach (identifier)\n"
1299 " Detach device by identifier.\n\n"
1305 cmdline_parse_token_string_t cmd_help_long_help =
1306 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1308 cmdline_parse_token_string_t cmd_help_long_section =
1309 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1310 "all#control#display#config#"
1311 "ports#registers#filters#traffic_management#devices");
1313 cmdline_parse_inst_t cmd_help_long = {
1314 .f = cmd_help_long_parsed,
1316 .help_str = "help all|control|display|config|ports|register|"
1317 "filters|traffic_management|devices: "
1320 (void *)&cmd_help_long_help,
1321 (void *)&cmd_help_long_section,
1327 /* *** start/stop/close all ports *** */
1328 struct cmd_operate_port_result {
1329 cmdline_fixed_string_t keyword;
1330 cmdline_fixed_string_t name;
1331 cmdline_fixed_string_t value;
1334 static void cmd_operate_port_parsed(void *parsed_result,
1335 __rte_unused struct cmdline *cl,
1336 __rte_unused void *data)
1338 struct cmd_operate_port_result *res = parsed_result;
1340 if (!strcmp(res->name, "start"))
1341 start_port(RTE_PORT_ALL);
1342 else if (!strcmp(res->name, "stop"))
1343 stop_port(RTE_PORT_ALL);
1344 else if (!strcmp(res->name, "close"))
1345 close_port(RTE_PORT_ALL);
1346 else if (!strcmp(res->name, "reset"))
1347 reset_port(RTE_PORT_ALL);
1349 printf("Unknown parameter\n");
1352 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1353 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1355 cmdline_parse_token_string_t cmd_operate_port_all_port =
1356 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1357 "start#stop#close#reset");
1358 cmdline_parse_token_string_t cmd_operate_port_all_all =
1359 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1361 cmdline_parse_inst_t cmd_operate_port = {
1362 .f = cmd_operate_port_parsed,
1364 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1366 (void *)&cmd_operate_port_all_cmd,
1367 (void *)&cmd_operate_port_all_port,
1368 (void *)&cmd_operate_port_all_all,
1373 /* *** start/stop/close specific port *** */
1374 struct cmd_operate_specific_port_result {
1375 cmdline_fixed_string_t keyword;
1376 cmdline_fixed_string_t name;
1380 static void cmd_operate_specific_port_parsed(void *parsed_result,
1381 __rte_unused struct cmdline *cl,
1382 __rte_unused void *data)
1384 struct cmd_operate_specific_port_result *res = parsed_result;
1386 if (!strcmp(res->name, "start"))
1387 start_port(res->value);
1388 else if (!strcmp(res->name, "stop"))
1389 stop_port(res->value);
1390 else if (!strcmp(res->name, "close"))
1391 close_port(res->value);
1392 else if (!strcmp(res->name, "reset"))
1393 reset_port(res->value);
1395 printf("Unknown parameter\n");
1398 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1399 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1401 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1402 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1403 name, "start#stop#close#reset");
1404 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1405 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1408 cmdline_parse_inst_t cmd_operate_specific_port = {
1409 .f = cmd_operate_specific_port_parsed,
1411 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1413 (void *)&cmd_operate_specific_port_cmd,
1414 (void *)&cmd_operate_specific_port_port,
1415 (void *)&cmd_operate_specific_port_id,
1420 /* *** enable port setup (after attach) via iterator or event *** */
1421 struct cmd_set_port_setup_on_result {
1422 cmdline_fixed_string_t set;
1423 cmdline_fixed_string_t port;
1424 cmdline_fixed_string_t setup;
1425 cmdline_fixed_string_t on;
1426 cmdline_fixed_string_t mode;
1429 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1430 __rte_unused struct cmdline *cl,
1431 __rte_unused void *data)
1433 struct cmd_set_port_setup_on_result *res = parsed_result;
1435 if (strcmp(res->mode, "event") == 0)
1436 setup_on_probe_event = true;
1437 else if (strcmp(res->mode, "iterator") == 0)
1438 setup_on_probe_event = false;
1440 printf("Unknown mode\n");
1443 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1444 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1446 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1447 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1449 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1450 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1452 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1453 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1455 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1456 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1457 mode, "iterator#event");
1459 cmdline_parse_inst_t cmd_set_port_setup_on = {
1460 .f = cmd_set_port_setup_on_parsed,
1462 .help_str = "set port setup on iterator|event",
1464 (void *)&cmd_set_port_setup_on_set,
1465 (void *)&cmd_set_port_setup_on_port,
1466 (void *)&cmd_set_port_setup_on_setup,
1467 (void *)&cmd_set_port_setup_on_on,
1468 (void *)&cmd_set_port_setup_on_mode,
1473 /* *** attach a specified port *** */
1474 struct cmd_operate_attach_port_result {
1475 cmdline_fixed_string_t port;
1476 cmdline_fixed_string_t keyword;
1477 cmdline_multi_string_t identifier;
1480 static void cmd_operate_attach_port_parsed(void *parsed_result,
1481 __rte_unused struct cmdline *cl,
1482 __rte_unused void *data)
1484 struct cmd_operate_attach_port_result *res = parsed_result;
1486 if (!strcmp(res->keyword, "attach"))
1487 attach_port(res->identifier);
1489 printf("Unknown parameter\n");
1492 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1493 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1495 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1496 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1498 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1499 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1500 identifier, TOKEN_STRING_MULTI);
1502 cmdline_parse_inst_t cmd_operate_attach_port = {
1503 .f = cmd_operate_attach_port_parsed,
1505 .help_str = "port attach <identifier>: "
1506 "(identifier: pci address or virtual dev name)",
1508 (void *)&cmd_operate_attach_port_port,
1509 (void *)&cmd_operate_attach_port_keyword,
1510 (void *)&cmd_operate_attach_port_identifier,
1515 /* *** detach a specified port *** */
1516 struct cmd_operate_detach_port_result {
1517 cmdline_fixed_string_t port;
1518 cmdline_fixed_string_t keyword;
1522 static void cmd_operate_detach_port_parsed(void *parsed_result,
1523 __rte_unused struct cmdline *cl,
1524 __rte_unused void *data)
1526 struct cmd_operate_detach_port_result *res = parsed_result;
1528 if (!strcmp(res->keyword, "detach")) {
1529 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1530 detach_port_device(res->port_id);
1532 printf("Unknown parameter\n");
1536 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1537 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1539 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1540 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1542 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1543 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1546 cmdline_parse_inst_t cmd_operate_detach_port = {
1547 .f = cmd_operate_detach_port_parsed,
1549 .help_str = "port detach <port_id>",
1551 (void *)&cmd_operate_detach_port_port,
1552 (void *)&cmd_operate_detach_port_keyword,
1553 (void *)&cmd_operate_detach_port_port_id,
1558 /* *** detach device by identifier *** */
1559 struct cmd_operate_detach_device_result {
1560 cmdline_fixed_string_t device;
1561 cmdline_fixed_string_t keyword;
1562 cmdline_fixed_string_t identifier;
1565 static void cmd_operate_detach_device_parsed(void *parsed_result,
1566 __rte_unused struct cmdline *cl,
1567 __rte_unused void *data)
1569 struct cmd_operate_detach_device_result *res = parsed_result;
1571 if (!strcmp(res->keyword, "detach"))
1572 detach_devargs(res->identifier);
1574 printf("Unknown parameter\n");
1577 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1578 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1580 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1581 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1583 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1584 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1587 cmdline_parse_inst_t cmd_operate_detach_device = {
1588 .f = cmd_operate_detach_device_parsed,
1590 .help_str = "device detach <identifier>:"
1591 "(identifier: pci address or virtual dev name)",
1593 (void *)&cmd_operate_detach_device_device,
1594 (void *)&cmd_operate_detach_device_keyword,
1595 (void *)&cmd_operate_detach_device_identifier,
1599 /* *** configure speed for all ports *** */
1600 struct cmd_config_speed_all {
1601 cmdline_fixed_string_t port;
1602 cmdline_fixed_string_t keyword;
1603 cmdline_fixed_string_t all;
1604 cmdline_fixed_string_t item1;
1605 cmdline_fixed_string_t item2;
1606 cmdline_fixed_string_t value1;
1607 cmdline_fixed_string_t value2;
1611 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1616 if (!strcmp(duplexstr, "half")) {
1617 duplex = ETH_LINK_HALF_DUPLEX;
1618 } else if (!strcmp(duplexstr, "full")) {
1619 duplex = ETH_LINK_FULL_DUPLEX;
1620 } else if (!strcmp(duplexstr, "auto")) {
1621 duplex = ETH_LINK_FULL_DUPLEX;
1623 printf("Unknown duplex parameter\n");
1627 if (!strcmp(speedstr, "10")) {
1628 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1629 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1630 } else if (!strcmp(speedstr, "100")) {
1631 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1632 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1634 if (duplex != ETH_LINK_FULL_DUPLEX) {
1635 printf("Invalid speed/duplex parameters\n");
1638 if (!strcmp(speedstr, "1000")) {
1639 *speed = ETH_LINK_SPEED_1G;
1640 } else if (!strcmp(speedstr, "10000")) {
1641 *speed = ETH_LINK_SPEED_10G;
1642 } else if (!strcmp(speedstr, "25000")) {
1643 *speed = ETH_LINK_SPEED_25G;
1644 } else if (!strcmp(speedstr, "40000")) {
1645 *speed = ETH_LINK_SPEED_40G;
1646 } else if (!strcmp(speedstr, "50000")) {
1647 *speed = ETH_LINK_SPEED_50G;
1648 } else if (!strcmp(speedstr, "100000")) {
1649 *speed = ETH_LINK_SPEED_100G;
1650 } else if (!strcmp(speedstr, "200000")) {
1651 *speed = ETH_LINK_SPEED_200G;
1652 } else if (!strcmp(speedstr, "auto")) {
1653 *speed = ETH_LINK_SPEED_AUTONEG;
1655 printf("Unknown speed parameter\n");
1664 cmd_config_speed_all_parsed(void *parsed_result,
1665 __rte_unused struct cmdline *cl,
1666 __rte_unused void *data)
1668 struct cmd_config_speed_all *res = parsed_result;
1669 uint32_t link_speed;
1672 if (!all_ports_stopped()) {
1673 printf("Please stop all ports first\n");
1677 if (parse_and_check_speed_duplex(res->value1, res->value2,
1681 RTE_ETH_FOREACH_DEV(pid) {
1682 ports[pid].dev_conf.link_speeds = link_speed;
1685 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1688 cmdline_parse_token_string_t cmd_config_speed_all_port =
1689 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1690 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1691 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1693 cmdline_parse_token_string_t cmd_config_speed_all_all =
1694 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1695 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1696 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1697 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1698 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1699 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1700 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1701 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1702 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1703 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1706 cmdline_parse_inst_t cmd_config_speed_all = {
1707 .f = cmd_config_speed_all_parsed,
1709 .help_str = "port config all speed "
1710 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1713 (void *)&cmd_config_speed_all_port,
1714 (void *)&cmd_config_speed_all_keyword,
1715 (void *)&cmd_config_speed_all_all,
1716 (void *)&cmd_config_speed_all_item1,
1717 (void *)&cmd_config_speed_all_value1,
1718 (void *)&cmd_config_speed_all_item2,
1719 (void *)&cmd_config_speed_all_value2,
1724 /* *** configure speed for specific port *** */
1725 struct cmd_config_speed_specific {
1726 cmdline_fixed_string_t port;
1727 cmdline_fixed_string_t keyword;
1729 cmdline_fixed_string_t item1;
1730 cmdline_fixed_string_t item2;
1731 cmdline_fixed_string_t value1;
1732 cmdline_fixed_string_t value2;
1736 cmd_config_speed_specific_parsed(void *parsed_result,
1737 __rte_unused struct cmdline *cl,
1738 __rte_unused void *data)
1740 struct cmd_config_speed_specific *res = parsed_result;
1741 uint32_t link_speed;
1743 if (!all_ports_stopped()) {
1744 printf("Please stop all ports first\n");
1748 if (port_id_is_invalid(res->id, ENABLED_WARN))
1751 if (parse_and_check_speed_duplex(res->value1, res->value2,
1755 ports[res->id].dev_conf.link_speeds = link_speed;
1757 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1761 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1762 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1764 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1765 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1767 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1768 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1769 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1770 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1772 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1773 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1774 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1775 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1776 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1778 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1779 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1782 cmdline_parse_inst_t cmd_config_speed_specific = {
1783 .f = cmd_config_speed_specific_parsed,
1785 .help_str = "port config <port_id> speed "
1786 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1789 (void *)&cmd_config_speed_specific_port,
1790 (void *)&cmd_config_speed_specific_keyword,
1791 (void *)&cmd_config_speed_specific_id,
1792 (void *)&cmd_config_speed_specific_item1,
1793 (void *)&cmd_config_speed_specific_value1,
1794 (void *)&cmd_config_speed_specific_item2,
1795 (void *)&cmd_config_speed_specific_value2,
1800 /* *** configure loopback for all ports *** */
1801 struct cmd_config_loopback_all {
1802 cmdline_fixed_string_t port;
1803 cmdline_fixed_string_t keyword;
1804 cmdline_fixed_string_t all;
1805 cmdline_fixed_string_t item;
1810 cmd_config_loopback_all_parsed(void *parsed_result,
1811 __rte_unused struct cmdline *cl,
1812 __rte_unused void *data)
1814 struct cmd_config_loopback_all *res = parsed_result;
1817 if (!all_ports_stopped()) {
1818 printf("Please stop all ports first\n");
1822 RTE_ETH_FOREACH_DEV(pid) {
1823 ports[pid].dev_conf.lpbk_mode = res->mode;
1826 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1829 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1830 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1831 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1832 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1834 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1835 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1836 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1837 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1839 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1840 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1842 cmdline_parse_inst_t cmd_config_loopback_all = {
1843 .f = cmd_config_loopback_all_parsed,
1845 .help_str = "port config all loopback <mode>",
1847 (void *)&cmd_config_loopback_all_port,
1848 (void *)&cmd_config_loopback_all_keyword,
1849 (void *)&cmd_config_loopback_all_all,
1850 (void *)&cmd_config_loopback_all_item,
1851 (void *)&cmd_config_loopback_all_mode,
1856 /* *** configure loopback for specific port *** */
1857 struct cmd_config_loopback_specific {
1858 cmdline_fixed_string_t port;
1859 cmdline_fixed_string_t keyword;
1861 cmdline_fixed_string_t item;
1866 cmd_config_loopback_specific_parsed(void *parsed_result,
1867 __rte_unused struct cmdline *cl,
1868 __rte_unused void *data)
1870 struct cmd_config_loopback_specific *res = parsed_result;
1872 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1875 if (!port_is_stopped(res->port_id)) {
1876 printf("Please stop port %u first\n", res->port_id);
1880 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1882 cmd_reconfig_device_queue(res->port_id, 1, 1);
1886 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1887 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1889 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1890 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1892 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1893 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1895 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1896 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1898 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1899 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1902 cmdline_parse_inst_t cmd_config_loopback_specific = {
1903 .f = cmd_config_loopback_specific_parsed,
1905 .help_str = "port config <port_id> loopback <mode>",
1907 (void *)&cmd_config_loopback_specific_port,
1908 (void *)&cmd_config_loopback_specific_keyword,
1909 (void *)&cmd_config_loopback_specific_id,
1910 (void *)&cmd_config_loopback_specific_item,
1911 (void *)&cmd_config_loopback_specific_mode,
1916 /* *** configure txq/rxq, txd/rxd *** */
1917 struct cmd_config_rx_tx {
1918 cmdline_fixed_string_t port;
1919 cmdline_fixed_string_t keyword;
1920 cmdline_fixed_string_t all;
1921 cmdline_fixed_string_t name;
1926 cmd_config_rx_tx_parsed(void *parsed_result,
1927 __rte_unused struct cmdline *cl,
1928 __rte_unused void *data)
1930 struct cmd_config_rx_tx *res = parsed_result;
1932 if (!all_ports_stopped()) {
1933 printf("Please stop all ports first\n");
1936 if (!strcmp(res->name, "rxq")) {
1937 if (!res->value && !nb_txq) {
1938 printf("Warning: Either rx or tx queues should be non zero\n");
1941 if (check_nb_rxq(res->value) != 0)
1943 nb_rxq = res->value;
1945 else if (!strcmp(res->name, "txq")) {
1946 if (!res->value && !nb_rxq) {
1947 printf("Warning: Either rx or tx queues should be non zero\n");
1950 if (check_nb_txq(res->value) != 0)
1952 nb_txq = res->value;
1954 else if (!strcmp(res->name, "rxd")) {
1955 if (check_nb_rxd(res->value) != 0)
1957 nb_rxd = res->value;
1958 } else if (!strcmp(res->name, "txd")) {
1959 if (check_nb_txd(res->value) != 0)
1962 nb_txd = res->value;
1964 printf("Unknown parameter\n");
1972 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1975 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1976 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1977 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1978 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1979 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1980 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1981 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1982 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1984 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1985 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1987 cmdline_parse_inst_t cmd_config_rx_tx = {
1988 .f = cmd_config_rx_tx_parsed,
1990 .help_str = "port config all rxq|txq|rxd|txd <value>",
1992 (void *)&cmd_config_rx_tx_port,
1993 (void *)&cmd_config_rx_tx_keyword,
1994 (void *)&cmd_config_rx_tx_all,
1995 (void *)&cmd_config_rx_tx_name,
1996 (void *)&cmd_config_rx_tx_value,
2001 /* *** config max packet length *** */
2002 struct cmd_config_max_pkt_len_result {
2003 cmdline_fixed_string_t port;
2004 cmdline_fixed_string_t keyword;
2005 cmdline_fixed_string_t all;
2006 cmdline_fixed_string_t name;
2011 cmd_config_max_pkt_len_parsed(void *parsed_result,
2012 __rte_unused struct cmdline *cl,
2013 __rte_unused void *data)
2015 struct cmd_config_max_pkt_len_result *res = parsed_result;
2018 if (!all_ports_stopped()) {
2019 printf("Please stop all ports first\n");
2023 RTE_ETH_FOREACH_DEV(pid) {
2024 struct rte_port *port = &ports[pid];
2025 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
2027 if (!strcmp(res->name, "max-pkt-len")) {
2028 if (res->value < RTE_ETHER_MIN_LEN) {
2029 printf("max-pkt-len can not be less than %d\n",
2033 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2036 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2037 if (res->value > RTE_ETHER_MAX_LEN)
2038 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2040 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2041 port->dev_conf.rxmode.offloads = rx_offloads;
2043 printf("Unknown parameter\n");
2050 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2053 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2054 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2056 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2057 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2059 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2060 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2062 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2063 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2065 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2066 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2069 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2070 .f = cmd_config_max_pkt_len_parsed,
2072 .help_str = "port config all max-pkt-len <value>",
2074 (void *)&cmd_config_max_pkt_len_port,
2075 (void *)&cmd_config_max_pkt_len_keyword,
2076 (void *)&cmd_config_max_pkt_len_all,
2077 (void *)&cmd_config_max_pkt_len_name,
2078 (void *)&cmd_config_max_pkt_len_value,
2083 /* *** config max LRO aggregated packet size *** */
2084 struct cmd_config_max_lro_pkt_size_result {
2085 cmdline_fixed_string_t port;
2086 cmdline_fixed_string_t keyword;
2087 cmdline_fixed_string_t all;
2088 cmdline_fixed_string_t name;
2093 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2094 __rte_unused struct cmdline *cl,
2095 __rte_unused void *data)
2097 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2100 if (!all_ports_stopped()) {
2101 printf("Please stop all ports first\n");
2105 RTE_ETH_FOREACH_DEV(pid) {
2106 struct rte_port *port = &ports[pid];
2108 if (!strcmp(res->name, "max-lro-pkt-size")) {
2110 port->dev_conf.rxmode.max_lro_pkt_size)
2113 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2115 printf("Unknown parameter\n");
2122 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2125 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2126 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2128 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2129 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2131 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2132 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2134 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2135 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2136 name, "max-lro-pkt-size");
2137 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2138 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2141 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2142 .f = cmd_config_max_lro_pkt_size_parsed,
2144 .help_str = "port config all max-lro-pkt-size <value>",
2146 (void *)&cmd_config_max_lro_pkt_size_port,
2147 (void *)&cmd_config_max_lro_pkt_size_keyword,
2148 (void *)&cmd_config_max_lro_pkt_size_all,
2149 (void *)&cmd_config_max_lro_pkt_size_name,
2150 (void *)&cmd_config_max_lro_pkt_size_value,
2155 /* *** configure port MTU *** */
2156 struct cmd_config_mtu_result {
2157 cmdline_fixed_string_t port;
2158 cmdline_fixed_string_t keyword;
2159 cmdline_fixed_string_t mtu;
2165 cmd_config_mtu_parsed(void *parsed_result,
2166 __rte_unused struct cmdline *cl,
2167 __rte_unused void *data)
2169 struct cmd_config_mtu_result *res = parsed_result;
2171 if (res->value < RTE_ETHER_MIN_LEN) {
2172 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2175 port_mtu_set(res->port_id, res->value);
2178 cmdline_parse_token_string_t cmd_config_mtu_port =
2179 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2181 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2182 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2184 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2185 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2187 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2188 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2189 cmdline_parse_token_num_t cmd_config_mtu_value =
2190 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2192 cmdline_parse_inst_t cmd_config_mtu = {
2193 .f = cmd_config_mtu_parsed,
2195 .help_str = "port config mtu <port_id> <value>",
2197 (void *)&cmd_config_mtu_port,
2198 (void *)&cmd_config_mtu_keyword,
2199 (void *)&cmd_config_mtu_mtu,
2200 (void *)&cmd_config_mtu_port_id,
2201 (void *)&cmd_config_mtu_value,
2206 /* *** configure rx mode *** */
2207 struct cmd_config_rx_mode_flag {
2208 cmdline_fixed_string_t port;
2209 cmdline_fixed_string_t keyword;
2210 cmdline_fixed_string_t all;
2211 cmdline_fixed_string_t name;
2212 cmdline_fixed_string_t value;
2216 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2217 __rte_unused struct cmdline *cl,
2218 __rte_unused void *data)
2220 struct cmd_config_rx_mode_flag *res = parsed_result;
2222 if (!all_ports_stopped()) {
2223 printf("Please stop all ports first\n");
2227 if (!strcmp(res->name, "drop-en")) {
2228 if (!strcmp(res->value, "on"))
2230 else if (!strcmp(res->value, "off"))
2233 printf("Unknown parameter\n");
2237 printf("Unknown parameter\n");
2243 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2246 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2247 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2248 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2249 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2251 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2252 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2253 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2254 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2256 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2257 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2260 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2261 .f = cmd_config_rx_mode_flag_parsed,
2263 .help_str = "port config all drop-en on|off",
2265 (void *)&cmd_config_rx_mode_flag_port,
2266 (void *)&cmd_config_rx_mode_flag_keyword,
2267 (void *)&cmd_config_rx_mode_flag_all,
2268 (void *)&cmd_config_rx_mode_flag_name,
2269 (void *)&cmd_config_rx_mode_flag_value,
2274 /* *** configure rss *** */
2275 struct cmd_config_rss {
2276 cmdline_fixed_string_t port;
2277 cmdline_fixed_string_t keyword;
2278 cmdline_fixed_string_t all;
2279 cmdline_fixed_string_t name;
2280 cmdline_fixed_string_t value;
2284 cmd_config_rss_parsed(void *parsed_result,
2285 __rte_unused struct cmdline *cl,
2286 __rte_unused void *data)
2288 struct cmd_config_rss *res = parsed_result;
2289 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2290 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2291 int use_default = 0;
2292 int all_updated = 1;
2297 if (!strcmp(res->value, "all"))
2298 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2299 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2300 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2301 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU;
2302 else if (!strcmp(res->value, "eth"))
2303 rss_conf.rss_hf = ETH_RSS_ETH;
2304 else if (!strcmp(res->value, "vlan"))
2305 rss_conf.rss_hf = ETH_RSS_VLAN;
2306 else if (!strcmp(res->value, "ip"))
2307 rss_conf.rss_hf = ETH_RSS_IP;
2308 else if (!strcmp(res->value, "udp"))
2309 rss_conf.rss_hf = ETH_RSS_UDP;
2310 else if (!strcmp(res->value, "tcp"))
2311 rss_conf.rss_hf = ETH_RSS_TCP;
2312 else if (!strcmp(res->value, "sctp"))
2313 rss_conf.rss_hf = ETH_RSS_SCTP;
2314 else if (!strcmp(res->value, "ether"))
2315 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2316 else if (!strcmp(res->value, "port"))
2317 rss_conf.rss_hf = ETH_RSS_PORT;
2318 else if (!strcmp(res->value, "vxlan"))
2319 rss_conf.rss_hf = ETH_RSS_VXLAN;
2320 else if (!strcmp(res->value, "geneve"))
2321 rss_conf.rss_hf = ETH_RSS_GENEVE;
2322 else if (!strcmp(res->value, "nvgre"))
2323 rss_conf.rss_hf = ETH_RSS_NVGRE;
2324 else if (!strcmp(res->value, "l3-pre32"))
2325 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2326 else if (!strcmp(res->value, "l3-pre40"))
2327 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2328 else if (!strcmp(res->value, "l3-pre48"))
2329 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2330 else if (!strcmp(res->value, "l3-pre56"))
2331 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2332 else if (!strcmp(res->value, "l3-pre64"))
2333 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2334 else if (!strcmp(res->value, "l3-pre96"))
2335 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2336 else if (!strcmp(res->value, "l3-src-only"))
2337 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2338 else if (!strcmp(res->value, "l3-dst-only"))
2339 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2340 else if (!strcmp(res->value, "l4-src-only"))
2341 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2342 else if (!strcmp(res->value, "l4-dst-only"))
2343 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2344 else if (!strcmp(res->value, "l2-src-only"))
2345 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2346 else if (!strcmp(res->value, "l2-dst-only"))
2347 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2348 else if (!strcmp(res->value, "l2tpv3"))
2349 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2350 else if (!strcmp(res->value, "esp"))
2351 rss_conf.rss_hf = ETH_RSS_ESP;
2352 else if (!strcmp(res->value, "ah"))
2353 rss_conf.rss_hf = ETH_RSS_AH;
2354 else if (!strcmp(res->value, "pfcp"))
2355 rss_conf.rss_hf = ETH_RSS_PFCP;
2356 else if (!strcmp(res->value, "pppoe"))
2357 rss_conf.rss_hf = ETH_RSS_PPPOE;
2358 else if (!strcmp(res->value, "gtpu"))
2359 rss_conf.rss_hf = ETH_RSS_GTPU;
2360 else if (!strcmp(res->value, "none"))
2361 rss_conf.rss_hf = 0;
2362 else if (!strcmp(res->value, "level-default")) {
2363 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2364 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2365 } else if (!strcmp(res->value, "level-outer")) {
2366 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2367 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2368 } else if (!strcmp(res->value, "level-inner")) {
2369 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2370 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2371 } else if (!strcmp(res->value, "default"))
2373 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2374 atoi(res->value) < 64)
2375 rss_conf.rss_hf = 1ULL << atoi(res->value);
2377 printf("Unknown parameter\n");
2380 rss_conf.rss_key = NULL;
2381 /* Update global configuration for RSS types. */
2382 RTE_ETH_FOREACH_DEV(i) {
2383 struct rte_eth_rss_conf local_rss_conf;
2385 ret = eth_dev_info_get_print_err(i, &dev_info);
2390 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2392 local_rss_conf = rss_conf;
2393 local_rss_conf.rss_hf = rss_conf.rss_hf &
2394 dev_info.flow_type_rss_offloads;
2395 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2396 printf("Port %u modified RSS hash function based on hardware support,"
2397 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2398 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2400 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2403 printf("Configuration of RSS hash at ethernet port %d "
2404 "failed with error (%d): %s.\n",
2405 i, -diag, strerror(-diag));
2408 if (all_updated && !use_default) {
2409 rss_hf = rss_conf.rss_hf;
2410 printf("rss_hf %#"PRIx64"\n", rss_hf);
2414 cmdline_parse_token_string_t cmd_config_rss_port =
2415 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2416 cmdline_parse_token_string_t cmd_config_rss_keyword =
2417 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2418 cmdline_parse_token_string_t cmd_config_rss_all =
2419 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2420 cmdline_parse_token_string_t cmd_config_rss_name =
2421 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2422 cmdline_parse_token_string_t cmd_config_rss_value =
2423 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2425 cmdline_parse_inst_t cmd_config_rss = {
2426 .f = cmd_config_rss_parsed,
2428 .help_str = "port config all rss "
2429 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2430 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|level-default|"
2431 "level-outer|level-inner|<flowtype_id>",
2433 (void *)&cmd_config_rss_port,
2434 (void *)&cmd_config_rss_keyword,
2435 (void *)&cmd_config_rss_all,
2436 (void *)&cmd_config_rss_name,
2437 (void *)&cmd_config_rss_value,
2442 /* *** configure rss hash key *** */
2443 struct cmd_config_rss_hash_key {
2444 cmdline_fixed_string_t port;
2445 cmdline_fixed_string_t config;
2447 cmdline_fixed_string_t rss_hash_key;
2448 cmdline_fixed_string_t rss_type;
2449 cmdline_fixed_string_t key;
2453 hexa_digit_to_value(char hexa_digit)
2455 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2456 return (uint8_t) (hexa_digit - '0');
2457 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2458 return (uint8_t) ((hexa_digit - 'a') + 10);
2459 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2460 return (uint8_t) ((hexa_digit - 'A') + 10);
2461 /* Invalid hexa digit */
2466 parse_and_check_key_hexa_digit(char *key, int idx)
2470 hexa_v = hexa_digit_to_value(key[idx]);
2472 printf("invalid key: character %c at position %d is not a "
2473 "valid hexa digit\n", key[idx], idx);
2478 cmd_config_rss_hash_key_parsed(void *parsed_result,
2479 __rte_unused struct cmdline *cl,
2480 __rte_unused void *data)
2482 struct cmd_config_rss_hash_key *res = parsed_result;
2483 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2487 struct rte_eth_dev_info dev_info;
2488 uint8_t hash_key_size;
2492 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2496 if (dev_info.hash_key_size > 0 &&
2497 dev_info.hash_key_size <= sizeof(hash_key))
2498 hash_key_size = dev_info.hash_key_size;
2500 printf("dev_info did not provide a valid hash key size\n");
2503 /* Check the length of the RSS hash key */
2504 key_len = strlen(res->key);
2505 if (key_len != (hash_key_size * 2)) {
2506 printf("key length: %d invalid - key must be a string of %d"
2507 " hexa-decimal numbers\n",
2508 (int) key_len, hash_key_size * 2);
2511 /* Translate RSS hash key into binary representation */
2512 for (i = 0; i < hash_key_size; i++) {
2513 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2516 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2519 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2521 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2525 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2526 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2527 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2528 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2530 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2531 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2532 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2533 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2534 rss_hash_key, "rss-hash-key");
2535 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2536 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2537 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2538 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2539 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2540 "ipv6-tcp-ex#ipv6-udp-ex#"
2541 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2542 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2543 "l2tpv3#esp#ah#pfcp#pppoe#gtpu");
2544 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2545 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2547 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2548 .f = cmd_config_rss_hash_key_parsed,
2550 .help_str = "port config <port_id> rss-hash-key "
2551 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2552 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2553 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2554 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2555 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2556 "l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2557 "<string of hex digits (variable length, NIC dependent)>",
2559 (void *)&cmd_config_rss_hash_key_port,
2560 (void *)&cmd_config_rss_hash_key_config,
2561 (void *)&cmd_config_rss_hash_key_port_id,
2562 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2563 (void *)&cmd_config_rss_hash_key_rss_type,
2564 (void *)&cmd_config_rss_hash_key_value,
2569 /* *** configure port rxq/txq ring size *** */
2570 struct cmd_config_rxtx_ring_size {
2571 cmdline_fixed_string_t port;
2572 cmdline_fixed_string_t config;
2574 cmdline_fixed_string_t rxtxq;
2576 cmdline_fixed_string_t rsize;
2581 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2582 __rte_unused struct cmdline *cl,
2583 __rte_unused void *data)
2585 struct cmd_config_rxtx_ring_size *res = parsed_result;
2586 struct rte_port *port;
2589 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2592 if (res->portid == (portid_t)RTE_PORT_ALL) {
2593 printf("Invalid port id\n");
2597 port = &ports[res->portid];
2599 if (!strcmp(res->rxtxq, "rxq"))
2601 else if (!strcmp(res->rxtxq, "txq"))
2604 printf("Unknown parameter\n");
2608 if (isrx && rx_queue_id_is_invalid(res->qid))
2610 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2613 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2614 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2620 port->nb_rx_desc[res->qid] = res->size;
2622 port->nb_tx_desc[res->qid] = res->size;
2624 cmd_reconfig_device_queue(res->portid, 0, 1);
2627 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2628 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2630 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2631 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2633 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2634 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2636 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2637 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2639 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2640 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2642 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2643 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2644 rsize, "ring_size");
2645 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2646 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2649 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2650 .f = cmd_config_rxtx_ring_size_parsed,
2652 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2654 (void *)&cmd_config_rxtx_ring_size_port,
2655 (void *)&cmd_config_rxtx_ring_size_config,
2656 (void *)&cmd_config_rxtx_ring_size_portid,
2657 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2658 (void *)&cmd_config_rxtx_ring_size_qid,
2659 (void *)&cmd_config_rxtx_ring_size_rsize,
2660 (void *)&cmd_config_rxtx_ring_size_size,
2665 /* *** configure port rxq/txq start/stop *** */
2666 struct cmd_config_rxtx_queue {
2667 cmdline_fixed_string_t port;
2669 cmdline_fixed_string_t rxtxq;
2671 cmdline_fixed_string_t opname;
2675 cmd_config_rxtx_queue_parsed(void *parsed_result,
2676 __rte_unused struct cmdline *cl,
2677 __rte_unused void *data)
2679 struct cmd_config_rxtx_queue *res = parsed_result;
2684 if (test_done == 0) {
2685 printf("Please stop forwarding first\n");
2689 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2692 if (port_is_started(res->portid) != 1) {
2693 printf("Please start port %u first\n", res->portid);
2697 if (!strcmp(res->rxtxq, "rxq"))
2699 else if (!strcmp(res->rxtxq, "txq"))
2702 printf("Unknown parameter\n");
2706 if (isrx && rx_queue_id_is_invalid(res->qid))
2708 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2711 if (!strcmp(res->opname, "start"))
2713 else if (!strcmp(res->opname, "stop"))
2716 printf("Unknown parameter\n");
2720 if (isstart && isrx)
2721 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2722 else if (!isstart && isrx)
2723 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2724 else if (isstart && !isrx)
2725 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2727 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2729 if (ret == -ENOTSUP)
2730 printf("Function not supported in PMD driver\n");
2733 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2734 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2735 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2736 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2737 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2738 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2739 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2740 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2741 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2742 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2745 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2746 .f = cmd_config_rxtx_queue_parsed,
2748 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2750 (void *)&cmd_config_rxtx_queue_port,
2751 (void *)&cmd_config_rxtx_queue_portid,
2752 (void *)&cmd_config_rxtx_queue_rxtxq,
2753 (void *)&cmd_config_rxtx_queue_qid,
2754 (void *)&cmd_config_rxtx_queue_opname,
2759 /* *** configure port rxq/txq deferred start on/off *** */
2760 struct cmd_config_deferred_start_rxtx_queue {
2761 cmdline_fixed_string_t port;
2763 cmdline_fixed_string_t rxtxq;
2765 cmdline_fixed_string_t opname;
2766 cmdline_fixed_string_t state;
2770 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2771 __rte_unused struct cmdline *cl,
2772 __rte_unused void *data)
2774 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2775 struct rte_port *port;
2778 uint8_t needreconfig = 0;
2780 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2783 if (port_is_started(res->port_id) != 0) {
2784 printf("Please stop port %u first\n", res->port_id);
2788 port = &ports[res->port_id];
2790 isrx = !strcmp(res->rxtxq, "rxq");
2792 if (isrx && rx_queue_id_is_invalid(res->qid))
2794 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2797 ison = !strcmp(res->state, "on");
2799 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2800 port->rx_conf[res->qid].rx_deferred_start = ison;
2802 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2803 port->tx_conf[res->qid].tx_deferred_start = ison;
2808 cmd_reconfig_device_queue(res->port_id, 0, 1);
2811 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2812 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2814 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2815 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2817 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2818 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2820 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2821 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2823 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2824 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2825 opname, "deferred_start");
2826 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2827 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2830 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2831 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2833 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2835 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2836 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2837 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2838 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2839 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2840 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2845 /* *** configure port rxq/txq setup *** */
2846 struct cmd_setup_rxtx_queue {
2847 cmdline_fixed_string_t port;
2849 cmdline_fixed_string_t rxtxq;
2851 cmdline_fixed_string_t setup;
2854 /* Common CLI fields for queue setup */
2855 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2856 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2857 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2858 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2859 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2860 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2861 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2862 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2863 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2864 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2867 cmd_setup_rxtx_queue_parsed(
2868 void *parsed_result,
2869 __rte_unused struct cmdline *cl,
2870 __rte_unused void *data)
2872 struct cmd_setup_rxtx_queue *res = parsed_result;
2873 struct rte_port *port;
2874 struct rte_mempool *mp;
2875 unsigned int socket_id;
2879 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2882 if (res->portid == (portid_t)RTE_PORT_ALL) {
2883 printf("Invalid port id\n");
2887 if (!strcmp(res->rxtxq, "rxq"))
2889 else if (!strcmp(res->rxtxq, "txq"))
2892 printf("Unknown parameter\n");
2896 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2897 printf("Invalid rx queue\n");
2899 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2900 printf("Invalid tx queue\n");
2904 port = &ports[res->portid];
2906 socket_id = rxring_numa[res->portid];
2907 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2908 socket_id = port->socket_id;
2910 mp = mbuf_pool_find(socket_id);
2912 printf("Failed to setup RX queue: "
2913 "No mempool allocation"
2914 " on the socket %d\n",
2915 rxring_numa[res->portid]);
2918 ret = rte_eth_rx_queue_setup(res->portid,
2920 port->nb_rx_desc[res->qid],
2922 &port->rx_conf[res->qid],
2925 printf("Failed to setup RX queue\n");
2927 socket_id = txring_numa[res->portid];
2928 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2929 socket_id = port->socket_id;
2931 ret = rte_eth_tx_queue_setup(res->portid,
2933 port->nb_tx_desc[res->qid],
2935 &port->tx_conf[res->qid]);
2937 printf("Failed to setup TX queue\n");
2941 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2942 .f = cmd_setup_rxtx_queue_parsed,
2944 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2946 (void *)&cmd_setup_rxtx_queue_port,
2947 (void *)&cmd_setup_rxtx_queue_portid,
2948 (void *)&cmd_setup_rxtx_queue_rxtxq,
2949 (void *)&cmd_setup_rxtx_queue_qid,
2950 (void *)&cmd_setup_rxtx_queue_setup,
2956 /* *** Configure RSS RETA *** */
2957 struct cmd_config_rss_reta {
2958 cmdline_fixed_string_t port;
2959 cmdline_fixed_string_t keyword;
2961 cmdline_fixed_string_t name;
2962 cmdline_fixed_string_t list_name;
2963 cmdline_fixed_string_t list_of_items;
2967 parse_reta_config(const char *str,
2968 struct rte_eth_rss_reta_entry64 *reta_conf,
2969 uint16_t nb_entries)
2973 uint16_t hash_index, idx, shift;
2976 const char *p, *p0 = str;
2983 unsigned long int_fld[_NUM_FLD];
2984 char *str_fld[_NUM_FLD];
2986 while ((p = strchr(p0,'(')) != NULL) {
2988 if((p0 = strchr(p,')')) == NULL)
2992 if(size >= sizeof(s))
2995 snprintf(s, sizeof(s), "%.*s", size, p);
2996 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2998 for (i = 0; i < _NUM_FLD; i++) {
3000 int_fld[i] = strtoul(str_fld[i], &end, 0);
3001 if (errno != 0 || end == str_fld[i] ||
3006 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
3007 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
3009 if (hash_index >= nb_entries) {
3010 printf("Invalid RETA hash index=%d\n", hash_index);
3014 idx = hash_index / RTE_RETA_GROUP_SIZE;
3015 shift = hash_index % RTE_RETA_GROUP_SIZE;
3016 reta_conf[idx].mask |= (1ULL << shift);
3017 reta_conf[idx].reta[shift] = nb_queue;
3024 cmd_set_rss_reta_parsed(void *parsed_result,
3025 __rte_unused struct cmdline *cl,
3026 __rte_unused void *data)
3029 struct rte_eth_dev_info dev_info;
3030 struct rte_eth_rss_reta_entry64 reta_conf[8];
3031 struct cmd_config_rss_reta *res = parsed_result;
3033 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3037 if (dev_info.reta_size == 0) {
3038 printf("Redirection table size is 0 which is "
3039 "invalid for RSS\n");
3042 printf("The reta size of port %d is %u\n",
3043 res->port_id, dev_info.reta_size);
3044 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3045 printf("Currently do not support more than %u entries of "
3046 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3050 memset(reta_conf, 0, sizeof(reta_conf));
3051 if (!strcmp(res->list_name, "reta")) {
3052 if (parse_reta_config(res->list_of_items, reta_conf,
3053 dev_info.reta_size)) {
3054 printf("Invalid RSS Redirection Table "
3055 "config entered\n");
3058 ret = rte_eth_dev_rss_reta_update(res->port_id,
3059 reta_conf, dev_info.reta_size);
3061 printf("Bad redirection table parameter, "
3062 "return code = %d \n", ret);
3066 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3067 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3068 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3069 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3070 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3071 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3072 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3073 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3074 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3075 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3076 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3077 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3079 cmdline_parse_inst_t cmd_config_rss_reta = {
3080 .f = cmd_set_rss_reta_parsed,
3082 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3084 (void *)&cmd_config_rss_reta_port,
3085 (void *)&cmd_config_rss_reta_keyword,
3086 (void *)&cmd_config_rss_reta_port_id,
3087 (void *)&cmd_config_rss_reta_name,
3088 (void *)&cmd_config_rss_reta_list_name,
3089 (void *)&cmd_config_rss_reta_list_of_items,
3094 /* *** SHOW PORT RETA INFO *** */
3095 struct cmd_showport_reta {
3096 cmdline_fixed_string_t show;
3097 cmdline_fixed_string_t port;
3099 cmdline_fixed_string_t rss;
3100 cmdline_fixed_string_t reta;
3102 cmdline_fixed_string_t list_of_items;
3106 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3107 uint16_t nb_entries,
3111 const char *p, *p0 = str;
3116 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3117 RTE_RETA_GROUP_SIZE;
3120 p = strchr(p0, '(');
3124 p0 = strchr(p, ')');
3128 if (size >= sizeof(s)) {
3129 printf("The string size exceeds the internal buffer size\n");
3132 snprintf(s, sizeof(s), "%.*s", size, p);
3133 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3134 if (ret <= 0 || ret != num) {
3135 printf("The bits of masks do not match the number of "
3136 "reta entries: %u\n", num);
3139 for (i = 0; i < ret; i++)
3140 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3146 cmd_showport_reta_parsed(void *parsed_result,
3147 __rte_unused struct cmdline *cl,
3148 __rte_unused void *data)
3150 struct cmd_showport_reta *res = parsed_result;
3151 struct rte_eth_rss_reta_entry64 reta_conf[8];
3152 struct rte_eth_dev_info dev_info;
3153 uint16_t max_reta_size;
3156 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3160 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3161 if (res->size == 0 || res->size > max_reta_size) {
3162 printf("Invalid redirection table size: %u (1-%u)\n",
3163 res->size, max_reta_size);
3167 memset(reta_conf, 0, sizeof(reta_conf));
3168 if (showport_parse_reta_config(reta_conf, res->size,
3169 res->list_of_items) < 0) {
3170 printf("Invalid string: %s for reta masks\n",
3171 res->list_of_items);
3174 port_rss_reta_info(res->port_id, reta_conf, res->size);
3177 cmdline_parse_token_string_t cmd_showport_reta_show =
3178 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3179 cmdline_parse_token_string_t cmd_showport_reta_port =
3180 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3181 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3182 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3183 cmdline_parse_token_string_t cmd_showport_reta_rss =
3184 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3185 cmdline_parse_token_string_t cmd_showport_reta_reta =
3186 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3187 cmdline_parse_token_num_t cmd_showport_reta_size =
3188 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3189 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3190 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3191 list_of_items, NULL);
3193 cmdline_parse_inst_t cmd_showport_reta = {
3194 .f = cmd_showport_reta_parsed,
3196 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3198 (void *)&cmd_showport_reta_show,
3199 (void *)&cmd_showport_reta_port,
3200 (void *)&cmd_showport_reta_port_id,
3201 (void *)&cmd_showport_reta_rss,
3202 (void *)&cmd_showport_reta_reta,
3203 (void *)&cmd_showport_reta_size,
3204 (void *)&cmd_showport_reta_list_of_items,
3209 /* *** Show RSS hash configuration *** */
3210 struct cmd_showport_rss_hash {
3211 cmdline_fixed_string_t show;
3212 cmdline_fixed_string_t port;
3214 cmdline_fixed_string_t rss_hash;
3215 cmdline_fixed_string_t rss_type;
3216 cmdline_fixed_string_t key; /* optional argument */
3219 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3220 __rte_unused struct cmdline *cl,
3223 struct cmd_showport_rss_hash *res = parsed_result;
3225 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3228 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3229 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3230 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3231 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3232 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3233 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3234 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3235 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3237 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3238 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3240 cmdline_parse_inst_t cmd_showport_rss_hash = {
3241 .f = cmd_showport_rss_hash_parsed,
3243 .help_str = "show port <port_id> rss-hash",
3245 (void *)&cmd_showport_rss_hash_show,
3246 (void *)&cmd_showport_rss_hash_port,
3247 (void *)&cmd_showport_rss_hash_port_id,
3248 (void *)&cmd_showport_rss_hash_rss_hash,
3253 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3254 .f = cmd_showport_rss_hash_parsed,
3256 .help_str = "show port <port_id> rss-hash key",
3258 (void *)&cmd_showport_rss_hash_show,
3259 (void *)&cmd_showport_rss_hash_port,
3260 (void *)&cmd_showport_rss_hash_port_id,
3261 (void *)&cmd_showport_rss_hash_rss_hash,
3262 (void *)&cmd_showport_rss_hash_rss_key,
3267 /* *** Configure DCB *** */
3268 struct cmd_config_dcb {
3269 cmdline_fixed_string_t port;
3270 cmdline_fixed_string_t config;
3272 cmdline_fixed_string_t dcb;
3273 cmdline_fixed_string_t vt;
3274 cmdline_fixed_string_t vt_en;
3276 cmdline_fixed_string_t pfc;
3277 cmdline_fixed_string_t pfc_en;
3281 cmd_config_dcb_parsed(void *parsed_result,
3282 __rte_unused struct cmdline *cl,
3283 __rte_unused void *data)
3285 struct cmd_config_dcb *res = parsed_result;
3286 portid_t port_id = res->port_id;
3287 struct rte_port *port;
3291 port = &ports[port_id];
3292 /** Check if the port is not started **/
3293 if (port->port_status != RTE_PORT_STOPPED) {
3294 printf("Please stop port %d first\n", port_id);
3298 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3299 printf("The invalid number of traffic class,"
3300 " only 4 or 8 allowed.\n");
3304 if (nb_fwd_lcores < res->num_tcs) {
3305 printf("nb_cores shouldn't be less than number of TCs.\n");
3308 if (!strncmp(res->pfc_en, "on", 2))
3313 /* DCB in VT mode */
3314 if (!strncmp(res->vt_en, "on", 2))
3315 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3316 (enum rte_eth_nb_tcs)res->num_tcs,
3319 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3320 (enum rte_eth_nb_tcs)res->num_tcs,
3325 printf("Cannot initialize network ports.\n");
3329 cmd_reconfig_device_queue(port_id, 1, 1);
3332 cmdline_parse_token_string_t cmd_config_dcb_port =
3333 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3334 cmdline_parse_token_string_t cmd_config_dcb_config =
3335 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3336 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3337 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3338 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3339 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3340 cmdline_parse_token_string_t cmd_config_dcb_vt =
3341 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3342 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3343 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3344 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3345 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3346 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3347 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3348 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3349 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3351 cmdline_parse_inst_t cmd_config_dcb = {
3352 .f = cmd_config_dcb_parsed,
3354 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3356 (void *)&cmd_config_dcb_port,
3357 (void *)&cmd_config_dcb_config,
3358 (void *)&cmd_config_dcb_port_id,
3359 (void *)&cmd_config_dcb_dcb,
3360 (void *)&cmd_config_dcb_vt,
3361 (void *)&cmd_config_dcb_vt_en,
3362 (void *)&cmd_config_dcb_num_tcs,
3363 (void *)&cmd_config_dcb_pfc,
3364 (void *)&cmd_config_dcb_pfc_en,
3369 /* *** configure number of packets per burst *** */
3370 struct cmd_config_burst {
3371 cmdline_fixed_string_t port;
3372 cmdline_fixed_string_t keyword;
3373 cmdline_fixed_string_t all;
3374 cmdline_fixed_string_t name;
3379 cmd_config_burst_parsed(void *parsed_result,
3380 __rte_unused struct cmdline *cl,
3381 __rte_unused void *data)
3383 struct cmd_config_burst *res = parsed_result;
3384 struct rte_eth_dev_info dev_info;
3385 uint16_t rec_nb_pkts;
3388 if (!all_ports_stopped()) {
3389 printf("Please stop all ports first\n");
3393 if (!strcmp(res->name, "burst")) {
3394 if (res->value == 0) {
3395 /* If user gives a value of zero, query the PMD for
3396 * its recommended Rx burst size. Testpmd uses a single
3397 * size for all ports, so assume all ports are the same
3398 * NIC model and use the values from Port 0.
3400 ret = eth_dev_info_get_print_err(0, &dev_info);
3404 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3406 if (rec_nb_pkts == 0) {
3407 printf("PMD does not recommend a burst size.\n"
3408 "User provided value must be between"
3409 " 1 and %d\n", MAX_PKT_BURST);
3411 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3412 printf("PMD recommended burst size of %d"
3413 " exceeds maximum value of %d\n",
3414 rec_nb_pkts, MAX_PKT_BURST);
3417 printf("Using PMD-provided burst value of %d\n",
3419 nb_pkt_per_burst = rec_nb_pkts;
3420 } else if (res->value > MAX_PKT_BURST) {
3421 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3424 nb_pkt_per_burst = res->value;
3426 printf("Unknown parameter\n");
3432 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3435 cmdline_parse_token_string_t cmd_config_burst_port =
3436 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3437 cmdline_parse_token_string_t cmd_config_burst_keyword =
3438 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3439 cmdline_parse_token_string_t cmd_config_burst_all =
3440 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3441 cmdline_parse_token_string_t cmd_config_burst_name =
3442 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3443 cmdline_parse_token_num_t cmd_config_burst_value =
3444 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3446 cmdline_parse_inst_t cmd_config_burst = {
3447 .f = cmd_config_burst_parsed,
3449 .help_str = "port config all burst <value>",
3451 (void *)&cmd_config_burst_port,
3452 (void *)&cmd_config_burst_keyword,
3453 (void *)&cmd_config_burst_all,
3454 (void *)&cmd_config_burst_name,
3455 (void *)&cmd_config_burst_value,
3460 /* *** configure rx/tx queues *** */
3461 struct cmd_config_thresh {
3462 cmdline_fixed_string_t port;
3463 cmdline_fixed_string_t keyword;
3464 cmdline_fixed_string_t all;
3465 cmdline_fixed_string_t name;
3470 cmd_config_thresh_parsed(void *parsed_result,
3471 __rte_unused struct cmdline *cl,
3472 __rte_unused void *data)
3474 struct cmd_config_thresh *res = parsed_result;
3476 if (!all_ports_stopped()) {
3477 printf("Please stop all ports first\n");
3481 if (!strcmp(res->name, "txpt"))
3482 tx_pthresh = res->value;
3483 else if(!strcmp(res->name, "txht"))
3484 tx_hthresh = res->value;
3485 else if(!strcmp(res->name, "txwt"))
3486 tx_wthresh = res->value;
3487 else if(!strcmp(res->name, "rxpt"))
3488 rx_pthresh = res->value;
3489 else if(!strcmp(res->name, "rxht"))
3490 rx_hthresh = res->value;
3491 else if(!strcmp(res->name, "rxwt"))
3492 rx_wthresh = res->value;
3494 printf("Unknown parameter\n");
3500 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3503 cmdline_parse_token_string_t cmd_config_thresh_port =
3504 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3505 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3506 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3507 cmdline_parse_token_string_t cmd_config_thresh_all =
3508 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3509 cmdline_parse_token_string_t cmd_config_thresh_name =
3510 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3511 "txpt#txht#txwt#rxpt#rxht#rxwt");
3512 cmdline_parse_token_num_t cmd_config_thresh_value =
3513 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3515 cmdline_parse_inst_t cmd_config_thresh = {
3516 .f = cmd_config_thresh_parsed,
3518 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3520 (void *)&cmd_config_thresh_port,
3521 (void *)&cmd_config_thresh_keyword,
3522 (void *)&cmd_config_thresh_all,
3523 (void *)&cmd_config_thresh_name,
3524 (void *)&cmd_config_thresh_value,
3529 /* *** configure free/rs threshold *** */
3530 struct cmd_config_threshold {
3531 cmdline_fixed_string_t port;
3532 cmdline_fixed_string_t keyword;
3533 cmdline_fixed_string_t all;
3534 cmdline_fixed_string_t name;
3539 cmd_config_threshold_parsed(void *parsed_result,
3540 __rte_unused struct cmdline *cl,
3541 __rte_unused void *data)
3543 struct cmd_config_threshold *res = parsed_result;
3545 if (!all_ports_stopped()) {
3546 printf("Please stop all ports first\n");
3550 if (!strcmp(res->name, "txfreet"))
3551 tx_free_thresh = res->value;
3552 else if (!strcmp(res->name, "txrst"))
3553 tx_rs_thresh = res->value;
3554 else if (!strcmp(res->name, "rxfreet"))
3555 rx_free_thresh = res->value;
3557 printf("Unknown parameter\n");
3563 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3566 cmdline_parse_token_string_t cmd_config_threshold_port =
3567 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3568 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3569 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3571 cmdline_parse_token_string_t cmd_config_threshold_all =
3572 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3573 cmdline_parse_token_string_t cmd_config_threshold_name =
3574 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3575 "txfreet#txrst#rxfreet");
3576 cmdline_parse_token_num_t cmd_config_threshold_value =
3577 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3579 cmdline_parse_inst_t cmd_config_threshold = {
3580 .f = cmd_config_threshold_parsed,
3582 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3584 (void *)&cmd_config_threshold_port,
3585 (void *)&cmd_config_threshold_keyword,
3586 (void *)&cmd_config_threshold_all,
3587 (void *)&cmd_config_threshold_name,
3588 (void *)&cmd_config_threshold_value,
3594 struct cmd_stop_result {
3595 cmdline_fixed_string_t stop;
3598 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3599 __rte_unused struct cmdline *cl,
3600 __rte_unused void *data)
3602 stop_packet_forwarding();
3605 cmdline_parse_token_string_t cmd_stop_stop =
3606 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3608 cmdline_parse_inst_t cmd_stop = {
3609 .f = cmd_stop_parsed,
3611 .help_str = "stop: Stop packet forwarding",
3613 (void *)&cmd_stop_stop,
3618 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3621 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3622 unsigned int *parsed_items, int check_unique_values)
3624 unsigned int nb_item;
3632 * First parse all items in the list and store their value.
3637 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3639 if ((c >= '0') && (c <= '9')) {
3640 value = (unsigned int) (value * 10 + (c - '0'));
3645 printf("character %c is not a decimal digit\n", c);
3649 printf("No valid value before comma\n");
3652 if (nb_item < max_items) {
3653 parsed_items[nb_item] = value;
3659 if (nb_item >= max_items) {
3660 printf("Number of %s = %u > %u (maximum items)\n",
3661 item_name, nb_item + 1, max_items);
3664 parsed_items[nb_item++] = value;
3665 if (! check_unique_values)
3669 * Then, check that all values in the list are differents.
3670 * No optimization here...
3672 for (i = 0; i < nb_item; i++) {
3673 for (j = i + 1; j < nb_item; j++) {
3674 if (parsed_items[j] == parsed_items[i]) {
3675 printf("duplicated %s %u at index %u and %u\n",
3676 item_name, parsed_items[i], i, j);
3684 struct cmd_set_list_result {
3685 cmdline_fixed_string_t cmd_keyword;
3686 cmdline_fixed_string_t list_name;
3687 cmdline_fixed_string_t list_of_items;
3690 static void cmd_set_list_parsed(void *parsed_result,
3691 __rte_unused struct cmdline *cl,
3692 __rte_unused void *data)
3694 struct cmd_set_list_result *res;
3696 unsigned int lcorelist[RTE_MAX_LCORE];
3697 unsigned int portlist[RTE_MAX_ETHPORTS];
3699 unsigned int nb_item;
3701 if (test_done == 0) {
3702 printf("Please stop forwarding first\n");
3706 res = parsed_result;
3707 if (!strcmp(res->list_name, "corelist")) {
3708 nb_item = parse_item_list(res->list_of_items, "core",
3710 parsed_items.lcorelist, 1);
3712 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3717 if (!strcmp(res->list_name, "portlist")) {
3718 nb_item = parse_item_list(res->list_of_items, "port",
3720 parsed_items.portlist, 1);
3722 set_fwd_ports_list(parsed_items.portlist, nb_item);
3728 cmdline_parse_token_string_t cmd_set_list_keyword =
3729 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3731 cmdline_parse_token_string_t cmd_set_list_name =
3732 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3733 "corelist#portlist");
3734 cmdline_parse_token_string_t cmd_set_list_of_items =
3735 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3738 cmdline_parse_inst_t cmd_set_fwd_list = {
3739 .f = cmd_set_list_parsed,
3741 .help_str = "set corelist|portlist <list0[,list1]*>",
3743 (void *)&cmd_set_list_keyword,
3744 (void *)&cmd_set_list_name,
3745 (void *)&cmd_set_list_of_items,
3750 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3752 struct cmd_setmask_result {
3753 cmdline_fixed_string_t set;
3754 cmdline_fixed_string_t mask;
3758 static void cmd_set_mask_parsed(void *parsed_result,
3759 __rte_unused struct cmdline *cl,
3760 __rte_unused void *data)
3762 struct cmd_setmask_result *res = parsed_result;
3764 if (test_done == 0) {
3765 printf("Please stop forwarding first\n");
3768 if (!strcmp(res->mask, "coremask")) {
3769 set_fwd_lcores_mask(res->hexavalue);
3771 } else if (!strcmp(res->mask, "portmask")) {
3772 set_fwd_ports_mask(res->hexavalue);
3777 cmdline_parse_token_string_t cmd_setmask_set =
3778 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3779 cmdline_parse_token_string_t cmd_setmask_mask =
3780 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3781 "coremask#portmask");
3782 cmdline_parse_token_num_t cmd_setmask_value =
3783 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3785 cmdline_parse_inst_t cmd_set_fwd_mask = {
3786 .f = cmd_set_mask_parsed,
3788 .help_str = "set coremask|portmask <hexadecimal value>",
3790 (void *)&cmd_setmask_set,
3791 (void *)&cmd_setmask_mask,
3792 (void *)&cmd_setmask_value,
3798 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3800 struct cmd_set_result {
3801 cmdline_fixed_string_t set;
3802 cmdline_fixed_string_t what;
3806 static void cmd_set_parsed(void *parsed_result,
3807 __rte_unused struct cmdline *cl,
3808 __rte_unused void *data)
3810 struct cmd_set_result *res = parsed_result;
3811 if (!strcmp(res->what, "nbport")) {
3812 set_fwd_ports_number(res->value);
3814 } else if (!strcmp(res->what, "nbcore")) {
3815 set_fwd_lcores_number(res->value);
3817 } else if (!strcmp(res->what, "burst"))
3818 set_nb_pkt_per_burst(res->value);
3819 else if (!strcmp(res->what, "verbose"))
3820 set_verbose_level(res->value);
3823 cmdline_parse_token_string_t cmd_set_set =
3824 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3825 cmdline_parse_token_string_t cmd_set_what =
3826 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3827 "nbport#nbcore#burst#verbose");
3828 cmdline_parse_token_num_t cmd_set_value =
3829 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3831 cmdline_parse_inst_t cmd_set_numbers = {
3832 .f = cmd_set_parsed,
3834 .help_str = "set nbport|nbcore|burst|verbose <value>",
3836 (void *)&cmd_set_set,
3837 (void *)&cmd_set_what,
3838 (void *)&cmd_set_value,
3843 /* *** SET LOG LEVEL CONFIGURATION *** */
3845 struct cmd_set_log_result {
3846 cmdline_fixed_string_t set;
3847 cmdline_fixed_string_t log;
3848 cmdline_fixed_string_t type;
3853 cmd_set_log_parsed(void *parsed_result,
3854 __rte_unused struct cmdline *cl,
3855 __rte_unused void *data)
3857 struct cmd_set_log_result *res;
3860 res = parsed_result;
3861 if (!strcmp(res->type, "global"))
3862 rte_log_set_global_level(res->level);
3864 ret = rte_log_set_level_regexp(res->type, res->level);
3866 printf("Unable to set log level\n");
3870 cmdline_parse_token_string_t cmd_set_log_set =
3871 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3872 cmdline_parse_token_string_t cmd_set_log_log =
3873 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3874 cmdline_parse_token_string_t cmd_set_log_type =
3875 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3876 cmdline_parse_token_num_t cmd_set_log_level =
3877 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3879 cmdline_parse_inst_t cmd_set_log = {
3880 .f = cmd_set_log_parsed,
3882 .help_str = "set log global|<type> <level>",
3884 (void *)&cmd_set_log_set,
3885 (void *)&cmd_set_log_log,
3886 (void *)&cmd_set_log_type,
3887 (void *)&cmd_set_log_level,
3892 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3894 struct cmd_set_txpkts_result {
3895 cmdline_fixed_string_t cmd_keyword;
3896 cmdline_fixed_string_t txpkts;
3897 cmdline_fixed_string_t seg_lengths;
3901 cmd_set_txpkts_parsed(void *parsed_result,
3902 __rte_unused struct cmdline *cl,
3903 __rte_unused void *data)
3905 struct cmd_set_txpkts_result *res;
3906 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3907 unsigned int nb_segs;
3909 res = parsed_result;
3910 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3911 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3913 set_tx_pkt_segments(seg_lengths, nb_segs);
3916 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3917 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3918 cmd_keyword, "set");
3919 cmdline_parse_token_string_t cmd_set_txpkts_name =
3920 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3922 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3923 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3926 cmdline_parse_inst_t cmd_set_txpkts = {
3927 .f = cmd_set_txpkts_parsed,
3929 .help_str = "set txpkts <len0[,len1]*>",
3931 (void *)&cmd_set_txpkts_keyword,
3932 (void *)&cmd_set_txpkts_name,
3933 (void *)&cmd_set_txpkts_lengths,
3938 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3940 struct cmd_set_txsplit_result {
3941 cmdline_fixed_string_t cmd_keyword;
3942 cmdline_fixed_string_t txsplit;
3943 cmdline_fixed_string_t mode;
3947 cmd_set_txsplit_parsed(void *parsed_result,
3948 __rte_unused struct cmdline *cl,
3949 __rte_unused void *data)
3951 struct cmd_set_txsplit_result *res;
3953 res = parsed_result;
3954 set_tx_pkt_split(res->mode);
3957 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3958 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3959 cmd_keyword, "set");
3960 cmdline_parse_token_string_t cmd_set_txsplit_name =
3961 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3962 txsplit, "txsplit");
3963 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3964 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3967 cmdline_parse_inst_t cmd_set_txsplit = {
3968 .f = cmd_set_txsplit_parsed,
3970 .help_str = "set txsplit on|off|rand",
3972 (void *)&cmd_set_txsplit_keyword,
3973 (void *)&cmd_set_txsplit_name,
3974 (void *)&cmd_set_txsplit_mode,
3979 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
3981 struct cmd_set_txtimes_result {
3982 cmdline_fixed_string_t cmd_keyword;
3983 cmdline_fixed_string_t txtimes;
3984 cmdline_fixed_string_t tx_times;
3988 cmd_set_txtimes_parsed(void *parsed_result,
3989 __rte_unused struct cmdline *cl,
3990 __rte_unused void *data)
3992 struct cmd_set_txtimes_result *res;
3993 unsigned int tx_times[2] = {0, 0};
3994 unsigned int n_times;
3996 res = parsed_result;
3997 n_times = parse_item_list(res->tx_times, "tx times",
4000 set_tx_pkt_times(tx_times);
4003 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4004 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4005 cmd_keyword, "set");
4006 cmdline_parse_token_string_t cmd_set_txtimes_name =
4007 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4008 txtimes, "txtimes");
4009 cmdline_parse_token_string_t cmd_set_txtimes_value =
4010 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4013 cmdline_parse_inst_t cmd_set_txtimes = {
4014 .f = cmd_set_txtimes_parsed,
4016 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4018 (void *)&cmd_set_txtimes_keyword,
4019 (void *)&cmd_set_txtimes_name,
4020 (void *)&cmd_set_txtimes_value,
4025 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4026 struct cmd_rx_vlan_filter_all_result {
4027 cmdline_fixed_string_t rx_vlan;
4028 cmdline_fixed_string_t what;
4029 cmdline_fixed_string_t all;
4034 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4035 __rte_unused struct cmdline *cl,
4036 __rte_unused void *data)
4038 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4040 if (!strcmp(res->what, "add"))
4041 rx_vlan_all_filter_set(res->port_id, 1);
4043 rx_vlan_all_filter_set(res->port_id, 0);
4046 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4047 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4048 rx_vlan, "rx_vlan");
4049 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4050 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4052 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4053 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4055 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4056 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4059 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4060 .f = cmd_rx_vlan_filter_all_parsed,
4062 .help_str = "rx_vlan add|rm all <port_id>: "
4063 "Add/Remove all identifiers to/from the set of VLAN "
4064 "identifiers filtered by a port",
4066 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4067 (void *)&cmd_rx_vlan_filter_all_what,
4068 (void *)&cmd_rx_vlan_filter_all_all,
4069 (void *)&cmd_rx_vlan_filter_all_portid,
4074 /* *** VLAN OFFLOAD SET ON A PORT *** */
4075 struct cmd_vlan_offload_result {
4076 cmdline_fixed_string_t vlan;
4077 cmdline_fixed_string_t set;
4078 cmdline_fixed_string_t vlan_type;
4079 cmdline_fixed_string_t what;
4080 cmdline_fixed_string_t on;
4081 cmdline_fixed_string_t port_id;
4085 cmd_vlan_offload_parsed(void *parsed_result,
4086 __rte_unused struct cmdline *cl,
4087 __rte_unused void *data)
4090 struct cmd_vlan_offload_result *res = parsed_result;
4093 portid_t port_id = 0;
4097 len = strnlen(str, STR_TOKEN_SIZE);
4099 /* Get port_id first */
4107 tmp = strtoul(str, NULL, 0);
4108 /* If port_id greater that what portid_t can represent, return */
4109 if(tmp >= RTE_MAX_ETHPORTS)
4111 port_id = (portid_t)tmp;
4113 if (!strcmp(res->on, "on"))
4118 if (!strcmp(res->what, "strip"))
4119 rx_vlan_strip_set(port_id, on);
4120 else if(!strcmp(res->what, "stripq")){
4121 uint16_t queue_id = 0;
4123 /* No queue_id, return */
4125 printf("must specify (port,queue_id)\n");
4128 tmp = strtoul(str + i + 1, NULL, 0);
4129 /* If queue_id greater that what 16-bits can represent, return */
4133 queue_id = (uint16_t)tmp;
4134 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4136 else if (!strcmp(res->what, "filter"))
4137 rx_vlan_filter_set(port_id, on);
4138 else if (!strcmp(res->what, "qinq_strip"))
4139 rx_vlan_qinq_strip_set(port_id, on);
4141 vlan_extend_set(port_id, on);
4146 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4147 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4149 cmdline_parse_token_string_t cmd_vlan_offload_set =
4150 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4152 cmdline_parse_token_string_t cmd_vlan_offload_what =
4153 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4154 what, "strip#filter#qinq_strip#extend#stripq");
4155 cmdline_parse_token_string_t cmd_vlan_offload_on =
4156 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4158 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4159 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4162 cmdline_parse_inst_t cmd_vlan_offload = {
4163 .f = cmd_vlan_offload_parsed,
4165 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4166 "<port_id[,queue_id]>: "
4167 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4169 (void *)&cmd_vlan_offload_vlan,
4170 (void *)&cmd_vlan_offload_set,
4171 (void *)&cmd_vlan_offload_what,
4172 (void *)&cmd_vlan_offload_on,
4173 (void *)&cmd_vlan_offload_portid,
4178 /* *** VLAN TPID SET ON A PORT *** */
4179 struct cmd_vlan_tpid_result {
4180 cmdline_fixed_string_t vlan;
4181 cmdline_fixed_string_t set;
4182 cmdline_fixed_string_t vlan_type;
4183 cmdline_fixed_string_t what;
4189 cmd_vlan_tpid_parsed(void *parsed_result,
4190 __rte_unused struct cmdline *cl,
4191 __rte_unused void *data)
4193 struct cmd_vlan_tpid_result *res = parsed_result;
4194 enum rte_vlan_type vlan_type;
4196 if (!strcmp(res->vlan_type, "inner"))
4197 vlan_type = ETH_VLAN_TYPE_INNER;
4198 else if (!strcmp(res->vlan_type, "outer"))
4199 vlan_type = ETH_VLAN_TYPE_OUTER;
4201 printf("Unknown vlan type\n");
4204 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4207 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4208 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4210 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4211 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4213 cmdline_parse_token_string_t cmd_vlan_type =
4214 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4215 vlan_type, "inner#outer");
4216 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4217 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4219 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4220 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4222 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4223 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4226 cmdline_parse_inst_t cmd_vlan_tpid = {
4227 .f = cmd_vlan_tpid_parsed,
4229 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4230 "Set the VLAN Ether type",
4232 (void *)&cmd_vlan_tpid_vlan,
4233 (void *)&cmd_vlan_tpid_set,
4234 (void *)&cmd_vlan_type,
4235 (void *)&cmd_vlan_tpid_what,
4236 (void *)&cmd_vlan_tpid_tpid,
4237 (void *)&cmd_vlan_tpid_portid,
4242 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4243 struct cmd_rx_vlan_filter_result {
4244 cmdline_fixed_string_t rx_vlan;
4245 cmdline_fixed_string_t what;
4251 cmd_rx_vlan_filter_parsed(void *parsed_result,
4252 __rte_unused struct cmdline *cl,
4253 __rte_unused void *data)
4255 struct cmd_rx_vlan_filter_result *res = parsed_result;
4257 if (!strcmp(res->what, "add"))
4258 rx_vft_set(res->port_id, res->vlan_id, 1);
4260 rx_vft_set(res->port_id, res->vlan_id, 0);
4263 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4264 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4265 rx_vlan, "rx_vlan");
4266 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4267 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4269 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4270 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4272 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4273 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4276 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4277 .f = cmd_rx_vlan_filter_parsed,
4279 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4280 "Add/Remove a VLAN identifier to/from the set of VLAN "
4281 "identifiers filtered by a port",
4283 (void *)&cmd_rx_vlan_filter_rx_vlan,
4284 (void *)&cmd_rx_vlan_filter_what,
4285 (void *)&cmd_rx_vlan_filter_vlanid,
4286 (void *)&cmd_rx_vlan_filter_portid,
4291 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4292 struct cmd_tx_vlan_set_result {
4293 cmdline_fixed_string_t tx_vlan;
4294 cmdline_fixed_string_t set;
4300 cmd_tx_vlan_set_parsed(void *parsed_result,
4301 __rte_unused struct cmdline *cl,
4302 __rte_unused void *data)
4304 struct cmd_tx_vlan_set_result *res = parsed_result;
4306 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4309 if (!port_is_stopped(res->port_id)) {
4310 printf("Please stop port %d first\n", res->port_id);
4314 tx_vlan_set(res->port_id, res->vlan_id);
4316 cmd_reconfig_device_queue(res->port_id, 1, 1);
4319 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4320 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4321 tx_vlan, "tx_vlan");
4322 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4323 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4325 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4326 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4328 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4329 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4332 cmdline_parse_inst_t cmd_tx_vlan_set = {
4333 .f = cmd_tx_vlan_set_parsed,
4335 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4336 "Enable hardware insertion of a single VLAN header "
4337 "with a given TAG Identifier in packets sent on a port",
4339 (void *)&cmd_tx_vlan_set_tx_vlan,
4340 (void *)&cmd_tx_vlan_set_set,
4341 (void *)&cmd_tx_vlan_set_portid,
4342 (void *)&cmd_tx_vlan_set_vlanid,
4347 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4348 struct cmd_tx_vlan_set_qinq_result {
4349 cmdline_fixed_string_t tx_vlan;
4350 cmdline_fixed_string_t set;
4353 uint16_t vlan_id_outer;
4357 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4358 __rte_unused struct cmdline *cl,
4359 __rte_unused void *data)
4361 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4363 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4366 if (!port_is_stopped(res->port_id)) {
4367 printf("Please stop port %d first\n", res->port_id);
4371 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4373 cmd_reconfig_device_queue(res->port_id, 1, 1);
4376 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4377 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4378 tx_vlan, "tx_vlan");
4379 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4380 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4382 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4383 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4385 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4386 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4388 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4389 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4390 vlan_id_outer, UINT16);
4392 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4393 .f = cmd_tx_vlan_set_qinq_parsed,
4395 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4396 "Enable hardware insertion of double VLAN header "
4397 "with given TAG Identifiers in packets sent on a port",
4399 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4400 (void *)&cmd_tx_vlan_set_qinq_set,
4401 (void *)&cmd_tx_vlan_set_qinq_portid,
4402 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4403 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4408 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4409 struct cmd_tx_vlan_set_pvid_result {
4410 cmdline_fixed_string_t tx_vlan;
4411 cmdline_fixed_string_t set;
4412 cmdline_fixed_string_t pvid;
4415 cmdline_fixed_string_t mode;
4419 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4420 __rte_unused struct cmdline *cl,
4421 __rte_unused void *data)
4423 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4425 if (strcmp(res->mode, "on") == 0)
4426 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4428 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4431 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4432 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4433 tx_vlan, "tx_vlan");
4434 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4435 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4437 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4438 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4440 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4441 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4443 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4444 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4446 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4447 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4450 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4451 .f = cmd_tx_vlan_set_pvid_parsed,
4453 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4455 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4456 (void *)&cmd_tx_vlan_set_pvid_set,
4457 (void *)&cmd_tx_vlan_set_pvid_pvid,
4458 (void *)&cmd_tx_vlan_set_pvid_port_id,
4459 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4460 (void *)&cmd_tx_vlan_set_pvid_mode,
4465 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4466 struct cmd_tx_vlan_reset_result {
4467 cmdline_fixed_string_t tx_vlan;
4468 cmdline_fixed_string_t reset;
4473 cmd_tx_vlan_reset_parsed(void *parsed_result,
4474 __rte_unused struct cmdline *cl,
4475 __rte_unused void *data)
4477 struct cmd_tx_vlan_reset_result *res = parsed_result;
4479 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4482 if (!port_is_stopped(res->port_id)) {
4483 printf("Please stop port %d first\n", res->port_id);
4487 tx_vlan_reset(res->port_id);
4489 cmd_reconfig_device_queue(res->port_id, 1, 1);
4492 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4493 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4494 tx_vlan, "tx_vlan");
4495 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4496 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4498 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4499 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4502 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4503 .f = cmd_tx_vlan_reset_parsed,
4505 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4506 "VLAN header in packets sent on a port",
4508 (void *)&cmd_tx_vlan_reset_tx_vlan,
4509 (void *)&cmd_tx_vlan_reset_reset,
4510 (void *)&cmd_tx_vlan_reset_portid,
4516 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4517 struct cmd_csum_result {
4518 cmdline_fixed_string_t csum;
4519 cmdline_fixed_string_t mode;
4520 cmdline_fixed_string_t proto;
4521 cmdline_fixed_string_t hwsw;
4526 csum_show(int port_id)
4528 struct rte_eth_dev_info dev_info;
4529 uint64_t tx_offloads;
4532 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4533 printf("Parse tunnel is %s\n",
4534 (ports[port_id].parse_tunnel) ? "on" : "off");
4535 printf("IP checksum offload is %s\n",
4536 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4537 printf("UDP checksum offload is %s\n",
4538 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4539 printf("TCP checksum offload is %s\n",
4540 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4541 printf("SCTP checksum offload is %s\n",
4542 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4543 printf("Outer-Ip checksum offload is %s\n",
4544 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4545 printf("Outer-Udp checksum offload is %s\n",
4546 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4548 /* display warnings if configuration is not supported by the NIC */
4549 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4553 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4554 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4555 printf("Warning: hardware IP checksum enabled but not "
4556 "supported by port %d\n", port_id);
4558 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4559 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4560 printf("Warning: hardware UDP checksum enabled but not "
4561 "supported by port %d\n", port_id);
4563 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4564 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4565 printf("Warning: hardware TCP checksum enabled but not "
4566 "supported by port %d\n", port_id);
4568 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4569 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4570 printf("Warning: hardware SCTP checksum enabled but not "
4571 "supported by port %d\n", port_id);
4573 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4574 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4575 printf("Warning: hardware outer IP checksum enabled but not "
4576 "supported by port %d\n", port_id);
4578 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4579 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4581 printf("Warning: hardware outer UDP checksum enabled but not "
4582 "supported by port %d\n", port_id);
4587 cmd_config_queue_tx_offloads(struct rte_port *port)
4591 /* Apply queue tx offloads configuration */
4592 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4593 port->tx_conf[k].offloads =
4594 port->dev_conf.txmode.offloads;
4598 cmd_csum_parsed(void *parsed_result,
4599 __rte_unused struct cmdline *cl,
4600 __rte_unused void *data)
4602 struct cmd_csum_result *res = parsed_result;
4604 uint64_t csum_offloads = 0;
4605 struct rte_eth_dev_info dev_info;
4608 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4609 printf("invalid port %d\n", res->port_id);
4612 if (!port_is_stopped(res->port_id)) {
4613 printf("Please stop port %d first\n", res->port_id);
4617 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4621 if (!strcmp(res->mode, "set")) {
4623 if (!strcmp(res->hwsw, "hw"))
4626 if (!strcmp(res->proto, "ip")) {
4627 if (hw == 0 || (dev_info.tx_offload_capa &
4628 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4629 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4631 printf("IP checksum offload is not supported "
4632 "by port %u\n", res->port_id);
4634 } else if (!strcmp(res->proto, "udp")) {
4635 if (hw == 0 || (dev_info.tx_offload_capa &
4636 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4637 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4639 printf("UDP checksum offload is not supported "
4640 "by port %u\n", res->port_id);
4642 } else if (!strcmp(res->proto, "tcp")) {
4643 if (hw == 0 || (dev_info.tx_offload_capa &
4644 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4645 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4647 printf("TCP checksum offload is not supported "
4648 "by port %u\n", res->port_id);
4650 } else if (!strcmp(res->proto, "sctp")) {
4651 if (hw == 0 || (dev_info.tx_offload_capa &
4652 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4653 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4655 printf("SCTP checksum offload is not supported "
4656 "by port %u\n", res->port_id);
4658 } else if (!strcmp(res->proto, "outer-ip")) {
4659 if (hw == 0 || (dev_info.tx_offload_capa &
4660 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4662 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4664 printf("Outer IP checksum offload is not "
4665 "supported by port %u\n", res->port_id);
4667 } else if (!strcmp(res->proto, "outer-udp")) {
4668 if (hw == 0 || (dev_info.tx_offload_capa &
4669 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4671 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4673 printf("Outer UDP checksum offload is not "
4674 "supported by port %u\n", res->port_id);
4679 ports[res->port_id].dev_conf.txmode.offloads |=
4682 ports[res->port_id].dev_conf.txmode.offloads &=
4685 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4687 csum_show(res->port_id);
4689 cmd_reconfig_device_queue(res->port_id, 1, 1);
4692 cmdline_parse_token_string_t cmd_csum_csum =
4693 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4695 cmdline_parse_token_string_t cmd_csum_mode =
4696 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4698 cmdline_parse_token_string_t cmd_csum_proto =
4699 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4700 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4701 cmdline_parse_token_string_t cmd_csum_hwsw =
4702 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4704 cmdline_parse_token_num_t cmd_csum_portid =
4705 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4708 cmdline_parse_inst_t cmd_csum_set = {
4709 .f = cmd_csum_parsed,
4711 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4712 "Enable/Disable hardware calculation of L3/L4 checksum when "
4713 "using csum forward engine",
4715 (void *)&cmd_csum_csum,
4716 (void *)&cmd_csum_mode,
4717 (void *)&cmd_csum_proto,
4718 (void *)&cmd_csum_hwsw,
4719 (void *)&cmd_csum_portid,
4724 cmdline_parse_token_string_t cmd_csum_mode_show =
4725 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4728 cmdline_parse_inst_t cmd_csum_show = {
4729 .f = cmd_csum_parsed,
4731 .help_str = "csum show <port_id>: Show checksum offload configuration",
4733 (void *)&cmd_csum_csum,
4734 (void *)&cmd_csum_mode_show,
4735 (void *)&cmd_csum_portid,
4740 /* Enable/disable tunnel parsing */
4741 struct cmd_csum_tunnel_result {
4742 cmdline_fixed_string_t csum;
4743 cmdline_fixed_string_t parse;
4744 cmdline_fixed_string_t onoff;
4749 cmd_csum_tunnel_parsed(void *parsed_result,
4750 __rte_unused struct cmdline *cl,
4751 __rte_unused void *data)
4753 struct cmd_csum_tunnel_result *res = parsed_result;
4755 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4758 if (!strcmp(res->onoff, "on"))
4759 ports[res->port_id].parse_tunnel = 1;
4761 ports[res->port_id].parse_tunnel = 0;
4763 csum_show(res->port_id);
4766 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4767 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4769 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4770 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4771 parse, "parse-tunnel");
4772 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4773 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4775 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4776 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4779 cmdline_parse_inst_t cmd_csum_tunnel = {
4780 .f = cmd_csum_tunnel_parsed,
4782 .help_str = "csum parse-tunnel on|off <port_id>: "
4783 "Enable/Disable parsing of tunnels for csum engine",
4785 (void *)&cmd_csum_tunnel_csum,
4786 (void *)&cmd_csum_tunnel_parse,
4787 (void *)&cmd_csum_tunnel_onoff,
4788 (void *)&cmd_csum_tunnel_portid,
4793 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4794 struct cmd_tso_set_result {
4795 cmdline_fixed_string_t tso;
4796 cmdline_fixed_string_t mode;
4802 cmd_tso_set_parsed(void *parsed_result,
4803 __rte_unused struct cmdline *cl,
4804 __rte_unused void *data)
4806 struct cmd_tso_set_result *res = parsed_result;
4807 struct rte_eth_dev_info dev_info;
4810 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4812 if (!port_is_stopped(res->port_id)) {
4813 printf("Please stop port %d first\n", res->port_id);
4817 if (!strcmp(res->mode, "set"))
4818 ports[res->port_id].tso_segsz = res->tso_segsz;
4820 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4824 if ((ports[res->port_id].tso_segsz != 0) &&
4825 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4826 printf("Error: TSO is not supported by port %d\n",
4831 if (ports[res->port_id].tso_segsz == 0) {
4832 ports[res->port_id].dev_conf.txmode.offloads &=
4833 ~DEV_TX_OFFLOAD_TCP_TSO;
4834 printf("TSO for non-tunneled packets is disabled\n");
4836 ports[res->port_id].dev_conf.txmode.offloads |=
4837 DEV_TX_OFFLOAD_TCP_TSO;
4838 printf("TSO segment size for non-tunneled packets is %d\n",
4839 ports[res->port_id].tso_segsz);
4841 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4843 /* display warnings if configuration is not supported by the NIC */
4844 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4848 if ((ports[res->port_id].tso_segsz != 0) &&
4849 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4850 printf("Warning: TSO enabled but not "
4851 "supported by port %d\n", res->port_id);
4854 cmd_reconfig_device_queue(res->port_id, 1, 1);
4857 cmdline_parse_token_string_t cmd_tso_set_tso =
4858 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4860 cmdline_parse_token_string_t cmd_tso_set_mode =
4861 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4863 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4864 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4866 cmdline_parse_token_num_t cmd_tso_set_portid =
4867 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4870 cmdline_parse_inst_t cmd_tso_set = {
4871 .f = cmd_tso_set_parsed,
4873 .help_str = "tso set <tso_segsz> <port_id>: "
4874 "Set TSO segment size of non-tunneled packets for csum engine "
4877 (void *)&cmd_tso_set_tso,
4878 (void *)&cmd_tso_set_mode,
4879 (void *)&cmd_tso_set_tso_segsz,
4880 (void *)&cmd_tso_set_portid,
4885 cmdline_parse_token_string_t cmd_tso_show_mode =
4886 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4890 cmdline_parse_inst_t cmd_tso_show = {
4891 .f = cmd_tso_set_parsed,
4893 .help_str = "tso show <port_id>: "
4894 "Show TSO segment size of non-tunneled packets for csum engine",
4896 (void *)&cmd_tso_set_tso,
4897 (void *)&cmd_tso_show_mode,
4898 (void *)&cmd_tso_set_portid,
4903 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4904 struct cmd_tunnel_tso_set_result {
4905 cmdline_fixed_string_t tso;
4906 cmdline_fixed_string_t mode;
4911 static struct rte_eth_dev_info
4912 check_tunnel_tso_nic_support(portid_t port_id)
4914 struct rte_eth_dev_info dev_info;
4916 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4919 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4920 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4921 "not enabled for port %d\n", port_id);
4922 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4923 printf("Warning: GRE TUNNEL TSO not supported therefore "
4924 "not enabled for port %d\n", port_id);
4925 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4926 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4927 "not enabled for port %d\n", port_id);
4928 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4929 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4930 "not enabled for port %d\n", port_id);
4931 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4932 printf("Warning: IP TUNNEL TSO not supported therefore "
4933 "not enabled for port %d\n", port_id);
4934 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4935 printf("Warning: UDP TUNNEL TSO not supported therefore "
4936 "not enabled for port %d\n", port_id);
4941 cmd_tunnel_tso_set_parsed(void *parsed_result,
4942 __rte_unused struct cmdline *cl,
4943 __rte_unused void *data)
4945 struct cmd_tunnel_tso_set_result *res = parsed_result;
4946 struct rte_eth_dev_info dev_info;
4948 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4950 if (!port_is_stopped(res->port_id)) {
4951 printf("Please stop port %d first\n", res->port_id);
4955 if (!strcmp(res->mode, "set"))
4956 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4958 dev_info = check_tunnel_tso_nic_support(res->port_id);
4959 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4960 ports[res->port_id].dev_conf.txmode.offloads &=
4961 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4962 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4963 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4964 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4965 DEV_TX_OFFLOAD_IP_TNL_TSO |
4966 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4967 printf("TSO for tunneled packets is disabled\n");
4969 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4970 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4971 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4972 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4973 DEV_TX_OFFLOAD_IP_TNL_TSO |
4974 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4976 ports[res->port_id].dev_conf.txmode.offloads |=
4977 (tso_offloads & dev_info.tx_offload_capa);
4978 printf("TSO segment size for tunneled packets is %d\n",
4979 ports[res->port_id].tunnel_tso_segsz);
4981 /* Below conditions are needed to make it work:
4982 * (1) tunnel TSO is supported by the NIC;
4983 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4985 * (3) for tunneled pkts with outer L3 of IPv4,
4986 * "csum set outer-ip" must be set to hw, because after tso,
4987 * total_len of outer IP header is changed, and the checksum
4988 * of outer IP header calculated by sw should be wrong; that
4989 * is not necessary for IPv6 tunneled pkts because there's no
4990 * checksum in IP header anymore.
4993 if (!ports[res->port_id].parse_tunnel)
4994 printf("Warning: csum parse_tunnel must be set "
4995 "so that tunneled packets are recognized\n");
4996 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4997 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4998 printf("Warning: csum set outer-ip must be set to hw "
4999 "if outer L3 is IPv4; not necessary for IPv6\n");
5002 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5003 cmd_reconfig_device_queue(res->port_id, 1, 1);
5006 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5007 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5009 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5010 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5012 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5013 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5015 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5016 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5019 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5020 .f = cmd_tunnel_tso_set_parsed,
5022 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5023 "Set TSO segment size of tunneled packets for csum engine "
5026 (void *)&cmd_tunnel_tso_set_tso,
5027 (void *)&cmd_tunnel_tso_set_mode,
5028 (void *)&cmd_tunnel_tso_set_tso_segsz,
5029 (void *)&cmd_tunnel_tso_set_portid,
5034 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5035 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5039 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5040 .f = cmd_tunnel_tso_set_parsed,
5042 .help_str = "tunnel_tso show <port_id> "
5043 "Show TSO segment size of tunneled packets for csum engine",
5045 (void *)&cmd_tunnel_tso_set_tso,
5046 (void *)&cmd_tunnel_tso_show_mode,
5047 (void *)&cmd_tunnel_tso_set_portid,
5052 /* *** SET GRO FOR A PORT *** */
5053 struct cmd_gro_enable_result {
5054 cmdline_fixed_string_t cmd_set;
5055 cmdline_fixed_string_t cmd_port;
5056 cmdline_fixed_string_t cmd_keyword;
5057 cmdline_fixed_string_t cmd_onoff;
5062 cmd_gro_enable_parsed(void *parsed_result,
5063 __rte_unused struct cmdline *cl,
5064 __rte_unused void *data)
5066 struct cmd_gro_enable_result *res;
5068 res = parsed_result;
5069 if (!strcmp(res->cmd_keyword, "gro"))
5070 setup_gro(res->cmd_onoff, res->cmd_pid);
5073 cmdline_parse_token_string_t cmd_gro_enable_set =
5074 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5076 cmdline_parse_token_string_t cmd_gro_enable_port =
5077 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5078 cmd_keyword, "port");
5079 cmdline_parse_token_num_t cmd_gro_enable_pid =
5080 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5082 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5083 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5084 cmd_keyword, "gro");
5085 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5086 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5087 cmd_onoff, "on#off");
5089 cmdline_parse_inst_t cmd_gro_enable = {
5090 .f = cmd_gro_enable_parsed,
5092 .help_str = "set port <port_id> gro on|off",
5094 (void *)&cmd_gro_enable_set,
5095 (void *)&cmd_gro_enable_port,
5096 (void *)&cmd_gro_enable_pid,
5097 (void *)&cmd_gro_enable_keyword,
5098 (void *)&cmd_gro_enable_onoff,
5103 /* *** DISPLAY GRO CONFIGURATION *** */
5104 struct cmd_gro_show_result {
5105 cmdline_fixed_string_t cmd_show;
5106 cmdline_fixed_string_t cmd_port;
5107 cmdline_fixed_string_t cmd_keyword;
5112 cmd_gro_show_parsed(void *parsed_result,
5113 __rte_unused struct cmdline *cl,
5114 __rte_unused void *data)
5116 struct cmd_gro_show_result *res;
5118 res = parsed_result;
5119 if (!strcmp(res->cmd_keyword, "gro"))
5120 show_gro(res->cmd_pid);
5123 cmdline_parse_token_string_t cmd_gro_show_show =
5124 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5126 cmdline_parse_token_string_t cmd_gro_show_port =
5127 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5129 cmdline_parse_token_num_t cmd_gro_show_pid =
5130 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5132 cmdline_parse_token_string_t cmd_gro_show_keyword =
5133 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5134 cmd_keyword, "gro");
5136 cmdline_parse_inst_t cmd_gro_show = {
5137 .f = cmd_gro_show_parsed,
5139 .help_str = "show port <port_id> gro",
5141 (void *)&cmd_gro_show_show,
5142 (void *)&cmd_gro_show_port,
5143 (void *)&cmd_gro_show_pid,
5144 (void *)&cmd_gro_show_keyword,
5149 /* *** SET FLUSH CYCLES FOR GRO *** */
5150 struct cmd_gro_flush_result {
5151 cmdline_fixed_string_t cmd_set;
5152 cmdline_fixed_string_t cmd_keyword;
5153 cmdline_fixed_string_t cmd_flush;
5158 cmd_gro_flush_parsed(void *parsed_result,
5159 __rte_unused struct cmdline *cl,
5160 __rte_unused void *data)
5162 struct cmd_gro_flush_result *res;
5164 res = parsed_result;
5165 if ((!strcmp(res->cmd_keyword, "gro")) &&
5166 (!strcmp(res->cmd_flush, "flush")))
5167 setup_gro_flush_cycles(res->cmd_cycles);
5170 cmdline_parse_token_string_t cmd_gro_flush_set =
5171 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5173 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5174 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5175 cmd_keyword, "gro");
5176 cmdline_parse_token_string_t cmd_gro_flush_flush =
5177 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5178 cmd_flush, "flush");
5179 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5180 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5183 cmdline_parse_inst_t cmd_gro_flush = {
5184 .f = cmd_gro_flush_parsed,
5186 .help_str = "set gro flush <cycles>",
5188 (void *)&cmd_gro_flush_set,
5189 (void *)&cmd_gro_flush_keyword,
5190 (void *)&cmd_gro_flush_flush,
5191 (void *)&cmd_gro_flush_cycles,
5196 /* *** ENABLE/DISABLE GSO *** */
5197 struct cmd_gso_enable_result {
5198 cmdline_fixed_string_t cmd_set;
5199 cmdline_fixed_string_t cmd_port;
5200 cmdline_fixed_string_t cmd_keyword;
5201 cmdline_fixed_string_t cmd_mode;
5206 cmd_gso_enable_parsed(void *parsed_result,
5207 __rte_unused struct cmdline *cl,
5208 __rte_unused void *data)
5210 struct cmd_gso_enable_result *res;
5212 res = parsed_result;
5213 if (!strcmp(res->cmd_keyword, "gso"))
5214 setup_gso(res->cmd_mode, res->cmd_pid);
5217 cmdline_parse_token_string_t cmd_gso_enable_set =
5218 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5220 cmdline_parse_token_string_t cmd_gso_enable_port =
5221 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5223 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5224 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5225 cmd_keyword, "gso");
5226 cmdline_parse_token_string_t cmd_gso_enable_mode =
5227 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5228 cmd_mode, "on#off");
5229 cmdline_parse_token_num_t cmd_gso_enable_pid =
5230 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5233 cmdline_parse_inst_t cmd_gso_enable = {
5234 .f = cmd_gso_enable_parsed,
5236 .help_str = "set port <port_id> gso on|off",
5238 (void *)&cmd_gso_enable_set,
5239 (void *)&cmd_gso_enable_port,
5240 (void *)&cmd_gso_enable_pid,
5241 (void *)&cmd_gso_enable_keyword,
5242 (void *)&cmd_gso_enable_mode,
5247 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5248 struct cmd_gso_size_result {
5249 cmdline_fixed_string_t cmd_set;
5250 cmdline_fixed_string_t cmd_keyword;
5251 cmdline_fixed_string_t cmd_segsz;
5256 cmd_gso_size_parsed(void *parsed_result,
5257 __rte_unused struct cmdline *cl,
5258 __rte_unused void *data)
5260 struct cmd_gso_size_result *res = parsed_result;
5262 if (test_done == 0) {
5263 printf("Before setting GSO segsz, please first"
5264 " stop forwarding\n");
5268 if (!strcmp(res->cmd_keyword, "gso") &&
5269 !strcmp(res->cmd_segsz, "segsz")) {
5270 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5271 printf("gso_size should be larger than %zu."
5272 " Please input a legal value\n",
5273 RTE_GSO_SEG_SIZE_MIN);
5275 gso_max_segment_size = res->cmd_size;
5279 cmdline_parse_token_string_t cmd_gso_size_set =
5280 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5282 cmdline_parse_token_string_t cmd_gso_size_keyword =
5283 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5284 cmd_keyword, "gso");
5285 cmdline_parse_token_string_t cmd_gso_size_segsz =
5286 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5287 cmd_segsz, "segsz");
5288 cmdline_parse_token_num_t cmd_gso_size_size =
5289 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5292 cmdline_parse_inst_t cmd_gso_size = {
5293 .f = cmd_gso_size_parsed,
5295 .help_str = "set gso segsz <length>",
5297 (void *)&cmd_gso_size_set,
5298 (void *)&cmd_gso_size_keyword,
5299 (void *)&cmd_gso_size_segsz,
5300 (void *)&cmd_gso_size_size,
5305 /* *** SHOW GSO CONFIGURATION *** */
5306 struct cmd_gso_show_result {
5307 cmdline_fixed_string_t cmd_show;
5308 cmdline_fixed_string_t cmd_port;
5309 cmdline_fixed_string_t cmd_keyword;
5314 cmd_gso_show_parsed(void *parsed_result,
5315 __rte_unused struct cmdline *cl,
5316 __rte_unused void *data)
5318 struct cmd_gso_show_result *res = parsed_result;
5320 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5321 printf("invalid port id %u\n", res->cmd_pid);
5324 if (!strcmp(res->cmd_keyword, "gso")) {
5325 if (gso_ports[res->cmd_pid].enable) {
5326 printf("Max GSO'd packet size: %uB\n"
5327 "Supported GSO types: TCP/IPv4, "
5328 "UDP/IPv4, VxLAN with inner "
5329 "TCP/IPv4 packet, GRE with inner "
5330 "TCP/IPv4 packet\n",
5331 gso_max_segment_size);
5333 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5337 cmdline_parse_token_string_t cmd_gso_show_show =
5338 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5340 cmdline_parse_token_string_t cmd_gso_show_port =
5341 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5343 cmdline_parse_token_string_t cmd_gso_show_keyword =
5344 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5345 cmd_keyword, "gso");
5346 cmdline_parse_token_num_t cmd_gso_show_pid =
5347 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5350 cmdline_parse_inst_t cmd_gso_show = {
5351 .f = cmd_gso_show_parsed,
5353 .help_str = "show port <port_id> gso",
5355 (void *)&cmd_gso_show_show,
5356 (void *)&cmd_gso_show_port,
5357 (void *)&cmd_gso_show_pid,
5358 (void *)&cmd_gso_show_keyword,
5363 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5364 struct cmd_set_flush_rx {
5365 cmdline_fixed_string_t set;
5366 cmdline_fixed_string_t flush_rx;
5367 cmdline_fixed_string_t mode;
5371 cmd_set_flush_rx_parsed(void *parsed_result,
5372 __rte_unused struct cmdline *cl,
5373 __rte_unused void *data)
5375 struct cmd_set_flush_rx *res = parsed_result;
5376 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5379 cmdline_parse_token_string_t cmd_setflushrx_set =
5380 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5382 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5383 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5384 flush_rx, "flush_rx");
5385 cmdline_parse_token_string_t cmd_setflushrx_mode =
5386 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5390 cmdline_parse_inst_t cmd_set_flush_rx = {
5391 .f = cmd_set_flush_rx_parsed,
5392 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5395 (void *)&cmd_setflushrx_set,
5396 (void *)&cmd_setflushrx_flush_rx,
5397 (void *)&cmd_setflushrx_mode,
5402 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5403 struct cmd_set_link_check {
5404 cmdline_fixed_string_t set;
5405 cmdline_fixed_string_t link_check;
5406 cmdline_fixed_string_t mode;
5410 cmd_set_link_check_parsed(void *parsed_result,
5411 __rte_unused struct cmdline *cl,
5412 __rte_unused void *data)
5414 struct cmd_set_link_check *res = parsed_result;
5415 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5418 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5419 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5421 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5422 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5423 link_check, "link_check");
5424 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5425 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5429 cmdline_parse_inst_t cmd_set_link_check = {
5430 .f = cmd_set_link_check_parsed,
5431 .help_str = "set link_check on|off: Enable/Disable link status check "
5432 "when starting/stopping a port",
5435 (void *)&cmd_setlinkcheck_set,
5436 (void *)&cmd_setlinkcheck_link_check,
5437 (void *)&cmd_setlinkcheck_mode,
5442 /* *** SET NIC BYPASS MODE *** */
5443 struct cmd_set_bypass_mode_result {
5444 cmdline_fixed_string_t set;
5445 cmdline_fixed_string_t bypass;
5446 cmdline_fixed_string_t mode;
5447 cmdline_fixed_string_t value;
5452 cmd_set_bypass_mode_parsed(void *parsed_result,
5453 __rte_unused struct cmdline *cl,
5454 __rte_unused void *data)
5456 struct cmd_set_bypass_mode_result *res = parsed_result;
5457 portid_t port_id = res->port_id;
5458 int32_t rc = -EINVAL;
5460 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5461 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5463 if (!strcmp(res->value, "bypass"))
5464 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5465 else if (!strcmp(res->value, "isolate"))
5466 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5468 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5470 /* Set the bypass mode for the relevant port. */
5471 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5474 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5477 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5478 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5480 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5481 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5483 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5484 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5486 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5487 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5488 value, "normal#bypass#isolate");
5489 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5490 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5493 cmdline_parse_inst_t cmd_set_bypass_mode = {
5494 .f = cmd_set_bypass_mode_parsed,
5495 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5496 "Set the NIC bypass mode for port_id",
5499 (void *)&cmd_setbypass_mode_set,
5500 (void *)&cmd_setbypass_mode_bypass,
5501 (void *)&cmd_setbypass_mode_mode,
5502 (void *)&cmd_setbypass_mode_value,
5503 (void *)&cmd_setbypass_mode_port,
5508 /* *** SET NIC BYPASS EVENT *** */
5509 struct cmd_set_bypass_event_result {
5510 cmdline_fixed_string_t set;
5511 cmdline_fixed_string_t bypass;
5512 cmdline_fixed_string_t event;
5513 cmdline_fixed_string_t event_value;
5514 cmdline_fixed_string_t mode;
5515 cmdline_fixed_string_t mode_value;
5520 cmd_set_bypass_event_parsed(void *parsed_result,
5521 __rte_unused struct cmdline *cl,
5522 __rte_unused void *data)
5524 int32_t rc = -EINVAL;
5525 struct cmd_set_bypass_event_result *res = parsed_result;
5526 portid_t port_id = res->port_id;
5528 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5529 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5530 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5532 if (!strcmp(res->event_value, "timeout"))
5533 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5534 else if (!strcmp(res->event_value, "os_on"))
5535 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5536 else if (!strcmp(res->event_value, "os_off"))
5537 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5538 else if (!strcmp(res->event_value, "power_on"))
5539 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5540 else if (!strcmp(res->event_value, "power_off"))
5541 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5543 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5545 if (!strcmp(res->mode_value, "bypass"))
5546 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5547 else if (!strcmp(res->mode_value, "isolate"))
5548 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5550 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5552 /* Set the watchdog timeout. */
5553 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5556 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5557 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5561 printf("Failed to set timeout value %u "
5562 "for port %d, errto code: %d.\n",
5563 bypass_timeout, port_id, rc);
5567 /* Set the bypass event to transition to bypass mode. */
5568 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5573 printf("\t Failed to set bypass event for port = %d.\n",
5577 cmdline_parse_token_string_t cmd_setbypass_event_set =
5578 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5580 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5581 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5583 cmdline_parse_token_string_t cmd_setbypass_event_event =
5584 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5586 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5587 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5588 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5589 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5590 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5592 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5593 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5594 mode_value, "normal#bypass#isolate");
5595 cmdline_parse_token_num_t cmd_setbypass_event_port =
5596 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5599 cmdline_parse_inst_t cmd_set_bypass_event = {
5600 .f = cmd_set_bypass_event_parsed,
5601 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5602 "power_off mode normal|bypass|isolate <port_id>: "
5603 "Set the NIC bypass event mode for port_id",
5606 (void *)&cmd_setbypass_event_set,
5607 (void *)&cmd_setbypass_event_bypass,
5608 (void *)&cmd_setbypass_event_event,
5609 (void *)&cmd_setbypass_event_event_value,
5610 (void *)&cmd_setbypass_event_mode,
5611 (void *)&cmd_setbypass_event_mode_value,
5612 (void *)&cmd_setbypass_event_port,
5618 /* *** SET NIC BYPASS TIMEOUT *** */
5619 struct cmd_set_bypass_timeout_result {
5620 cmdline_fixed_string_t set;
5621 cmdline_fixed_string_t bypass;
5622 cmdline_fixed_string_t timeout;
5623 cmdline_fixed_string_t value;
5627 cmd_set_bypass_timeout_parsed(void *parsed_result,
5628 __rte_unused struct cmdline *cl,
5629 __rte_unused void *data)
5631 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5633 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5634 if (!strcmp(res->value, "1.5"))
5635 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5636 else if (!strcmp(res->value, "2"))
5637 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5638 else if (!strcmp(res->value, "3"))
5639 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5640 else if (!strcmp(res->value, "4"))
5641 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5642 else if (!strcmp(res->value, "8"))
5643 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5644 else if (!strcmp(res->value, "16"))
5645 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5646 else if (!strcmp(res->value, "32"))
5647 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5649 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5653 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5654 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5656 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5657 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5659 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5660 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5661 timeout, "timeout");
5662 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5663 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5664 value, "0#1.5#2#3#4#8#16#32");
5666 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5667 .f = cmd_set_bypass_timeout_parsed,
5668 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5669 "Set the NIC bypass watchdog timeout in seconds",
5672 (void *)&cmd_setbypass_timeout_set,
5673 (void *)&cmd_setbypass_timeout_bypass,
5674 (void *)&cmd_setbypass_timeout_timeout,
5675 (void *)&cmd_setbypass_timeout_value,
5680 /* *** SHOW NIC BYPASS MODE *** */
5681 struct cmd_show_bypass_config_result {
5682 cmdline_fixed_string_t show;
5683 cmdline_fixed_string_t bypass;
5684 cmdline_fixed_string_t config;
5689 cmd_show_bypass_config_parsed(void *parsed_result,
5690 __rte_unused struct cmdline *cl,
5691 __rte_unused void *data)
5693 struct cmd_show_bypass_config_result *res = parsed_result;
5694 portid_t port_id = res->port_id;
5696 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5697 uint32_t event_mode;
5698 uint32_t bypass_mode;
5699 uint32_t timeout = bypass_timeout;
5702 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5703 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5704 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5705 {"UNKNOWN", "normal", "bypass", "isolate"};
5706 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5714 /* Display the bypass mode.*/
5715 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5716 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5720 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5721 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5723 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5726 /* Display the bypass timeout.*/
5727 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5728 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5730 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5732 /* Display the bypass events and associated modes. */
5733 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5735 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5736 printf("\tFailed to get bypass mode for event = %s\n",
5739 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5740 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5742 printf("\tbypass event: %-16s = %s\n", events[i],
5748 printf("\tFailed to get bypass configuration for port = %d\n",
5752 cmdline_parse_token_string_t cmd_showbypass_config_show =
5753 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5755 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5756 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5758 cmdline_parse_token_string_t cmd_showbypass_config_config =
5759 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5761 cmdline_parse_token_num_t cmd_showbypass_config_port =
5762 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5765 cmdline_parse_inst_t cmd_show_bypass_config = {
5766 .f = cmd_show_bypass_config_parsed,
5767 .help_str = "show bypass config <port_id>: "
5768 "Show the NIC bypass config for port_id",
5771 (void *)&cmd_showbypass_config_show,
5772 (void *)&cmd_showbypass_config_bypass,
5773 (void *)&cmd_showbypass_config_config,
5774 (void *)&cmd_showbypass_config_port,
5779 #ifdef RTE_LIBRTE_PMD_BOND
5780 /* *** SET BONDING MODE *** */
5781 struct cmd_set_bonding_mode_result {
5782 cmdline_fixed_string_t set;
5783 cmdline_fixed_string_t bonding;
5784 cmdline_fixed_string_t mode;
5789 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5790 __rte_unused struct cmdline *cl,
5791 __rte_unused void *data)
5793 struct cmd_set_bonding_mode_result *res = parsed_result;
5794 portid_t port_id = res->port_id;
5796 /* Set the bonding mode for the relevant port. */
5797 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5798 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5801 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5802 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5804 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5805 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5806 bonding, "bonding");
5807 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5808 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5810 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5811 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5813 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5814 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5817 cmdline_parse_inst_t cmd_set_bonding_mode = {
5818 .f = cmd_set_bonding_mode_parsed,
5819 .help_str = "set bonding mode <mode_value> <port_id>: "
5820 "Set the bonding mode for port_id",
5823 (void *) &cmd_setbonding_mode_set,
5824 (void *) &cmd_setbonding_mode_bonding,
5825 (void *) &cmd_setbonding_mode_mode,
5826 (void *) &cmd_setbonding_mode_value,
5827 (void *) &cmd_setbonding_mode_port,
5832 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5833 struct cmd_set_bonding_lacp_dedicated_queues_result {
5834 cmdline_fixed_string_t set;
5835 cmdline_fixed_string_t bonding;
5836 cmdline_fixed_string_t lacp;
5837 cmdline_fixed_string_t dedicated_queues;
5839 cmdline_fixed_string_t mode;
5842 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5843 __rte_unused struct cmdline *cl,
5844 __rte_unused void *data)
5846 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5847 portid_t port_id = res->port_id;
5848 struct rte_port *port;
5850 port = &ports[port_id];
5852 /** Check if the port is not started **/
5853 if (port->port_status != RTE_PORT_STOPPED) {
5854 printf("Please stop port %d first\n", port_id);
5858 if (!strcmp(res->mode, "enable")) {
5859 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5860 printf("Dedicate queues for LACP control packets"
5863 printf("Enabling dedicate queues for LACP control "
5864 "packets on port %d failed\n", port_id);
5865 } else if (!strcmp(res->mode, "disable")) {
5866 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5867 printf("Dedicated queues for LACP control packets "
5870 printf("Disabling dedicated queues for LACP control "
5871 "traffic on port %d failed\n", port_id);
5875 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5876 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5878 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5879 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5880 bonding, "bonding");
5881 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5882 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5884 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5885 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5886 dedicated_queues, "dedicated_queues");
5887 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5888 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5890 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5891 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5892 mode, "enable#disable");
5894 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5895 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5896 .help_str = "set bonding lacp dedicated_queues <port_id> "
5898 "Enable/disable dedicated queues for LACP control traffic for port_id",
5901 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5902 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5903 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5904 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5905 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5906 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5911 /* *** SET BALANCE XMIT POLICY *** */
5912 struct cmd_set_bonding_balance_xmit_policy_result {
5913 cmdline_fixed_string_t set;
5914 cmdline_fixed_string_t bonding;
5915 cmdline_fixed_string_t balance_xmit_policy;
5917 cmdline_fixed_string_t policy;
5920 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5921 __rte_unused struct cmdline *cl,
5922 __rte_unused void *data)
5924 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5925 portid_t port_id = res->port_id;
5928 if (!strcmp(res->policy, "l2")) {
5929 policy = BALANCE_XMIT_POLICY_LAYER2;
5930 } else if (!strcmp(res->policy, "l23")) {
5931 policy = BALANCE_XMIT_POLICY_LAYER23;
5932 } else if (!strcmp(res->policy, "l34")) {
5933 policy = BALANCE_XMIT_POLICY_LAYER34;
5935 printf("\t Invalid xmit policy selection");
5939 /* Set the bonding mode for the relevant port. */
5940 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5941 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5946 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5947 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5949 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5950 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5951 bonding, "bonding");
5952 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5953 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5954 balance_xmit_policy, "balance_xmit_policy");
5955 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5956 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5958 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5959 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5960 policy, "l2#l23#l34");
5962 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5963 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5964 .help_str = "set bonding balance_xmit_policy <port_id> "
5966 "Set the bonding balance_xmit_policy for port_id",
5969 (void *)&cmd_setbonding_balance_xmit_policy_set,
5970 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5971 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5972 (void *)&cmd_setbonding_balance_xmit_policy_port,
5973 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5978 /* *** SHOW NIC BONDING CONFIGURATION *** */
5979 struct cmd_show_bonding_config_result {
5980 cmdline_fixed_string_t show;
5981 cmdline_fixed_string_t bonding;
5982 cmdline_fixed_string_t config;
5986 static void cmd_show_bonding_config_parsed(void *parsed_result,
5987 __rte_unused struct cmdline *cl,
5988 __rte_unused void *data)
5990 struct cmd_show_bonding_config_result *res = parsed_result;
5991 int bonding_mode, agg_mode;
5992 portid_t slaves[RTE_MAX_ETHPORTS];
5993 int num_slaves, num_active_slaves;
5996 portid_t port_id = res->port_id;
5998 /* Display the bonding mode.*/
5999 bonding_mode = rte_eth_bond_mode_get(port_id);
6000 if (bonding_mode < 0) {
6001 printf("\tFailed to get bonding mode for port = %d\n", port_id);
6004 printf("\tBonding mode: %d\n", bonding_mode);
6006 if (bonding_mode == BONDING_MODE_BALANCE) {
6007 int balance_xmit_policy;
6009 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6010 if (balance_xmit_policy < 0) {
6011 printf("\tFailed to get balance xmit policy for port = %d\n",
6015 printf("\tBalance Xmit Policy: ");
6017 switch (balance_xmit_policy) {
6018 case BALANCE_XMIT_POLICY_LAYER2:
6019 printf("BALANCE_XMIT_POLICY_LAYER2");
6021 case BALANCE_XMIT_POLICY_LAYER23:
6022 printf("BALANCE_XMIT_POLICY_LAYER23");
6024 case BALANCE_XMIT_POLICY_LAYER34:
6025 printf("BALANCE_XMIT_POLICY_LAYER34");
6032 if (bonding_mode == BONDING_MODE_8023AD) {
6033 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6034 printf("\tIEEE802.3AD Aggregator Mode: ");
6037 printf("bandwidth");
6049 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6051 if (num_slaves < 0) {
6052 printf("\tFailed to get slave list for port = %d\n", port_id);
6055 if (num_slaves > 0) {
6056 printf("\tSlaves (%d): [", num_slaves);
6057 for (i = 0; i < num_slaves - 1; i++)
6058 printf("%d ", slaves[i]);
6060 printf("%d]\n", slaves[num_slaves - 1]);
6062 printf("\tSlaves: []\n");
6066 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6069 if (num_active_slaves < 0) {
6070 printf("\tFailed to get active slave list for port = %d\n", port_id);
6073 if (num_active_slaves > 0) {
6074 printf("\tActive Slaves (%d): [", num_active_slaves);
6075 for (i = 0; i < num_active_slaves - 1; i++)
6076 printf("%d ", slaves[i]);
6078 printf("%d]\n", slaves[num_active_slaves - 1]);
6081 printf("\tActive Slaves: []\n");
6085 primary_id = rte_eth_bond_primary_get(port_id);
6086 if (primary_id < 0) {
6087 printf("\tFailed to get primary slave for port = %d\n", port_id);
6090 printf("\tPrimary: [%d]\n", primary_id);
6094 cmdline_parse_token_string_t cmd_showbonding_config_show =
6095 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6097 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6098 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6099 bonding, "bonding");
6100 cmdline_parse_token_string_t cmd_showbonding_config_config =
6101 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6103 cmdline_parse_token_num_t cmd_showbonding_config_port =
6104 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6107 cmdline_parse_inst_t cmd_show_bonding_config = {
6108 .f = cmd_show_bonding_config_parsed,
6109 .help_str = "show bonding config <port_id>: "
6110 "Show the bonding config for port_id",
6113 (void *)&cmd_showbonding_config_show,
6114 (void *)&cmd_showbonding_config_bonding,
6115 (void *)&cmd_showbonding_config_config,
6116 (void *)&cmd_showbonding_config_port,
6121 /* *** SET BONDING PRIMARY *** */
6122 struct cmd_set_bonding_primary_result {
6123 cmdline_fixed_string_t set;
6124 cmdline_fixed_string_t bonding;
6125 cmdline_fixed_string_t primary;
6130 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6131 __rte_unused struct cmdline *cl,
6132 __rte_unused void *data)
6134 struct cmd_set_bonding_primary_result *res = parsed_result;
6135 portid_t master_port_id = res->port_id;
6136 portid_t slave_port_id = res->slave_id;
6138 /* Set the primary slave for a bonded device. */
6139 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6140 printf("\t Failed to set primary slave for port = %d.\n",
6147 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6148 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6150 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6151 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6152 bonding, "bonding");
6153 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6154 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6155 primary, "primary");
6156 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6157 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6159 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6160 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6163 cmdline_parse_inst_t cmd_set_bonding_primary = {
6164 .f = cmd_set_bonding_primary_parsed,
6165 .help_str = "set bonding primary <slave_id> <port_id>: "
6166 "Set the primary slave for port_id",
6169 (void *)&cmd_setbonding_primary_set,
6170 (void *)&cmd_setbonding_primary_bonding,
6171 (void *)&cmd_setbonding_primary_primary,
6172 (void *)&cmd_setbonding_primary_slave,
6173 (void *)&cmd_setbonding_primary_port,
6178 /* *** ADD SLAVE *** */
6179 struct cmd_add_bonding_slave_result {
6180 cmdline_fixed_string_t add;
6181 cmdline_fixed_string_t bonding;
6182 cmdline_fixed_string_t slave;
6187 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6188 __rte_unused struct cmdline *cl,
6189 __rte_unused void *data)
6191 struct cmd_add_bonding_slave_result *res = parsed_result;
6192 portid_t master_port_id = res->port_id;
6193 portid_t slave_port_id = res->slave_id;
6195 /* add the slave for a bonded device. */
6196 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6197 printf("\t Failed to add slave %d to master port = %d.\n",
6198 slave_port_id, master_port_id);
6202 set_port_slave_flag(slave_port_id);
6205 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6206 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6208 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6209 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6210 bonding, "bonding");
6211 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6212 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6214 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6215 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6217 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6218 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6221 cmdline_parse_inst_t cmd_add_bonding_slave = {
6222 .f = cmd_add_bonding_slave_parsed,
6223 .help_str = "add bonding slave <slave_id> <port_id>: "
6224 "Add a slave device to a bonded device",
6227 (void *)&cmd_addbonding_slave_add,
6228 (void *)&cmd_addbonding_slave_bonding,
6229 (void *)&cmd_addbonding_slave_slave,
6230 (void *)&cmd_addbonding_slave_slaveid,
6231 (void *)&cmd_addbonding_slave_port,
6236 /* *** REMOVE SLAVE *** */
6237 struct cmd_remove_bonding_slave_result {
6238 cmdline_fixed_string_t remove;
6239 cmdline_fixed_string_t bonding;
6240 cmdline_fixed_string_t slave;
6245 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6246 __rte_unused struct cmdline *cl,
6247 __rte_unused void *data)
6249 struct cmd_remove_bonding_slave_result *res = parsed_result;
6250 portid_t master_port_id = res->port_id;
6251 portid_t slave_port_id = res->slave_id;
6253 /* remove the slave from a bonded device. */
6254 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6255 printf("\t Failed to remove slave %d from master port = %d.\n",
6256 slave_port_id, master_port_id);
6260 clear_port_slave_flag(slave_port_id);
6263 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6264 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6266 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6267 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6268 bonding, "bonding");
6269 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6270 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6272 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6273 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6275 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6276 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6279 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6280 .f = cmd_remove_bonding_slave_parsed,
6281 .help_str = "remove bonding slave <slave_id> <port_id>: "
6282 "Remove a slave device from a bonded device",
6285 (void *)&cmd_removebonding_slave_remove,
6286 (void *)&cmd_removebonding_slave_bonding,
6287 (void *)&cmd_removebonding_slave_slave,
6288 (void *)&cmd_removebonding_slave_slaveid,
6289 (void *)&cmd_removebonding_slave_port,
6294 /* *** CREATE BONDED DEVICE *** */
6295 struct cmd_create_bonded_device_result {
6296 cmdline_fixed_string_t create;
6297 cmdline_fixed_string_t bonded;
6298 cmdline_fixed_string_t device;
6303 static int bond_dev_num = 0;
6305 static void cmd_create_bonded_device_parsed(void *parsed_result,
6306 __rte_unused struct cmdline *cl,
6307 __rte_unused void *data)
6309 struct cmd_create_bonded_device_result *res = parsed_result;
6310 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6314 if (test_done == 0) {
6315 printf("Please stop forwarding first\n");
6319 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6322 /* Create a new bonded device. */
6323 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6325 printf("\t Failed to create bonded device.\n");
6328 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6331 /* Update number of ports */
6332 nb_ports = rte_eth_dev_count_avail();
6333 reconfig(port_id, res->socket);
6334 ret = rte_eth_promiscuous_enable(port_id);
6336 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6337 port_id, rte_strerror(-ret));
6339 ports[port_id].need_setup = 0;
6340 ports[port_id].port_status = RTE_PORT_STOPPED;
6345 cmdline_parse_token_string_t cmd_createbonded_device_create =
6346 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6348 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6349 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6351 cmdline_parse_token_string_t cmd_createbonded_device_device =
6352 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6354 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6355 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6357 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6358 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6361 cmdline_parse_inst_t cmd_create_bonded_device = {
6362 .f = cmd_create_bonded_device_parsed,
6363 .help_str = "create bonded device <mode> <socket>: "
6364 "Create a new bonded device with specific bonding mode and socket",
6367 (void *)&cmd_createbonded_device_create,
6368 (void *)&cmd_createbonded_device_bonded,
6369 (void *)&cmd_createbonded_device_device,
6370 (void *)&cmd_createbonded_device_mode,
6371 (void *)&cmd_createbonded_device_socket,
6376 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6377 struct cmd_set_bond_mac_addr_result {
6378 cmdline_fixed_string_t set;
6379 cmdline_fixed_string_t bonding;
6380 cmdline_fixed_string_t mac_addr;
6382 struct rte_ether_addr address;
6385 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6386 __rte_unused struct cmdline *cl,
6387 __rte_unused void *data)
6389 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6392 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6395 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6397 /* check the return value and print it if is < 0 */
6399 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6402 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6403 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6404 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6405 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6407 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6408 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6410 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6411 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6413 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6414 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6416 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6417 .f = cmd_set_bond_mac_addr_parsed,
6419 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6421 (void *)&cmd_set_bond_mac_addr_set,
6422 (void *)&cmd_set_bond_mac_addr_bonding,
6423 (void *)&cmd_set_bond_mac_addr_mac,
6424 (void *)&cmd_set_bond_mac_addr_portnum,
6425 (void *)&cmd_set_bond_mac_addr_addr,
6431 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6432 struct cmd_set_bond_mon_period_result {
6433 cmdline_fixed_string_t set;
6434 cmdline_fixed_string_t bonding;
6435 cmdline_fixed_string_t mon_period;
6440 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6441 __rte_unused struct cmdline *cl,
6442 __rte_unused void *data)
6444 struct cmd_set_bond_mon_period_result *res = parsed_result;
6447 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6449 /* check the return value and print it if is < 0 */
6451 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6454 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6455 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6457 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6458 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6459 bonding, "bonding");
6460 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6461 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6462 mon_period, "mon_period");
6463 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6464 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6466 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6467 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6470 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6471 .f = cmd_set_bond_mon_period_parsed,
6473 .help_str = "set bonding mon_period <port_id> <period_ms>",
6475 (void *)&cmd_set_bond_mon_period_set,
6476 (void *)&cmd_set_bond_mon_period_bonding,
6477 (void *)&cmd_set_bond_mon_period_mon_period,
6478 (void *)&cmd_set_bond_mon_period_portnum,
6479 (void *)&cmd_set_bond_mon_period_period_ms,
6486 struct cmd_set_bonding_agg_mode_policy_result {
6487 cmdline_fixed_string_t set;
6488 cmdline_fixed_string_t bonding;
6489 cmdline_fixed_string_t agg_mode;
6491 cmdline_fixed_string_t policy;
6496 cmd_set_bonding_agg_mode(void *parsed_result,
6497 __rte_unused struct cmdline *cl,
6498 __rte_unused void *data)
6500 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6501 uint8_t policy = AGG_BANDWIDTH;
6503 if (!strcmp(res->policy, "bandwidth"))
6504 policy = AGG_BANDWIDTH;
6505 else if (!strcmp(res->policy, "stable"))
6506 policy = AGG_STABLE;
6507 else if (!strcmp(res->policy, "count"))
6510 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6514 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6515 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6517 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6518 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6519 bonding, "bonding");
6521 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6522 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6523 agg_mode, "agg_mode");
6525 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6526 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6529 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6530 TOKEN_STRING_INITIALIZER(
6531 struct cmd_set_bonding_balance_xmit_policy_result,
6532 policy, "stable#bandwidth#count");
6534 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6535 .f = cmd_set_bonding_agg_mode,
6537 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6539 (void *)&cmd_set_bonding_agg_mode_set,
6540 (void *)&cmd_set_bonding_agg_mode_bonding,
6541 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6542 (void *)&cmd_set_bonding_agg_mode_portnum,
6543 (void *)&cmd_set_bonding_agg_mode_policy_string,
6549 #endif /* RTE_LIBRTE_PMD_BOND */
6551 /* *** SET FORWARDING MODE *** */
6552 struct cmd_set_fwd_mode_result {
6553 cmdline_fixed_string_t set;
6554 cmdline_fixed_string_t fwd;
6555 cmdline_fixed_string_t mode;
6558 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6559 __rte_unused struct cmdline *cl,
6560 __rte_unused void *data)
6562 struct cmd_set_fwd_mode_result *res = parsed_result;
6565 set_pkt_forwarding_mode(res->mode);
6568 cmdline_parse_token_string_t cmd_setfwd_set =
6569 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6570 cmdline_parse_token_string_t cmd_setfwd_fwd =
6571 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6572 cmdline_parse_token_string_t cmd_setfwd_mode =
6573 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6574 "" /* defined at init */);
6576 cmdline_parse_inst_t cmd_set_fwd_mode = {
6577 .f = cmd_set_fwd_mode_parsed,
6579 .help_str = NULL, /* defined at init */
6581 (void *)&cmd_setfwd_set,
6582 (void *)&cmd_setfwd_fwd,
6583 (void *)&cmd_setfwd_mode,
6588 static void cmd_set_fwd_mode_init(void)
6591 static char token[128];
6592 static char help[256];
6593 cmdline_parse_token_string_t *token_struct;
6595 modes = list_pkt_forwarding_modes();
6596 snprintf(help, sizeof(help), "set fwd %s: "
6597 "Set packet forwarding mode", modes);
6598 cmd_set_fwd_mode.help_str = help;
6600 /* string token separator is # */
6601 for (c = token; *modes != '\0'; modes++)
6606 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6607 token_struct->string_data.str = token;
6610 /* *** SET RETRY FORWARDING MODE *** */
6611 struct cmd_set_fwd_retry_mode_result {
6612 cmdline_fixed_string_t set;
6613 cmdline_fixed_string_t fwd;
6614 cmdline_fixed_string_t mode;
6615 cmdline_fixed_string_t retry;
6618 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6619 __rte_unused struct cmdline *cl,
6620 __rte_unused void *data)
6622 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6625 set_pkt_forwarding_mode(res->mode);
6628 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6629 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6631 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6632 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6634 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6635 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6637 "" /* defined at init */);
6638 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6639 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6642 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6643 .f = cmd_set_fwd_retry_mode_parsed,
6645 .help_str = NULL, /* defined at init */
6647 (void *)&cmd_setfwd_retry_set,
6648 (void *)&cmd_setfwd_retry_fwd,
6649 (void *)&cmd_setfwd_retry_mode,
6650 (void *)&cmd_setfwd_retry_retry,
6655 static void cmd_set_fwd_retry_mode_init(void)
6658 static char token[128];
6659 static char help[256];
6660 cmdline_parse_token_string_t *token_struct;
6662 modes = list_pkt_forwarding_retry_modes();
6663 snprintf(help, sizeof(help), "set fwd %s retry: "
6664 "Set packet forwarding mode with retry", modes);
6665 cmd_set_fwd_retry_mode.help_str = help;
6667 /* string token separator is # */
6668 for (c = token; *modes != '\0'; modes++)
6673 token_struct = (cmdline_parse_token_string_t *)
6674 cmd_set_fwd_retry_mode.tokens[2];
6675 token_struct->string_data.str = token;
6678 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6679 struct cmd_set_burst_tx_retry_result {
6680 cmdline_fixed_string_t set;
6681 cmdline_fixed_string_t burst;
6682 cmdline_fixed_string_t tx;
6683 cmdline_fixed_string_t delay;
6685 cmdline_fixed_string_t retry;
6689 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6690 __rte_unused struct cmdline *cl,
6691 __rte_unused void *data)
6693 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6695 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6696 && !strcmp(res->tx, "tx")) {
6697 if (!strcmp(res->delay, "delay"))
6698 burst_tx_delay_time = res->time;
6699 if (!strcmp(res->retry, "retry"))
6700 burst_tx_retry_num = res->retry_num;
6705 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6706 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6707 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6708 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6710 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6711 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6712 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6713 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6714 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6715 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6716 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6717 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6718 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6719 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6721 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6722 .f = cmd_set_burst_tx_retry_parsed,
6723 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6725 (void *)&cmd_set_burst_tx_retry_set,
6726 (void *)&cmd_set_burst_tx_retry_burst,
6727 (void *)&cmd_set_burst_tx_retry_tx,
6728 (void *)&cmd_set_burst_tx_retry_delay,
6729 (void *)&cmd_set_burst_tx_retry_time,
6730 (void *)&cmd_set_burst_tx_retry_retry,
6731 (void *)&cmd_set_burst_tx_retry_retry_num,
6736 /* *** SET PROMISC MODE *** */
6737 struct cmd_set_promisc_mode_result {
6738 cmdline_fixed_string_t set;
6739 cmdline_fixed_string_t promisc;
6740 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6741 uint16_t port_num; /* valid if "allports" argument == 0 */
6742 cmdline_fixed_string_t mode;
6745 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6746 __rte_unused struct cmdline *cl,
6749 struct cmd_set_promisc_mode_result *res = parsed_result;
6753 if (!strcmp(res->mode, "on"))
6760 RTE_ETH_FOREACH_DEV(i)
6761 eth_set_promisc_mode(i, enable);
6763 eth_set_promisc_mode(res->port_num, enable);
6767 cmdline_parse_token_string_t cmd_setpromisc_set =
6768 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6769 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6770 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6772 cmdline_parse_token_string_t cmd_setpromisc_portall =
6773 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6775 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6776 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6778 cmdline_parse_token_string_t cmd_setpromisc_mode =
6779 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6782 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6783 .f = cmd_set_promisc_mode_parsed,
6785 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6787 (void *)&cmd_setpromisc_set,
6788 (void *)&cmd_setpromisc_promisc,
6789 (void *)&cmd_setpromisc_portall,
6790 (void *)&cmd_setpromisc_mode,
6795 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6796 .f = cmd_set_promisc_mode_parsed,
6798 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6800 (void *)&cmd_setpromisc_set,
6801 (void *)&cmd_setpromisc_promisc,
6802 (void *)&cmd_setpromisc_portnum,
6803 (void *)&cmd_setpromisc_mode,
6808 /* *** SET ALLMULTI MODE *** */
6809 struct cmd_set_allmulti_mode_result {
6810 cmdline_fixed_string_t set;
6811 cmdline_fixed_string_t allmulti;
6812 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6813 uint16_t port_num; /* valid if "allports" argument == 0 */
6814 cmdline_fixed_string_t mode;
6817 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6818 __rte_unused struct cmdline *cl,
6821 struct cmd_set_allmulti_mode_result *res = parsed_result;
6825 if (!strcmp(res->mode, "on"))
6832 RTE_ETH_FOREACH_DEV(i) {
6833 eth_set_allmulticast_mode(i, enable);
6837 eth_set_allmulticast_mode(res->port_num, enable);
6841 cmdline_parse_token_string_t cmd_setallmulti_set =
6842 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6843 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6844 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6846 cmdline_parse_token_string_t cmd_setallmulti_portall =
6847 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6849 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6850 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6852 cmdline_parse_token_string_t cmd_setallmulti_mode =
6853 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6856 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6857 .f = cmd_set_allmulti_mode_parsed,
6859 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6861 (void *)&cmd_setallmulti_set,
6862 (void *)&cmd_setallmulti_allmulti,
6863 (void *)&cmd_setallmulti_portall,
6864 (void *)&cmd_setallmulti_mode,
6869 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6870 .f = cmd_set_allmulti_mode_parsed,
6872 .help_str = "set allmulti <port_id> on|off: "
6873 "Set allmulti mode on port_id",
6875 (void *)&cmd_setallmulti_set,
6876 (void *)&cmd_setallmulti_allmulti,
6877 (void *)&cmd_setallmulti_portnum,
6878 (void *)&cmd_setallmulti_mode,
6883 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6884 struct cmd_link_flow_ctrl_set_result {
6885 cmdline_fixed_string_t set;
6886 cmdline_fixed_string_t flow_ctrl;
6887 cmdline_fixed_string_t rx;
6888 cmdline_fixed_string_t rx_lfc_mode;
6889 cmdline_fixed_string_t tx;
6890 cmdline_fixed_string_t tx_lfc_mode;
6891 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6892 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6893 cmdline_fixed_string_t autoneg_str;
6894 cmdline_fixed_string_t autoneg;
6895 cmdline_fixed_string_t hw_str;
6896 uint32_t high_water;
6897 cmdline_fixed_string_t lw_str;
6899 cmdline_fixed_string_t pt_str;
6900 uint16_t pause_time;
6901 cmdline_fixed_string_t xon_str;
6906 cmdline_parse_token_string_t cmd_lfc_set_set =
6907 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6909 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6910 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6911 flow_ctrl, "flow_ctrl");
6912 cmdline_parse_token_string_t cmd_lfc_set_rx =
6913 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6915 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6916 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6917 rx_lfc_mode, "on#off");
6918 cmdline_parse_token_string_t cmd_lfc_set_tx =
6919 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6921 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6922 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6923 tx_lfc_mode, "on#off");
6924 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6925 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6926 hw_str, "high_water");
6927 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6928 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6929 high_water, UINT32);
6930 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6931 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6932 lw_str, "low_water");
6933 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6934 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6936 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6937 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6938 pt_str, "pause_time");
6939 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6940 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6941 pause_time, UINT16);
6942 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6943 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6944 xon_str, "send_xon");
6945 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6946 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6948 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6949 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6950 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6951 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6952 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6953 mac_ctrl_frame_fwd_mode, "on#off");
6954 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6955 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6956 autoneg_str, "autoneg");
6957 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6958 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6960 cmdline_parse_token_num_t cmd_lfc_set_portid =
6961 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6964 /* forward declaration */
6966 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6969 cmdline_parse_inst_t cmd_link_flow_control_set = {
6970 .f = cmd_link_flow_ctrl_set_parsed,
6972 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6973 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6974 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6976 (void *)&cmd_lfc_set_set,
6977 (void *)&cmd_lfc_set_flow_ctrl,
6978 (void *)&cmd_lfc_set_rx,
6979 (void *)&cmd_lfc_set_rx_mode,
6980 (void *)&cmd_lfc_set_tx,
6981 (void *)&cmd_lfc_set_tx_mode,
6982 (void *)&cmd_lfc_set_high_water,
6983 (void *)&cmd_lfc_set_low_water,
6984 (void *)&cmd_lfc_set_pause_time,
6985 (void *)&cmd_lfc_set_send_xon,
6986 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6987 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6988 (void *)&cmd_lfc_set_autoneg_str,
6989 (void *)&cmd_lfc_set_autoneg,
6990 (void *)&cmd_lfc_set_portid,
6995 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6996 .f = cmd_link_flow_ctrl_set_parsed,
6997 .data = (void *)&cmd_link_flow_control_set_rx,
6998 .help_str = "set flow_ctrl rx on|off <port_id>: "
6999 "Change rx flow control parameter",
7001 (void *)&cmd_lfc_set_set,
7002 (void *)&cmd_lfc_set_flow_ctrl,
7003 (void *)&cmd_lfc_set_rx,
7004 (void *)&cmd_lfc_set_rx_mode,
7005 (void *)&cmd_lfc_set_portid,
7010 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7011 .f = cmd_link_flow_ctrl_set_parsed,
7012 .data = (void *)&cmd_link_flow_control_set_tx,
7013 .help_str = "set flow_ctrl tx on|off <port_id>: "
7014 "Change tx flow control parameter",
7016 (void *)&cmd_lfc_set_set,
7017 (void *)&cmd_lfc_set_flow_ctrl,
7018 (void *)&cmd_lfc_set_tx,
7019 (void *)&cmd_lfc_set_tx_mode,
7020 (void *)&cmd_lfc_set_portid,
7025 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7026 .f = cmd_link_flow_ctrl_set_parsed,
7027 .data = (void *)&cmd_link_flow_control_set_hw,
7028 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7029 "Change high water flow control parameter",
7031 (void *)&cmd_lfc_set_set,
7032 (void *)&cmd_lfc_set_flow_ctrl,
7033 (void *)&cmd_lfc_set_high_water_str,
7034 (void *)&cmd_lfc_set_high_water,
7035 (void *)&cmd_lfc_set_portid,
7040 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7041 .f = cmd_link_flow_ctrl_set_parsed,
7042 .data = (void *)&cmd_link_flow_control_set_lw,
7043 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7044 "Change low water flow control parameter",
7046 (void *)&cmd_lfc_set_set,
7047 (void *)&cmd_lfc_set_flow_ctrl,
7048 (void *)&cmd_lfc_set_low_water_str,
7049 (void *)&cmd_lfc_set_low_water,
7050 (void *)&cmd_lfc_set_portid,
7055 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7056 .f = cmd_link_flow_ctrl_set_parsed,
7057 .data = (void *)&cmd_link_flow_control_set_pt,
7058 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7059 "Change pause time flow control parameter",
7061 (void *)&cmd_lfc_set_set,
7062 (void *)&cmd_lfc_set_flow_ctrl,
7063 (void *)&cmd_lfc_set_pause_time_str,
7064 (void *)&cmd_lfc_set_pause_time,
7065 (void *)&cmd_lfc_set_portid,
7070 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7071 .f = cmd_link_flow_ctrl_set_parsed,
7072 .data = (void *)&cmd_link_flow_control_set_xon,
7073 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7074 "Change send_xon flow control parameter",
7076 (void *)&cmd_lfc_set_set,
7077 (void *)&cmd_lfc_set_flow_ctrl,
7078 (void *)&cmd_lfc_set_send_xon_str,
7079 (void *)&cmd_lfc_set_send_xon,
7080 (void *)&cmd_lfc_set_portid,
7085 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7086 .f = cmd_link_flow_ctrl_set_parsed,
7087 .data = (void *)&cmd_link_flow_control_set_macfwd,
7088 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7089 "Change mac ctrl fwd flow control parameter",
7091 (void *)&cmd_lfc_set_set,
7092 (void *)&cmd_lfc_set_flow_ctrl,
7093 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7094 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7095 (void *)&cmd_lfc_set_portid,
7100 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7101 .f = cmd_link_flow_ctrl_set_parsed,
7102 .data = (void *)&cmd_link_flow_control_set_autoneg,
7103 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7104 "Change autoneg flow control parameter",
7106 (void *)&cmd_lfc_set_set,
7107 (void *)&cmd_lfc_set_flow_ctrl,
7108 (void *)&cmd_lfc_set_autoneg_str,
7109 (void *)&cmd_lfc_set_autoneg,
7110 (void *)&cmd_lfc_set_portid,
7116 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7117 __rte_unused struct cmdline *cl,
7120 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7121 cmdline_parse_inst_t *cmd = data;
7122 struct rte_eth_fc_conf fc_conf;
7128 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7129 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7130 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7131 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7133 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7134 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7137 /* Partial command line, retrieve current configuration */
7139 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7141 printf("cannot get current flow ctrl parameters, return"
7142 "code = %d\n", ret);
7146 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7147 (fc_conf.mode == RTE_FC_FULL))
7149 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7150 (fc_conf.mode == RTE_FC_FULL))
7154 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7155 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7157 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7158 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7160 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7162 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7163 fc_conf.high_water = res->high_water;
7165 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7166 fc_conf.low_water = res->low_water;
7168 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7169 fc_conf.pause_time = res->pause_time;
7171 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7172 fc_conf.send_xon = res->send_xon;
7174 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7175 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7176 fc_conf.mac_ctrl_frame_fwd = 1;
7178 fc_conf.mac_ctrl_frame_fwd = 0;
7181 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7182 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7184 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7186 printf("bad flow contrl parameter, return code = %d \n", ret);
7189 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7190 struct cmd_priority_flow_ctrl_set_result {
7191 cmdline_fixed_string_t set;
7192 cmdline_fixed_string_t pfc_ctrl;
7193 cmdline_fixed_string_t rx;
7194 cmdline_fixed_string_t rx_pfc_mode;
7195 cmdline_fixed_string_t tx;
7196 cmdline_fixed_string_t tx_pfc_mode;
7197 uint32_t high_water;
7199 uint16_t pause_time;
7205 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7206 __rte_unused struct cmdline *cl,
7207 __rte_unused void *data)
7209 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7210 struct rte_eth_pfc_conf pfc_conf;
7211 int rx_fc_enable, tx_fc_enable;
7215 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7216 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7217 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7218 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7220 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7221 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7224 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7225 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7226 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7227 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7228 pfc_conf.fc.high_water = res->high_water;
7229 pfc_conf.fc.low_water = res->low_water;
7230 pfc_conf.fc.pause_time = res->pause_time;
7231 pfc_conf.priority = res->priority;
7233 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7235 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7238 cmdline_parse_token_string_t cmd_pfc_set_set =
7239 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7241 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7242 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7243 pfc_ctrl, "pfc_ctrl");
7244 cmdline_parse_token_string_t cmd_pfc_set_rx =
7245 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7247 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7248 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7249 rx_pfc_mode, "on#off");
7250 cmdline_parse_token_string_t cmd_pfc_set_tx =
7251 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7253 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7254 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7255 tx_pfc_mode, "on#off");
7256 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7257 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7258 high_water, UINT32);
7259 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7260 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7262 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7263 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7264 pause_time, UINT16);
7265 cmdline_parse_token_num_t cmd_pfc_set_priority =
7266 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7268 cmdline_parse_token_num_t cmd_pfc_set_portid =
7269 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7272 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7273 .f = cmd_priority_flow_ctrl_set_parsed,
7275 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7276 "<pause_time> <priority> <port_id>: "
7277 "Configure the Ethernet priority flow control",
7279 (void *)&cmd_pfc_set_set,
7280 (void *)&cmd_pfc_set_flow_ctrl,
7281 (void *)&cmd_pfc_set_rx,
7282 (void *)&cmd_pfc_set_rx_mode,
7283 (void *)&cmd_pfc_set_tx,
7284 (void *)&cmd_pfc_set_tx_mode,
7285 (void *)&cmd_pfc_set_high_water,
7286 (void *)&cmd_pfc_set_low_water,
7287 (void *)&cmd_pfc_set_pause_time,
7288 (void *)&cmd_pfc_set_priority,
7289 (void *)&cmd_pfc_set_portid,
7294 /* *** RESET CONFIGURATION *** */
7295 struct cmd_reset_result {
7296 cmdline_fixed_string_t reset;
7297 cmdline_fixed_string_t def;
7300 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7302 __rte_unused void *data)
7304 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7305 set_def_fwd_config();
7308 cmdline_parse_token_string_t cmd_reset_set =
7309 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7310 cmdline_parse_token_string_t cmd_reset_def =
7311 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7314 cmdline_parse_inst_t cmd_reset = {
7315 .f = cmd_reset_parsed,
7317 .help_str = "set default: Reset default forwarding configuration",
7319 (void *)&cmd_reset_set,
7320 (void *)&cmd_reset_def,
7325 /* *** START FORWARDING *** */
7326 struct cmd_start_result {
7327 cmdline_fixed_string_t start;
7330 cmdline_parse_token_string_t cmd_start_start =
7331 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7333 static void cmd_start_parsed(__rte_unused void *parsed_result,
7334 __rte_unused struct cmdline *cl,
7335 __rte_unused void *data)
7337 start_packet_forwarding(0);
7340 cmdline_parse_inst_t cmd_start = {
7341 .f = cmd_start_parsed,
7343 .help_str = "start: Start packet forwarding",
7345 (void *)&cmd_start_start,
7350 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7351 struct cmd_start_tx_first_result {
7352 cmdline_fixed_string_t start;
7353 cmdline_fixed_string_t tx_first;
7357 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7358 __rte_unused struct cmdline *cl,
7359 __rte_unused void *data)
7361 start_packet_forwarding(1);
7364 cmdline_parse_token_string_t cmd_start_tx_first_start =
7365 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7367 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7368 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7369 tx_first, "tx_first");
7371 cmdline_parse_inst_t cmd_start_tx_first = {
7372 .f = cmd_start_tx_first_parsed,
7374 .help_str = "start tx_first: Start packet forwarding, "
7375 "after sending 1 burst of packets",
7377 (void *)&cmd_start_tx_first_start,
7378 (void *)&cmd_start_tx_first_tx_first,
7383 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7384 struct cmd_start_tx_first_n_result {
7385 cmdline_fixed_string_t start;
7386 cmdline_fixed_string_t tx_first;
7391 cmd_start_tx_first_n_parsed(void *parsed_result,
7392 __rte_unused struct cmdline *cl,
7393 __rte_unused void *data)
7395 struct cmd_start_tx_first_n_result *res = parsed_result;
7397 start_packet_forwarding(res->tx_num);
7400 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7401 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7403 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7404 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7405 tx_first, "tx_first");
7406 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7407 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7410 cmdline_parse_inst_t cmd_start_tx_first_n = {
7411 .f = cmd_start_tx_first_n_parsed,
7413 .help_str = "start tx_first <num>: "
7414 "packet forwarding, after sending <num> bursts of packets",
7416 (void *)&cmd_start_tx_first_n_start,
7417 (void *)&cmd_start_tx_first_n_tx_first,
7418 (void *)&cmd_start_tx_first_n_tx_num,
7423 /* *** SET LINK UP *** */
7424 struct cmd_set_link_up_result {
7425 cmdline_fixed_string_t set;
7426 cmdline_fixed_string_t link_up;
7427 cmdline_fixed_string_t port;
7431 cmdline_parse_token_string_t cmd_set_link_up_set =
7432 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7433 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7434 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7436 cmdline_parse_token_string_t cmd_set_link_up_port =
7437 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7438 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7439 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7441 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7442 __rte_unused struct cmdline *cl,
7443 __rte_unused void *data)
7445 struct cmd_set_link_up_result *res = parsed_result;
7446 dev_set_link_up(res->port_id);
7449 cmdline_parse_inst_t cmd_set_link_up = {
7450 .f = cmd_set_link_up_parsed,
7452 .help_str = "set link-up port <port id>",
7454 (void *)&cmd_set_link_up_set,
7455 (void *)&cmd_set_link_up_link_up,
7456 (void *)&cmd_set_link_up_port,
7457 (void *)&cmd_set_link_up_port_id,
7462 /* *** SET LINK DOWN *** */
7463 struct cmd_set_link_down_result {
7464 cmdline_fixed_string_t set;
7465 cmdline_fixed_string_t link_down;
7466 cmdline_fixed_string_t port;
7470 cmdline_parse_token_string_t cmd_set_link_down_set =
7471 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7472 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7473 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7475 cmdline_parse_token_string_t cmd_set_link_down_port =
7476 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7477 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7478 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7480 static void cmd_set_link_down_parsed(
7481 __rte_unused void *parsed_result,
7482 __rte_unused struct cmdline *cl,
7483 __rte_unused void *data)
7485 struct cmd_set_link_down_result *res = parsed_result;
7486 dev_set_link_down(res->port_id);
7489 cmdline_parse_inst_t cmd_set_link_down = {
7490 .f = cmd_set_link_down_parsed,
7492 .help_str = "set link-down port <port id>",
7494 (void *)&cmd_set_link_down_set,
7495 (void *)&cmd_set_link_down_link_down,
7496 (void *)&cmd_set_link_down_port,
7497 (void *)&cmd_set_link_down_port_id,
7502 /* *** SHOW CFG *** */
7503 struct cmd_showcfg_result {
7504 cmdline_fixed_string_t show;
7505 cmdline_fixed_string_t cfg;
7506 cmdline_fixed_string_t what;
7509 static void cmd_showcfg_parsed(void *parsed_result,
7510 __rte_unused struct cmdline *cl,
7511 __rte_unused void *data)
7513 struct cmd_showcfg_result *res = parsed_result;
7514 if (!strcmp(res->what, "rxtx"))
7515 rxtx_config_display();
7516 else if (!strcmp(res->what, "cores"))
7517 fwd_lcores_config_display();
7518 else if (!strcmp(res->what, "fwd"))
7519 pkt_fwd_config_display(&cur_fwd_config);
7520 else if (!strcmp(res->what, "txpkts"))
7521 show_tx_pkt_segments();
7522 else if (!strcmp(res->what, "txtimes"))
7523 show_tx_pkt_times();
7526 cmdline_parse_token_string_t cmd_showcfg_show =
7527 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7528 cmdline_parse_token_string_t cmd_showcfg_port =
7529 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7530 cmdline_parse_token_string_t cmd_showcfg_what =
7531 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7532 "rxtx#cores#fwd#txpkts#txtimes");
7534 cmdline_parse_inst_t cmd_showcfg = {
7535 .f = cmd_showcfg_parsed,
7537 .help_str = "show config rxtx|cores|fwd|txpkts|txtimes",
7539 (void *)&cmd_showcfg_show,
7540 (void *)&cmd_showcfg_port,
7541 (void *)&cmd_showcfg_what,
7546 /* *** SHOW ALL PORT INFO *** */
7547 struct cmd_showportall_result {
7548 cmdline_fixed_string_t show;
7549 cmdline_fixed_string_t port;
7550 cmdline_fixed_string_t what;
7551 cmdline_fixed_string_t all;
7554 static void cmd_showportall_parsed(void *parsed_result,
7555 __rte_unused struct cmdline *cl,
7556 __rte_unused void *data)
7560 struct cmd_showportall_result *res = parsed_result;
7561 if (!strcmp(res->show, "clear")) {
7562 if (!strcmp(res->what, "stats"))
7563 RTE_ETH_FOREACH_DEV(i)
7565 else if (!strcmp(res->what, "xstats"))
7566 RTE_ETH_FOREACH_DEV(i)
7567 nic_xstats_clear(i);
7568 } else if (!strcmp(res->what, "info"))
7569 RTE_ETH_FOREACH_DEV(i)
7570 port_infos_display(i);
7571 else if (!strcmp(res->what, "summary")) {
7572 port_summary_header_display();
7573 RTE_ETH_FOREACH_DEV(i)
7574 port_summary_display(i);
7576 else if (!strcmp(res->what, "stats"))
7577 RTE_ETH_FOREACH_DEV(i)
7578 nic_stats_display(i);
7579 else if (!strcmp(res->what, "xstats"))
7580 RTE_ETH_FOREACH_DEV(i)
7581 nic_xstats_display(i);
7582 else if (!strcmp(res->what, "fdir"))
7583 RTE_ETH_FOREACH_DEV(i)
7585 else if (!strcmp(res->what, "stat_qmap"))
7586 RTE_ETH_FOREACH_DEV(i)
7587 nic_stats_mapping_display(i);
7588 else if (!strcmp(res->what, "dcb_tc"))
7589 RTE_ETH_FOREACH_DEV(i)
7590 port_dcb_info_display(i);
7591 else if (!strcmp(res->what, "cap"))
7592 RTE_ETH_FOREACH_DEV(i)
7593 port_offload_cap_display(i);
7596 cmdline_parse_token_string_t cmd_showportall_show =
7597 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7599 cmdline_parse_token_string_t cmd_showportall_port =
7600 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7601 cmdline_parse_token_string_t cmd_showportall_what =
7602 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7603 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7604 cmdline_parse_token_string_t cmd_showportall_all =
7605 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7606 cmdline_parse_inst_t cmd_showportall = {
7607 .f = cmd_showportall_parsed,
7609 .help_str = "show|clear port "
7610 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7612 (void *)&cmd_showportall_show,
7613 (void *)&cmd_showportall_port,
7614 (void *)&cmd_showportall_what,
7615 (void *)&cmd_showportall_all,
7620 /* *** SHOW PORT INFO *** */
7621 struct cmd_showport_result {
7622 cmdline_fixed_string_t show;
7623 cmdline_fixed_string_t port;
7624 cmdline_fixed_string_t what;
7628 static void cmd_showport_parsed(void *parsed_result,
7629 __rte_unused struct cmdline *cl,
7630 __rte_unused void *data)
7632 struct cmd_showport_result *res = parsed_result;
7633 if (!strcmp(res->show, "clear")) {
7634 if (!strcmp(res->what, "stats"))
7635 nic_stats_clear(res->portnum);
7636 else if (!strcmp(res->what, "xstats"))
7637 nic_xstats_clear(res->portnum);
7638 } else if (!strcmp(res->what, "info"))
7639 port_infos_display(res->portnum);
7640 else if (!strcmp(res->what, "summary")) {
7641 port_summary_header_display();
7642 port_summary_display(res->portnum);
7644 else if (!strcmp(res->what, "stats"))
7645 nic_stats_display(res->portnum);
7646 else if (!strcmp(res->what, "xstats"))
7647 nic_xstats_display(res->portnum);
7648 else if (!strcmp(res->what, "fdir"))
7649 fdir_get_infos(res->portnum);
7650 else if (!strcmp(res->what, "stat_qmap"))
7651 nic_stats_mapping_display(res->portnum);
7652 else if (!strcmp(res->what, "dcb_tc"))
7653 port_dcb_info_display(res->portnum);
7654 else if (!strcmp(res->what, "cap"))
7655 port_offload_cap_display(res->portnum);
7658 cmdline_parse_token_string_t cmd_showport_show =
7659 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7661 cmdline_parse_token_string_t cmd_showport_port =
7662 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7663 cmdline_parse_token_string_t cmd_showport_what =
7664 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7665 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7666 cmdline_parse_token_num_t cmd_showport_portnum =
7667 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7669 cmdline_parse_inst_t cmd_showport = {
7670 .f = cmd_showport_parsed,
7672 .help_str = "show|clear port "
7673 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7676 (void *)&cmd_showport_show,
7677 (void *)&cmd_showport_port,
7678 (void *)&cmd_showport_what,
7679 (void *)&cmd_showport_portnum,
7684 /* *** SHOW DEVICE INFO *** */
7685 struct cmd_showdevice_result {
7686 cmdline_fixed_string_t show;
7687 cmdline_fixed_string_t device;
7688 cmdline_fixed_string_t what;
7689 cmdline_fixed_string_t identifier;
7692 static void cmd_showdevice_parsed(void *parsed_result,
7693 __rte_unused struct cmdline *cl,
7694 __rte_unused void *data)
7696 struct cmd_showdevice_result *res = parsed_result;
7697 if (!strcmp(res->what, "info")) {
7698 if (!strcmp(res->identifier, "all"))
7699 device_infos_display(NULL);
7701 device_infos_display(res->identifier);
7705 cmdline_parse_token_string_t cmd_showdevice_show =
7706 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7708 cmdline_parse_token_string_t cmd_showdevice_device =
7709 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7710 cmdline_parse_token_string_t cmd_showdevice_what =
7711 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7713 cmdline_parse_token_string_t cmd_showdevice_identifier =
7714 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7717 cmdline_parse_inst_t cmd_showdevice = {
7718 .f = cmd_showdevice_parsed,
7720 .help_str = "show device info <identifier>|all",
7722 (void *)&cmd_showdevice_show,
7723 (void *)&cmd_showdevice_device,
7724 (void *)&cmd_showdevice_what,
7725 (void *)&cmd_showdevice_identifier,
7730 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7731 struct cmd_showeeprom_result {
7732 cmdline_fixed_string_t show;
7733 cmdline_fixed_string_t port;
7735 cmdline_fixed_string_t type;
7738 static void cmd_showeeprom_parsed(void *parsed_result,
7739 __rte_unused struct cmdline *cl,
7740 __rte_unused void *data)
7742 struct cmd_showeeprom_result *res = parsed_result;
7744 if (!strcmp(res->type, "eeprom"))
7745 port_eeprom_display(res->portnum);
7746 else if (!strcmp(res->type, "module_eeprom"))
7747 port_module_eeprom_display(res->portnum);
7749 printf("Unknown argument\n");
7752 cmdline_parse_token_string_t cmd_showeeprom_show =
7753 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7754 cmdline_parse_token_string_t cmd_showeeprom_port =
7755 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7756 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7757 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum, UINT16);
7758 cmdline_parse_token_string_t cmd_showeeprom_type =
7759 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7761 cmdline_parse_inst_t cmd_showeeprom = {
7762 .f = cmd_showeeprom_parsed,
7764 .help_str = "show port <port_id> module_eeprom|eeprom",
7766 (void *)&cmd_showeeprom_show,
7767 (void *)&cmd_showeeprom_port,
7768 (void *)&cmd_showeeprom_portnum,
7769 (void *)&cmd_showeeprom_type,
7774 /* *** SHOW QUEUE INFO *** */
7775 struct cmd_showqueue_result {
7776 cmdline_fixed_string_t show;
7777 cmdline_fixed_string_t type;
7778 cmdline_fixed_string_t what;
7784 cmd_showqueue_parsed(void *parsed_result,
7785 __rte_unused struct cmdline *cl,
7786 __rte_unused void *data)
7788 struct cmd_showqueue_result *res = parsed_result;
7790 if (!strcmp(res->type, "rxq"))
7791 rx_queue_infos_display(res->portnum, res->queuenum);
7792 else if (!strcmp(res->type, "txq"))
7793 tx_queue_infos_display(res->portnum, res->queuenum);
7796 cmdline_parse_token_string_t cmd_showqueue_show =
7797 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7798 cmdline_parse_token_string_t cmd_showqueue_type =
7799 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7800 cmdline_parse_token_string_t cmd_showqueue_what =
7801 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7802 cmdline_parse_token_num_t cmd_showqueue_portnum =
7803 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7804 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7805 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7807 cmdline_parse_inst_t cmd_showqueue = {
7808 .f = cmd_showqueue_parsed,
7810 .help_str = "show rxq|txq info <port_id> <queue_id>",
7812 (void *)&cmd_showqueue_show,
7813 (void *)&cmd_showqueue_type,
7814 (void *)&cmd_showqueue_what,
7815 (void *)&cmd_showqueue_portnum,
7816 (void *)&cmd_showqueue_queuenum,
7821 /* show/clear fwd engine statistics */
7823 cmdline_fixed_string_t action;
7824 cmdline_fixed_string_t fwd;
7825 cmdline_fixed_string_t stats;
7826 cmdline_fixed_string_t all;
7829 cmdline_parse_token_string_t cmd_fwd_action =
7830 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7831 cmdline_parse_token_string_t cmd_fwd_fwd =
7832 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7833 cmdline_parse_token_string_t cmd_fwd_stats =
7834 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7835 cmdline_parse_token_string_t cmd_fwd_all =
7836 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7839 cmd_showfwdall_parsed(void *parsed_result,
7840 __rte_unused struct cmdline *cl,
7841 __rte_unused void *data)
7843 struct fwd_result *res = parsed_result;
7845 if (!strcmp(res->action, "show"))
7846 fwd_stats_display();
7851 static cmdline_parse_inst_t cmd_showfwdall = {
7852 .f = cmd_showfwdall_parsed,
7854 .help_str = "show|clear fwd stats all",
7856 (void *)&cmd_fwd_action,
7857 (void *)&cmd_fwd_fwd,
7858 (void *)&cmd_fwd_stats,
7859 (void *)&cmd_fwd_all,
7864 /* *** READ PORT REGISTER *** */
7865 struct cmd_read_reg_result {
7866 cmdline_fixed_string_t read;
7867 cmdline_fixed_string_t reg;
7873 cmd_read_reg_parsed(void *parsed_result,
7874 __rte_unused struct cmdline *cl,
7875 __rte_unused void *data)
7877 struct cmd_read_reg_result *res = parsed_result;
7878 port_reg_display(res->port_id, res->reg_off);
7881 cmdline_parse_token_string_t cmd_read_reg_read =
7882 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7883 cmdline_parse_token_string_t cmd_read_reg_reg =
7884 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7885 cmdline_parse_token_num_t cmd_read_reg_port_id =
7886 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7887 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7888 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7890 cmdline_parse_inst_t cmd_read_reg = {
7891 .f = cmd_read_reg_parsed,
7893 .help_str = "read reg <port_id> <reg_off>",
7895 (void *)&cmd_read_reg_read,
7896 (void *)&cmd_read_reg_reg,
7897 (void *)&cmd_read_reg_port_id,
7898 (void *)&cmd_read_reg_reg_off,
7903 /* *** READ PORT REGISTER BIT FIELD *** */
7904 struct cmd_read_reg_bit_field_result {
7905 cmdline_fixed_string_t read;
7906 cmdline_fixed_string_t regfield;
7914 cmd_read_reg_bit_field_parsed(void *parsed_result,
7915 __rte_unused struct cmdline *cl,
7916 __rte_unused void *data)
7918 struct cmd_read_reg_bit_field_result *res = parsed_result;
7919 port_reg_bit_field_display(res->port_id, res->reg_off,
7920 res->bit1_pos, res->bit2_pos);
7923 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7924 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7926 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7927 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7928 regfield, "regfield");
7929 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7930 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7932 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7933 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7935 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7936 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7938 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7939 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7942 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7943 .f = cmd_read_reg_bit_field_parsed,
7945 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7946 "Read register bit field between bit_x and bit_y included",
7948 (void *)&cmd_read_reg_bit_field_read,
7949 (void *)&cmd_read_reg_bit_field_regfield,
7950 (void *)&cmd_read_reg_bit_field_port_id,
7951 (void *)&cmd_read_reg_bit_field_reg_off,
7952 (void *)&cmd_read_reg_bit_field_bit1_pos,
7953 (void *)&cmd_read_reg_bit_field_bit2_pos,
7958 /* *** READ PORT REGISTER BIT *** */
7959 struct cmd_read_reg_bit_result {
7960 cmdline_fixed_string_t read;
7961 cmdline_fixed_string_t regbit;
7968 cmd_read_reg_bit_parsed(void *parsed_result,
7969 __rte_unused struct cmdline *cl,
7970 __rte_unused void *data)
7972 struct cmd_read_reg_bit_result *res = parsed_result;
7973 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7976 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7977 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7978 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7979 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7981 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7982 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7983 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7984 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7985 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7986 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7988 cmdline_parse_inst_t cmd_read_reg_bit = {
7989 .f = cmd_read_reg_bit_parsed,
7991 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7993 (void *)&cmd_read_reg_bit_read,
7994 (void *)&cmd_read_reg_bit_regbit,
7995 (void *)&cmd_read_reg_bit_port_id,
7996 (void *)&cmd_read_reg_bit_reg_off,
7997 (void *)&cmd_read_reg_bit_bit_pos,
8002 /* *** WRITE PORT REGISTER *** */
8003 struct cmd_write_reg_result {
8004 cmdline_fixed_string_t write;
8005 cmdline_fixed_string_t reg;
8012 cmd_write_reg_parsed(void *parsed_result,
8013 __rte_unused struct cmdline *cl,
8014 __rte_unused void *data)
8016 struct cmd_write_reg_result *res = parsed_result;
8017 port_reg_set(res->port_id, res->reg_off, res->value);
8020 cmdline_parse_token_string_t cmd_write_reg_write =
8021 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8022 cmdline_parse_token_string_t cmd_write_reg_reg =
8023 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8024 cmdline_parse_token_num_t cmd_write_reg_port_id =
8025 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
8026 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8027 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
8028 cmdline_parse_token_num_t cmd_write_reg_value =
8029 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
8031 cmdline_parse_inst_t cmd_write_reg = {
8032 .f = cmd_write_reg_parsed,
8034 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8036 (void *)&cmd_write_reg_write,
8037 (void *)&cmd_write_reg_reg,
8038 (void *)&cmd_write_reg_port_id,
8039 (void *)&cmd_write_reg_reg_off,
8040 (void *)&cmd_write_reg_value,
8045 /* *** WRITE PORT REGISTER BIT FIELD *** */
8046 struct cmd_write_reg_bit_field_result {
8047 cmdline_fixed_string_t write;
8048 cmdline_fixed_string_t regfield;
8057 cmd_write_reg_bit_field_parsed(void *parsed_result,
8058 __rte_unused struct cmdline *cl,
8059 __rte_unused void *data)
8061 struct cmd_write_reg_bit_field_result *res = parsed_result;
8062 port_reg_bit_field_set(res->port_id, res->reg_off,
8063 res->bit1_pos, res->bit2_pos, res->value);
8066 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8067 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8069 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8070 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8071 regfield, "regfield");
8072 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8073 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8075 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8076 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8078 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8079 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8081 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8082 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8084 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8085 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8088 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8089 .f = cmd_write_reg_bit_field_parsed,
8091 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8093 "Set register bit field between bit_x and bit_y included",
8095 (void *)&cmd_write_reg_bit_field_write,
8096 (void *)&cmd_write_reg_bit_field_regfield,
8097 (void *)&cmd_write_reg_bit_field_port_id,
8098 (void *)&cmd_write_reg_bit_field_reg_off,
8099 (void *)&cmd_write_reg_bit_field_bit1_pos,
8100 (void *)&cmd_write_reg_bit_field_bit2_pos,
8101 (void *)&cmd_write_reg_bit_field_value,
8106 /* *** WRITE PORT REGISTER BIT *** */
8107 struct cmd_write_reg_bit_result {
8108 cmdline_fixed_string_t write;
8109 cmdline_fixed_string_t regbit;
8117 cmd_write_reg_bit_parsed(void *parsed_result,
8118 __rte_unused struct cmdline *cl,
8119 __rte_unused void *data)
8121 struct cmd_write_reg_bit_result *res = parsed_result;
8122 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8125 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8126 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8128 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8129 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8131 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8132 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
8133 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8134 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
8135 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8136 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
8137 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8138 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
8140 cmdline_parse_inst_t cmd_write_reg_bit = {
8141 .f = cmd_write_reg_bit_parsed,
8143 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8146 (void *)&cmd_write_reg_bit_write,
8147 (void *)&cmd_write_reg_bit_regbit,
8148 (void *)&cmd_write_reg_bit_port_id,
8149 (void *)&cmd_write_reg_bit_reg_off,
8150 (void *)&cmd_write_reg_bit_bit_pos,
8151 (void *)&cmd_write_reg_bit_value,
8156 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8157 struct cmd_read_rxd_txd_result {
8158 cmdline_fixed_string_t read;
8159 cmdline_fixed_string_t rxd_txd;
8166 cmd_read_rxd_txd_parsed(void *parsed_result,
8167 __rte_unused struct cmdline *cl,
8168 __rte_unused void *data)
8170 struct cmd_read_rxd_txd_result *res = parsed_result;
8172 if (!strcmp(res->rxd_txd, "rxd"))
8173 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8174 else if (!strcmp(res->rxd_txd, "txd"))
8175 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8178 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8179 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8180 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8181 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8183 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8184 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8185 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8186 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8187 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8188 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8190 cmdline_parse_inst_t cmd_read_rxd_txd = {
8191 .f = cmd_read_rxd_txd_parsed,
8193 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8195 (void *)&cmd_read_rxd_txd_read,
8196 (void *)&cmd_read_rxd_txd_rxd_txd,
8197 (void *)&cmd_read_rxd_txd_port_id,
8198 (void *)&cmd_read_rxd_txd_queue_id,
8199 (void *)&cmd_read_rxd_txd_desc_id,
8205 struct cmd_quit_result {
8206 cmdline_fixed_string_t quit;
8209 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8211 __rte_unused void *data)
8216 cmdline_parse_token_string_t cmd_quit_quit =
8217 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8219 cmdline_parse_inst_t cmd_quit = {
8220 .f = cmd_quit_parsed,
8222 .help_str = "quit: Exit application",
8224 (void *)&cmd_quit_quit,
8229 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8230 struct cmd_mac_addr_result {
8231 cmdline_fixed_string_t mac_addr_cmd;
8232 cmdline_fixed_string_t what;
8234 struct rte_ether_addr address;
8237 static void cmd_mac_addr_parsed(void *parsed_result,
8238 __rte_unused struct cmdline *cl,
8239 __rte_unused void *data)
8241 struct cmd_mac_addr_result *res = parsed_result;
8244 if (strcmp(res->what, "add") == 0)
8245 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8246 else if (strcmp(res->what, "set") == 0)
8247 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8250 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8252 /* check the return value and print it if is < 0 */
8254 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8258 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8259 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8261 cmdline_parse_token_string_t cmd_mac_addr_what =
8262 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8264 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8265 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8267 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8268 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8270 cmdline_parse_inst_t cmd_mac_addr = {
8271 .f = cmd_mac_addr_parsed,
8273 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8274 "Add/Remove/Set MAC address on port_id",
8276 (void *)&cmd_mac_addr_cmd,
8277 (void *)&cmd_mac_addr_what,
8278 (void *)&cmd_mac_addr_portnum,
8279 (void *)&cmd_mac_addr_addr,
8284 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8285 struct cmd_eth_peer_result {
8286 cmdline_fixed_string_t set;
8287 cmdline_fixed_string_t eth_peer;
8289 cmdline_fixed_string_t peer_addr;
8292 static void cmd_set_eth_peer_parsed(void *parsed_result,
8293 __rte_unused struct cmdline *cl,
8294 __rte_unused void *data)
8296 struct cmd_eth_peer_result *res = parsed_result;
8298 if (test_done == 0) {
8299 printf("Please stop forwarding first\n");
8302 if (!strcmp(res->eth_peer, "eth-peer")) {
8303 set_fwd_eth_peer(res->port_id, res->peer_addr);
8307 cmdline_parse_token_string_t cmd_eth_peer_set =
8308 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8309 cmdline_parse_token_string_t cmd_eth_peer =
8310 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8311 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8312 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8313 cmdline_parse_token_string_t cmd_eth_peer_addr =
8314 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8316 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8317 .f = cmd_set_eth_peer_parsed,
8319 .help_str = "set eth-peer <port_id> <peer_mac>",
8321 (void *)&cmd_eth_peer_set,
8322 (void *)&cmd_eth_peer,
8323 (void *)&cmd_eth_peer_port_id,
8324 (void *)&cmd_eth_peer_addr,
8329 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8330 struct cmd_set_qmap_result {
8331 cmdline_fixed_string_t set;
8332 cmdline_fixed_string_t qmap;
8333 cmdline_fixed_string_t what;
8340 cmd_set_qmap_parsed(void *parsed_result,
8341 __rte_unused struct cmdline *cl,
8342 __rte_unused void *data)
8344 struct cmd_set_qmap_result *res = parsed_result;
8345 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8347 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8350 cmdline_parse_token_string_t cmd_setqmap_set =
8351 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8353 cmdline_parse_token_string_t cmd_setqmap_qmap =
8354 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8356 cmdline_parse_token_string_t cmd_setqmap_what =
8357 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8359 cmdline_parse_token_num_t cmd_setqmap_portid =
8360 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8362 cmdline_parse_token_num_t cmd_setqmap_queueid =
8363 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8365 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8366 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8369 cmdline_parse_inst_t cmd_set_qmap = {
8370 .f = cmd_set_qmap_parsed,
8372 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8373 "Set statistics mapping value on tx|rx queue_id of port_id",
8375 (void *)&cmd_setqmap_set,
8376 (void *)&cmd_setqmap_qmap,
8377 (void *)&cmd_setqmap_what,
8378 (void *)&cmd_setqmap_portid,
8379 (void *)&cmd_setqmap_queueid,
8380 (void *)&cmd_setqmap_mapvalue,
8385 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8386 struct cmd_set_xstats_hide_zero_result {
8387 cmdline_fixed_string_t keyword;
8388 cmdline_fixed_string_t name;
8389 cmdline_fixed_string_t on_off;
8393 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8394 __rte_unused struct cmdline *cl,
8395 __rte_unused void *data)
8397 struct cmd_set_xstats_hide_zero_result *res;
8398 uint16_t on_off = 0;
8400 res = parsed_result;
8401 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8402 set_xstats_hide_zero(on_off);
8405 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8406 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8408 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8409 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8410 name, "xstats-hide-zero");
8411 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8412 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8415 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8416 .f = cmd_set_xstats_hide_zero_parsed,
8418 .help_str = "set xstats-hide-zero on|off",
8420 (void *)&cmd_set_xstats_hide_zero_keyword,
8421 (void *)&cmd_set_xstats_hide_zero_name,
8422 (void *)&cmd_set_xstats_hide_zero_on_off,
8427 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8428 struct cmd_set_record_core_cycles_result {
8429 cmdline_fixed_string_t keyword;
8430 cmdline_fixed_string_t name;
8431 cmdline_fixed_string_t on_off;
8435 cmd_set_record_core_cycles_parsed(void *parsed_result,
8436 __rte_unused struct cmdline *cl,
8437 __rte_unused void *data)
8439 struct cmd_set_record_core_cycles_result *res;
8440 uint16_t on_off = 0;
8442 res = parsed_result;
8443 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8444 set_record_core_cycles(on_off);
8447 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8448 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8450 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8451 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8452 name, "record-core-cycles");
8453 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8454 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8457 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8458 .f = cmd_set_record_core_cycles_parsed,
8460 .help_str = "set record-core-cycles on|off",
8462 (void *)&cmd_set_record_core_cycles_keyword,
8463 (void *)&cmd_set_record_core_cycles_name,
8464 (void *)&cmd_set_record_core_cycles_on_off,
8469 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8470 struct cmd_set_record_burst_stats_result {
8471 cmdline_fixed_string_t keyword;
8472 cmdline_fixed_string_t name;
8473 cmdline_fixed_string_t on_off;
8477 cmd_set_record_burst_stats_parsed(void *parsed_result,
8478 __rte_unused struct cmdline *cl,
8479 __rte_unused void *data)
8481 struct cmd_set_record_burst_stats_result *res;
8482 uint16_t on_off = 0;
8484 res = parsed_result;
8485 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8486 set_record_burst_stats(on_off);
8489 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8490 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8492 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8493 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8494 name, "record-burst-stats");
8495 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8496 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8499 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8500 .f = cmd_set_record_burst_stats_parsed,
8502 .help_str = "set record-burst-stats on|off",
8504 (void *)&cmd_set_record_burst_stats_keyword,
8505 (void *)&cmd_set_record_burst_stats_name,
8506 (void *)&cmd_set_record_burst_stats_on_off,
8511 /* *** CONFIGURE UNICAST HASH TABLE *** */
8512 struct cmd_set_uc_hash_table {
8513 cmdline_fixed_string_t set;
8514 cmdline_fixed_string_t port;
8516 cmdline_fixed_string_t what;
8517 struct rte_ether_addr address;
8518 cmdline_fixed_string_t mode;
8522 cmd_set_uc_hash_parsed(void *parsed_result,
8523 __rte_unused struct cmdline *cl,
8524 __rte_unused void *data)
8527 struct cmd_set_uc_hash_table *res = parsed_result;
8529 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8531 if (strcmp(res->what, "uta") == 0)
8532 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8533 &res->address,(uint8_t)is_on);
8535 printf("bad unicast hash table parameter, return code = %d \n", ret);
8539 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8540 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8542 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8543 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8545 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8546 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8548 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8549 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8551 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8552 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8554 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8555 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8558 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8559 .f = cmd_set_uc_hash_parsed,
8561 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8563 (void *)&cmd_set_uc_hash_set,
8564 (void *)&cmd_set_uc_hash_port,
8565 (void *)&cmd_set_uc_hash_portid,
8566 (void *)&cmd_set_uc_hash_what,
8567 (void *)&cmd_set_uc_hash_mac,
8568 (void *)&cmd_set_uc_hash_mode,
8573 struct cmd_set_uc_all_hash_table {
8574 cmdline_fixed_string_t set;
8575 cmdline_fixed_string_t port;
8577 cmdline_fixed_string_t what;
8578 cmdline_fixed_string_t value;
8579 cmdline_fixed_string_t mode;
8583 cmd_set_uc_all_hash_parsed(void *parsed_result,
8584 __rte_unused struct cmdline *cl,
8585 __rte_unused void *data)
8588 struct cmd_set_uc_all_hash_table *res = parsed_result;
8590 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8592 if ((strcmp(res->what, "uta") == 0) &&
8593 (strcmp(res->value, "all") == 0))
8594 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8596 printf("bad unicast hash table parameter,"
8597 "return code = %d \n", ret);
8600 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8601 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8603 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8604 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8606 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8607 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8609 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8610 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8612 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8613 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8615 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8616 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8619 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8620 .f = cmd_set_uc_all_hash_parsed,
8622 .help_str = "set port <port_id> uta all on|off",
8624 (void *)&cmd_set_uc_all_hash_set,
8625 (void *)&cmd_set_uc_all_hash_port,
8626 (void *)&cmd_set_uc_all_hash_portid,
8627 (void *)&cmd_set_uc_all_hash_what,
8628 (void *)&cmd_set_uc_all_hash_value,
8629 (void *)&cmd_set_uc_all_hash_mode,
8634 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8635 struct cmd_set_vf_macvlan_filter {
8636 cmdline_fixed_string_t set;
8637 cmdline_fixed_string_t port;
8639 cmdline_fixed_string_t vf;
8641 struct rte_ether_addr address;
8642 cmdline_fixed_string_t filter_type;
8643 cmdline_fixed_string_t mode;
8647 cmd_set_vf_macvlan_parsed(void *parsed_result,
8648 __rte_unused struct cmdline *cl,
8649 __rte_unused void *data)
8652 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8653 struct rte_eth_mac_filter filter;
8655 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8657 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8659 /* set VF MAC filter */
8663 filter.dst_id = res->vf_id;
8665 if (!strcmp(res->filter_type, "exact-mac"))
8666 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8667 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8668 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8669 else if (!strcmp(res->filter_type, "hashmac"))
8670 filter.filter_type = RTE_MAC_HASH_MATCH;
8671 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8672 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8674 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8677 ret = rte_eth_dev_filter_ctrl(res->port_id,
8678 RTE_ETH_FILTER_MACVLAN,
8682 ret = rte_eth_dev_filter_ctrl(res->port_id,
8683 RTE_ETH_FILTER_MACVLAN,
8684 RTE_ETH_FILTER_DELETE,
8688 printf("bad set MAC hash parameter, return code = %d\n", ret);
8692 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8693 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8695 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8696 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8698 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8699 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8701 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8702 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8704 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8705 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8707 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8708 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8710 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8711 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8712 filter_type, "exact-mac#exact-mac-vlan"
8713 "#hashmac#hashmac-vlan");
8714 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8715 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8718 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8719 .f = cmd_set_vf_macvlan_parsed,
8721 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8722 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8723 "Exact match rule: exact match of MAC or MAC and VLAN; "
8724 "hash match rule: hash match of MAC and exact match of VLAN",
8726 (void *)&cmd_set_vf_macvlan_set,
8727 (void *)&cmd_set_vf_macvlan_port,
8728 (void *)&cmd_set_vf_macvlan_portid,
8729 (void *)&cmd_set_vf_macvlan_vf,
8730 (void *)&cmd_set_vf_macvlan_vf_id,
8731 (void *)&cmd_set_vf_macvlan_mac,
8732 (void *)&cmd_set_vf_macvlan_filter_type,
8733 (void *)&cmd_set_vf_macvlan_mode,
8738 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8739 struct cmd_set_vf_traffic {
8740 cmdline_fixed_string_t set;
8741 cmdline_fixed_string_t port;
8743 cmdline_fixed_string_t vf;
8745 cmdline_fixed_string_t what;
8746 cmdline_fixed_string_t mode;
8750 cmd_set_vf_traffic_parsed(void *parsed_result,
8751 __rte_unused struct cmdline *cl,
8752 __rte_unused void *data)
8754 struct cmd_set_vf_traffic *res = parsed_result;
8755 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8756 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8758 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8761 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8762 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8764 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8765 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8767 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8768 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8770 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8771 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8773 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8774 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8776 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8777 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8779 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8780 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8783 cmdline_parse_inst_t cmd_set_vf_traffic = {
8784 .f = cmd_set_vf_traffic_parsed,
8786 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8788 (void *)&cmd_setvf_traffic_set,
8789 (void *)&cmd_setvf_traffic_port,
8790 (void *)&cmd_setvf_traffic_portid,
8791 (void *)&cmd_setvf_traffic_vf,
8792 (void *)&cmd_setvf_traffic_vfid,
8793 (void *)&cmd_setvf_traffic_what,
8794 (void *)&cmd_setvf_traffic_mode,
8799 /* *** CONFIGURE VF RECEIVE MODE *** */
8800 struct cmd_set_vf_rxmode {
8801 cmdline_fixed_string_t set;
8802 cmdline_fixed_string_t port;
8804 cmdline_fixed_string_t vf;
8806 cmdline_fixed_string_t what;
8807 cmdline_fixed_string_t mode;
8808 cmdline_fixed_string_t on;
8812 cmd_set_vf_rxmode_parsed(void *parsed_result,
8813 __rte_unused struct cmdline *cl,
8814 __rte_unused void *data)
8817 uint16_t vf_rxmode = 0;
8818 struct cmd_set_vf_rxmode *res = parsed_result;
8820 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8821 if (!strcmp(res->what,"rxmode")) {
8822 if (!strcmp(res->mode, "AUPE"))
8823 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8824 else if (!strcmp(res->mode, "ROPE"))
8825 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8826 else if (!strcmp(res->mode, "BAM"))
8827 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8828 else if (!strncmp(res->mode, "MPE",3))
8829 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8832 RTE_SET_USED(is_on);
8834 #ifdef RTE_LIBRTE_IXGBE_PMD
8835 if (ret == -ENOTSUP)
8836 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8837 vf_rxmode, (uint8_t)is_on);
8839 #ifdef RTE_LIBRTE_BNXT_PMD
8840 if (ret == -ENOTSUP)
8841 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8842 vf_rxmode, (uint8_t)is_on);
8845 printf("bad VF receive mode parameter, return code = %d \n",
8849 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8850 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8852 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8853 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8855 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8856 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8858 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8859 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8861 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8862 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8864 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8865 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8867 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8868 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8869 mode, "AUPE#ROPE#BAM#MPE");
8870 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8871 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8874 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8875 .f = cmd_set_vf_rxmode_parsed,
8877 .help_str = "set port <port_id> vf <vf_id> rxmode "
8878 "AUPE|ROPE|BAM|MPE on|off",
8880 (void *)&cmd_set_vf_rxmode_set,
8881 (void *)&cmd_set_vf_rxmode_port,
8882 (void *)&cmd_set_vf_rxmode_portid,
8883 (void *)&cmd_set_vf_rxmode_vf,
8884 (void *)&cmd_set_vf_rxmode_vfid,
8885 (void *)&cmd_set_vf_rxmode_what,
8886 (void *)&cmd_set_vf_rxmode_mode,
8887 (void *)&cmd_set_vf_rxmode_on,
8892 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8893 struct cmd_vf_mac_addr_result {
8894 cmdline_fixed_string_t mac_addr_cmd;
8895 cmdline_fixed_string_t what;
8896 cmdline_fixed_string_t port;
8898 cmdline_fixed_string_t vf;
8900 struct rte_ether_addr address;
8903 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8904 __rte_unused struct cmdline *cl,
8905 __rte_unused void *data)
8907 struct cmd_vf_mac_addr_result *res = parsed_result;
8910 if (strcmp(res->what, "add") != 0)
8913 #ifdef RTE_LIBRTE_I40E_PMD
8914 if (ret == -ENOTSUP)
8915 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8918 #ifdef RTE_LIBRTE_BNXT_PMD
8919 if (ret == -ENOTSUP)
8920 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8925 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8929 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8930 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8931 mac_addr_cmd,"mac_addr");
8932 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8933 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8935 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8936 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8938 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8939 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8941 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8942 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8944 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8945 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8947 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8948 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8951 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8952 .f = cmd_vf_mac_addr_parsed,
8954 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8955 "Add MAC address filtering for a VF on port_id",
8957 (void *)&cmd_vf_mac_addr_cmd,
8958 (void *)&cmd_vf_mac_addr_what,
8959 (void *)&cmd_vf_mac_addr_port,
8960 (void *)&cmd_vf_mac_addr_portnum,
8961 (void *)&cmd_vf_mac_addr_vf,
8962 (void *)&cmd_vf_mac_addr_vfnum,
8963 (void *)&cmd_vf_mac_addr_addr,
8968 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8969 struct cmd_vf_rx_vlan_filter {
8970 cmdline_fixed_string_t rx_vlan;
8971 cmdline_fixed_string_t what;
8973 cmdline_fixed_string_t port;
8975 cmdline_fixed_string_t vf;
8980 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8981 __rte_unused struct cmdline *cl,
8982 __rte_unused void *data)
8984 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8987 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8989 #ifdef RTE_LIBRTE_IXGBE_PMD
8990 if (ret == -ENOTSUP)
8991 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8992 res->vlan_id, res->vf_mask, is_add);
8994 #ifdef RTE_LIBRTE_I40E_PMD
8995 if (ret == -ENOTSUP)
8996 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8997 res->vlan_id, res->vf_mask, is_add);
8999 #ifdef RTE_LIBRTE_BNXT_PMD
9000 if (ret == -ENOTSUP)
9001 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9002 res->vlan_id, res->vf_mask, is_add);
9009 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
9010 res->vlan_id, res->vf_mask);
9013 printf("invalid port_id %d\n", res->port_id);
9016 printf("function not implemented or supported\n");
9019 printf("programming error: (%s)\n", strerror(-ret));
9023 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9024 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9025 rx_vlan, "rx_vlan");
9026 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9027 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9029 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9030 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9032 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9033 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9035 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9036 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9038 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9039 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9041 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9042 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9045 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9046 .f = cmd_vf_rx_vlan_filter_parsed,
9048 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9049 "(vf_mask = hexadecimal VF mask)",
9051 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9052 (void *)&cmd_vf_rx_vlan_filter_what,
9053 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9054 (void *)&cmd_vf_rx_vlan_filter_port,
9055 (void *)&cmd_vf_rx_vlan_filter_portid,
9056 (void *)&cmd_vf_rx_vlan_filter_vf,
9057 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9062 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9063 struct cmd_queue_rate_limit_result {
9064 cmdline_fixed_string_t set;
9065 cmdline_fixed_string_t port;
9067 cmdline_fixed_string_t queue;
9069 cmdline_fixed_string_t rate;
9073 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9074 __rte_unused struct cmdline *cl,
9075 __rte_unused void *data)
9077 struct cmd_queue_rate_limit_result *res = parsed_result;
9080 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9081 && (strcmp(res->queue, "queue") == 0)
9082 && (strcmp(res->rate, "rate") == 0))
9083 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9086 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
9090 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9091 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9093 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9094 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9096 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9097 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9099 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9100 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9102 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9103 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9105 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9106 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9108 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9109 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9112 cmdline_parse_inst_t cmd_queue_rate_limit = {
9113 .f = cmd_queue_rate_limit_parsed,
9115 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9116 "Set rate limit for a queue on port_id",
9118 (void *)&cmd_queue_rate_limit_set,
9119 (void *)&cmd_queue_rate_limit_port,
9120 (void *)&cmd_queue_rate_limit_portnum,
9121 (void *)&cmd_queue_rate_limit_queue,
9122 (void *)&cmd_queue_rate_limit_queuenum,
9123 (void *)&cmd_queue_rate_limit_rate,
9124 (void *)&cmd_queue_rate_limit_ratenum,
9129 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9130 struct cmd_vf_rate_limit_result {
9131 cmdline_fixed_string_t set;
9132 cmdline_fixed_string_t port;
9134 cmdline_fixed_string_t vf;
9136 cmdline_fixed_string_t rate;
9138 cmdline_fixed_string_t q_msk;
9142 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9143 __rte_unused struct cmdline *cl,
9144 __rte_unused void *data)
9146 struct cmd_vf_rate_limit_result *res = parsed_result;
9149 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9150 && (strcmp(res->vf, "vf") == 0)
9151 && (strcmp(res->rate, "rate") == 0)
9152 && (strcmp(res->q_msk, "queue_mask") == 0))
9153 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9154 res->rate_num, res->q_msk_val);
9156 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9160 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9161 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9163 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9164 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9166 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9167 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9169 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9170 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9172 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9173 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9175 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9176 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9178 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9179 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9181 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9182 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9183 q_msk, "queue_mask");
9184 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9185 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9188 cmdline_parse_inst_t cmd_vf_rate_limit = {
9189 .f = cmd_vf_rate_limit_parsed,
9191 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9192 "queue_mask <queue_mask_value>: "
9193 "Set rate limit for queues of VF on port_id",
9195 (void *)&cmd_vf_rate_limit_set,
9196 (void *)&cmd_vf_rate_limit_port,
9197 (void *)&cmd_vf_rate_limit_portnum,
9198 (void *)&cmd_vf_rate_limit_vf,
9199 (void *)&cmd_vf_rate_limit_vfnum,
9200 (void *)&cmd_vf_rate_limit_rate,
9201 (void *)&cmd_vf_rate_limit_ratenum,
9202 (void *)&cmd_vf_rate_limit_q_msk,
9203 (void *)&cmd_vf_rate_limit_q_msk_val,
9208 /* *** ADD TUNNEL FILTER OF A PORT *** */
9209 struct cmd_tunnel_filter_result {
9210 cmdline_fixed_string_t cmd;
9211 cmdline_fixed_string_t what;
9213 struct rte_ether_addr outer_mac;
9214 struct rte_ether_addr inner_mac;
9215 cmdline_ipaddr_t ip_value;
9216 uint16_t inner_vlan;
9217 cmdline_fixed_string_t tunnel_type;
9218 cmdline_fixed_string_t filter_type;
9224 cmd_tunnel_filter_parsed(void *parsed_result,
9225 __rte_unused struct cmdline *cl,
9226 __rte_unused void *data)
9228 struct cmd_tunnel_filter_result *res = parsed_result;
9229 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
9232 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
9234 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
9235 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
9236 tunnel_filter_conf.inner_vlan = res->inner_vlan;
9238 if (res->ip_value.family == AF_INET) {
9239 tunnel_filter_conf.ip_addr.ipv4_addr =
9240 res->ip_value.addr.ipv4.s_addr;
9241 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
9243 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
9244 &(res->ip_value.addr.ipv6),
9245 sizeof(struct in6_addr));
9246 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
9249 if (!strcmp(res->filter_type, "imac-ivlan"))
9250 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
9251 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
9252 tunnel_filter_conf.filter_type =
9253 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
9254 else if (!strcmp(res->filter_type, "imac-tenid"))
9255 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
9256 else if (!strcmp(res->filter_type, "imac"))
9257 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
9258 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
9259 tunnel_filter_conf.filter_type =
9260 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
9261 else if (!strcmp(res->filter_type, "oip"))
9262 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9263 else if (!strcmp(res->filter_type, "iip"))
9264 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9266 printf("The filter type is not supported");
9270 if (!strcmp(res->tunnel_type, "vxlan"))
9271 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9272 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9273 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9274 else if (!strcmp(res->tunnel_type, "nvgre"))
9275 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9276 else if (!strcmp(res->tunnel_type, "ipingre"))
9277 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9279 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9283 tunnel_filter_conf.tenant_id = res->tenant_id;
9284 tunnel_filter_conf.queue_id = res->queue_num;
9285 if (!strcmp(res->what, "add"))
9286 ret = rte_eth_dev_filter_ctrl(res->port_id,
9287 RTE_ETH_FILTER_TUNNEL,
9289 &tunnel_filter_conf);
9291 ret = rte_eth_dev_filter_ctrl(res->port_id,
9292 RTE_ETH_FILTER_TUNNEL,
9293 RTE_ETH_FILTER_DELETE,
9294 &tunnel_filter_conf);
9296 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9300 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9301 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9302 cmd, "tunnel_filter");
9303 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9304 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9306 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9307 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9309 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9310 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9312 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9313 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9315 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9316 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9317 inner_vlan, UINT16);
9318 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9319 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9321 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9322 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9323 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9325 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9326 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9327 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9328 "imac#omac-imac-tenid");
9329 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9330 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9332 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9333 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9336 cmdline_parse_inst_t cmd_tunnel_filter = {
9337 .f = cmd_tunnel_filter_parsed,
9339 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9340 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9341 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9342 "<queue_id>: Add/Rm tunnel filter of a port",
9344 (void *)&cmd_tunnel_filter_cmd,
9345 (void *)&cmd_tunnel_filter_what,
9346 (void *)&cmd_tunnel_filter_port_id,
9347 (void *)&cmd_tunnel_filter_outer_mac,
9348 (void *)&cmd_tunnel_filter_inner_mac,
9349 (void *)&cmd_tunnel_filter_ip_value,
9350 (void *)&cmd_tunnel_filter_innner_vlan,
9351 (void *)&cmd_tunnel_filter_tunnel_type,
9352 (void *)&cmd_tunnel_filter_filter_type,
9353 (void *)&cmd_tunnel_filter_tenant_id,
9354 (void *)&cmd_tunnel_filter_queue_num,
9359 /* *** CONFIGURE TUNNEL UDP PORT *** */
9360 struct cmd_tunnel_udp_config {
9361 cmdline_fixed_string_t cmd;
9362 cmdline_fixed_string_t what;
9368 cmd_tunnel_udp_config_parsed(void *parsed_result,
9369 __rte_unused struct cmdline *cl,
9370 __rte_unused void *data)
9372 struct cmd_tunnel_udp_config *res = parsed_result;
9373 struct rte_eth_udp_tunnel tunnel_udp;
9376 tunnel_udp.udp_port = res->udp_port;
9378 if (!strcmp(res->cmd, "rx_vxlan_port"))
9379 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9381 if (!strcmp(res->what, "add"))
9382 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9385 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9389 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9392 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9393 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9394 cmd, "rx_vxlan_port");
9395 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9396 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9398 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9399 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9401 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9402 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9405 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9406 .f = cmd_tunnel_udp_config_parsed,
9408 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9409 "Add/Remove a tunneling UDP port filter",
9411 (void *)&cmd_tunnel_udp_config_cmd,
9412 (void *)&cmd_tunnel_udp_config_what,
9413 (void *)&cmd_tunnel_udp_config_udp_port,
9414 (void *)&cmd_tunnel_udp_config_port_id,
9419 struct cmd_config_tunnel_udp_port {
9420 cmdline_fixed_string_t port;
9421 cmdline_fixed_string_t config;
9423 cmdline_fixed_string_t udp_tunnel_port;
9424 cmdline_fixed_string_t action;
9425 cmdline_fixed_string_t tunnel_type;
9430 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9431 __rte_unused struct cmdline *cl,
9432 __rte_unused void *data)
9434 struct cmd_config_tunnel_udp_port *res = parsed_result;
9435 struct rte_eth_udp_tunnel tunnel_udp;
9438 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9441 tunnel_udp.udp_port = res->udp_port;
9443 if (!strcmp(res->tunnel_type, "vxlan")) {
9444 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9445 } else if (!strcmp(res->tunnel_type, "geneve")) {
9446 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9447 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9448 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9450 printf("Invalid tunnel type\n");
9454 if (!strcmp(res->action, "add"))
9455 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9458 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9462 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9465 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9466 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9468 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9469 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9471 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9472 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9474 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9475 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9478 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9479 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9481 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9482 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9483 "vxlan#geneve#vxlan-gpe");
9484 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9485 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9488 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9489 .f = cmd_cfg_tunnel_udp_port_parsed,
9491 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9493 (void *)&cmd_config_tunnel_udp_port_port,
9494 (void *)&cmd_config_tunnel_udp_port_config,
9495 (void *)&cmd_config_tunnel_udp_port_port_id,
9496 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9497 (void *)&cmd_config_tunnel_udp_port_action,
9498 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9499 (void *)&cmd_config_tunnel_udp_port_value,
9504 /* *** GLOBAL CONFIG *** */
9505 struct cmd_global_config_result {
9506 cmdline_fixed_string_t cmd;
9508 cmdline_fixed_string_t cfg_type;
9513 cmd_global_config_parsed(void *parsed_result,
9514 __rte_unused struct cmdline *cl,
9515 __rte_unused void *data)
9517 struct cmd_global_config_result *res = parsed_result;
9518 struct rte_eth_global_cfg conf;
9521 memset(&conf, 0, sizeof(conf));
9522 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9523 conf.cfg.gre_key_len = res->len;
9524 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9525 RTE_ETH_FILTER_SET, &conf);
9526 #ifdef RTE_LIBRTE_I40E_PMD
9527 if (ret == -ENOTSUP)
9528 ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len);
9531 printf("Global config error\n");
9534 cmdline_parse_token_string_t cmd_global_config_cmd =
9535 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9537 cmdline_parse_token_num_t cmd_global_config_port_id =
9538 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9540 cmdline_parse_token_string_t cmd_global_config_type =
9541 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9542 cfg_type, "gre-key-len");
9543 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9544 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9547 cmdline_parse_inst_t cmd_global_config = {
9548 .f = cmd_global_config_parsed,
9549 .data = (void *)NULL,
9550 .help_str = "global_config <port_id> gre-key-len <key_len>",
9552 (void *)&cmd_global_config_cmd,
9553 (void *)&cmd_global_config_port_id,
9554 (void *)&cmd_global_config_type,
9555 (void *)&cmd_global_config_gre_key_len,
9560 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9561 struct cmd_set_mirror_mask_result {
9562 cmdline_fixed_string_t set;
9563 cmdline_fixed_string_t port;
9565 cmdline_fixed_string_t mirror;
9567 cmdline_fixed_string_t what;
9568 cmdline_fixed_string_t value;
9569 cmdline_fixed_string_t dstpool;
9571 cmdline_fixed_string_t on;
9574 cmdline_parse_token_string_t cmd_mirror_mask_set =
9575 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9577 cmdline_parse_token_string_t cmd_mirror_mask_port =
9578 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9580 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9581 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9583 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9584 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9585 mirror, "mirror-rule");
9586 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9587 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9589 cmdline_parse_token_string_t cmd_mirror_mask_what =
9590 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9591 what, "pool-mirror-up#pool-mirror-down"
9593 cmdline_parse_token_string_t cmd_mirror_mask_value =
9594 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9596 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9597 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9598 dstpool, "dst-pool");
9599 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9600 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9602 cmdline_parse_token_string_t cmd_mirror_mask_on =
9603 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9607 cmd_set_mirror_mask_parsed(void *parsed_result,
9608 __rte_unused struct cmdline *cl,
9609 __rte_unused void *data)
9612 struct cmd_set_mirror_mask_result *res = parsed_result;
9613 struct rte_eth_mirror_conf mr_conf;
9615 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9617 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9619 mr_conf.dst_pool = res->dstpool_id;
9621 if (!strcmp(res->what, "pool-mirror-up")) {
9622 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9623 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9624 } else if (!strcmp(res->what, "pool-mirror-down")) {
9625 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9626 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9627 } else if (!strcmp(res->what, "vlan-mirror")) {
9628 mr_conf.rule_type = ETH_MIRROR_VLAN;
9629 nb_item = parse_item_list(res->value, "vlan",
9630 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9634 for (i = 0; i < nb_item; i++) {
9635 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9636 printf("Invalid vlan_id: must be < 4096\n");
9640 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9641 mr_conf.vlan.vlan_mask |= 1ULL << i;
9645 if (!strcmp(res->on, "on"))
9646 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9649 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9652 printf("mirror rule add error: (%s)\n", strerror(-ret));
9655 cmdline_parse_inst_t cmd_set_mirror_mask = {
9656 .f = cmd_set_mirror_mask_parsed,
9658 .help_str = "set port <port_id> mirror-rule <rule_id> "
9659 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9660 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9662 (void *)&cmd_mirror_mask_set,
9663 (void *)&cmd_mirror_mask_port,
9664 (void *)&cmd_mirror_mask_portid,
9665 (void *)&cmd_mirror_mask_mirror,
9666 (void *)&cmd_mirror_mask_ruleid,
9667 (void *)&cmd_mirror_mask_what,
9668 (void *)&cmd_mirror_mask_value,
9669 (void *)&cmd_mirror_mask_dstpool,
9670 (void *)&cmd_mirror_mask_poolid,
9671 (void *)&cmd_mirror_mask_on,
9676 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9677 struct cmd_set_mirror_link_result {
9678 cmdline_fixed_string_t set;
9679 cmdline_fixed_string_t port;
9681 cmdline_fixed_string_t mirror;
9683 cmdline_fixed_string_t what;
9684 cmdline_fixed_string_t dstpool;
9686 cmdline_fixed_string_t on;
9689 cmdline_parse_token_string_t cmd_mirror_link_set =
9690 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9692 cmdline_parse_token_string_t cmd_mirror_link_port =
9693 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9695 cmdline_parse_token_num_t cmd_mirror_link_portid =
9696 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9698 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9699 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9700 mirror, "mirror-rule");
9701 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9702 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9704 cmdline_parse_token_string_t cmd_mirror_link_what =
9705 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9706 what, "uplink-mirror#downlink-mirror");
9707 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9708 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9709 dstpool, "dst-pool");
9710 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9711 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9713 cmdline_parse_token_string_t cmd_mirror_link_on =
9714 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9718 cmd_set_mirror_link_parsed(void *parsed_result,
9719 __rte_unused struct cmdline *cl,
9720 __rte_unused void *data)
9723 struct cmd_set_mirror_link_result *res = parsed_result;
9724 struct rte_eth_mirror_conf mr_conf;
9726 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9727 if (!strcmp(res->what, "uplink-mirror"))
9728 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9730 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9732 mr_conf.dst_pool = res->dstpool_id;
9734 if (!strcmp(res->on, "on"))
9735 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9738 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9741 /* check the return value and print it if is < 0 */
9743 printf("mirror rule add error: (%s)\n", strerror(-ret));
9747 cmdline_parse_inst_t cmd_set_mirror_link = {
9748 .f = cmd_set_mirror_link_parsed,
9750 .help_str = "set port <port_id> mirror-rule <rule_id> "
9751 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9753 (void *)&cmd_mirror_link_set,
9754 (void *)&cmd_mirror_link_port,
9755 (void *)&cmd_mirror_link_portid,
9756 (void *)&cmd_mirror_link_mirror,
9757 (void *)&cmd_mirror_link_ruleid,
9758 (void *)&cmd_mirror_link_what,
9759 (void *)&cmd_mirror_link_dstpool,
9760 (void *)&cmd_mirror_link_poolid,
9761 (void *)&cmd_mirror_link_on,
9766 /* *** RESET VM MIRROR RULE *** */
9767 struct cmd_rm_mirror_rule_result {
9768 cmdline_fixed_string_t reset;
9769 cmdline_fixed_string_t port;
9771 cmdline_fixed_string_t mirror;
9775 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9776 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9778 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9779 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9781 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9782 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9784 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9785 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9786 mirror, "mirror-rule");
9787 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9788 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9792 cmd_reset_mirror_rule_parsed(void *parsed_result,
9793 __rte_unused struct cmdline *cl,
9794 __rte_unused void *data)
9797 struct cmd_set_mirror_link_result *res = parsed_result;
9799 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9801 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9804 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9805 .f = cmd_reset_mirror_rule_parsed,
9807 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9809 (void *)&cmd_rm_mirror_rule_reset,
9810 (void *)&cmd_rm_mirror_rule_port,
9811 (void *)&cmd_rm_mirror_rule_portid,
9812 (void *)&cmd_rm_mirror_rule_mirror,
9813 (void *)&cmd_rm_mirror_rule_ruleid,
9818 /* ******************************************************************************** */
9820 struct cmd_dump_result {
9821 cmdline_fixed_string_t dump;
9825 dump_struct_sizes(void)
9827 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9828 DUMP_SIZE(struct rte_mbuf);
9829 DUMP_SIZE(struct rte_mempool);
9830 DUMP_SIZE(struct rte_ring);
9835 /* Dump the socket memory statistics on console */
9837 dump_socket_mem(FILE *f)
9839 struct rte_malloc_socket_stats socket_stats;
9844 unsigned int n_alloc = 0;
9845 unsigned int n_free = 0;
9846 static size_t last_allocs;
9847 static size_t last_total;
9850 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9851 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9852 !socket_stats.heap_totalsz_bytes)
9854 total += socket_stats.heap_totalsz_bytes;
9855 alloc += socket_stats.heap_allocsz_bytes;
9856 free += socket_stats.heap_freesz_bytes;
9857 n_alloc += socket_stats.alloc_count;
9858 n_free += socket_stats.free_count;
9860 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9862 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9863 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9864 (double)socket_stats.heap_allocsz_bytes * 100 /
9865 (double)socket_stats.heap_totalsz_bytes,
9866 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9867 socket_stats.alloc_count,
9868 socket_stats.free_count);
9871 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9872 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9873 (double)alloc * 100 / (double)total,
9874 (double)free / (1024 * 1024),
9877 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9878 ((double)total - (double)last_total) / (1024 * 1024),
9879 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9880 last_allocs = alloc;
9884 static void cmd_dump_parsed(void *parsed_result,
9885 __rte_unused struct cmdline *cl,
9886 __rte_unused void *data)
9888 struct cmd_dump_result *res = parsed_result;
9890 if (!strcmp(res->dump, "dump_physmem"))
9891 rte_dump_physmem_layout(stdout);
9892 else if (!strcmp(res->dump, "dump_socket_mem"))
9893 dump_socket_mem(stdout);
9894 else if (!strcmp(res->dump, "dump_memzone"))
9895 rte_memzone_dump(stdout);
9896 else if (!strcmp(res->dump, "dump_struct_sizes"))
9897 dump_struct_sizes();
9898 else if (!strcmp(res->dump, "dump_ring"))
9899 rte_ring_list_dump(stdout);
9900 else if (!strcmp(res->dump, "dump_mempool"))
9901 rte_mempool_list_dump(stdout);
9902 else if (!strcmp(res->dump, "dump_devargs"))
9903 rte_devargs_dump(stdout);
9904 else if (!strcmp(res->dump, "dump_log_types"))
9905 rte_log_dump(stdout);
9908 cmdline_parse_token_string_t cmd_dump_dump =
9909 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9913 "dump_struct_sizes#"
9919 cmdline_parse_inst_t cmd_dump = {
9920 .f = cmd_dump_parsed, /* function to call */
9921 .data = NULL, /* 2nd arg of func */
9922 .help_str = "Dump status",
9923 .tokens = { /* token list, NULL terminated */
9924 (void *)&cmd_dump_dump,
9929 /* ******************************************************************************** */
9931 struct cmd_dump_one_result {
9932 cmdline_fixed_string_t dump;
9933 cmdline_fixed_string_t name;
9936 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9937 __rte_unused void *data)
9939 struct cmd_dump_one_result *res = parsed_result;
9941 if (!strcmp(res->dump, "dump_ring")) {
9943 r = rte_ring_lookup(res->name);
9945 cmdline_printf(cl, "Cannot find ring\n");
9948 rte_ring_dump(stdout, r);
9949 } else if (!strcmp(res->dump, "dump_mempool")) {
9950 struct rte_mempool *mp;
9951 mp = rte_mempool_lookup(res->name);
9953 cmdline_printf(cl, "Cannot find mempool\n");
9956 rte_mempool_dump(stdout, mp);
9960 cmdline_parse_token_string_t cmd_dump_one_dump =
9961 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9962 "dump_ring#dump_mempool");
9964 cmdline_parse_token_string_t cmd_dump_one_name =
9965 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9967 cmdline_parse_inst_t cmd_dump_one = {
9968 .f = cmd_dump_one_parsed, /* function to call */
9969 .data = NULL, /* 2nd arg of func */
9970 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9971 .tokens = { /* token list, NULL terminated */
9972 (void *)&cmd_dump_one_dump,
9973 (void *)&cmd_dump_one_name,
9978 /* *** Add/Del syn filter *** */
9979 struct cmd_syn_filter_result {
9980 cmdline_fixed_string_t filter;
9982 cmdline_fixed_string_t ops;
9983 cmdline_fixed_string_t priority;
9984 cmdline_fixed_string_t high;
9985 cmdline_fixed_string_t queue;
9990 cmd_syn_filter_parsed(void *parsed_result,
9991 __rte_unused struct cmdline *cl,
9992 __rte_unused void *data)
9994 struct cmd_syn_filter_result *res = parsed_result;
9995 struct rte_eth_syn_filter syn_filter;
9998 ret = rte_eth_dev_filter_supported(res->port_id,
9999 RTE_ETH_FILTER_SYN);
10001 printf("syn filter is not supported on port %u.\n",
10006 memset(&syn_filter, 0, sizeof(syn_filter));
10008 if (!strcmp(res->ops, "add")) {
10009 if (!strcmp(res->high, "high"))
10010 syn_filter.hig_pri = 1;
10012 syn_filter.hig_pri = 0;
10014 syn_filter.queue = res->queue_id;
10015 ret = rte_eth_dev_filter_ctrl(res->port_id,
10016 RTE_ETH_FILTER_SYN,
10017 RTE_ETH_FILTER_ADD,
10020 ret = rte_eth_dev_filter_ctrl(res->port_id,
10021 RTE_ETH_FILTER_SYN,
10022 RTE_ETH_FILTER_DELETE,
10026 printf("syn filter programming error: (%s)\n",
10030 cmdline_parse_token_string_t cmd_syn_filter_filter =
10031 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10032 filter, "syn_filter");
10033 cmdline_parse_token_num_t cmd_syn_filter_port_id =
10034 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
10036 cmdline_parse_token_string_t cmd_syn_filter_ops =
10037 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10039 cmdline_parse_token_string_t cmd_syn_filter_priority =
10040 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10041 priority, "priority");
10042 cmdline_parse_token_string_t cmd_syn_filter_high =
10043 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10045 cmdline_parse_token_string_t cmd_syn_filter_queue =
10046 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10048 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
10049 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
10052 cmdline_parse_inst_t cmd_syn_filter = {
10053 .f = cmd_syn_filter_parsed,
10055 .help_str = "syn_filter <port_id> add|del priority high|low queue "
10056 "<queue_id>: Add/Delete syn filter",
10058 (void *)&cmd_syn_filter_filter,
10059 (void *)&cmd_syn_filter_port_id,
10060 (void *)&cmd_syn_filter_ops,
10061 (void *)&cmd_syn_filter_priority,
10062 (void *)&cmd_syn_filter_high,
10063 (void *)&cmd_syn_filter_queue,
10064 (void *)&cmd_syn_filter_queue_id,
10069 /* *** queue region set *** */
10070 struct cmd_queue_region_result {
10071 cmdline_fixed_string_t set;
10072 cmdline_fixed_string_t port;
10074 cmdline_fixed_string_t cmd;
10075 cmdline_fixed_string_t region;
10077 cmdline_fixed_string_t queue_start_index;
10079 cmdline_fixed_string_t queue_num;
10080 uint8_t queue_num_value;
10084 cmd_queue_region_parsed(void *parsed_result,
10085 __rte_unused struct cmdline *cl,
10086 __rte_unused void *data)
10088 struct cmd_queue_region_result *res = parsed_result;
10089 int ret = -ENOTSUP;
10090 #ifdef RTE_LIBRTE_I40E_PMD
10091 struct rte_pmd_i40e_queue_region_conf region_conf;
10092 enum rte_pmd_i40e_queue_region_op op_type;
10095 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10098 #ifdef RTE_LIBRTE_I40E_PMD
10099 memset(®ion_conf, 0, sizeof(region_conf));
10100 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
10101 region_conf.region_id = res->region_id;
10102 region_conf.queue_num = res->queue_num_value;
10103 region_conf.queue_start_index = res->queue_id;
10105 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10106 op_type, ®ion_conf);
10113 printf("function not implemented or supported\n");
10116 printf("queue region config error: (%s)\n", strerror(-ret));
10120 cmdline_parse_token_string_t cmd_queue_region_set =
10121 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10123 cmdline_parse_token_string_t cmd_queue_region_port =
10124 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10125 cmdline_parse_token_num_t cmd_queue_region_port_id =
10126 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10128 cmdline_parse_token_string_t cmd_queue_region_cmd =
10129 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10130 cmd, "queue-region");
10131 cmdline_parse_token_string_t cmd_queue_region_id =
10132 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10133 region, "region_id");
10134 cmdline_parse_token_num_t cmd_queue_region_index =
10135 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10137 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10138 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10139 queue_start_index, "queue_start_index");
10140 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10141 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10143 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10144 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10145 queue_num, "queue_num");
10146 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10147 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10148 queue_num_value, UINT8);
10150 cmdline_parse_inst_t cmd_queue_region = {
10151 .f = cmd_queue_region_parsed,
10153 .help_str = "set port <port_id> queue-region region_id <value> "
10154 "queue_start_index <value> queue_num <value>: Set a queue region",
10156 (void *)&cmd_queue_region_set,
10157 (void *)&cmd_queue_region_port,
10158 (void *)&cmd_queue_region_port_id,
10159 (void *)&cmd_queue_region_cmd,
10160 (void *)&cmd_queue_region_id,
10161 (void *)&cmd_queue_region_index,
10162 (void *)&cmd_queue_region_queue_start_index,
10163 (void *)&cmd_queue_region_queue_id,
10164 (void *)&cmd_queue_region_queue_num,
10165 (void *)&cmd_queue_region_queue_num_value,
10170 /* *** queue region and flowtype set *** */
10171 struct cmd_region_flowtype_result {
10172 cmdline_fixed_string_t set;
10173 cmdline_fixed_string_t port;
10175 cmdline_fixed_string_t cmd;
10176 cmdline_fixed_string_t region;
10178 cmdline_fixed_string_t flowtype;
10179 uint8_t flowtype_id;
10183 cmd_region_flowtype_parsed(void *parsed_result,
10184 __rte_unused struct cmdline *cl,
10185 __rte_unused void *data)
10187 struct cmd_region_flowtype_result *res = parsed_result;
10188 int ret = -ENOTSUP;
10189 #ifdef RTE_LIBRTE_I40E_PMD
10190 struct rte_pmd_i40e_queue_region_conf region_conf;
10191 enum rte_pmd_i40e_queue_region_op op_type;
10194 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10197 #ifdef RTE_LIBRTE_I40E_PMD
10198 memset(®ion_conf, 0, sizeof(region_conf));
10200 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10201 region_conf.region_id = res->region_id;
10202 region_conf.hw_flowtype = res->flowtype_id;
10204 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10205 op_type, ®ion_conf);
10212 printf("function not implemented or supported\n");
10215 printf("region flowtype config error: (%s)\n", strerror(-ret));
10219 cmdline_parse_token_string_t cmd_region_flowtype_set =
10220 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10222 cmdline_parse_token_string_t cmd_region_flowtype_port =
10223 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10225 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10226 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10228 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10229 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10230 cmd, "queue-region");
10231 cmdline_parse_token_string_t cmd_region_flowtype_index =
10232 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10233 region, "region_id");
10234 cmdline_parse_token_num_t cmd_region_flowtype_id =
10235 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10237 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10238 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10239 flowtype, "flowtype");
10240 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10241 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10242 flowtype_id, UINT8);
10243 cmdline_parse_inst_t cmd_region_flowtype = {
10244 .f = cmd_region_flowtype_parsed,
10246 .help_str = "set port <port_id> queue-region region_id <value> "
10247 "flowtype <value>: Set a flowtype region index",
10249 (void *)&cmd_region_flowtype_set,
10250 (void *)&cmd_region_flowtype_port,
10251 (void *)&cmd_region_flowtype_port_index,
10252 (void *)&cmd_region_flowtype_cmd,
10253 (void *)&cmd_region_flowtype_index,
10254 (void *)&cmd_region_flowtype_id,
10255 (void *)&cmd_region_flowtype_flow_index,
10256 (void *)&cmd_region_flowtype_flow_id,
10261 /* *** User Priority (UP) to queue region (region_id) set *** */
10262 struct cmd_user_priority_region_result {
10263 cmdline_fixed_string_t set;
10264 cmdline_fixed_string_t port;
10266 cmdline_fixed_string_t cmd;
10267 cmdline_fixed_string_t user_priority;
10268 uint8_t user_priority_id;
10269 cmdline_fixed_string_t region;
10274 cmd_user_priority_region_parsed(void *parsed_result,
10275 __rte_unused struct cmdline *cl,
10276 __rte_unused void *data)
10278 struct cmd_user_priority_region_result *res = parsed_result;
10279 int ret = -ENOTSUP;
10280 #ifdef RTE_LIBRTE_I40E_PMD
10281 struct rte_pmd_i40e_queue_region_conf region_conf;
10282 enum rte_pmd_i40e_queue_region_op op_type;
10285 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10288 #ifdef RTE_LIBRTE_I40E_PMD
10289 memset(®ion_conf, 0, sizeof(region_conf));
10290 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10291 region_conf.user_priority = res->user_priority_id;
10292 region_conf.region_id = res->region_id;
10294 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10295 op_type, ®ion_conf);
10302 printf("function not implemented or supported\n");
10305 printf("user_priority region config error: (%s)\n",
10310 cmdline_parse_token_string_t cmd_user_priority_region_set =
10311 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10313 cmdline_parse_token_string_t cmd_user_priority_region_port =
10314 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10316 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10317 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10319 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10320 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10321 cmd, "queue-region");
10322 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10323 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10324 user_priority, "UP");
10325 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10326 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10327 user_priority_id, UINT8);
10328 cmdline_parse_token_string_t cmd_user_priority_region_region =
10329 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10330 region, "region_id");
10331 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10332 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10335 cmdline_parse_inst_t cmd_user_priority_region = {
10336 .f = cmd_user_priority_region_parsed,
10338 .help_str = "set port <port_id> queue-region UP <value> "
10339 "region_id <value>: Set the mapping of User Priority (UP) "
10340 "to queue region (region_id) ",
10342 (void *)&cmd_user_priority_region_set,
10343 (void *)&cmd_user_priority_region_port,
10344 (void *)&cmd_user_priority_region_port_index,
10345 (void *)&cmd_user_priority_region_cmd,
10346 (void *)&cmd_user_priority_region_UP,
10347 (void *)&cmd_user_priority_region_UP_id,
10348 (void *)&cmd_user_priority_region_region,
10349 (void *)&cmd_user_priority_region_region_id,
10354 /* *** flush all queue region related configuration *** */
10355 struct cmd_flush_queue_region_result {
10356 cmdline_fixed_string_t set;
10357 cmdline_fixed_string_t port;
10359 cmdline_fixed_string_t cmd;
10360 cmdline_fixed_string_t flush;
10361 cmdline_fixed_string_t what;
10365 cmd_flush_queue_region_parsed(void *parsed_result,
10366 __rte_unused struct cmdline *cl,
10367 __rte_unused void *data)
10369 struct cmd_flush_queue_region_result *res = parsed_result;
10370 int ret = -ENOTSUP;
10371 #ifdef RTE_LIBRTE_I40E_PMD
10372 struct rte_pmd_i40e_queue_region_conf region_conf;
10373 enum rte_pmd_i40e_queue_region_op op_type;
10376 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10379 #ifdef RTE_LIBRTE_I40E_PMD
10380 memset(®ion_conf, 0, sizeof(region_conf));
10382 if (strcmp(res->what, "on") == 0)
10383 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10385 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10387 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10388 op_type, ®ion_conf);
10395 printf("function not implemented or supported\n");
10398 printf("queue region config flush error: (%s)\n",
10403 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10404 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10406 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10407 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10409 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10410 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10412 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10413 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10414 cmd, "queue-region");
10415 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10416 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10418 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10419 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10422 cmdline_parse_inst_t cmd_flush_queue_region = {
10423 .f = cmd_flush_queue_region_parsed,
10425 .help_str = "set port <port_id> queue-region flush on|off"
10426 ": flush all queue region related configuration",
10428 (void *)&cmd_flush_queue_region_set,
10429 (void *)&cmd_flush_queue_region_port,
10430 (void *)&cmd_flush_queue_region_port_index,
10431 (void *)&cmd_flush_queue_region_cmd,
10432 (void *)&cmd_flush_queue_region_flush,
10433 (void *)&cmd_flush_queue_region_what,
10438 /* *** get all queue region related configuration info *** */
10439 struct cmd_show_queue_region_info {
10440 cmdline_fixed_string_t show;
10441 cmdline_fixed_string_t port;
10443 cmdline_fixed_string_t cmd;
10447 cmd_show_queue_region_info_parsed(void *parsed_result,
10448 __rte_unused struct cmdline *cl,
10449 __rte_unused void *data)
10451 struct cmd_show_queue_region_info *res = parsed_result;
10452 int ret = -ENOTSUP;
10453 #ifdef RTE_LIBRTE_I40E_PMD
10454 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10455 enum rte_pmd_i40e_queue_region_op op_type;
10458 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10461 #ifdef RTE_LIBRTE_I40E_PMD
10462 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10464 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10466 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10467 op_type, &rte_pmd_regions);
10469 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10476 printf("function not implemented or supported\n");
10479 printf("queue region config info show error: (%s)\n",
10484 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10485 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10487 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10488 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10490 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10491 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10493 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10494 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10495 cmd, "queue-region");
10497 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10498 .f = cmd_show_queue_region_info_parsed,
10500 .help_str = "show port <port_id> queue-region"
10501 ": show all queue region related configuration info",
10503 (void *)&cmd_show_queue_region_info_get,
10504 (void *)&cmd_show_queue_region_info_port,
10505 (void *)&cmd_show_queue_region_info_port_index,
10506 (void *)&cmd_show_queue_region_info_cmd,
10511 /* *** ADD/REMOVE A 2tuple FILTER *** */
10512 struct cmd_2tuple_filter_result {
10513 cmdline_fixed_string_t filter;
10515 cmdline_fixed_string_t ops;
10516 cmdline_fixed_string_t dst_port;
10517 uint16_t dst_port_value;
10518 cmdline_fixed_string_t protocol;
10519 uint8_t protocol_value;
10520 cmdline_fixed_string_t mask;
10521 uint8_t mask_value;
10522 cmdline_fixed_string_t tcp_flags;
10523 uint8_t tcp_flags_value;
10524 cmdline_fixed_string_t priority;
10525 uint8_t priority_value;
10526 cmdline_fixed_string_t queue;
10531 cmd_2tuple_filter_parsed(void *parsed_result,
10532 __rte_unused struct cmdline *cl,
10533 __rte_unused void *data)
10535 struct rte_eth_ntuple_filter filter;
10536 struct cmd_2tuple_filter_result *res = parsed_result;
10539 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10541 printf("ntuple filter is not supported on port %u.\n",
10546 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10548 filter.flags = RTE_2TUPLE_FLAGS;
10549 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10550 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10551 filter.proto = res->protocol_value;
10552 filter.priority = res->priority_value;
10553 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10554 printf("nonzero tcp_flags is only meaningful"
10555 " when protocol is TCP.\n");
10558 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10559 printf("invalid TCP flags.\n");
10563 if (res->tcp_flags_value != 0) {
10564 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10565 filter.tcp_flags = res->tcp_flags_value;
10568 /* need convert to big endian. */
10569 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10570 filter.queue = res->queue_id;
10572 if (!strcmp(res->ops, "add"))
10573 ret = rte_eth_dev_filter_ctrl(res->port_id,
10574 RTE_ETH_FILTER_NTUPLE,
10575 RTE_ETH_FILTER_ADD,
10578 ret = rte_eth_dev_filter_ctrl(res->port_id,
10579 RTE_ETH_FILTER_NTUPLE,
10580 RTE_ETH_FILTER_DELETE,
10583 printf("2tuple filter programming error: (%s)\n",
10588 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10589 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10590 filter, "2tuple_filter");
10591 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10592 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10594 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10595 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10597 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10598 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10599 dst_port, "dst_port");
10600 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10601 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10602 dst_port_value, UINT16);
10603 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10604 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10605 protocol, "protocol");
10606 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10607 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10608 protocol_value, UINT8);
10609 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10610 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10612 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10613 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10615 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10616 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10617 tcp_flags, "tcp_flags");
10618 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10619 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10620 tcp_flags_value, UINT8);
10621 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10622 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10623 priority, "priority");
10624 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10625 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10626 priority_value, UINT8);
10627 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10628 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10630 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10631 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10634 cmdline_parse_inst_t cmd_2tuple_filter = {
10635 .f = cmd_2tuple_filter_parsed,
10637 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10638 "<value> mask <value> tcp_flags <value> priority <value> queue "
10639 "<queue_id>: Add a 2tuple filter",
10641 (void *)&cmd_2tuple_filter_filter,
10642 (void *)&cmd_2tuple_filter_port_id,
10643 (void *)&cmd_2tuple_filter_ops,
10644 (void *)&cmd_2tuple_filter_dst_port,
10645 (void *)&cmd_2tuple_filter_dst_port_value,
10646 (void *)&cmd_2tuple_filter_protocol,
10647 (void *)&cmd_2tuple_filter_protocol_value,
10648 (void *)&cmd_2tuple_filter_mask,
10649 (void *)&cmd_2tuple_filter_mask_value,
10650 (void *)&cmd_2tuple_filter_tcp_flags,
10651 (void *)&cmd_2tuple_filter_tcp_flags_value,
10652 (void *)&cmd_2tuple_filter_priority,
10653 (void *)&cmd_2tuple_filter_priority_value,
10654 (void *)&cmd_2tuple_filter_queue,
10655 (void *)&cmd_2tuple_filter_queue_id,
10660 /* *** ADD/REMOVE A 5tuple FILTER *** */
10661 struct cmd_5tuple_filter_result {
10662 cmdline_fixed_string_t filter;
10664 cmdline_fixed_string_t ops;
10665 cmdline_fixed_string_t dst_ip;
10666 cmdline_ipaddr_t dst_ip_value;
10667 cmdline_fixed_string_t src_ip;
10668 cmdline_ipaddr_t src_ip_value;
10669 cmdline_fixed_string_t dst_port;
10670 uint16_t dst_port_value;
10671 cmdline_fixed_string_t src_port;
10672 uint16_t src_port_value;
10673 cmdline_fixed_string_t protocol;
10674 uint8_t protocol_value;
10675 cmdline_fixed_string_t mask;
10676 uint8_t mask_value;
10677 cmdline_fixed_string_t tcp_flags;
10678 uint8_t tcp_flags_value;
10679 cmdline_fixed_string_t priority;
10680 uint8_t priority_value;
10681 cmdline_fixed_string_t queue;
10686 cmd_5tuple_filter_parsed(void *parsed_result,
10687 __rte_unused struct cmdline *cl,
10688 __rte_unused void *data)
10690 struct rte_eth_ntuple_filter filter;
10691 struct cmd_5tuple_filter_result *res = parsed_result;
10694 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10696 printf("ntuple filter is not supported on port %u.\n",
10701 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10703 filter.flags = RTE_5TUPLE_FLAGS;
10704 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10705 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10706 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10707 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10708 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10709 filter.proto = res->protocol_value;
10710 filter.priority = res->priority_value;
10711 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10712 printf("nonzero tcp_flags is only meaningful"
10713 " when protocol is TCP.\n");
10716 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10717 printf("invalid TCP flags.\n");
10721 if (res->tcp_flags_value != 0) {
10722 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10723 filter.tcp_flags = res->tcp_flags_value;
10726 if (res->dst_ip_value.family == AF_INET)
10727 /* no need to convert, already big endian. */
10728 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10730 if (filter.dst_ip_mask == 0) {
10731 printf("can not support ipv6 involved compare.\n");
10737 if (res->src_ip_value.family == AF_INET)
10738 /* no need to convert, already big endian. */
10739 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10741 if (filter.src_ip_mask == 0) {
10742 printf("can not support ipv6 involved compare.\n");
10747 /* need convert to big endian. */
10748 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10749 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10750 filter.queue = res->queue_id;
10752 if (!strcmp(res->ops, "add"))
10753 ret = rte_eth_dev_filter_ctrl(res->port_id,
10754 RTE_ETH_FILTER_NTUPLE,
10755 RTE_ETH_FILTER_ADD,
10758 ret = rte_eth_dev_filter_ctrl(res->port_id,
10759 RTE_ETH_FILTER_NTUPLE,
10760 RTE_ETH_FILTER_DELETE,
10763 printf("5tuple filter programming error: (%s)\n",
10767 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10768 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10769 filter, "5tuple_filter");
10770 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10771 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10773 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10774 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10776 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10777 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10779 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10780 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10782 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10783 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10785 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10786 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10788 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10789 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10790 dst_port, "dst_port");
10791 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10792 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10793 dst_port_value, UINT16);
10794 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10795 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10796 src_port, "src_port");
10797 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10798 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10799 src_port_value, UINT16);
10800 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10801 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10802 protocol, "protocol");
10803 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10804 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10805 protocol_value, UINT8);
10806 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10807 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10809 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10810 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10812 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10813 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10814 tcp_flags, "tcp_flags");
10815 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10816 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10817 tcp_flags_value, UINT8);
10818 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10819 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10820 priority, "priority");
10821 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10822 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10823 priority_value, UINT8);
10824 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10825 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10827 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10828 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10831 cmdline_parse_inst_t cmd_5tuple_filter = {
10832 .f = cmd_5tuple_filter_parsed,
10834 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10835 "src_ip <value> dst_port <value> src_port <value> "
10836 "protocol <value> mask <value> tcp_flags <value> "
10837 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10839 (void *)&cmd_5tuple_filter_filter,
10840 (void *)&cmd_5tuple_filter_port_id,
10841 (void *)&cmd_5tuple_filter_ops,
10842 (void *)&cmd_5tuple_filter_dst_ip,
10843 (void *)&cmd_5tuple_filter_dst_ip_value,
10844 (void *)&cmd_5tuple_filter_src_ip,
10845 (void *)&cmd_5tuple_filter_src_ip_value,
10846 (void *)&cmd_5tuple_filter_dst_port,
10847 (void *)&cmd_5tuple_filter_dst_port_value,
10848 (void *)&cmd_5tuple_filter_src_port,
10849 (void *)&cmd_5tuple_filter_src_port_value,
10850 (void *)&cmd_5tuple_filter_protocol,
10851 (void *)&cmd_5tuple_filter_protocol_value,
10852 (void *)&cmd_5tuple_filter_mask,
10853 (void *)&cmd_5tuple_filter_mask_value,
10854 (void *)&cmd_5tuple_filter_tcp_flags,
10855 (void *)&cmd_5tuple_filter_tcp_flags_value,
10856 (void *)&cmd_5tuple_filter_priority,
10857 (void *)&cmd_5tuple_filter_priority_value,
10858 (void *)&cmd_5tuple_filter_queue,
10859 (void *)&cmd_5tuple_filter_queue_id,
10864 /* *** ADD/REMOVE A flex FILTER *** */
10865 struct cmd_flex_filter_result {
10866 cmdline_fixed_string_t filter;
10867 cmdline_fixed_string_t ops;
10869 cmdline_fixed_string_t len;
10871 cmdline_fixed_string_t bytes;
10872 cmdline_fixed_string_t bytes_value;
10873 cmdline_fixed_string_t mask;
10874 cmdline_fixed_string_t mask_value;
10875 cmdline_fixed_string_t priority;
10876 uint8_t priority_value;
10877 cmdline_fixed_string_t queue;
10881 static int xdigit2val(unsigned char c)
10886 else if (isupper(c))
10887 val = c - 'A' + 10;
10889 val = c - 'a' + 10;
10894 cmd_flex_filter_parsed(void *parsed_result,
10895 __rte_unused struct cmdline *cl,
10896 __rte_unused void *data)
10899 struct rte_eth_flex_filter filter;
10900 struct cmd_flex_filter_result *res = parsed_result;
10901 char *bytes_ptr, *mask_ptr;
10902 uint16_t len, i, j = 0;
10907 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10908 printf("the len exceed the max length 128\n");
10911 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10912 filter.len = res->len_value;
10913 filter.priority = res->priority_value;
10914 filter.queue = res->queue_id;
10915 bytes_ptr = res->bytes_value;
10916 mask_ptr = res->mask_value;
10918 /* translate bytes string to array. */
10919 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10920 (bytes_ptr[1] == 'X')))
10922 len = strnlen(bytes_ptr, res->len_value * 2);
10923 if (len == 0 || (len % 8 != 0)) {
10924 printf("please check len and bytes input\n");
10927 for (i = 0; i < len; i++) {
10929 if (isxdigit(c) == 0) {
10930 /* invalid characters. */
10931 printf("invalid input\n");
10934 val = xdigit2val(c);
10937 filter.bytes[j] = byte;
10938 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10945 /* translate mask string to uint8_t array. */
10946 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10947 (mask_ptr[1] == 'X')))
10949 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10951 printf("invalid input\n");
10956 for (i = 0; i < len; i++) {
10958 if (isxdigit(c) == 0) {
10959 /* invalid characters. */
10960 printf("invalid input\n");
10963 val = xdigit2val(c);
10966 filter.mask[j] = byte;
10967 printf("mask[%d]:%02x ", j, filter.mask[j]);
10975 if (!strcmp(res->ops, "add"))
10976 ret = rte_eth_dev_filter_ctrl(res->port_id,
10977 RTE_ETH_FILTER_FLEXIBLE,
10978 RTE_ETH_FILTER_ADD,
10981 ret = rte_eth_dev_filter_ctrl(res->port_id,
10982 RTE_ETH_FILTER_FLEXIBLE,
10983 RTE_ETH_FILTER_DELETE,
10987 printf("flex filter setting error: (%s)\n", strerror(-ret));
10990 cmdline_parse_token_string_t cmd_flex_filter_filter =
10991 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10992 filter, "flex_filter");
10993 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10994 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10996 cmdline_parse_token_string_t cmd_flex_filter_ops =
10997 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10999 cmdline_parse_token_string_t cmd_flex_filter_len =
11000 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11002 cmdline_parse_token_num_t cmd_flex_filter_len_value =
11003 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11005 cmdline_parse_token_string_t cmd_flex_filter_bytes =
11006 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11008 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
11009 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11010 bytes_value, NULL);
11011 cmdline_parse_token_string_t cmd_flex_filter_mask =
11012 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11014 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
11015 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11017 cmdline_parse_token_string_t cmd_flex_filter_priority =
11018 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11019 priority, "priority");
11020 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
11021 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11022 priority_value, UINT8);
11023 cmdline_parse_token_string_t cmd_flex_filter_queue =
11024 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11026 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
11027 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11029 cmdline_parse_inst_t cmd_flex_filter = {
11030 .f = cmd_flex_filter_parsed,
11032 .help_str = "flex_filter <port_id> add|del len <value> bytes "
11033 "<value> mask <value> priority <value> queue <queue_id>: "
11034 "Add/Del a flex filter",
11036 (void *)&cmd_flex_filter_filter,
11037 (void *)&cmd_flex_filter_port_id,
11038 (void *)&cmd_flex_filter_ops,
11039 (void *)&cmd_flex_filter_len,
11040 (void *)&cmd_flex_filter_len_value,
11041 (void *)&cmd_flex_filter_bytes,
11042 (void *)&cmd_flex_filter_bytes_value,
11043 (void *)&cmd_flex_filter_mask,
11044 (void *)&cmd_flex_filter_mask_value,
11045 (void *)&cmd_flex_filter_priority,
11046 (void *)&cmd_flex_filter_priority_value,
11047 (void *)&cmd_flex_filter_queue,
11048 (void *)&cmd_flex_filter_queue_id,
11053 /* *** Filters Control *** */
11055 /* *** deal with ethertype filter *** */
11056 struct cmd_ethertype_filter_result {
11057 cmdline_fixed_string_t filter;
11059 cmdline_fixed_string_t ops;
11060 cmdline_fixed_string_t mac;
11061 struct rte_ether_addr mac_addr;
11062 cmdline_fixed_string_t ethertype;
11063 uint16_t ethertype_value;
11064 cmdline_fixed_string_t drop;
11065 cmdline_fixed_string_t queue;
11069 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
11070 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11071 filter, "ethertype_filter");
11072 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
11073 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
11075 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
11076 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11078 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
11079 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11080 mac, "mac_addr#mac_ignr");
11081 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
11082 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
11084 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
11085 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11086 ethertype, "ethertype");
11087 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
11088 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
11089 ethertype_value, UINT16);
11090 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
11091 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11093 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
11094 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11096 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
11097 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
11101 cmd_ethertype_filter_parsed(void *parsed_result,
11102 __rte_unused struct cmdline *cl,
11103 __rte_unused void *data)
11105 struct cmd_ethertype_filter_result *res = parsed_result;
11106 struct rte_eth_ethertype_filter filter;
11109 ret = rte_eth_dev_filter_supported(res->port_id,
11110 RTE_ETH_FILTER_ETHERTYPE);
11112 printf("ethertype filter is not supported on port %u.\n",
11117 memset(&filter, 0, sizeof(filter));
11118 if (!strcmp(res->mac, "mac_addr")) {
11119 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
11120 rte_memcpy(&filter.mac_addr, &res->mac_addr,
11121 sizeof(struct rte_ether_addr));
11123 if (!strcmp(res->drop, "drop"))
11124 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
11125 filter.ether_type = res->ethertype_value;
11126 filter.queue = res->queue_id;
11128 if (!strcmp(res->ops, "add"))
11129 ret = rte_eth_dev_filter_ctrl(res->port_id,
11130 RTE_ETH_FILTER_ETHERTYPE,
11131 RTE_ETH_FILTER_ADD,
11134 ret = rte_eth_dev_filter_ctrl(res->port_id,
11135 RTE_ETH_FILTER_ETHERTYPE,
11136 RTE_ETH_FILTER_DELETE,
11139 printf("ethertype filter programming error: (%s)\n",
11143 cmdline_parse_inst_t cmd_ethertype_filter = {
11144 .f = cmd_ethertype_filter_parsed,
11146 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
11147 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
11148 "Add or delete an ethertype filter entry",
11150 (void *)&cmd_ethertype_filter_filter,
11151 (void *)&cmd_ethertype_filter_port_id,
11152 (void *)&cmd_ethertype_filter_ops,
11153 (void *)&cmd_ethertype_filter_mac,
11154 (void *)&cmd_ethertype_filter_mac_addr,
11155 (void *)&cmd_ethertype_filter_ethertype,
11156 (void *)&cmd_ethertype_filter_ethertype_value,
11157 (void *)&cmd_ethertype_filter_drop,
11158 (void *)&cmd_ethertype_filter_queue,
11159 (void *)&cmd_ethertype_filter_queue_id,
11164 /* *** deal with flow director filter *** */
11165 struct cmd_flow_director_result {
11166 cmdline_fixed_string_t flow_director_filter;
11168 cmdline_fixed_string_t mode;
11169 cmdline_fixed_string_t mode_value;
11170 cmdline_fixed_string_t ops;
11171 cmdline_fixed_string_t flow;
11172 cmdline_fixed_string_t flow_type;
11173 cmdline_fixed_string_t ether;
11174 uint16_t ether_type;
11175 cmdline_fixed_string_t src;
11176 cmdline_ipaddr_t ip_src;
11178 cmdline_fixed_string_t dst;
11179 cmdline_ipaddr_t ip_dst;
11181 cmdline_fixed_string_t verify_tag;
11182 uint32_t verify_tag_value;
11183 cmdline_fixed_string_t tos;
11185 cmdline_fixed_string_t proto;
11186 uint8_t proto_value;
11187 cmdline_fixed_string_t ttl;
11189 cmdline_fixed_string_t vlan;
11190 uint16_t vlan_value;
11191 cmdline_fixed_string_t flexbytes;
11192 cmdline_fixed_string_t flexbytes_value;
11193 cmdline_fixed_string_t pf_vf;
11194 cmdline_fixed_string_t drop;
11195 cmdline_fixed_string_t queue;
11197 cmdline_fixed_string_t fd_id;
11198 uint32_t fd_id_value;
11199 cmdline_fixed_string_t mac;
11200 struct rte_ether_addr mac_addr;
11201 cmdline_fixed_string_t tunnel;
11202 cmdline_fixed_string_t tunnel_type;
11203 cmdline_fixed_string_t tunnel_id;
11204 uint32_t tunnel_id_value;
11205 cmdline_fixed_string_t packet;
11210 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
11213 const char *p, *p0 = q_arg;
11215 unsigned long int_fld;
11216 char *str_fld[max_num];
11221 p = strchr(p0, '(');
11225 p0 = strchr(p, ')');
11230 if (size >= sizeof(s))
11233 snprintf(s, sizeof(s), "%.*s", size, p);
11234 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11235 if (ret < 0 || ret > max_num)
11237 for (i = 0; i < ret; i++) {
11239 int_fld = strtoul(str_fld[i], &end, 0);
11240 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
11242 flexbytes[i] = (uint8_t)int_fld;
11248 str2flowtype(char *string)
11251 static const struct {
11254 } flowtype_str[] = {
11255 {"raw", RTE_ETH_FLOW_RAW},
11256 {"ipv4", RTE_ETH_FLOW_IPV4},
11257 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11258 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11259 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11260 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11261 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11262 {"ipv6", RTE_ETH_FLOW_IPV6},
11263 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11264 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11265 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11266 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11267 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11268 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11271 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
11272 if (!strcmp(flowtype_str[i].str, string))
11273 return flowtype_str[i].type;
11276 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
11277 return (uint16_t)atoi(string);
11279 return RTE_ETH_FLOW_UNKNOWN;
11282 static enum rte_eth_fdir_tunnel_type
11283 str2fdir_tunneltype(char *string)
11287 static const struct {
11289 enum rte_eth_fdir_tunnel_type type;
11290 } tunneltype_str[] = {
11291 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
11292 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
11295 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
11296 if (!strcmp(tunneltype_str[i].str, string))
11297 return tunneltype_str[i].type;
11299 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
11302 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
11304 if ((ip_addr).family == AF_INET) \
11305 (ip) = (ip_addr).addr.ipv4.s_addr; \
11307 printf("invalid parameter.\n"); \
11312 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
11314 if ((ip_addr).family == AF_INET6) \
11315 rte_memcpy(&(ip), \
11316 &((ip_addr).addr.ipv6), \
11317 sizeof(struct in6_addr)); \
11319 printf("invalid parameter.\n"); \
11325 cmd_flow_director_filter_parsed(void *parsed_result,
11326 __rte_unused struct cmdline *cl,
11327 __rte_unused void *data)
11329 struct cmd_flow_director_result *res = parsed_result;
11330 struct rte_eth_fdir_filter entry;
11331 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11333 unsigned long vf_id;
11336 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11338 printf("flow director is not supported on port %u.\n",
11342 memset(flexbytes, 0, sizeof(flexbytes));
11343 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11345 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11346 if (strcmp(res->mode_value, "MAC-VLAN")) {
11347 printf("Please set mode to MAC-VLAN.\n");
11350 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11351 if (strcmp(res->mode_value, "Tunnel")) {
11352 printf("Please set mode to Tunnel.\n");
11356 if (!strcmp(res->mode_value, "raw")) {
11357 #ifdef RTE_LIBRTE_I40E_PMD
11358 struct rte_pmd_i40e_flow_type_mapping
11359 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11360 struct rte_pmd_i40e_pkt_template_conf conf;
11361 uint16_t flow_type = str2flowtype(res->flow_type);
11362 uint16_t i, port = res->port_id;
11365 memset(&conf, 0, sizeof(conf));
11367 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11368 printf("Invalid flow type specified.\n");
11371 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11375 if (mapping[flow_type].pctype == 0ULL) {
11376 printf("Invalid flow type specified.\n");
11379 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11380 if (mapping[flow_type].pctype & (1ULL << i)) {
11381 conf.input.pctype = i;
11386 conf.input.packet = open_file(res->filepath,
11387 &conf.input.length);
11388 if (!conf.input.packet)
11390 if (!strcmp(res->drop, "drop"))
11391 conf.action.behavior =
11392 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11394 conf.action.behavior =
11395 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11396 conf.action.report_status =
11397 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11398 conf.action.rx_queue = res->queue_id;
11399 conf.soft_id = res->fd_id_value;
11400 add = strcmp(res->ops, "del") ? 1 : 0;
11401 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11405 printf("flow director config error: (%s)\n",
11407 close_file(conf.input.packet);
11410 } else if (strcmp(res->mode_value, "IP")) {
11411 printf("Please set mode to IP or raw.\n");
11414 entry.input.flow_type = str2flowtype(res->flow_type);
11417 ret = parse_flexbytes(res->flexbytes_value,
11419 RTE_ETH_FDIR_MAX_FLEXLEN);
11421 printf("error: Cannot parse flexbytes input.\n");
11425 switch (entry.input.flow_type) {
11426 case RTE_ETH_FLOW_FRAG_IPV4:
11427 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11428 entry.input.flow.ip4_flow.proto = res->proto_value;
11430 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11431 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11432 IPV4_ADDR_TO_UINT(res->ip_dst,
11433 entry.input.flow.ip4_flow.dst_ip);
11434 IPV4_ADDR_TO_UINT(res->ip_src,
11435 entry.input.flow.ip4_flow.src_ip);
11436 entry.input.flow.ip4_flow.tos = res->tos_value;
11437 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11438 /* need convert to big endian. */
11439 entry.input.flow.udp4_flow.dst_port =
11440 rte_cpu_to_be_16(res->port_dst);
11441 entry.input.flow.udp4_flow.src_port =
11442 rte_cpu_to_be_16(res->port_src);
11444 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11445 IPV4_ADDR_TO_UINT(res->ip_dst,
11446 entry.input.flow.sctp4_flow.ip.dst_ip);
11447 IPV4_ADDR_TO_UINT(res->ip_src,
11448 entry.input.flow.sctp4_flow.ip.src_ip);
11449 entry.input.flow.ip4_flow.tos = res->tos_value;
11450 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11451 /* need convert to big endian. */
11452 entry.input.flow.sctp4_flow.dst_port =
11453 rte_cpu_to_be_16(res->port_dst);
11454 entry.input.flow.sctp4_flow.src_port =
11455 rte_cpu_to_be_16(res->port_src);
11456 entry.input.flow.sctp4_flow.verify_tag =
11457 rte_cpu_to_be_32(res->verify_tag_value);
11459 case RTE_ETH_FLOW_FRAG_IPV6:
11460 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11461 entry.input.flow.ipv6_flow.proto = res->proto_value;
11463 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11464 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11465 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11466 entry.input.flow.ipv6_flow.dst_ip);
11467 IPV6_ADDR_TO_ARRAY(res->ip_src,
11468 entry.input.flow.ipv6_flow.src_ip);
11469 entry.input.flow.ipv6_flow.tc = res->tos_value;
11470 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11471 /* need convert to big endian. */
11472 entry.input.flow.udp6_flow.dst_port =
11473 rte_cpu_to_be_16(res->port_dst);
11474 entry.input.flow.udp6_flow.src_port =
11475 rte_cpu_to_be_16(res->port_src);
11477 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11478 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11479 entry.input.flow.sctp6_flow.ip.dst_ip);
11480 IPV6_ADDR_TO_ARRAY(res->ip_src,
11481 entry.input.flow.sctp6_flow.ip.src_ip);
11482 entry.input.flow.ipv6_flow.tc = res->tos_value;
11483 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11484 /* need convert to big endian. */
11485 entry.input.flow.sctp6_flow.dst_port =
11486 rte_cpu_to_be_16(res->port_dst);
11487 entry.input.flow.sctp6_flow.src_port =
11488 rte_cpu_to_be_16(res->port_src);
11489 entry.input.flow.sctp6_flow.verify_tag =
11490 rte_cpu_to_be_32(res->verify_tag_value);
11492 case RTE_ETH_FLOW_L2_PAYLOAD:
11493 entry.input.flow.l2_flow.ether_type =
11494 rte_cpu_to_be_16(res->ether_type);
11500 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11501 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11503 sizeof(struct rte_ether_addr));
11505 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11506 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11508 sizeof(struct rte_ether_addr));
11509 entry.input.flow.tunnel_flow.tunnel_type =
11510 str2fdir_tunneltype(res->tunnel_type);
11511 entry.input.flow.tunnel_flow.tunnel_id =
11512 rte_cpu_to_be_32(res->tunnel_id_value);
11515 rte_memcpy(entry.input.flow_ext.flexbytes,
11517 RTE_ETH_FDIR_MAX_FLEXLEN);
11519 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11521 entry.action.flex_off = 0; /*use 0 by default */
11522 if (!strcmp(res->drop, "drop"))
11523 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11525 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11527 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11528 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11529 if (!strcmp(res->pf_vf, "pf"))
11530 entry.input.flow_ext.is_vf = 0;
11531 else if (!strncmp(res->pf_vf, "vf", 2)) {
11532 struct rte_eth_dev_info dev_info;
11534 ret = eth_dev_info_get_print_err(res->port_id,
11540 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11541 if (errno != 0 || *end != '\0' ||
11542 vf_id >= dev_info.max_vfs) {
11543 printf("invalid parameter %s.\n", res->pf_vf);
11546 entry.input.flow_ext.is_vf = 1;
11547 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11549 printf("invalid parameter %s.\n", res->pf_vf);
11554 /* set to report FD ID by default */
11555 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11556 entry.action.rx_queue = res->queue_id;
11557 entry.soft_id = res->fd_id_value;
11558 if (!strcmp(res->ops, "add"))
11559 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11560 RTE_ETH_FILTER_ADD, &entry);
11561 else if (!strcmp(res->ops, "del"))
11562 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11563 RTE_ETH_FILTER_DELETE, &entry);
11565 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11566 RTE_ETH_FILTER_UPDATE, &entry);
11568 printf("flow director programming error: (%s)\n",
11572 cmdline_parse_token_string_t cmd_flow_director_filter =
11573 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11574 flow_director_filter, "flow_director_filter");
11575 cmdline_parse_token_num_t cmd_flow_director_port_id =
11576 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11578 cmdline_parse_token_string_t cmd_flow_director_ops =
11579 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11580 ops, "add#del#update");
11581 cmdline_parse_token_string_t cmd_flow_director_flow =
11582 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11584 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11585 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11587 cmdline_parse_token_string_t cmd_flow_director_ether =
11588 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11590 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11591 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11592 ether_type, UINT16);
11593 cmdline_parse_token_string_t cmd_flow_director_src =
11594 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11596 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11597 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11599 cmdline_parse_token_num_t cmd_flow_director_port_src =
11600 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11602 cmdline_parse_token_string_t cmd_flow_director_dst =
11603 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11605 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11606 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11608 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11609 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11611 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11612 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11613 verify_tag, "verify_tag");
11614 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11615 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11616 verify_tag_value, UINT32);
11617 cmdline_parse_token_string_t cmd_flow_director_tos =
11618 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11620 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11621 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11623 cmdline_parse_token_string_t cmd_flow_director_proto =
11624 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11626 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11627 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11628 proto_value, UINT8);
11629 cmdline_parse_token_string_t cmd_flow_director_ttl =
11630 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11632 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11633 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11635 cmdline_parse_token_string_t cmd_flow_director_vlan =
11636 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11638 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11639 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11640 vlan_value, UINT16);
11641 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11642 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11643 flexbytes, "flexbytes");
11644 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11645 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11646 flexbytes_value, NULL);
11647 cmdline_parse_token_string_t cmd_flow_director_drop =
11648 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11650 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11651 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11653 cmdline_parse_token_string_t cmd_flow_director_queue =
11654 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11656 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11657 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11659 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11660 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11662 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11663 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11664 fd_id_value, UINT32);
11666 cmdline_parse_token_string_t cmd_flow_director_mode =
11667 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11669 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11670 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11672 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11673 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11674 mode_value, "MAC-VLAN");
11675 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11676 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11677 mode_value, "Tunnel");
11678 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11679 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11680 mode_value, "raw");
11681 cmdline_parse_token_string_t cmd_flow_director_mac =
11682 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11684 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11685 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11687 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11688 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11690 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11691 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11692 tunnel_type, "NVGRE#VxLAN");
11693 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11694 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11695 tunnel_id, "tunnel-id");
11696 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11697 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11698 tunnel_id_value, UINT32);
11699 cmdline_parse_token_string_t cmd_flow_director_packet =
11700 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11702 cmdline_parse_token_string_t cmd_flow_director_filepath =
11703 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11706 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11707 .f = cmd_flow_director_filter_parsed,
11709 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11710 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11711 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11712 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11713 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11714 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11715 "fd_id <fd_id_value>: "
11716 "Add or delete an ip flow director entry on NIC",
11718 (void *)&cmd_flow_director_filter,
11719 (void *)&cmd_flow_director_port_id,
11720 (void *)&cmd_flow_director_mode,
11721 (void *)&cmd_flow_director_mode_ip,
11722 (void *)&cmd_flow_director_ops,
11723 (void *)&cmd_flow_director_flow,
11724 (void *)&cmd_flow_director_flow_type,
11725 (void *)&cmd_flow_director_src,
11726 (void *)&cmd_flow_director_ip_src,
11727 (void *)&cmd_flow_director_dst,
11728 (void *)&cmd_flow_director_ip_dst,
11729 (void *)&cmd_flow_director_tos,
11730 (void *)&cmd_flow_director_tos_value,
11731 (void *)&cmd_flow_director_proto,
11732 (void *)&cmd_flow_director_proto_value,
11733 (void *)&cmd_flow_director_ttl,
11734 (void *)&cmd_flow_director_ttl_value,
11735 (void *)&cmd_flow_director_vlan,
11736 (void *)&cmd_flow_director_vlan_value,
11737 (void *)&cmd_flow_director_flexbytes,
11738 (void *)&cmd_flow_director_flexbytes_value,
11739 (void *)&cmd_flow_director_drop,
11740 (void *)&cmd_flow_director_pf_vf,
11741 (void *)&cmd_flow_director_queue,
11742 (void *)&cmd_flow_director_queue_id,
11743 (void *)&cmd_flow_director_fd_id,
11744 (void *)&cmd_flow_director_fd_id_value,
11749 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11750 .f = cmd_flow_director_filter_parsed,
11752 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11753 "director entry on NIC",
11755 (void *)&cmd_flow_director_filter,
11756 (void *)&cmd_flow_director_port_id,
11757 (void *)&cmd_flow_director_mode,
11758 (void *)&cmd_flow_director_mode_ip,
11759 (void *)&cmd_flow_director_ops,
11760 (void *)&cmd_flow_director_flow,
11761 (void *)&cmd_flow_director_flow_type,
11762 (void *)&cmd_flow_director_src,
11763 (void *)&cmd_flow_director_ip_src,
11764 (void *)&cmd_flow_director_port_src,
11765 (void *)&cmd_flow_director_dst,
11766 (void *)&cmd_flow_director_ip_dst,
11767 (void *)&cmd_flow_director_port_dst,
11768 (void *)&cmd_flow_director_tos,
11769 (void *)&cmd_flow_director_tos_value,
11770 (void *)&cmd_flow_director_ttl,
11771 (void *)&cmd_flow_director_ttl_value,
11772 (void *)&cmd_flow_director_vlan,
11773 (void *)&cmd_flow_director_vlan_value,
11774 (void *)&cmd_flow_director_flexbytes,
11775 (void *)&cmd_flow_director_flexbytes_value,
11776 (void *)&cmd_flow_director_drop,
11777 (void *)&cmd_flow_director_pf_vf,
11778 (void *)&cmd_flow_director_queue,
11779 (void *)&cmd_flow_director_queue_id,
11780 (void *)&cmd_flow_director_fd_id,
11781 (void *)&cmd_flow_director_fd_id_value,
11786 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11787 .f = cmd_flow_director_filter_parsed,
11789 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11790 "director entry on NIC",
11792 (void *)&cmd_flow_director_filter,
11793 (void *)&cmd_flow_director_port_id,
11794 (void *)&cmd_flow_director_mode,
11795 (void *)&cmd_flow_director_mode_ip,
11796 (void *)&cmd_flow_director_ops,
11797 (void *)&cmd_flow_director_flow,
11798 (void *)&cmd_flow_director_flow_type,
11799 (void *)&cmd_flow_director_src,
11800 (void *)&cmd_flow_director_ip_src,
11801 (void *)&cmd_flow_director_port_src,
11802 (void *)&cmd_flow_director_dst,
11803 (void *)&cmd_flow_director_ip_dst,
11804 (void *)&cmd_flow_director_port_dst,
11805 (void *)&cmd_flow_director_verify_tag,
11806 (void *)&cmd_flow_director_verify_tag_value,
11807 (void *)&cmd_flow_director_tos,
11808 (void *)&cmd_flow_director_tos_value,
11809 (void *)&cmd_flow_director_ttl,
11810 (void *)&cmd_flow_director_ttl_value,
11811 (void *)&cmd_flow_director_vlan,
11812 (void *)&cmd_flow_director_vlan_value,
11813 (void *)&cmd_flow_director_flexbytes,
11814 (void *)&cmd_flow_director_flexbytes_value,
11815 (void *)&cmd_flow_director_drop,
11816 (void *)&cmd_flow_director_pf_vf,
11817 (void *)&cmd_flow_director_queue,
11818 (void *)&cmd_flow_director_queue_id,
11819 (void *)&cmd_flow_director_fd_id,
11820 (void *)&cmd_flow_director_fd_id_value,
11825 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11826 .f = cmd_flow_director_filter_parsed,
11828 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11829 "director entry on NIC",
11831 (void *)&cmd_flow_director_filter,
11832 (void *)&cmd_flow_director_port_id,
11833 (void *)&cmd_flow_director_mode,
11834 (void *)&cmd_flow_director_mode_ip,
11835 (void *)&cmd_flow_director_ops,
11836 (void *)&cmd_flow_director_flow,
11837 (void *)&cmd_flow_director_flow_type,
11838 (void *)&cmd_flow_director_ether,
11839 (void *)&cmd_flow_director_ether_type,
11840 (void *)&cmd_flow_director_flexbytes,
11841 (void *)&cmd_flow_director_flexbytes_value,
11842 (void *)&cmd_flow_director_drop,
11843 (void *)&cmd_flow_director_pf_vf,
11844 (void *)&cmd_flow_director_queue,
11845 (void *)&cmd_flow_director_queue_id,
11846 (void *)&cmd_flow_director_fd_id,
11847 (void *)&cmd_flow_director_fd_id_value,
11852 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11853 .f = cmd_flow_director_filter_parsed,
11855 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11856 "director entry on NIC",
11858 (void *)&cmd_flow_director_filter,
11859 (void *)&cmd_flow_director_port_id,
11860 (void *)&cmd_flow_director_mode,
11861 (void *)&cmd_flow_director_mode_mac_vlan,
11862 (void *)&cmd_flow_director_ops,
11863 (void *)&cmd_flow_director_mac,
11864 (void *)&cmd_flow_director_mac_addr,
11865 (void *)&cmd_flow_director_vlan,
11866 (void *)&cmd_flow_director_vlan_value,
11867 (void *)&cmd_flow_director_flexbytes,
11868 (void *)&cmd_flow_director_flexbytes_value,
11869 (void *)&cmd_flow_director_drop,
11870 (void *)&cmd_flow_director_queue,
11871 (void *)&cmd_flow_director_queue_id,
11872 (void *)&cmd_flow_director_fd_id,
11873 (void *)&cmd_flow_director_fd_id_value,
11878 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11879 .f = cmd_flow_director_filter_parsed,
11881 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11882 "director entry on NIC",
11884 (void *)&cmd_flow_director_filter,
11885 (void *)&cmd_flow_director_port_id,
11886 (void *)&cmd_flow_director_mode,
11887 (void *)&cmd_flow_director_mode_tunnel,
11888 (void *)&cmd_flow_director_ops,
11889 (void *)&cmd_flow_director_mac,
11890 (void *)&cmd_flow_director_mac_addr,
11891 (void *)&cmd_flow_director_vlan,
11892 (void *)&cmd_flow_director_vlan_value,
11893 (void *)&cmd_flow_director_tunnel,
11894 (void *)&cmd_flow_director_tunnel_type,
11895 (void *)&cmd_flow_director_tunnel_id,
11896 (void *)&cmd_flow_director_tunnel_id_value,
11897 (void *)&cmd_flow_director_flexbytes,
11898 (void *)&cmd_flow_director_flexbytes_value,
11899 (void *)&cmd_flow_director_drop,
11900 (void *)&cmd_flow_director_queue,
11901 (void *)&cmd_flow_director_queue_id,
11902 (void *)&cmd_flow_director_fd_id,
11903 (void *)&cmd_flow_director_fd_id_value,
11908 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11909 .f = cmd_flow_director_filter_parsed,
11911 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11912 "director entry on NIC",
11914 (void *)&cmd_flow_director_filter,
11915 (void *)&cmd_flow_director_port_id,
11916 (void *)&cmd_flow_director_mode,
11917 (void *)&cmd_flow_director_mode_raw,
11918 (void *)&cmd_flow_director_ops,
11919 (void *)&cmd_flow_director_flow,
11920 (void *)&cmd_flow_director_flow_type,
11921 (void *)&cmd_flow_director_drop,
11922 (void *)&cmd_flow_director_queue,
11923 (void *)&cmd_flow_director_queue_id,
11924 (void *)&cmd_flow_director_fd_id,
11925 (void *)&cmd_flow_director_fd_id_value,
11926 (void *)&cmd_flow_director_packet,
11927 (void *)&cmd_flow_director_filepath,
11932 struct cmd_flush_flow_director_result {
11933 cmdline_fixed_string_t flush_flow_director;
11937 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11938 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11939 flush_flow_director, "flush_flow_director");
11940 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11941 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11945 cmd_flush_flow_director_parsed(void *parsed_result,
11946 __rte_unused struct cmdline *cl,
11947 __rte_unused void *data)
11949 struct cmd_flow_director_result *res = parsed_result;
11952 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11954 printf("flow director is not supported on port %u.\n",
11959 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11960 RTE_ETH_FILTER_FLUSH, NULL);
11962 printf("flow director table flushing error: (%s)\n",
11966 cmdline_parse_inst_t cmd_flush_flow_director = {
11967 .f = cmd_flush_flow_director_parsed,
11969 .help_str = "flush_flow_director <port_id>: "
11970 "Flush all flow director entries of a device on NIC",
11972 (void *)&cmd_flush_flow_director_flush,
11973 (void *)&cmd_flush_flow_director_port_id,
11978 /* *** deal with flow director mask *** */
11979 struct cmd_flow_director_mask_result {
11980 cmdline_fixed_string_t flow_director_mask;
11982 cmdline_fixed_string_t mode;
11983 cmdline_fixed_string_t mode_value;
11984 cmdline_fixed_string_t vlan;
11985 uint16_t vlan_mask;
11986 cmdline_fixed_string_t src_mask;
11987 cmdline_ipaddr_t ipv4_src;
11988 cmdline_ipaddr_t ipv6_src;
11990 cmdline_fixed_string_t dst_mask;
11991 cmdline_ipaddr_t ipv4_dst;
11992 cmdline_ipaddr_t ipv6_dst;
11994 cmdline_fixed_string_t mac;
11995 uint8_t mac_addr_byte_mask;
11996 cmdline_fixed_string_t tunnel_id;
11997 uint32_t tunnel_id_mask;
11998 cmdline_fixed_string_t tunnel_type;
11999 uint8_t tunnel_type_mask;
12003 cmd_flow_director_mask_parsed(void *parsed_result,
12004 __rte_unused struct cmdline *cl,
12005 __rte_unused void *data)
12007 struct cmd_flow_director_mask_result *res = parsed_result;
12008 struct rte_eth_fdir_masks *mask;
12009 struct rte_port *port;
12011 port = &ports[res->port_id];
12012 /** Check if the port is not started **/
12013 if (port->port_status != RTE_PORT_STOPPED) {
12014 printf("Please stop port %d first\n", res->port_id);
12018 mask = &port->dev_conf.fdir_conf.mask;
12020 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
12021 if (strcmp(res->mode_value, "MAC-VLAN")) {
12022 printf("Please set mode to MAC-VLAN.\n");
12026 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
12027 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
12028 if (strcmp(res->mode_value, "Tunnel")) {
12029 printf("Please set mode to Tunnel.\n");
12033 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
12034 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
12035 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
12036 mask->tunnel_type_mask = res->tunnel_type_mask;
12038 if (strcmp(res->mode_value, "IP")) {
12039 printf("Please set mode to IP.\n");
12043 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
12044 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
12045 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
12046 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
12047 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
12048 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
12049 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
12052 cmd_reconfig_device_queue(res->port_id, 1, 1);
12055 cmdline_parse_token_string_t cmd_flow_director_mask =
12056 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12057 flow_director_mask, "flow_director_mask");
12058 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
12059 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12061 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
12062 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12064 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
12065 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12066 vlan_mask, UINT16);
12067 cmdline_parse_token_string_t cmd_flow_director_mask_src =
12068 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12069 src_mask, "src_mask");
12070 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
12071 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12073 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
12074 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12076 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
12077 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12079 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
12080 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12081 dst_mask, "dst_mask");
12082 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
12083 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12085 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
12086 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12088 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
12089 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12092 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
12093 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12095 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
12096 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12098 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
12099 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12100 mode_value, "MAC-VLAN");
12101 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
12102 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12103 mode_value, "Tunnel");
12104 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
12105 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12107 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
12108 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12109 mac_addr_byte_mask, UINT8);
12110 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
12111 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12112 tunnel_type, "tunnel-type");
12113 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
12114 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12115 tunnel_type_mask, UINT8);
12116 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
12117 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12118 tunnel_id, "tunnel-id");
12119 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
12120 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12121 tunnel_id_mask, UINT32);
12123 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
12124 .f = cmd_flow_director_mask_parsed,
12126 .help_str = "flow_director_mask ... : "
12127 "Set IP mode flow director's mask on NIC",
12129 (void *)&cmd_flow_director_mask,
12130 (void *)&cmd_flow_director_mask_port_id,
12131 (void *)&cmd_flow_director_mask_mode,
12132 (void *)&cmd_flow_director_mask_mode_ip,
12133 (void *)&cmd_flow_director_mask_vlan,
12134 (void *)&cmd_flow_director_mask_vlan_value,
12135 (void *)&cmd_flow_director_mask_src,
12136 (void *)&cmd_flow_director_mask_ipv4_src,
12137 (void *)&cmd_flow_director_mask_ipv6_src,
12138 (void *)&cmd_flow_director_mask_port_src,
12139 (void *)&cmd_flow_director_mask_dst,
12140 (void *)&cmd_flow_director_mask_ipv4_dst,
12141 (void *)&cmd_flow_director_mask_ipv6_dst,
12142 (void *)&cmd_flow_director_mask_port_dst,
12147 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
12148 .f = cmd_flow_director_mask_parsed,
12150 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
12151 "flow director's mask on NIC",
12153 (void *)&cmd_flow_director_mask,
12154 (void *)&cmd_flow_director_mask_port_id,
12155 (void *)&cmd_flow_director_mask_mode,
12156 (void *)&cmd_flow_director_mask_mode_mac_vlan,
12157 (void *)&cmd_flow_director_mask_vlan,
12158 (void *)&cmd_flow_director_mask_vlan_value,
12163 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
12164 .f = cmd_flow_director_mask_parsed,
12166 .help_str = "flow_director_mask ... : Set tunnel mode "
12167 "flow director's mask on NIC",
12169 (void *)&cmd_flow_director_mask,
12170 (void *)&cmd_flow_director_mask_port_id,
12171 (void *)&cmd_flow_director_mask_mode,
12172 (void *)&cmd_flow_director_mask_mode_tunnel,
12173 (void *)&cmd_flow_director_mask_vlan,
12174 (void *)&cmd_flow_director_mask_vlan_value,
12175 (void *)&cmd_flow_director_mask_mac,
12176 (void *)&cmd_flow_director_mask_mac_value,
12177 (void *)&cmd_flow_director_mask_tunnel_type,
12178 (void *)&cmd_flow_director_mask_tunnel_type_value,
12179 (void *)&cmd_flow_director_mask_tunnel_id,
12180 (void *)&cmd_flow_director_mask_tunnel_id_value,
12185 /* *** deal with flow director mask on flexible payload *** */
12186 struct cmd_flow_director_flex_mask_result {
12187 cmdline_fixed_string_t flow_director_flexmask;
12189 cmdline_fixed_string_t flow;
12190 cmdline_fixed_string_t flow_type;
12191 cmdline_fixed_string_t mask;
12195 cmd_flow_director_flex_mask_parsed(void *parsed_result,
12196 __rte_unused struct cmdline *cl,
12197 __rte_unused void *data)
12199 struct cmd_flow_director_flex_mask_result *res = parsed_result;
12200 struct rte_eth_fdir_info fdir_info;
12201 struct rte_eth_fdir_flex_mask flex_mask;
12202 struct rte_port *port;
12203 uint64_t flow_type_mask;
12207 port = &ports[res->port_id];
12208 /** Check if the port is not started **/
12209 if (port->port_status != RTE_PORT_STOPPED) {
12210 printf("Please stop port %d first\n", res->port_id);
12214 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
12215 ret = parse_flexbytes(res->mask,
12217 RTE_ETH_FDIR_MAX_FLEXLEN);
12219 printf("error: Cannot parse mask input.\n");
12223 memset(&fdir_info, 0, sizeof(fdir_info));
12224 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12225 RTE_ETH_FILTER_INFO, &fdir_info);
12227 printf("Cannot get FDir filter info\n");
12231 if (!strcmp(res->flow_type, "none")) {
12232 /* means don't specify the flow type */
12233 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
12234 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
12235 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
12236 0, sizeof(struct rte_eth_fdir_flex_mask));
12237 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
12238 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
12240 sizeof(struct rte_eth_fdir_flex_mask));
12241 cmd_reconfig_device_queue(res->port_id, 1, 1);
12244 flow_type_mask = fdir_info.flow_types_mask[0];
12245 if (!strcmp(res->flow_type, "all")) {
12246 if (!flow_type_mask) {
12247 printf("No flow type supported\n");
12250 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
12251 if (flow_type_mask & (1ULL << i)) {
12252 flex_mask.flow_type = i;
12253 fdir_set_flex_mask(res->port_id, &flex_mask);
12256 cmd_reconfig_device_queue(res->port_id, 1, 1);
12259 flex_mask.flow_type = str2flowtype(res->flow_type);
12260 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
12261 printf("Flow type %s not supported on port %d\n",
12262 res->flow_type, res->port_id);
12265 fdir_set_flex_mask(res->port_id, &flex_mask);
12266 cmd_reconfig_device_queue(res->port_id, 1, 1);
12269 cmdline_parse_token_string_t cmd_flow_director_flexmask =
12270 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12271 flow_director_flexmask,
12272 "flow_director_flex_mask");
12273 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
12274 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12276 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
12277 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12279 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
12280 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12281 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
12282 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
12283 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
12284 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12287 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
12288 .f = cmd_flow_director_flex_mask_parsed,
12290 .help_str = "flow_director_flex_mask ... : "
12291 "Set flow director's flex mask on NIC",
12293 (void *)&cmd_flow_director_flexmask,
12294 (void *)&cmd_flow_director_flexmask_port_id,
12295 (void *)&cmd_flow_director_flexmask_flow,
12296 (void *)&cmd_flow_director_flexmask_flow_type,
12297 (void *)&cmd_flow_director_flexmask_mask,
12302 /* *** deal with flow director flexible payload configuration *** */
12303 struct cmd_flow_director_flexpayload_result {
12304 cmdline_fixed_string_t flow_director_flexpayload;
12306 cmdline_fixed_string_t payload_layer;
12307 cmdline_fixed_string_t payload_cfg;
12311 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
12314 const char *p, *p0 = q_arg;
12316 unsigned long int_fld;
12317 char *str_fld[max_num];
12322 p = strchr(p0, '(');
12326 p0 = strchr(p, ')');
12331 if (size >= sizeof(s))
12334 snprintf(s, sizeof(s), "%.*s", size, p);
12335 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12336 if (ret < 0 || ret > max_num)
12338 for (i = 0; i < ret; i++) {
12340 int_fld = strtoul(str_fld[i], &end, 0);
12341 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12343 offsets[i] = (uint16_t)int_fld;
12349 cmd_flow_director_flxpld_parsed(void *parsed_result,
12350 __rte_unused struct cmdline *cl,
12351 __rte_unused void *data)
12353 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12354 struct rte_eth_flex_payload_cfg flex_cfg;
12355 struct rte_port *port;
12358 port = &ports[res->port_id];
12359 /** Check if the port is not started **/
12360 if (port->port_status != RTE_PORT_STOPPED) {
12361 printf("Please stop port %d first\n", res->port_id);
12365 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12367 if (!strcmp(res->payload_layer, "raw"))
12368 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12369 else if (!strcmp(res->payload_layer, "l2"))
12370 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12371 else if (!strcmp(res->payload_layer, "l3"))
12372 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12373 else if (!strcmp(res->payload_layer, "l4"))
12374 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12376 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12377 RTE_ETH_FDIR_MAX_FLEXLEN);
12379 printf("error: Cannot parse flex payload input.\n");
12383 fdir_set_flex_payload(res->port_id, &flex_cfg);
12384 cmd_reconfig_device_queue(res->port_id, 1, 1);
12387 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12388 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12389 flow_director_flexpayload,
12390 "flow_director_flex_payload");
12391 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12392 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12394 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12395 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12396 payload_layer, "raw#l2#l3#l4");
12397 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12398 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12399 payload_cfg, NULL);
12401 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12402 .f = cmd_flow_director_flxpld_parsed,
12404 .help_str = "flow_director_flexpayload ... : "
12405 "Set flow director's flex payload on NIC",
12407 (void *)&cmd_flow_director_flexpayload,
12408 (void *)&cmd_flow_director_flexpayload_port_id,
12409 (void *)&cmd_flow_director_flexpayload_payload_layer,
12410 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12415 /* Generic flow interface command. */
12416 extern cmdline_parse_inst_t cmd_flow;
12418 /* *** Classification Filters Control *** */
12419 /* *** Get symmetric hash enable per port *** */
12420 struct cmd_get_sym_hash_ena_per_port_result {
12421 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12426 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12427 __rte_unused struct cmdline *cl,
12428 __rte_unused void *data)
12430 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12431 struct rte_eth_hash_filter_info info;
12434 if (rte_eth_dev_filter_supported(res->port_id,
12435 RTE_ETH_FILTER_HASH) < 0) {
12436 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12441 memset(&info, 0, sizeof(info));
12442 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12443 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12444 RTE_ETH_FILTER_GET, &info);
12447 printf("Cannot get symmetric hash enable per port "
12448 "on port %u\n", res->port_id);
12452 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12453 "enabled" : "disabled", res->port_id);
12456 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12457 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12458 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12459 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12460 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12463 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12464 .f = cmd_get_sym_hash_per_port_parsed,
12466 .help_str = "get_sym_hash_ena_per_port <port_id>",
12468 (void *)&cmd_get_sym_hash_ena_per_port_all,
12469 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12474 /* *** Set symmetric hash enable per port *** */
12475 struct cmd_set_sym_hash_ena_per_port_result {
12476 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12477 cmdline_fixed_string_t enable;
12482 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12483 __rte_unused struct cmdline *cl,
12484 __rte_unused void *data)
12486 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12487 struct rte_eth_hash_filter_info info;
12490 if (rte_eth_dev_filter_supported(res->port_id,
12491 RTE_ETH_FILTER_HASH) < 0) {
12492 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12497 memset(&info, 0, sizeof(info));
12498 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12499 if (!strcmp(res->enable, "enable"))
12500 info.info.enable = 1;
12501 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12502 RTE_ETH_FILTER_SET, &info);
12504 printf("Cannot set symmetric hash enable per port on "
12505 "port %u\n", res->port_id);
12508 printf("Symmetric hash has been set to %s on port %u\n",
12509 res->enable, res->port_id);
12512 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12513 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12514 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12515 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12516 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12518 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12519 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12520 enable, "enable#disable");
12522 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12523 .f = cmd_set_sym_hash_per_port_parsed,
12525 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12527 (void *)&cmd_set_sym_hash_ena_per_port_all,
12528 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12529 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12534 /* Get global config of hash function */
12535 struct cmd_get_hash_global_config_result {
12536 cmdline_fixed_string_t get_hash_global_config;
12541 flowtype_to_str(uint16_t ftype)
12547 } ftype_table[] = {
12548 {"ipv4", RTE_ETH_FLOW_IPV4},
12549 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12550 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12551 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12552 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12553 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12554 {"ipv6", RTE_ETH_FLOW_IPV6},
12555 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12556 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12557 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12558 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12559 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12560 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12561 {"port", RTE_ETH_FLOW_PORT},
12562 {"vxlan", RTE_ETH_FLOW_VXLAN},
12563 {"geneve", RTE_ETH_FLOW_GENEVE},
12564 {"nvgre", RTE_ETH_FLOW_NVGRE},
12565 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12568 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12569 if (ftype_table[i].ftype == ftype)
12570 return ftype_table[i].str;
12577 cmd_get_hash_global_config_parsed(void *parsed_result,
12578 __rte_unused struct cmdline *cl,
12579 __rte_unused void *data)
12581 struct cmd_get_hash_global_config_result *res = parsed_result;
12582 struct rte_eth_hash_filter_info info;
12583 uint32_t idx, offset;
12588 if (rte_eth_dev_filter_supported(res->port_id,
12589 RTE_ETH_FILTER_HASH) < 0) {
12590 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12595 memset(&info, 0, sizeof(info));
12596 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12597 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12598 RTE_ETH_FILTER_GET, &info);
12600 printf("Cannot get hash global configurations by port %d\n",
12605 switch (info.info.global_conf.hash_func) {
12606 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12607 printf("Hash function is Toeplitz\n");
12609 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12610 printf("Hash function is Simple XOR\n");
12612 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12613 printf("Hash function is Symmetric Toeplitz\n");
12616 printf("Unknown hash function\n");
12620 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12621 idx = i / UINT64_BIT;
12622 offset = i % UINT64_BIT;
12623 if (!(info.info.global_conf.valid_bit_mask[idx] &
12626 str = flowtype_to_str(i);
12629 printf("Symmetric hash is %s globally for flow type %s "
12631 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12632 (1ULL << offset)) ? "enabled" : "disabled"), str,
12637 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12638 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12639 get_hash_global_config, "get_hash_global_config");
12640 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12641 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12644 cmdline_parse_inst_t cmd_get_hash_global_config = {
12645 .f = cmd_get_hash_global_config_parsed,
12647 .help_str = "get_hash_global_config <port_id>",
12649 (void *)&cmd_get_hash_global_config_all,
12650 (void *)&cmd_get_hash_global_config_port_id,
12655 /* Set global config of hash function */
12656 struct cmd_set_hash_global_config_result {
12657 cmdline_fixed_string_t set_hash_global_config;
12659 cmdline_fixed_string_t hash_func;
12660 cmdline_fixed_string_t flow_type;
12661 cmdline_fixed_string_t enable;
12665 cmd_set_hash_global_config_parsed(void *parsed_result,
12666 __rte_unused struct cmdline *cl,
12667 __rte_unused void *data)
12669 struct cmd_set_hash_global_config_result *res = parsed_result;
12670 struct rte_eth_hash_filter_info info;
12671 uint32_t ftype, idx, offset;
12674 if (rte_eth_dev_filter_supported(res->port_id,
12675 RTE_ETH_FILTER_HASH) < 0) {
12676 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12680 memset(&info, 0, sizeof(info));
12681 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12682 if (!strcmp(res->hash_func, "toeplitz"))
12683 info.info.global_conf.hash_func =
12684 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12685 else if (!strcmp(res->hash_func, "simple_xor"))
12686 info.info.global_conf.hash_func =
12687 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12688 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12689 info.info.global_conf.hash_func =
12690 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12691 else if (!strcmp(res->hash_func, "default"))
12692 info.info.global_conf.hash_func =
12693 RTE_ETH_HASH_FUNCTION_DEFAULT;
12695 ftype = str2flowtype(res->flow_type);
12696 idx = ftype / UINT64_BIT;
12697 offset = ftype % UINT64_BIT;
12698 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12699 if (!strcmp(res->enable, "enable"))
12700 info.info.global_conf.sym_hash_enable_mask[idx] |=
12702 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12703 RTE_ETH_FILTER_SET, &info);
12705 printf("Cannot set global hash configurations by port %d\n",
12708 printf("Global hash configurations have been set "
12709 "successfully by port %d\n", res->port_id);
12712 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12713 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12714 set_hash_global_config, "set_hash_global_config");
12715 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12716 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12718 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12719 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12720 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12721 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12722 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12724 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12725 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12726 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12727 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12728 enable, "enable#disable");
12730 cmdline_parse_inst_t cmd_set_hash_global_config = {
12731 .f = cmd_set_hash_global_config_parsed,
12733 .help_str = "set_hash_global_config <port_id> "
12734 "toeplitz|simple_xor|symmetric_toeplitz|default "
12735 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12736 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12737 "l2_payload enable|disable",
12739 (void *)&cmd_set_hash_global_config_all,
12740 (void *)&cmd_set_hash_global_config_port_id,
12741 (void *)&cmd_set_hash_global_config_hash_func,
12742 (void *)&cmd_set_hash_global_config_flow_type,
12743 (void *)&cmd_set_hash_global_config_enable,
12748 /* Set hash input set */
12749 struct cmd_set_hash_input_set_result {
12750 cmdline_fixed_string_t set_hash_input_set;
12752 cmdline_fixed_string_t flow_type;
12753 cmdline_fixed_string_t inset_field;
12754 cmdline_fixed_string_t select;
12757 static enum rte_eth_input_set_field
12758 str2inset(char *string)
12762 static const struct {
12764 enum rte_eth_input_set_field inset;
12765 } inset_table[] = {
12766 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12767 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12768 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12769 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12770 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12771 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12772 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12773 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12774 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12775 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12776 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12777 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12778 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12779 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12780 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12781 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12782 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12783 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12784 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12785 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12786 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12787 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12788 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12789 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12790 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12791 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12792 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12793 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12794 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12795 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12796 {"none", RTE_ETH_INPUT_SET_NONE},
12799 for (i = 0; i < RTE_DIM(inset_table); i++) {
12800 if (!strcmp(string, inset_table[i].str))
12801 return inset_table[i].inset;
12804 return RTE_ETH_INPUT_SET_UNKNOWN;
12808 cmd_set_hash_input_set_parsed(void *parsed_result,
12809 __rte_unused struct cmdline *cl,
12810 __rte_unused void *data)
12812 struct cmd_set_hash_input_set_result *res = parsed_result;
12813 struct rte_eth_hash_filter_info info;
12815 memset(&info, 0, sizeof(info));
12816 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12817 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12818 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12819 info.info.input_set_conf.inset_size = 1;
12820 if (!strcmp(res->select, "select"))
12821 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12822 else if (!strcmp(res->select, "add"))
12823 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12824 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12825 RTE_ETH_FILTER_SET, &info);
12828 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12829 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12830 set_hash_input_set, "set_hash_input_set");
12831 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12832 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12834 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12835 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12837 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12838 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12840 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12841 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12842 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12843 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12844 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12846 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12847 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12848 select, "select#add");
12850 cmdline_parse_inst_t cmd_set_hash_input_set = {
12851 .f = cmd_set_hash_input_set_parsed,
12853 .help_str = "set_hash_input_set <port_id> "
12854 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12855 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12856 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12857 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12858 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12859 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12860 "fld-7th|fld-8th|none select|add",
12862 (void *)&cmd_set_hash_input_set_cmd,
12863 (void *)&cmd_set_hash_input_set_port_id,
12864 (void *)&cmd_set_hash_input_set_flow_type,
12865 (void *)&cmd_set_hash_input_set_field,
12866 (void *)&cmd_set_hash_input_set_select,
12871 /* Set flow director input set */
12872 struct cmd_set_fdir_input_set_result {
12873 cmdline_fixed_string_t set_fdir_input_set;
12875 cmdline_fixed_string_t flow_type;
12876 cmdline_fixed_string_t inset_field;
12877 cmdline_fixed_string_t select;
12881 cmd_set_fdir_input_set_parsed(void *parsed_result,
12882 __rte_unused struct cmdline *cl,
12883 __rte_unused void *data)
12885 struct cmd_set_fdir_input_set_result *res = parsed_result;
12886 struct rte_eth_fdir_filter_info info;
12888 memset(&info, 0, sizeof(info));
12889 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12890 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12891 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12892 info.info.input_set_conf.inset_size = 1;
12893 if (!strcmp(res->select, "select"))
12894 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12895 else if (!strcmp(res->select, "add"))
12896 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12897 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12898 RTE_ETH_FILTER_SET, &info);
12901 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12902 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12903 set_fdir_input_set, "set_fdir_input_set");
12904 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12905 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12907 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12908 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12910 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12911 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12912 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12913 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12915 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12916 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12917 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12918 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12919 "sctp-veri-tag#none");
12920 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12921 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12922 select, "select#add");
12924 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12925 .f = cmd_set_fdir_input_set_parsed,
12927 .help_str = "set_fdir_input_set <port_id> "
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 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12931 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12932 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12933 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12934 "sctp-veri-tag|none select|add",
12936 (void *)&cmd_set_fdir_input_set_cmd,
12937 (void *)&cmd_set_fdir_input_set_port_id,
12938 (void *)&cmd_set_fdir_input_set_flow_type,
12939 (void *)&cmd_set_fdir_input_set_field,
12940 (void *)&cmd_set_fdir_input_set_select,
12945 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12946 struct cmd_mcast_addr_result {
12947 cmdline_fixed_string_t mcast_addr_cmd;
12948 cmdline_fixed_string_t what;
12950 struct rte_ether_addr mc_addr;
12953 static void cmd_mcast_addr_parsed(void *parsed_result,
12954 __rte_unused struct cmdline *cl,
12955 __rte_unused void *data)
12957 struct cmd_mcast_addr_result *res = parsed_result;
12959 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12960 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12961 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12962 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12963 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12966 if (strcmp(res->what, "add") == 0)
12967 mcast_addr_add(res->port_num, &res->mc_addr);
12969 mcast_addr_remove(res->port_num, &res->mc_addr);
12972 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12973 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12974 mcast_addr_cmd, "mcast_addr");
12975 cmdline_parse_token_string_t cmd_mcast_addr_what =
12976 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12978 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12979 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12980 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12981 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12983 cmdline_parse_inst_t cmd_mcast_addr = {
12984 .f = cmd_mcast_addr_parsed,
12986 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12987 "Add/Remove multicast MAC address on port_id",
12989 (void *)&cmd_mcast_addr_cmd,
12990 (void *)&cmd_mcast_addr_what,
12991 (void *)&cmd_mcast_addr_portnum,
12992 (void *)&cmd_mcast_addr_addr,
12997 /* l2 tunnel config
12998 * only support E-tag now.
13001 /* Ether type config */
13002 struct cmd_config_l2_tunnel_eth_type_result {
13003 cmdline_fixed_string_t port;
13004 cmdline_fixed_string_t config;
13005 cmdline_fixed_string_t all;
13007 cmdline_fixed_string_t l2_tunnel;
13008 cmdline_fixed_string_t l2_tunnel_type;
13009 cmdline_fixed_string_t eth_type;
13010 uint16_t eth_type_val;
13013 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
13014 TOKEN_STRING_INITIALIZER
13015 (struct cmd_config_l2_tunnel_eth_type_result,
13017 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
13018 TOKEN_STRING_INITIALIZER
13019 (struct cmd_config_l2_tunnel_eth_type_result,
13021 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
13022 TOKEN_STRING_INITIALIZER
13023 (struct cmd_config_l2_tunnel_eth_type_result,
13025 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
13026 TOKEN_NUM_INITIALIZER
13027 (struct cmd_config_l2_tunnel_eth_type_result,
13029 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
13030 TOKEN_STRING_INITIALIZER
13031 (struct cmd_config_l2_tunnel_eth_type_result,
13032 l2_tunnel, "l2-tunnel");
13033 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
13034 TOKEN_STRING_INITIALIZER
13035 (struct cmd_config_l2_tunnel_eth_type_result,
13036 l2_tunnel_type, "E-tag");
13037 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
13038 TOKEN_STRING_INITIALIZER
13039 (struct cmd_config_l2_tunnel_eth_type_result,
13040 eth_type, "ether-type");
13041 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
13042 TOKEN_NUM_INITIALIZER
13043 (struct cmd_config_l2_tunnel_eth_type_result,
13044 eth_type_val, UINT16);
13046 static enum rte_eth_tunnel_type
13047 str2fdir_l2_tunnel_type(char *string)
13051 static const struct {
13053 enum rte_eth_tunnel_type type;
13054 } l2_tunnel_type_str[] = {
13055 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
13058 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
13059 if (!strcmp(l2_tunnel_type_str[i].str, string))
13060 return l2_tunnel_type_str[i].type;
13062 return RTE_TUNNEL_TYPE_NONE;
13065 /* ether type config for all ports */
13067 cmd_config_l2_tunnel_eth_type_all_parsed
13068 (void *parsed_result,
13069 __rte_unused struct cmdline *cl,
13070 __rte_unused void *data)
13072 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
13073 struct rte_eth_l2_tunnel_conf entry;
13076 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13077 entry.ether_type = res->eth_type_val;
13079 RTE_ETH_FOREACH_DEV(pid) {
13080 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
13084 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
13085 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
13087 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
13089 (void *)&cmd_config_l2_tunnel_eth_type_port,
13090 (void *)&cmd_config_l2_tunnel_eth_type_config,
13091 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
13092 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
13093 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
13094 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
13095 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
13100 /* ether type config for a specific port */
13102 cmd_config_l2_tunnel_eth_type_specific_parsed(
13103 void *parsed_result,
13104 __rte_unused struct cmdline *cl,
13105 __rte_unused void *data)
13107 struct cmd_config_l2_tunnel_eth_type_result *res =
13109 struct rte_eth_l2_tunnel_conf entry;
13111 if (port_id_is_invalid(res->id, ENABLED_WARN))
13114 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13115 entry.ether_type = res->eth_type_val;
13117 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
13120 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
13121 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
13123 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
13125 (void *)&cmd_config_l2_tunnel_eth_type_port,
13126 (void *)&cmd_config_l2_tunnel_eth_type_config,
13127 (void *)&cmd_config_l2_tunnel_eth_type_id,
13128 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
13129 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
13130 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
13131 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
13136 /* Enable/disable l2 tunnel */
13137 struct cmd_config_l2_tunnel_en_dis_result {
13138 cmdline_fixed_string_t port;
13139 cmdline_fixed_string_t config;
13140 cmdline_fixed_string_t all;
13142 cmdline_fixed_string_t l2_tunnel;
13143 cmdline_fixed_string_t l2_tunnel_type;
13144 cmdline_fixed_string_t en_dis;
13147 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
13148 TOKEN_STRING_INITIALIZER
13149 (struct cmd_config_l2_tunnel_en_dis_result,
13151 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
13152 TOKEN_STRING_INITIALIZER
13153 (struct cmd_config_l2_tunnel_en_dis_result,
13155 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
13156 TOKEN_STRING_INITIALIZER
13157 (struct cmd_config_l2_tunnel_en_dis_result,
13159 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
13160 TOKEN_NUM_INITIALIZER
13161 (struct cmd_config_l2_tunnel_en_dis_result,
13163 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
13164 TOKEN_STRING_INITIALIZER
13165 (struct cmd_config_l2_tunnel_en_dis_result,
13166 l2_tunnel, "l2-tunnel");
13167 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
13168 TOKEN_STRING_INITIALIZER
13169 (struct cmd_config_l2_tunnel_en_dis_result,
13170 l2_tunnel_type, "E-tag");
13171 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
13172 TOKEN_STRING_INITIALIZER
13173 (struct cmd_config_l2_tunnel_en_dis_result,
13174 en_dis, "enable#disable");
13176 /* enable/disable l2 tunnel for all ports */
13178 cmd_config_l2_tunnel_en_dis_all_parsed(
13179 void *parsed_result,
13180 __rte_unused struct cmdline *cl,
13181 __rte_unused void *data)
13183 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
13184 struct rte_eth_l2_tunnel_conf entry;
13188 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13190 if (!strcmp("enable", res->en_dis))
13195 RTE_ETH_FOREACH_DEV(pid) {
13196 rte_eth_dev_l2_tunnel_offload_set(pid,
13198 ETH_L2_TUNNEL_ENABLE_MASK,
13203 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
13204 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
13206 .help_str = "port config all l2-tunnel E-tag enable|disable",
13208 (void *)&cmd_config_l2_tunnel_en_dis_port,
13209 (void *)&cmd_config_l2_tunnel_en_dis_config,
13210 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
13211 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13212 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13213 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13218 /* enable/disable l2 tunnel for a port */
13220 cmd_config_l2_tunnel_en_dis_specific_parsed(
13221 void *parsed_result,
13222 __rte_unused struct cmdline *cl,
13223 __rte_unused void *data)
13225 struct cmd_config_l2_tunnel_en_dis_result *res =
13227 struct rte_eth_l2_tunnel_conf entry;
13229 if (port_id_is_invalid(res->id, ENABLED_WARN))
13232 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13234 if (!strcmp("enable", res->en_dis))
13235 rte_eth_dev_l2_tunnel_offload_set(res->id,
13237 ETH_L2_TUNNEL_ENABLE_MASK,
13240 rte_eth_dev_l2_tunnel_offload_set(res->id,
13242 ETH_L2_TUNNEL_ENABLE_MASK,
13246 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
13247 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
13249 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
13251 (void *)&cmd_config_l2_tunnel_en_dis_port,
13252 (void *)&cmd_config_l2_tunnel_en_dis_config,
13253 (void *)&cmd_config_l2_tunnel_en_dis_id,
13254 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13255 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13256 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13261 /* E-tag configuration */
13263 /* Common result structure for all E-tag configuration */
13264 struct cmd_config_e_tag_result {
13265 cmdline_fixed_string_t e_tag;
13266 cmdline_fixed_string_t set;
13267 cmdline_fixed_string_t insertion;
13268 cmdline_fixed_string_t stripping;
13269 cmdline_fixed_string_t forwarding;
13270 cmdline_fixed_string_t filter;
13271 cmdline_fixed_string_t add;
13272 cmdline_fixed_string_t del;
13273 cmdline_fixed_string_t on;
13274 cmdline_fixed_string_t off;
13275 cmdline_fixed_string_t on_off;
13276 cmdline_fixed_string_t port_tag_id;
13277 uint32_t port_tag_id_val;
13278 cmdline_fixed_string_t e_tag_id;
13279 uint16_t e_tag_id_val;
13280 cmdline_fixed_string_t dst_pool;
13281 uint8_t dst_pool_val;
13282 cmdline_fixed_string_t port;
13284 cmdline_fixed_string_t vf;
13288 /* Common CLI fields for all E-tag configuration */
13289 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
13290 TOKEN_STRING_INITIALIZER
13291 (struct cmd_config_e_tag_result,
13293 cmdline_parse_token_string_t cmd_config_e_tag_set =
13294 TOKEN_STRING_INITIALIZER
13295 (struct cmd_config_e_tag_result,
13297 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
13298 TOKEN_STRING_INITIALIZER
13299 (struct cmd_config_e_tag_result,
13300 insertion, "insertion");
13301 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
13302 TOKEN_STRING_INITIALIZER
13303 (struct cmd_config_e_tag_result,
13304 stripping, "stripping");
13305 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
13306 TOKEN_STRING_INITIALIZER
13307 (struct cmd_config_e_tag_result,
13308 forwarding, "forwarding");
13309 cmdline_parse_token_string_t cmd_config_e_tag_filter =
13310 TOKEN_STRING_INITIALIZER
13311 (struct cmd_config_e_tag_result,
13313 cmdline_parse_token_string_t cmd_config_e_tag_add =
13314 TOKEN_STRING_INITIALIZER
13315 (struct cmd_config_e_tag_result,
13317 cmdline_parse_token_string_t cmd_config_e_tag_del =
13318 TOKEN_STRING_INITIALIZER
13319 (struct cmd_config_e_tag_result,
13321 cmdline_parse_token_string_t cmd_config_e_tag_on =
13322 TOKEN_STRING_INITIALIZER
13323 (struct cmd_config_e_tag_result,
13325 cmdline_parse_token_string_t cmd_config_e_tag_off =
13326 TOKEN_STRING_INITIALIZER
13327 (struct cmd_config_e_tag_result,
13329 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13330 TOKEN_STRING_INITIALIZER
13331 (struct cmd_config_e_tag_result,
13333 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13334 TOKEN_STRING_INITIALIZER
13335 (struct cmd_config_e_tag_result,
13336 port_tag_id, "port-tag-id");
13337 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13338 TOKEN_NUM_INITIALIZER
13339 (struct cmd_config_e_tag_result,
13340 port_tag_id_val, UINT32);
13341 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13342 TOKEN_STRING_INITIALIZER
13343 (struct cmd_config_e_tag_result,
13344 e_tag_id, "e-tag-id");
13345 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13346 TOKEN_NUM_INITIALIZER
13347 (struct cmd_config_e_tag_result,
13348 e_tag_id_val, UINT16);
13349 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13350 TOKEN_STRING_INITIALIZER
13351 (struct cmd_config_e_tag_result,
13352 dst_pool, "dst-pool");
13353 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13354 TOKEN_NUM_INITIALIZER
13355 (struct cmd_config_e_tag_result,
13356 dst_pool_val, UINT8);
13357 cmdline_parse_token_string_t cmd_config_e_tag_port =
13358 TOKEN_STRING_INITIALIZER
13359 (struct cmd_config_e_tag_result,
13361 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13362 TOKEN_NUM_INITIALIZER
13363 (struct cmd_config_e_tag_result,
13365 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13366 TOKEN_STRING_INITIALIZER
13367 (struct cmd_config_e_tag_result,
13369 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13370 TOKEN_NUM_INITIALIZER
13371 (struct cmd_config_e_tag_result,
13374 /* E-tag insertion configuration */
13376 cmd_config_e_tag_insertion_en_parsed(
13377 void *parsed_result,
13378 __rte_unused struct cmdline *cl,
13379 __rte_unused void *data)
13381 struct cmd_config_e_tag_result *res =
13383 struct rte_eth_l2_tunnel_conf entry;
13385 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13388 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13389 entry.tunnel_id = res->port_tag_id_val;
13390 entry.vf_id = res->vf_id;
13391 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13393 ETH_L2_TUNNEL_INSERTION_MASK,
13398 cmd_config_e_tag_insertion_dis_parsed(
13399 void *parsed_result,
13400 __rte_unused struct cmdline *cl,
13401 __rte_unused void *data)
13403 struct cmd_config_e_tag_result *res =
13405 struct rte_eth_l2_tunnel_conf entry;
13407 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13410 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13411 entry.vf_id = res->vf_id;
13413 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13415 ETH_L2_TUNNEL_INSERTION_MASK,
13419 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13420 .f = cmd_config_e_tag_insertion_en_parsed,
13422 .help_str = "E-tag ... : E-tag insertion enable",
13424 (void *)&cmd_config_e_tag_e_tag,
13425 (void *)&cmd_config_e_tag_set,
13426 (void *)&cmd_config_e_tag_insertion,
13427 (void *)&cmd_config_e_tag_on,
13428 (void *)&cmd_config_e_tag_port_tag_id,
13429 (void *)&cmd_config_e_tag_port_tag_id_val,
13430 (void *)&cmd_config_e_tag_port,
13431 (void *)&cmd_config_e_tag_port_id,
13432 (void *)&cmd_config_e_tag_vf,
13433 (void *)&cmd_config_e_tag_vf_id,
13438 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13439 .f = cmd_config_e_tag_insertion_dis_parsed,
13441 .help_str = "E-tag ... : E-tag insertion disable",
13443 (void *)&cmd_config_e_tag_e_tag,
13444 (void *)&cmd_config_e_tag_set,
13445 (void *)&cmd_config_e_tag_insertion,
13446 (void *)&cmd_config_e_tag_off,
13447 (void *)&cmd_config_e_tag_port,
13448 (void *)&cmd_config_e_tag_port_id,
13449 (void *)&cmd_config_e_tag_vf,
13450 (void *)&cmd_config_e_tag_vf_id,
13455 /* E-tag stripping configuration */
13457 cmd_config_e_tag_stripping_parsed(
13458 void *parsed_result,
13459 __rte_unused struct cmdline *cl,
13460 __rte_unused void *data)
13462 struct cmd_config_e_tag_result *res =
13464 struct rte_eth_l2_tunnel_conf entry;
13466 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13469 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13471 if (!strcmp(res->on_off, "on"))
13472 rte_eth_dev_l2_tunnel_offload_set
13475 ETH_L2_TUNNEL_STRIPPING_MASK,
13478 rte_eth_dev_l2_tunnel_offload_set
13481 ETH_L2_TUNNEL_STRIPPING_MASK,
13485 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13486 .f = cmd_config_e_tag_stripping_parsed,
13488 .help_str = "E-tag ... : E-tag stripping enable/disable",
13490 (void *)&cmd_config_e_tag_e_tag,
13491 (void *)&cmd_config_e_tag_set,
13492 (void *)&cmd_config_e_tag_stripping,
13493 (void *)&cmd_config_e_tag_on_off,
13494 (void *)&cmd_config_e_tag_port,
13495 (void *)&cmd_config_e_tag_port_id,
13500 /* E-tag forwarding configuration */
13502 cmd_config_e_tag_forwarding_parsed(
13503 void *parsed_result,
13504 __rte_unused struct cmdline *cl,
13505 __rte_unused void *data)
13507 struct cmd_config_e_tag_result *res = parsed_result;
13508 struct rte_eth_l2_tunnel_conf entry;
13510 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13513 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13515 if (!strcmp(res->on_off, "on"))
13516 rte_eth_dev_l2_tunnel_offload_set
13519 ETH_L2_TUNNEL_FORWARDING_MASK,
13522 rte_eth_dev_l2_tunnel_offload_set
13525 ETH_L2_TUNNEL_FORWARDING_MASK,
13529 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13530 .f = cmd_config_e_tag_forwarding_parsed,
13532 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13534 (void *)&cmd_config_e_tag_e_tag,
13535 (void *)&cmd_config_e_tag_set,
13536 (void *)&cmd_config_e_tag_forwarding,
13537 (void *)&cmd_config_e_tag_on_off,
13538 (void *)&cmd_config_e_tag_port,
13539 (void *)&cmd_config_e_tag_port_id,
13544 /* E-tag filter configuration */
13546 cmd_config_e_tag_filter_add_parsed(
13547 void *parsed_result,
13548 __rte_unused struct cmdline *cl,
13549 __rte_unused void *data)
13551 struct cmd_config_e_tag_result *res = parsed_result;
13552 struct rte_eth_l2_tunnel_conf entry;
13555 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13558 if (res->e_tag_id_val > 0x3fff) {
13559 printf("e-tag-id must be equal or less than 0x3fff.\n");
13563 ret = rte_eth_dev_filter_supported(res->port_id,
13564 RTE_ETH_FILTER_L2_TUNNEL);
13566 printf("E-tag filter is not supported on port %u.\n",
13571 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13572 entry.tunnel_id = res->e_tag_id_val;
13573 entry.pool = res->dst_pool_val;
13575 ret = rte_eth_dev_filter_ctrl(res->port_id,
13576 RTE_ETH_FILTER_L2_TUNNEL,
13577 RTE_ETH_FILTER_ADD,
13580 printf("E-tag filter programming error: (%s)\n",
13584 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13585 .f = cmd_config_e_tag_filter_add_parsed,
13587 .help_str = "E-tag ... : E-tag filter add",
13589 (void *)&cmd_config_e_tag_e_tag,
13590 (void *)&cmd_config_e_tag_set,
13591 (void *)&cmd_config_e_tag_filter,
13592 (void *)&cmd_config_e_tag_add,
13593 (void *)&cmd_config_e_tag_e_tag_id,
13594 (void *)&cmd_config_e_tag_e_tag_id_val,
13595 (void *)&cmd_config_e_tag_dst_pool,
13596 (void *)&cmd_config_e_tag_dst_pool_val,
13597 (void *)&cmd_config_e_tag_port,
13598 (void *)&cmd_config_e_tag_port_id,
13604 cmd_config_e_tag_filter_del_parsed(
13605 void *parsed_result,
13606 __rte_unused struct cmdline *cl,
13607 __rte_unused void *data)
13609 struct cmd_config_e_tag_result *res = parsed_result;
13610 struct rte_eth_l2_tunnel_conf entry;
13613 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13616 if (res->e_tag_id_val > 0x3fff) {
13617 printf("e-tag-id must be less than 0x3fff.\n");
13621 ret = rte_eth_dev_filter_supported(res->port_id,
13622 RTE_ETH_FILTER_L2_TUNNEL);
13624 printf("E-tag filter is not supported on port %u.\n",
13629 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13630 entry.tunnel_id = res->e_tag_id_val;
13632 ret = rte_eth_dev_filter_ctrl(res->port_id,
13633 RTE_ETH_FILTER_L2_TUNNEL,
13634 RTE_ETH_FILTER_DELETE,
13637 printf("E-tag filter programming error: (%s)\n",
13641 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13642 .f = cmd_config_e_tag_filter_del_parsed,
13644 .help_str = "E-tag ... : E-tag filter delete",
13646 (void *)&cmd_config_e_tag_e_tag,
13647 (void *)&cmd_config_e_tag_set,
13648 (void *)&cmd_config_e_tag_filter,
13649 (void *)&cmd_config_e_tag_del,
13650 (void *)&cmd_config_e_tag_e_tag_id,
13651 (void *)&cmd_config_e_tag_e_tag_id_val,
13652 (void *)&cmd_config_e_tag_port,
13653 (void *)&cmd_config_e_tag_port_id,
13658 /* vf vlan anti spoof configuration */
13660 /* Common result structure for vf vlan anti spoof */
13661 struct cmd_vf_vlan_anti_spoof_result {
13662 cmdline_fixed_string_t set;
13663 cmdline_fixed_string_t vf;
13664 cmdline_fixed_string_t vlan;
13665 cmdline_fixed_string_t antispoof;
13668 cmdline_fixed_string_t on_off;
13671 /* Common CLI fields for vf vlan anti spoof enable disable */
13672 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13673 TOKEN_STRING_INITIALIZER
13674 (struct cmd_vf_vlan_anti_spoof_result,
13676 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13677 TOKEN_STRING_INITIALIZER
13678 (struct cmd_vf_vlan_anti_spoof_result,
13680 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13681 TOKEN_STRING_INITIALIZER
13682 (struct cmd_vf_vlan_anti_spoof_result,
13684 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13685 TOKEN_STRING_INITIALIZER
13686 (struct cmd_vf_vlan_anti_spoof_result,
13687 antispoof, "antispoof");
13688 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13689 TOKEN_NUM_INITIALIZER
13690 (struct cmd_vf_vlan_anti_spoof_result,
13692 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13693 TOKEN_NUM_INITIALIZER
13694 (struct cmd_vf_vlan_anti_spoof_result,
13696 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13697 TOKEN_STRING_INITIALIZER
13698 (struct cmd_vf_vlan_anti_spoof_result,
13702 cmd_set_vf_vlan_anti_spoof_parsed(
13703 void *parsed_result,
13704 __rte_unused struct cmdline *cl,
13705 __rte_unused void *data)
13707 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13708 int ret = -ENOTSUP;
13710 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13712 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13715 #ifdef RTE_LIBRTE_IXGBE_PMD
13716 if (ret == -ENOTSUP)
13717 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13718 res->vf_id, is_on);
13720 #ifdef RTE_LIBRTE_I40E_PMD
13721 if (ret == -ENOTSUP)
13722 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13723 res->vf_id, is_on);
13725 #ifdef RTE_LIBRTE_BNXT_PMD
13726 if (ret == -ENOTSUP)
13727 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13728 res->vf_id, is_on);
13735 printf("invalid vf_id %d\n", res->vf_id);
13738 printf("invalid port_id %d\n", res->port_id);
13741 printf("function not implemented\n");
13744 printf("programming error: (%s)\n", strerror(-ret));
13748 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13749 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13751 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13753 (void *)&cmd_vf_vlan_anti_spoof_set,
13754 (void *)&cmd_vf_vlan_anti_spoof_vf,
13755 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13756 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13757 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13758 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13759 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13764 /* vf mac anti spoof configuration */
13766 /* Common result structure for vf mac anti spoof */
13767 struct cmd_vf_mac_anti_spoof_result {
13768 cmdline_fixed_string_t set;
13769 cmdline_fixed_string_t vf;
13770 cmdline_fixed_string_t mac;
13771 cmdline_fixed_string_t antispoof;
13774 cmdline_fixed_string_t on_off;
13777 /* Common CLI fields for vf mac anti spoof enable disable */
13778 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13779 TOKEN_STRING_INITIALIZER
13780 (struct cmd_vf_mac_anti_spoof_result,
13782 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13783 TOKEN_STRING_INITIALIZER
13784 (struct cmd_vf_mac_anti_spoof_result,
13786 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13787 TOKEN_STRING_INITIALIZER
13788 (struct cmd_vf_mac_anti_spoof_result,
13790 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13791 TOKEN_STRING_INITIALIZER
13792 (struct cmd_vf_mac_anti_spoof_result,
13793 antispoof, "antispoof");
13794 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13795 TOKEN_NUM_INITIALIZER
13796 (struct cmd_vf_mac_anti_spoof_result,
13798 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13799 TOKEN_NUM_INITIALIZER
13800 (struct cmd_vf_mac_anti_spoof_result,
13802 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13803 TOKEN_STRING_INITIALIZER
13804 (struct cmd_vf_mac_anti_spoof_result,
13808 cmd_set_vf_mac_anti_spoof_parsed(
13809 void *parsed_result,
13810 __rte_unused struct cmdline *cl,
13811 __rte_unused void *data)
13813 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13814 int ret = -ENOTSUP;
13816 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13818 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13821 #ifdef RTE_LIBRTE_IXGBE_PMD
13822 if (ret == -ENOTSUP)
13823 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13824 res->vf_id, is_on);
13826 #ifdef RTE_LIBRTE_I40E_PMD
13827 if (ret == -ENOTSUP)
13828 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13829 res->vf_id, is_on);
13831 #ifdef RTE_LIBRTE_BNXT_PMD
13832 if (ret == -ENOTSUP)
13833 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13834 res->vf_id, is_on);
13841 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13844 printf("invalid port_id %d\n", res->port_id);
13847 printf("function not implemented\n");
13850 printf("programming error: (%s)\n", strerror(-ret));
13854 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13855 .f = cmd_set_vf_mac_anti_spoof_parsed,
13857 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13859 (void *)&cmd_vf_mac_anti_spoof_set,
13860 (void *)&cmd_vf_mac_anti_spoof_vf,
13861 (void *)&cmd_vf_mac_anti_spoof_mac,
13862 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13863 (void *)&cmd_vf_mac_anti_spoof_port_id,
13864 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13865 (void *)&cmd_vf_mac_anti_spoof_on_off,
13870 /* vf vlan strip queue configuration */
13872 /* Common result structure for vf mac anti spoof */
13873 struct cmd_vf_vlan_stripq_result {
13874 cmdline_fixed_string_t set;
13875 cmdline_fixed_string_t vf;
13876 cmdline_fixed_string_t vlan;
13877 cmdline_fixed_string_t stripq;
13880 cmdline_fixed_string_t on_off;
13883 /* Common CLI fields for vf vlan strip enable disable */
13884 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13885 TOKEN_STRING_INITIALIZER
13886 (struct cmd_vf_vlan_stripq_result,
13888 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13889 TOKEN_STRING_INITIALIZER
13890 (struct cmd_vf_vlan_stripq_result,
13892 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13893 TOKEN_STRING_INITIALIZER
13894 (struct cmd_vf_vlan_stripq_result,
13896 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13897 TOKEN_STRING_INITIALIZER
13898 (struct cmd_vf_vlan_stripq_result,
13900 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13901 TOKEN_NUM_INITIALIZER
13902 (struct cmd_vf_vlan_stripq_result,
13904 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13905 TOKEN_NUM_INITIALIZER
13906 (struct cmd_vf_vlan_stripq_result,
13908 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13909 TOKEN_STRING_INITIALIZER
13910 (struct cmd_vf_vlan_stripq_result,
13914 cmd_set_vf_vlan_stripq_parsed(
13915 void *parsed_result,
13916 __rte_unused struct cmdline *cl,
13917 __rte_unused void *data)
13919 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13920 int ret = -ENOTSUP;
13922 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13924 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13927 #ifdef RTE_LIBRTE_IXGBE_PMD
13928 if (ret == -ENOTSUP)
13929 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13930 res->vf_id, is_on);
13932 #ifdef RTE_LIBRTE_I40E_PMD
13933 if (ret == -ENOTSUP)
13934 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13935 res->vf_id, is_on);
13937 #ifdef RTE_LIBRTE_BNXT_PMD
13938 if (ret == -ENOTSUP)
13939 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13940 res->vf_id, is_on);
13947 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13950 printf("invalid port_id %d\n", res->port_id);
13953 printf("function not implemented\n");
13956 printf("programming error: (%s)\n", strerror(-ret));
13960 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13961 .f = cmd_set_vf_vlan_stripq_parsed,
13963 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13965 (void *)&cmd_vf_vlan_stripq_set,
13966 (void *)&cmd_vf_vlan_stripq_vf,
13967 (void *)&cmd_vf_vlan_stripq_vlan,
13968 (void *)&cmd_vf_vlan_stripq_stripq,
13969 (void *)&cmd_vf_vlan_stripq_port_id,
13970 (void *)&cmd_vf_vlan_stripq_vf_id,
13971 (void *)&cmd_vf_vlan_stripq_on_off,
13976 /* vf vlan insert configuration */
13978 /* Common result structure for vf vlan insert */
13979 struct cmd_vf_vlan_insert_result {
13980 cmdline_fixed_string_t set;
13981 cmdline_fixed_string_t vf;
13982 cmdline_fixed_string_t vlan;
13983 cmdline_fixed_string_t insert;
13989 /* Common CLI fields for vf vlan insert enable disable */
13990 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13991 TOKEN_STRING_INITIALIZER
13992 (struct cmd_vf_vlan_insert_result,
13994 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13995 TOKEN_STRING_INITIALIZER
13996 (struct cmd_vf_vlan_insert_result,
13998 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13999 TOKEN_STRING_INITIALIZER
14000 (struct cmd_vf_vlan_insert_result,
14002 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
14003 TOKEN_STRING_INITIALIZER
14004 (struct cmd_vf_vlan_insert_result,
14006 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
14007 TOKEN_NUM_INITIALIZER
14008 (struct cmd_vf_vlan_insert_result,
14010 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
14011 TOKEN_NUM_INITIALIZER
14012 (struct cmd_vf_vlan_insert_result,
14014 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
14015 TOKEN_NUM_INITIALIZER
14016 (struct cmd_vf_vlan_insert_result,
14020 cmd_set_vf_vlan_insert_parsed(
14021 void *parsed_result,
14022 __rte_unused struct cmdline *cl,
14023 __rte_unused void *data)
14025 struct cmd_vf_vlan_insert_result *res = parsed_result;
14026 int ret = -ENOTSUP;
14028 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14031 #ifdef RTE_LIBRTE_IXGBE_PMD
14032 if (ret == -ENOTSUP)
14033 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
14036 #ifdef RTE_LIBRTE_I40E_PMD
14037 if (ret == -ENOTSUP)
14038 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
14041 #ifdef RTE_LIBRTE_BNXT_PMD
14042 if (ret == -ENOTSUP)
14043 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
14051 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
14054 printf("invalid port_id %d\n", res->port_id);
14057 printf("function not implemented\n");
14060 printf("programming error: (%s)\n", strerror(-ret));
14064 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
14065 .f = cmd_set_vf_vlan_insert_parsed,
14067 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
14069 (void *)&cmd_vf_vlan_insert_set,
14070 (void *)&cmd_vf_vlan_insert_vf,
14071 (void *)&cmd_vf_vlan_insert_vlan,
14072 (void *)&cmd_vf_vlan_insert_insert,
14073 (void *)&cmd_vf_vlan_insert_port_id,
14074 (void *)&cmd_vf_vlan_insert_vf_id,
14075 (void *)&cmd_vf_vlan_insert_vlan_id,
14080 /* tx loopback configuration */
14082 /* Common result structure for tx loopback */
14083 struct cmd_tx_loopback_result {
14084 cmdline_fixed_string_t set;
14085 cmdline_fixed_string_t tx;
14086 cmdline_fixed_string_t loopback;
14088 cmdline_fixed_string_t on_off;
14091 /* Common CLI fields for tx loopback enable disable */
14092 cmdline_parse_token_string_t cmd_tx_loopback_set =
14093 TOKEN_STRING_INITIALIZER
14094 (struct cmd_tx_loopback_result,
14096 cmdline_parse_token_string_t cmd_tx_loopback_tx =
14097 TOKEN_STRING_INITIALIZER
14098 (struct cmd_tx_loopback_result,
14100 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
14101 TOKEN_STRING_INITIALIZER
14102 (struct cmd_tx_loopback_result,
14103 loopback, "loopback");
14104 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
14105 TOKEN_NUM_INITIALIZER
14106 (struct cmd_tx_loopback_result,
14108 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
14109 TOKEN_STRING_INITIALIZER
14110 (struct cmd_tx_loopback_result,
14114 cmd_set_tx_loopback_parsed(
14115 void *parsed_result,
14116 __rte_unused struct cmdline *cl,
14117 __rte_unused void *data)
14119 struct cmd_tx_loopback_result *res = parsed_result;
14120 int ret = -ENOTSUP;
14122 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14124 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14127 #ifdef RTE_LIBRTE_IXGBE_PMD
14128 if (ret == -ENOTSUP)
14129 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
14131 #ifdef RTE_LIBRTE_I40E_PMD
14132 if (ret == -ENOTSUP)
14133 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
14135 #ifdef RTE_LIBRTE_BNXT_PMD
14136 if (ret == -ENOTSUP)
14137 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
14139 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
14140 if (ret == -ENOTSUP)
14141 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
14148 printf("invalid is_on %d\n", is_on);
14151 printf("invalid port_id %d\n", res->port_id);
14154 printf("function not implemented\n");
14157 printf("programming error: (%s)\n", strerror(-ret));
14161 cmdline_parse_inst_t cmd_set_tx_loopback = {
14162 .f = cmd_set_tx_loopback_parsed,
14164 .help_str = "set tx loopback <port_id> on|off",
14166 (void *)&cmd_tx_loopback_set,
14167 (void *)&cmd_tx_loopback_tx,
14168 (void *)&cmd_tx_loopback_loopback,
14169 (void *)&cmd_tx_loopback_port_id,
14170 (void *)&cmd_tx_loopback_on_off,
14175 /* all queues drop enable configuration */
14177 /* Common result structure for all queues drop enable */
14178 struct cmd_all_queues_drop_en_result {
14179 cmdline_fixed_string_t set;
14180 cmdline_fixed_string_t all;
14181 cmdline_fixed_string_t queues;
14182 cmdline_fixed_string_t drop;
14184 cmdline_fixed_string_t on_off;
14187 /* Common CLI fields for tx loopback enable disable */
14188 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
14189 TOKEN_STRING_INITIALIZER
14190 (struct cmd_all_queues_drop_en_result,
14192 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
14193 TOKEN_STRING_INITIALIZER
14194 (struct cmd_all_queues_drop_en_result,
14196 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
14197 TOKEN_STRING_INITIALIZER
14198 (struct cmd_all_queues_drop_en_result,
14200 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
14201 TOKEN_STRING_INITIALIZER
14202 (struct cmd_all_queues_drop_en_result,
14204 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
14205 TOKEN_NUM_INITIALIZER
14206 (struct cmd_all_queues_drop_en_result,
14208 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
14209 TOKEN_STRING_INITIALIZER
14210 (struct cmd_all_queues_drop_en_result,
14214 cmd_set_all_queues_drop_en_parsed(
14215 void *parsed_result,
14216 __rte_unused struct cmdline *cl,
14217 __rte_unused void *data)
14219 struct cmd_all_queues_drop_en_result *res = parsed_result;
14220 int ret = -ENOTSUP;
14221 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14223 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14226 #ifdef RTE_LIBRTE_IXGBE_PMD
14227 if (ret == -ENOTSUP)
14228 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
14230 #ifdef RTE_LIBRTE_BNXT_PMD
14231 if (ret == -ENOTSUP)
14232 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
14238 printf("invalid is_on %d\n", is_on);
14241 printf("invalid port_id %d\n", res->port_id);
14244 printf("function not implemented\n");
14247 printf("programming error: (%s)\n", strerror(-ret));
14251 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
14252 .f = cmd_set_all_queues_drop_en_parsed,
14254 .help_str = "set all queues drop <port_id> on|off",
14256 (void *)&cmd_all_queues_drop_en_set,
14257 (void *)&cmd_all_queues_drop_en_all,
14258 (void *)&cmd_all_queues_drop_en_queues,
14259 (void *)&cmd_all_queues_drop_en_drop,
14260 (void *)&cmd_all_queues_drop_en_port_id,
14261 (void *)&cmd_all_queues_drop_en_on_off,
14266 /* vf split drop enable configuration */
14268 /* Common result structure for vf split drop enable */
14269 struct cmd_vf_split_drop_en_result {
14270 cmdline_fixed_string_t set;
14271 cmdline_fixed_string_t vf;
14272 cmdline_fixed_string_t split;
14273 cmdline_fixed_string_t drop;
14276 cmdline_fixed_string_t on_off;
14279 /* Common CLI fields for vf split drop enable disable */
14280 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
14281 TOKEN_STRING_INITIALIZER
14282 (struct cmd_vf_split_drop_en_result,
14284 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
14285 TOKEN_STRING_INITIALIZER
14286 (struct cmd_vf_split_drop_en_result,
14288 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
14289 TOKEN_STRING_INITIALIZER
14290 (struct cmd_vf_split_drop_en_result,
14292 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
14293 TOKEN_STRING_INITIALIZER
14294 (struct cmd_vf_split_drop_en_result,
14296 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
14297 TOKEN_NUM_INITIALIZER
14298 (struct cmd_vf_split_drop_en_result,
14300 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
14301 TOKEN_NUM_INITIALIZER
14302 (struct cmd_vf_split_drop_en_result,
14304 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
14305 TOKEN_STRING_INITIALIZER
14306 (struct cmd_vf_split_drop_en_result,
14310 cmd_set_vf_split_drop_en_parsed(
14311 void *parsed_result,
14312 __rte_unused struct cmdline *cl,
14313 __rte_unused void *data)
14315 struct cmd_vf_split_drop_en_result *res = parsed_result;
14316 int ret = -ENOTSUP;
14317 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14319 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14322 #ifdef RTE_LIBRTE_IXGBE_PMD
14323 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14330 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14333 printf("invalid port_id %d\n", res->port_id);
14336 printf("not supported on port %d\n", res->port_id);
14339 printf("programming error: (%s)\n", strerror(-ret));
14343 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14344 .f = cmd_set_vf_split_drop_en_parsed,
14346 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14348 (void *)&cmd_vf_split_drop_en_set,
14349 (void *)&cmd_vf_split_drop_en_vf,
14350 (void *)&cmd_vf_split_drop_en_split,
14351 (void *)&cmd_vf_split_drop_en_drop,
14352 (void *)&cmd_vf_split_drop_en_port_id,
14353 (void *)&cmd_vf_split_drop_en_vf_id,
14354 (void *)&cmd_vf_split_drop_en_on_off,
14359 /* vf mac address configuration */
14361 /* Common result structure for vf mac address */
14362 struct cmd_set_vf_mac_addr_result {
14363 cmdline_fixed_string_t set;
14364 cmdline_fixed_string_t vf;
14365 cmdline_fixed_string_t mac;
14366 cmdline_fixed_string_t addr;
14369 struct rte_ether_addr mac_addr;
14373 /* Common CLI fields for vf split drop enable disable */
14374 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14375 TOKEN_STRING_INITIALIZER
14376 (struct cmd_set_vf_mac_addr_result,
14378 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14379 TOKEN_STRING_INITIALIZER
14380 (struct cmd_set_vf_mac_addr_result,
14382 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14383 TOKEN_STRING_INITIALIZER
14384 (struct cmd_set_vf_mac_addr_result,
14386 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14387 TOKEN_STRING_INITIALIZER
14388 (struct cmd_set_vf_mac_addr_result,
14390 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14391 TOKEN_NUM_INITIALIZER
14392 (struct cmd_set_vf_mac_addr_result,
14394 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14395 TOKEN_NUM_INITIALIZER
14396 (struct cmd_set_vf_mac_addr_result,
14398 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14399 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14403 cmd_set_vf_mac_addr_parsed(
14404 void *parsed_result,
14405 __rte_unused struct cmdline *cl,
14406 __rte_unused void *data)
14408 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14409 int ret = -ENOTSUP;
14411 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14414 #ifdef RTE_LIBRTE_IXGBE_PMD
14415 if (ret == -ENOTSUP)
14416 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14419 #ifdef RTE_LIBRTE_I40E_PMD
14420 if (ret == -ENOTSUP)
14421 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14424 #ifdef RTE_LIBRTE_BNXT_PMD
14425 if (ret == -ENOTSUP)
14426 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14434 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14437 printf("invalid port_id %d\n", res->port_id);
14440 printf("function not implemented\n");
14443 printf("programming error: (%s)\n", strerror(-ret));
14447 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14448 .f = cmd_set_vf_mac_addr_parsed,
14450 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14452 (void *)&cmd_set_vf_mac_addr_set,
14453 (void *)&cmd_set_vf_mac_addr_vf,
14454 (void *)&cmd_set_vf_mac_addr_mac,
14455 (void *)&cmd_set_vf_mac_addr_addr,
14456 (void *)&cmd_set_vf_mac_addr_port_id,
14457 (void *)&cmd_set_vf_mac_addr_vf_id,
14458 (void *)&cmd_set_vf_mac_addr_mac_addr,
14463 /* MACsec configuration */
14465 /* Common result structure for MACsec offload enable */
14466 struct cmd_macsec_offload_on_result {
14467 cmdline_fixed_string_t set;
14468 cmdline_fixed_string_t macsec;
14469 cmdline_fixed_string_t offload;
14471 cmdline_fixed_string_t on;
14472 cmdline_fixed_string_t encrypt;
14473 cmdline_fixed_string_t en_on_off;
14474 cmdline_fixed_string_t replay_protect;
14475 cmdline_fixed_string_t rp_on_off;
14478 /* Common CLI fields for MACsec offload disable */
14479 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14480 TOKEN_STRING_INITIALIZER
14481 (struct cmd_macsec_offload_on_result,
14483 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14484 TOKEN_STRING_INITIALIZER
14485 (struct cmd_macsec_offload_on_result,
14487 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14488 TOKEN_STRING_INITIALIZER
14489 (struct cmd_macsec_offload_on_result,
14490 offload, "offload");
14491 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14492 TOKEN_NUM_INITIALIZER
14493 (struct cmd_macsec_offload_on_result,
14495 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14496 TOKEN_STRING_INITIALIZER
14497 (struct cmd_macsec_offload_on_result,
14499 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14500 TOKEN_STRING_INITIALIZER
14501 (struct cmd_macsec_offload_on_result,
14502 encrypt, "encrypt");
14503 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14504 TOKEN_STRING_INITIALIZER
14505 (struct cmd_macsec_offload_on_result,
14506 en_on_off, "on#off");
14507 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14508 TOKEN_STRING_INITIALIZER
14509 (struct cmd_macsec_offload_on_result,
14510 replay_protect, "replay-protect");
14511 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14512 TOKEN_STRING_INITIALIZER
14513 (struct cmd_macsec_offload_on_result,
14514 rp_on_off, "on#off");
14517 cmd_set_macsec_offload_on_parsed(
14518 void *parsed_result,
14519 __rte_unused struct cmdline *cl,
14520 __rte_unused void *data)
14522 struct cmd_macsec_offload_on_result *res = parsed_result;
14523 int ret = -ENOTSUP;
14524 portid_t port_id = res->port_id;
14525 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14526 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14527 struct rte_eth_dev_info dev_info;
14529 if (port_id_is_invalid(port_id, ENABLED_WARN))
14531 if (!port_is_stopped(port_id)) {
14532 printf("Please stop port %d first\n", port_id);
14536 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14540 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14541 #ifdef RTE_LIBRTE_IXGBE_PMD
14542 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14550 ports[port_id].dev_conf.txmode.offloads |=
14551 DEV_TX_OFFLOAD_MACSEC_INSERT;
14552 cmd_reconfig_device_queue(port_id, 1, 1);
14555 printf("invalid port_id %d\n", port_id);
14558 printf("not supported on port %d\n", port_id);
14561 printf("programming error: (%s)\n", strerror(-ret));
14565 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14566 .f = cmd_set_macsec_offload_on_parsed,
14568 .help_str = "set macsec offload <port_id> on "
14569 "encrypt on|off replay-protect on|off",
14571 (void *)&cmd_macsec_offload_on_set,
14572 (void *)&cmd_macsec_offload_on_macsec,
14573 (void *)&cmd_macsec_offload_on_offload,
14574 (void *)&cmd_macsec_offload_on_port_id,
14575 (void *)&cmd_macsec_offload_on_on,
14576 (void *)&cmd_macsec_offload_on_encrypt,
14577 (void *)&cmd_macsec_offload_on_en_on_off,
14578 (void *)&cmd_macsec_offload_on_replay_protect,
14579 (void *)&cmd_macsec_offload_on_rp_on_off,
14584 /* Common result structure for MACsec offload disable */
14585 struct cmd_macsec_offload_off_result {
14586 cmdline_fixed_string_t set;
14587 cmdline_fixed_string_t macsec;
14588 cmdline_fixed_string_t offload;
14590 cmdline_fixed_string_t off;
14593 /* Common CLI fields for MACsec offload disable */
14594 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14595 TOKEN_STRING_INITIALIZER
14596 (struct cmd_macsec_offload_off_result,
14598 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14599 TOKEN_STRING_INITIALIZER
14600 (struct cmd_macsec_offload_off_result,
14602 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14603 TOKEN_STRING_INITIALIZER
14604 (struct cmd_macsec_offload_off_result,
14605 offload, "offload");
14606 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14607 TOKEN_NUM_INITIALIZER
14608 (struct cmd_macsec_offload_off_result,
14610 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14611 TOKEN_STRING_INITIALIZER
14612 (struct cmd_macsec_offload_off_result,
14616 cmd_set_macsec_offload_off_parsed(
14617 void *parsed_result,
14618 __rte_unused struct cmdline *cl,
14619 __rte_unused void *data)
14621 struct cmd_macsec_offload_off_result *res = parsed_result;
14622 int ret = -ENOTSUP;
14623 struct rte_eth_dev_info dev_info;
14624 portid_t port_id = res->port_id;
14626 if (port_id_is_invalid(port_id, ENABLED_WARN))
14628 if (!port_is_stopped(port_id)) {
14629 printf("Please stop port %d first\n", port_id);
14633 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14637 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14638 #ifdef RTE_LIBRTE_IXGBE_PMD
14639 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14644 ports[port_id].dev_conf.txmode.offloads &=
14645 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14646 cmd_reconfig_device_queue(port_id, 1, 1);
14649 printf("invalid port_id %d\n", port_id);
14652 printf("not supported on port %d\n", port_id);
14655 printf("programming error: (%s)\n", strerror(-ret));
14659 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14660 .f = cmd_set_macsec_offload_off_parsed,
14662 .help_str = "set macsec offload <port_id> off",
14664 (void *)&cmd_macsec_offload_off_set,
14665 (void *)&cmd_macsec_offload_off_macsec,
14666 (void *)&cmd_macsec_offload_off_offload,
14667 (void *)&cmd_macsec_offload_off_port_id,
14668 (void *)&cmd_macsec_offload_off_off,
14673 /* Common result structure for MACsec secure connection configure */
14674 struct cmd_macsec_sc_result {
14675 cmdline_fixed_string_t set;
14676 cmdline_fixed_string_t macsec;
14677 cmdline_fixed_string_t sc;
14678 cmdline_fixed_string_t tx_rx;
14680 struct rte_ether_addr mac;
14684 /* Common CLI fields for MACsec secure connection configure */
14685 cmdline_parse_token_string_t cmd_macsec_sc_set =
14686 TOKEN_STRING_INITIALIZER
14687 (struct cmd_macsec_sc_result,
14689 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14690 TOKEN_STRING_INITIALIZER
14691 (struct cmd_macsec_sc_result,
14693 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14694 TOKEN_STRING_INITIALIZER
14695 (struct cmd_macsec_sc_result,
14697 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14698 TOKEN_STRING_INITIALIZER
14699 (struct cmd_macsec_sc_result,
14701 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14702 TOKEN_NUM_INITIALIZER
14703 (struct cmd_macsec_sc_result,
14705 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14706 TOKEN_ETHERADDR_INITIALIZER
14707 (struct cmd_macsec_sc_result,
14709 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14710 TOKEN_NUM_INITIALIZER
14711 (struct cmd_macsec_sc_result,
14715 cmd_set_macsec_sc_parsed(
14716 void *parsed_result,
14717 __rte_unused struct cmdline *cl,
14718 __rte_unused void *data)
14720 struct cmd_macsec_sc_result *res = parsed_result;
14721 int ret = -ENOTSUP;
14722 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14724 #ifdef RTE_LIBRTE_IXGBE_PMD
14726 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14727 res->mac.addr_bytes) :
14728 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14729 res->mac.addr_bytes, res->pi);
14731 RTE_SET_USED(is_tx);
14737 printf("invalid port_id %d\n", res->port_id);
14740 printf("not supported on port %d\n", res->port_id);
14743 printf("programming error: (%s)\n", strerror(-ret));
14747 cmdline_parse_inst_t cmd_set_macsec_sc = {
14748 .f = cmd_set_macsec_sc_parsed,
14750 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14752 (void *)&cmd_macsec_sc_set,
14753 (void *)&cmd_macsec_sc_macsec,
14754 (void *)&cmd_macsec_sc_sc,
14755 (void *)&cmd_macsec_sc_tx_rx,
14756 (void *)&cmd_macsec_sc_port_id,
14757 (void *)&cmd_macsec_sc_mac,
14758 (void *)&cmd_macsec_sc_pi,
14763 /* Common result structure for MACsec secure connection configure */
14764 struct cmd_macsec_sa_result {
14765 cmdline_fixed_string_t set;
14766 cmdline_fixed_string_t macsec;
14767 cmdline_fixed_string_t sa;
14768 cmdline_fixed_string_t tx_rx;
14773 cmdline_fixed_string_t key;
14776 /* Common CLI fields for MACsec secure connection configure */
14777 cmdline_parse_token_string_t cmd_macsec_sa_set =
14778 TOKEN_STRING_INITIALIZER
14779 (struct cmd_macsec_sa_result,
14781 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14782 TOKEN_STRING_INITIALIZER
14783 (struct cmd_macsec_sa_result,
14785 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14786 TOKEN_STRING_INITIALIZER
14787 (struct cmd_macsec_sa_result,
14789 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14790 TOKEN_STRING_INITIALIZER
14791 (struct cmd_macsec_sa_result,
14793 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14794 TOKEN_NUM_INITIALIZER
14795 (struct cmd_macsec_sa_result,
14797 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14798 TOKEN_NUM_INITIALIZER
14799 (struct cmd_macsec_sa_result,
14801 cmdline_parse_token_num_t cmd_macsec_sa_an =
14802 TOKEN_NUM_INITIALIZER
14803 (struct cmd_macsec_sa_result,
14805 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14806 TOKEN_NUM_INITIALIZER
14807 (struct cmd_macsec_sa_result,
14809 cmdline_parse_token_string_t cmd_macsec_sa_key =
14810 TOKEN_STRING_INITIALIZER
14811 (struct cmd_macsec_sa_result,
14815 cmd_set_macsec_sa_parsed(
14816 void *parsed_result,
14817 __rte_unused struct cmdline *cl,
14818 __rte_unused void *data)
14820 struct cmd_macsec_sa_result *res = parsed_result;
14821 int ret = -ENOTSUP;
14822 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14823 uint8_t key[16] = { 0 };
14829 key_len = strlen(res->key) / 2;
14833 for (i = 0; i < key_len; i++) {
14834 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14837 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14840 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14843 #ifdef RTE_LIBRTE_IXGBE_PMD
14845 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14846 res->idx, res->an, res->pn, key) :
14847 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14848 res->idx, res->an, res->pn, key);
14850 RTE_SET_USED(is_tx);
14857 printf("invalid idx %d or an %d\n", res->idx, res->an);
14860 printf("invalid port_id %d\n", res->port_id);
14863 printf("not supported on port %d\n", res->port_id);
14866 printf("programming error: (%s)\n", strerror(-ret));
14870 cmdline_parse_inst_t cmd_set_macsec_sa = {
14871 .f = cmd_set_macsec_sa_parsed,
14873 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14875 (void *)&cmd_macsec_sa_set,
14876 (void *)&cmd_macsec_sa_macsec,
14877 (void *)&cmd_macsec_sa_sa,
14878 (void *)&cmd_macsec_sa_tx_rx,
14879 (void *)&cmd_macsec_sa_port_id,
14880 (void *)&cmd_macsec_sa_idx,
14881 (void *)&cmd_macsec_sa_an,
14882 (void *)&cmd_macsec_sa_pn,
14883 (void *)&cmd_macsec_sa_key,
14888 /* VF unicast promiscuous mode configuration */
14890 /* Common result structure for VF unicast promiscuous mode */
14891 struct cmd_vf_promisc_result {
14892 cmdline_fixed_string_t set;
14893 cmdline_fixed_string_t vf;
14894 cmdline_fixed_string_t promisc;
14897 cmdline_fixed_string_t on_off;
14900 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14901 cmdline_parse_token_string_t cmd_vf_promisc_set =
14902 TOKEN_STRING_INITIALIZER
14903 (struct cmd_vf_promisc_result,
14905 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14906 TOKEN_STRING_INITIALIZER
14907 (struct cmd_vf_promisc_result,
14909 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14910 TOKEN_STRING_INITIALIZER
14911 (struct cmd_vf_promisc_result,
14912 promisc, "promisc");
14913 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14914 TOKEN_NUM_INITIALIZER
14915 (struct cmd_vf_promisc_result,
14917 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14918 TOKEN_NUM_INITIALIZER
14919 (struct cmd_vf_promisc_result,
14921 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14922 TOKEN_STRING_INITIALIZER
14923 (struct cmd_vf_promisc_result,
14927 cmd_set_vf_promisc_parsed(
14928 void *parsed_result,
14929 __rte_unused struct cmdline *cl,
14930 __rte_unused void *data)
14932 struct cmd_vf_promisc_result *res = parsed_result;
14933 int ret = -ENOTSUP;
14935 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14937 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14940 #ifdef RTE_LIBRTE_I40E_PMD
14941 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14942 res->vf_id, is_on);
14949 printf("invalid vf_id %d\n", res->vf_id);
14952 printf("invalid port_id %d\n", res->port_id);
14955 printf("function not implemented\n");
14958 printf("programming error: (%s)\n", strerror(-ret));
14962 cmdline_parse_inst_t cmd_set_vf_promisc = {
14963 .f = cmd_set_vf_promisc_parsed,
14965 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14966 "Set unicast promiscuous mode for a VF from the PF",
14968 (void *)&cmd_vf_promisc_set,
14969 (void *)&cmd_vf_promisc_vf,
14970 (void *)&cmd_vf_promisc_promisc,
14971 (void *)&cmd_vf_promisc_port_id,
14972 (void *)&cmd_vf_promisc_vf_id,
14973 (void *)&cmd_vf_promisc_on_off,
14978 /* VF multicast promiscuous mode configuration */
14980 /* Common result structure for VF multicast promiscuous mode */
14981 struct cmd_vf_allmulti_result {
14982 cmdline_fixed_string_t set;
14983 cmdline_fixed_string_t vf;
14984 cmdline_fixed_string_t allmulti;
14987 cmdline_fixed_string_t on_off;
14990 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14991 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14992 TOKEN_STRING_INITIALIZER
14993 (struct cmd_vf_allmulti_result,
14995 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14996 TOKEN_STRING_INITIALIZER
14997 (struct cmd_vf_allmulti_result,
14999 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
15000 TOKEN_STRING_INITIALIZER
15001 (struct cmd_vf_allmulti_result,
15002 allmulti, "allmulti");
15003 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
15004 TOKEN_NUM_INITIALIZER
15005 (struct cmd_vf_allmulti_result,
15007 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
15008 TOKEN_NUM_INITIALIZER
15009 (struct cmd_vf_allmulti_result,
15011 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
15012 TOKEN_STRING_INITIALIZER
15013 (struct cmd_vf_allmulti_result,
15017 cmd_set_vf_allmulti_parsed(
15018 void *parsed_result,
15019 __rte_unused struct cmdline *cl,
15020 __rte_unused void *data)
15022 struct cmd_vf_allmulti_result *res = parsed_result;
15023 int ret = -ENOTSUP;
15025 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15027 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15030 #ifdef RTE_LIBRTE_I40E_PMD
15031 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
15032 res->vf_id, is_on);
15039 printf("invalid vf_id %d\n", res->vf_id);
15042 printf("invalid port_id %d\n", res->port_id);
15045 printf("function not implemented\n");
15048 printf("programming error: (%s)\n", strerror(-ret));
15052 cmdline_parse_inst_t cmd_set_vf_allmulti = {
15053 .f = cmd_set_vf_allmulti_parsed,
15055 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
15056 "Set multicast promiscuous mode for a VF from the PF",
15058 (void *)&cmd_vf_allmulti_set,
15059 (void *)&cmd_vf_allmulti_vf,
15060 (void *)&cmd_vf_allmulti_allmulti,
15061 (void *)&cmd_vf_allmulti_port_id,
15062 (void *)&cmd_vf_allmulti_vf_id,
15063 (void *)&cmd_vf_allmulti_on_off,
15068 /* vf broadcast mode configuration */
15070 /* Common result structure for vf broadcast */
15071 struct cmd_set_vf_broadcast_result {
15072 cmdline_fixed_string_t set;
15073 cmdline_fixed_string_t vf;
15074 cmdline_fixed_string_t broadcast;
15077 cmdline_fixed_string_t on_off;
15080 /* Common CLI fields for vf broadcast enable disable */
15081 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
15082 TOKEN_STRING_INITIALIZER
15083 (struct cmd_set_vf_broadcast_result,
15085 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
15086 TOKEN_STRING_INITIALIZER
15087 (struct cmd_set_vf_broadcast_result,
15089 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
15090 TOKEN_STRING_INITIALIZER
15091 (struct cmd_set_vf_broadcast_result,
15092 broadcast, "broadcast");
15093 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
15094 TOKEN_NUM_INITIALIZER
15095 (struct cmd_set_vf_broadcast_result,
15097 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
15098 TOKEN_NUM_INITIALIZER
15099 (struct cmd_set_vf_broadcast_result,
15101 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
15102 TOKEN_STRING_INITIALIZER
15103 (struct cmd_set_vf_broadcast_result,
15107 cmd_set_vf_broadcast_parsed(
15108 void *parsed_result,
15109 __rte_unused struct cmdline *cl,
15110 __rte_unused void *data)
15112 struct cmd_set_vf_broadcast_result *res = parsed_result;
15113 int ret = -ENOTSUP;
15115 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15117 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15120 #ifdef RTE_LIBRTE_I40E_PMD
15121 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
15122 res->vf_id, is_on);
15129 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15132 printf("invalid port_id %d\n", res->port_id);
15135 printf("function not implemented\n");
15138 printf("programming error: (%s)\n", strerror(-ret));
15142 cmdline_parse_inst_t cmd_set_vf_broadcast = {
15143 .f = cmd_set_vf_broadcast_parsed,
15145 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
15147 (void *)&cmd_set_vf_broadcast_set,
15148 (void *)&cmd_set_vf_broadcast_vf,
15149 (void *)&cmd_set_vf_broadcast_broadcast,
15150 (void *)&cmd_set_vf_broadcast_port_id,
15151 (void *)&cmd_set_vf_broadcast_vf_id,
15152 (void *)&cmd_set_vf_broadcast_on_off,
15157 /* vf vlan tag configuration */
15159 /* Common result structure for vf vlan tag */
15160 struct cmd_set_vf_vlan_tag_result {
15161 cmdline_fixed_string_t set;
15162 cmdline_fixed_string_t vf;
15163 cmdline_fixed_string_t vlan;
15164 cmdline_fixed_string_t tag;
15167 cmdline_fixed_string_t on_off;
15170 /* Common CLI fields for vf vlan tag enable disable */
15171 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
15172 TOKEN_STRING_INITIALIZER
15173 (struct cmd_set_vf_vlan_tag_result,
15175 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
15176 TOKEN_STRING_INITIALIZER
15177 (struct cmd_set_vf_vlan_tag_result,
15179 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
15180 TOKEN_STRING_INITIALIZER
15181 (struct cmd_set_vf_vlan_tag_result,
15183 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
15184 TOKEN_STRING_INITIALIZER
15185 (struct cmd_set_vf_vlan_tag_result,
15187 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
15188 TOKEN_NUM_INITIALIZER
15189 (struct cmd_set_vf_vlan_tag_result,
15191 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
15192 TOKEN_NUM_INITIALIZER
15193 (struct cmd_set_vf_vlan_tag_result,
15195 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
15196 TOKEN_STRING_INITIALIZER
15197 (struct cmd_set_vf_vlan_tag_result,
15201 cmd_set_vf_vlan_tag_parsed(
15202 void *parsed_result,
15203 __rte_unused struct cmdline *cl,
15204 __rte_unused void *data)
15206 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
15207 int ret = -ENOTSUP;
15209 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15211 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15214 #ifdef RTE_LIBRTE_I40E_PMD
15215 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
15216 res->vf_id, is_on);
15223 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15226 printf("invalid port_id %d\n", res->port_id);
15229 printf("function not implemented\n");
15232 printf("programming error: (%s)\n", strerror(-ret));
15236 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
15237 .f = cmd_set_vf_vlan_tag_parsed,
15239 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
15241 (void *)&cmd_set_vf_vlan_tag_set,
15242 (void *)&cmd_set_vf_vlan_tag_vf,
15243 (void *)&cmd_set_vf_vlan_tag_vlan,
15244 (void *)&cmd_set_vf_vlan_tag_tag,
15245 (void *)&cmd_set_vf_vlan_tag_port_id,
15246 (void *)&cmd_set_vf_vlan_tag_vf_id,
15247 (void *)&cmd_set_vf_vlan_tag_on_off,
15252 /* Common definition of VF and TC TX bandwidth configuration */
15253 struct cmd_vf_tc_bw_result {
15254 cmdline_fixed_string_t set;
15255 cmdline_fixed_string_t vf;
15256 cmdline_fixed_string_t tc;
15257 cmdline_fixed_string_t tx;
15258 cmdline_fixed_string_t min_bw;
15259 cmdline_fixed_string_t max_bw;
15260 cmdline_fixed_string_t strict_link_prio;
15265 cmdline_fixed_string_t bw_list;
15269 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
15270 TOKEN_STRING_INITIALIZER
15271 (struct cmd_vf_tc_bw_result,
15273 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
15274 TOKEN_STRING_INITIALIZER
15275 (struct cmd_vf_tc_bw_result,
15277 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
15278 TOKEN_STRING_INITIALIZER
15279 (struct cmd_vf_tc_bw_result,
15281 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
15282 TOKEN_STRING_INITIALIZER
15283 (struct cmd_vf_tc_bw_result,
15285 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
15286 TOKEN_STRING_INITIALIZER
15287 (struct cmd_vf_tc_bw_result,
15288 strict_link_prio, "strict-link-priority");
15289 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
15290 TOKEN_STRING_INITIALIZER
15291 (struct cmd_vf_tc_bw_result,
15292 min_bw, "min-bandwidth");
15293 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
15294 TOKEN_STRING_INITIALIZER
15295 (struct cmd_vf_tc_bw_result,
15296 max_bw, "max-bandwidth");
15297 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
15298 TOKEN_NUM_INITIALIZER
15299 (struct cmd_vf_tc_bw_result,
15301 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
15302 TOKEN_NUM_INITIALIZER
15303 (struct cmd_vf_tc_bw_result,
15305 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
15306 TOKEN_NUM_INITIALIZER
15307 (struct cmd_vf_tc_bw_result,
15309 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
15310 TOKEN_NUM_INITIALIZER
15311 (struct cmd_vf_tc_bw_result,
15313 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
15314 TOKEN_STRING_INITIALIZER
15315 (struct cmd_vf_tc_bw_result,
15317 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
15318 TOKEN_NUM_INITIALIZER
15319 (struct cmd_vf_tc_bw_result,
15322 /* VF max bandwidth setting */
15324 cmd_vf_max_bw_parsed(
15325 void *parsed_result,
15326 __rte_unused struct cmdline *cl,
15327 __rte_unused void *data)
15329 struct cmd_vf_tc_bw_result *res = parsed_result;
15330 int ret = -ENOTSUP;
15332 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15335 #ifdef RTE_LIBRTE_I40E_PMD
15336 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15337 res->vf_id, res->bw);
15344 printf("invalid vf_id %d or bandwidth %d\n",
15345 res->vf_id, res->bw);
15348 printf("invalid port_id %d\n", res->port_id);
15351 printf("function not implemented\n");
15354 printf("programming error: (%s)\n", strerror(-ret));
15358 cmdline_parse_inst_t cmd_vf_max_bw = {
15359 .f = cmd_vf_max_bw_parsed,
15361 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15363 (void *)&cmd_vf_tc_bw_set,
15364 (void *)&cmd_vf_tc_bw_vf,
15365 (void *)&cmd_vf_tc_bw_tx,
15366 (void *)&cmd_vf_tc_bw_max_bw,
15367 (void *)&cmd_vf_tc_bw_port_id,
15368 (void *)&cmd_vf_tc_bw_vf_id,
15369 (void *)&cmd_vf_tc_bw_bw,
15375 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15380 const char *p, *p0 = str;
15387 p = strchr(p0, '(');
15389 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15393 p0 = strchr(p, ')');
15395 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15399 if (size >= sizeof(s)) {
15400 printf("The string size exceeds the internal buffer size\n");
15403 snprintf(s, sizeof(s), "%.*s", size, p);
15404 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15406 printf("Failed to get the bandwidth list. ");
15410 for (i = 0; i < ret; i++)
15411 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15416 /* TC min bandwidth setting */
15418 cmd_vf_tc_min_bw_parsed(
15419 void *parsed_result,
15420 __rte_unused struct cmdline *cl,
15421 __rte_unused void *data)
15423 struct cmd_vf_tc_bw_result *res = parsed_result;
15426 int ret = -ENOTSUP;
15428 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15431 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15435 #ifdef RTE_LIBRTE_I40E_PMD
15436 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15444 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15447 printf("invalid port_id %d\n", res->port_id);
15450 printf("function not implemented\n");
15453 printf("programming error: (%s)\n", strerror(-ret));
15457 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15458 .f = cmd_vf_tc_min_bw_parsed,
15460 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15461 " <bw1, bw2, ...>",
15463 (void *)&cmd_vf_tc_bw_set,
15464 (void *)&cmd_vf_tc_bw_vf,
15465 (void *)&cmd_vf_tc_bw_tc,
15466 (void *)&cmd_vf_tc_bw_tx,
15467 (void *)&cmd_vf_tc_bw_min_bw,
15468 (void *)&cmd_vf_tc_bw_port_id,
15469 (void *)&cmd_vf_tc_bw_vf_id,
15470 (void *)&cmd_vf_tc_bw_bw_list,
15476 cmd_tc_min_bw_parsed(
15477 void *parsed_result,
15478 __rte_unused struct cmdline *cl,
15479 __rte_unused void *data)
15481 struct cmd_vf_tc_bw_result *res = parsed_result;
15482 struct rte_port *port;
15485 int ret = -ENOTSUP;
15487 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15490 port = &ports[res->port_id];
15491 /** Check if the port is not started **/
15492 if (port->port_status != RTE_PORT_STOPPED) {
15493 printf("Please stop port %d first\n", res->port_id);
15497 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15501 #ifdef RTE_LIBRTE_IXGBE_PMD
15502 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15509 printf("invalid bandwidth\n");
15512 printf("invalid port_id %d\n", res->port_id);
15515 printf("function not implemented\n");
15518 printf("programming error: (%s)\n", strerror(-ret));
15522 cmdline_parse_inst_t cmd_tc_min_bw = {
15523 .f = cmd_tc_min_bw_parsed,
15525 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15527 (void *)&cmd_vf_tc_bw_set,
15528 (void *)&cmd_vf_tc_bw_tc,
15529 (void *)&cmd_vf_tc_bw_tx,
15530 (void *)&cmd_vf_tc_bw_min_bw,
15531 (void *)&cmd_vf_tc_bw_port_id,
15532 (void *)&cmd_vf_tc_bw_bw_list,
15537 /* TC max bandwidth setting */
15539 cmd_vf_tc_max_bw_parsed(
15540 void *parsed_result,
15541 __rte_unused struct cmdline *cl,
15542 __rte_unused void *data)
15544 struct cmd_vf_tc_bw_result *res = parsed_result;
15545 int ret = -ENOTSUP;
15547 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15550 #ifdef RTE_LIBRTE_I40E_PMD
15551 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15552 res->tc_no, res->bw);
15559 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15560 res->vf_id, res->tc_no, res->bw);
15563 printf("invalid port_id %d\n", res->port_id);
15566 printf("function not implemented\n");
15569 printf("programming error: (%s)\n", strerror(-ret));
15573 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15574 .f = cmd_vf_tc_max_bw_parsed,
15576 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15579 (void *)&cmd_vf_tc_bw_set,
15580 (void *)&cmd_vf_tc_bw_vf,
15581 (void *)&cmd_vf_tc_bw_tc,
15582 (void *)&cmd_vf_tc_bw_tx,
15583 (void *)&cmd_vf_tc_bw_max_bw,
15584 (void *)&cmd_vf_tc_bw_port_id,
15585 (void *)&cmd_vf_tc_bw_vf_id,
15586 (void *)&cmd_vf_tc_bw_tc_no,
15587 (void *)&cmd_vf_tc_bw_bw,
15592 /** Set VXLAN encapsulation details */
15593 struct cmd_set_vxlan_result {
15594 cmdline_fixed_string_t set;
15595 cmdline_fixed_string_t vxlan;
15596 cmdline_fixed_string_t pos_token;
15597 cmdline_fixed_string_t ip_version;
15598 uint32_t vlan_present:1;
15602 cmdline_ipaddr_t ip_src;
15603 cmdline_ipaddr_t ip_dst;
15607 struct rte_ether_addr eth_src;
15608 struct rte_ether_addr eth_dst;
15611 cmdline_parse_token_string_t cmd_set_vxlan_set =
15612 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15613 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15614 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15615 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15616 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15618 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15619 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15620 "vxlan-with-vlan");
15621 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15622 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15624 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15625 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15627 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15628 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15630 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15631 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15632 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15633 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15635 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15636 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15637 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15638 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15640 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15641 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15642 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15643 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15645 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15646 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15647 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15648 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15650 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15651 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15652 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15653 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15655 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15656 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15657 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15658 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15660 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15661 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15662 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15663 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15665 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15666 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15667 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15668 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15670 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15671 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15672 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15673 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15675 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15676 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15678 static void cmd_set_vxlan_parsed(void *parsed_result,
15679 __rte_unused struct cmdline *cl,
15680 __rte_unused void *data)
15682 struct cmd_set_vxlan_result *res = parsed_result;
15687 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15690 vxlan_encap_conf.select_tos_ttl = 0;
15691 if (strcmp(res->vxlan, "vxlan") == 0)
15692 vxlan_encap_conf.select_vlan = 0;
15693 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15694 vxlan_encap_conf.select_vlan = 1;
15695 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15696 vxlan_encap_conf.select_vlan = 0;
15697 vxlan_encap_conf.select_tos_ttl = 1;
15699 if (strcmp(res->ip_version, "ipv4") == 0)
15700 vxlan_encap_conf.select_ipv4 = 1;
15701 else if (strcmp(res->ip_version, "ipv6") == 0)
15702 vxlan_encap_conf.select_ipv4 = 0;
15705 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15706 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15707 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15708 vxlan_encap_conf.ip_tos = res->tos;
15709 vxlan_encap_conf.ip_ttl = res->ttl;
15710 if (vxlan_encap_conf.select_ipv4) {
15711 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15712 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15714 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15715 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15717 if (vxlan_encap_conf.select_vlan)
15718 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15719 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15720 RTE_ETHER_ADDR_LEN);
15721 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15722 RTE_ETHER_ADDR_LEN);
15725 cmdline_parse_inst_t cmd_set_vxlan = {
15726 .f = cmd_set_vxlan_parsed,
15728 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15729 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15730 " eth-src <eth-src> eth-dst <eth-dst>",
15732 (void *)&cmd_set_vxlan_set,
15733 (void *)&cmd_set_vxlan_vxlan,
15734 (void *)&cmd_set_vxlan_ip_version,
15735 (void *)&cmd_set_vxlan_ip_version_value,
15736 (void *)&cmd_set_vxlan_vni,
15737 (void *)&cmd_set_vxlan_vni_value,
15738 (void *)&cmd_set_vxlan_udp_src,
15739 (void *)&cmd_set_vxlan_udp_src_value,
15740 (void *)&cmd_set_vxlan_udp_dst,
15741 (void *)&cmd_set_vxlan_udp_dst_value,
15742 (void *)&cmd_set_vxlan_ip_src,
15743 (void *)&cmd_set_vxlan_ip_src_value,
15744 (void *)&cmd_set_vxlan_ip_dst,
15745 (void *)&cmd_set_vxlan_ip_dst_value,
15746 (void *)&cmd_set_vxlan_eth_src,
15747 (void *)&cmd_set_vxlan_eth_src_value,
15748 (void *)&cmd_set_vxlan_eth_dst,
15749 (void *)&cmd_set_vxlan_eth_dst_value,
15754 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15755 .f = cmd_set_vxlan_parsed,
15757 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15758 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15759 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15760 " eth-dst <eth-dst>",
15762 (void *)&cmd_set_vxlan_set,
15763 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15764 (void *)&cmd_set_vxlan_ip_version,
15765 (void *)&cmd_set_vxlan_ip_version_value,
15766 (void *)&cmd_set_vxlan_vni,
15767 (void *)&cmd_set_vxlan_vni_value,
15768 (void *)&cmd_set_vxlan_udp_src,
15769 (void *)&cmd_set_vxlan_udp_src_value,
15770 (void *)&cmd_set_vxlan_udp_dst,
15771 (void *)&cmd_set_vxlan_udp_dst_value,
15772 (void *)&cmd_set_vxlan_ip_tos,
15773 (void *)&cmd_set_vxlan_ip_tos_value,
15774 (void *)&cmd_set_vxlan_ip_ttl,
15775 (void *)&cmd_set_vxlan_ip_ttl_value,
15776 (void *)&cmd_set_vxlan_ip_src,
15777 (void *)&cmd_set_vxlan_ip_src_value,
15778 (void *)&cmd_set_vxlan_ip_dst,
15779 (void *)&cmd_set_vxlan_ip_dst_value,
15780 (void *)&cmd_set_vxlan_eth_src,
15781 (void *)&cmd_set_vxlan_eth_src_value,
15782 (void *)&cmd_set_vxlan_eth_dst,
15783 (void *)&cmd_set_vxlan_eth_dst_value,
15788 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15789 .f = cmd_set_vxlan_parsed,
15791 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15792 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15793 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15796 (void *)&cmd_set_vxlan_set,
15797 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15798 (void *)&cmd_set_vxlan_ip_version,
15799 (void *)&cmd_set_vxlan_ip_version_value,
15800 (void *)&cmd_set_vxlan_vni,
15801 (void *)&cmd_set_vxlan_vni_value,
15802 (void *)&cmd_set_vxlan_udp_src,
15803 (void *)&cmd_set_vxlan_udp_src_value,
15804 (void *)&cmd_set_vxlan_udp_dst,
15805 (void *)&cmd_set_vxlan_udp_dst_value,
15806 (void *)&cmd_set_vxlan_ip_src,
15807 (void *)&cmd_set_vxlan_ip_src_value,
15808 (void *)&cmd_set_vxlan_ip_dst,
15809 (void *)&cmd_set_vxlan_ip_dst_value,
15810 (void *)&cmd_set_vxlan_vlan,
15811 (void *)&cmd_set_vxlan_vlan_value,
15812 (void *)&cmd_set_vxlan_eth_src,
15813 (void *)&cmd_set_vxlan_eth_src_value,
15814 (void *)&cmd_set_vxlan_eth_dst,
15815 (void *)&cmd_set_vxlan_eth_dst_value,
15820 /** Set NVGRE encapsulation details */
15821 struct cmd_set_nvgre_result {
15822 cmdline_fixed_string_t set;
15823 cmdline_fixed_string_t nvgre;
15824 cmdline_fixed_string_t pos_token;
15825 cmdline_fixed_string_t ip_version;
15827 cmdline_ipaddr_t ip_src;
15828 cmdline_ipaddr_t ip_dst;
15830 struct rte_ether_addr eth_src;
15831 struct rte_ether_addr eth_dst;
15834 cmdline_parse_token_string_t cmd_set_nvgre_set =
15835 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15836 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15837 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15838 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15839 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15840 "nvgre-with-vlan");
15841 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15842 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15844 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15845 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15847 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15848 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15850 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15851 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15852 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15853 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15855 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15856 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15857 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15858 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15860 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15861 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15862 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15863 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15865 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15866 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15867 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15868 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15870 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15871 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15872 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15873 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15875 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15876 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15878 static void cmd_set_nvgre_parsed(void *parsed_result,
15879 __rte_unused struct cmdline *cl,
15880 __rte_unused void *data)
15882 struct cmd_set_nvgre_result *res = parsed_result;
15884 uint32_t nvgre_tni;
15887 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15890 if (strcmp(res->nvgre, "nvgre") == 0)
15891 nvgre_encap_conf.select_vlan = 0;
15892 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15893 nvgre_encap_conf.select_vlan = 1;
15894 if (strcmp(res->ip_version, "ipv4") == 0)
15895 nvgre_encap_conf.select_ipv4 = 1;
15896 else if (strcmp(res->ip_version, "ipv6") == 0)
15897 nvgre_encap_conf.select_ipv4 = 0;
15900 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15901 if (nvgre_encap_conf.select_ipv4) {
15902 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15903 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15905 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15906 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15908 if (nvgre_encap_conf.select_vlan)
15909 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15910 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15911 RTE_ETHER_ADDR_LEN);
15912 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15913 RTE_ETHER_ADDR_LEN);
15916 cmdline_parse_inst_t cmd_set_nvgre = {
15917 .f = cmd_set_nvgre_parsed,
15919 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15920 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15921 " eth-dst <eth-dst>",
15923 (void *)&cmd_set_nvgre_set,
15924 (void *)&cmd_set_nvgre_nvgre,
15925 (void *)&cmd_set_nvgre_ip_version,
15926 (void *)&cmd_set_nvgre_ip_version_value,
15927 (void *)&cmd_set_nvgre_tni,
15928 (void *)&cmd_set_nvgre_tni_value,
15929 (void *)&cmd_set_nvgre_ip_src,
15930 (void *)&cmd_set_nvgre_ip_src_value,
15931 (void *)&cmd_set_nvgre_ip_dst,
15932 (void *)&cmd_set_nvgre_ip_dst_value,
15933 (void *)&cmd_set_nvgre_eth_src,
15934 (void *)&cmd_set_nvgre_eth_src_value,
15935 (void *)&cmd_set_nvgre_eth_dst,
15936 (void *)&cmd_set_nvgre_eth_dst_value,
15941 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15942 .f = cmd_set_nvgre_parsed,
15944 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15945 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15946 " eth-src <eth-src> eth-dst <eth-dst>",
15948 (void *)&cmd_set_nvgre_set,
15949 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15950 (void *)&cmd_set_nvgre_ip_version,
15951 (void *)&cmd_set_nvgre_ip_version_value,
15952 (void *)&cmd_set_nvgre_tni,
15953 (void *)&cmd_set_nvgre_tni_value,
15954 (void *)&cmd_set_nvgre_ip_src,
15955 (void *)&cmd_set_nvgre_ip_src_value,
15956 (void *)&cmd_set_nvgre_ip_dst,
15957 (void *)&cmd_set_nvgre_ip_dst_value,
15958 (void *)&cmd_set_nvgre_vlan,
15959 (void *)&cmd_set_nvgre_vlan_value,
15960 (void *)&cmd_set_nvgre_eth_src,
15961 (void *)&cmd_set_nvgre_eth_src_value,
15962 (void *)&cmd_set_nvgre_eth_dst,
15963 (void *)&cmd_set_nvgre_eth_dst_value,
15968 /** Set L2 encapsulation details */
15969 struct cmd_set_l2_encap_result {
15970 cmdline_fixed_string_t set;
15971 cmdline_fixed_string_t l2_encap;
15972 cmdline_fixed_string_t pos_token;
15973 cmdline_fixed_string_t ip_version;
15974 uint32_t vlan_present:1;
15976 struct rte_ether_addr eth_src;
15977 struct rte_ether_addr eth_dst;
15980 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15981 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15982 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15983 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15984 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15985 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15986 "l2_encap-with-vlan");
15987 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15988 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15990 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15991 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15993 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15994 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15996 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15997 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15998 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15999 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
16001 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
16002 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
16003 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
16004 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
16006 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
16007 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
16009 static void cmd_set_l2_encap_parsed(void *parsed_result,
16010 __rte_unused struct cmdline *cl,
16011 __rte_unused void *data)
16013 struct cmd_set_l2_encap_result *res = parsed_result;
16015 if (strcmp(res->l2_encap, "l2_encap") == 0)
16016 l2_encap_conf.select_vlan = 0;
16017 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
16018 l2_encap_conf.select_vlan = 1;
16019 if (strcmp(res->ip_version, "ipv4") == 0)
16020 l2_encap_conf.select_ipv4 = 1;
16021 else if (strcmp(res->ip_version, "ipv6") == 0)
16022 l2_encap_conf.select_ipv4 = 0;
16025 if (l2_encap_conf.select_vlan)
16026 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16027 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
16028 RTE_ETHER_ADDR_LEN);
16029 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16030 RTE_ETHER_ADDR_LEN);
16033 cmdline_parse_inst_t cmd_set_l2_encap = {
16034 .f = cmd_set_l2_encap_parsed,
16036 .help_str = "set l2_encap ip-version ipv4|ipv6"
16037 " eth-src <eth-src> eth-dst <eth-dst>",
16039 (void *)&cmd_set_l2_encap_set,
16040 (void *)&cmd_set_l2_encap_l2_encap,
16041 (void *)&cmd_set_l2_encap_ip_version,
16042 (void *)&cmd_set_l2_encap_ip_version_value,
16043 (void *)&cmd_set_l2_encap_eth_src,
16044 (void *)&cmd_set_l2_encap_eth_src_value,
16045 (void *)&cmd_set_l2_encap_eth_dst,
16046 (void *)&cmd_set_l2_encap_eth_dst_value,
16051 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
16052 .f = cmd_set_l2_encap_parsed,
16054 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
16055 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16057 (void *)&cmd_set_l2_encap_set,
16058 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
16059 (void *)&cmd_set_l2_encap_ip_version,
16060 (void *)&cmd_set_l2_encap_ip_version_value,
16061 (void *)&cmd_set_l2_encap_vlan,
16062 (void *)&cmd_set_l2_encap_vlan_value,
16063 (void *)&cmd_set_l2_encap_eth_src,
16064 (void *)&cmd_set_l2_encap_eth_src_value,
16065 (void *)&cmd_set_l2_encap_eth_dst,
16066 (void *)&cmd_set_l2_encap_eth_dst_value,
16071 /** Set L2 decapsulation details */
16072 struct cmd_set_l2_decap_result {
16073 cmdline_fixed_string_t set;
16074 cmdline_fixed_string_t l2_decap;
16075 cmdline_fixed_string_t pos_token;
16076 uint32_t vlan_present:1;
16079 cmdline_parse_token_string_t cmd_set_l2_decap_set =
16080 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
16081 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
16082 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
16084 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
16085 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
16086 "l2_decap-with-vlan");
16088 static void cmd_set_l2_decap_parsed(void *parsed_result,
16089 __rte_unused struct cmdline *cl,
16090 __rte_unused void *data)
16092 struct cmd_set_l2_decap_result *res = parsed_result;
16094 if (strcmp(res->l2_decap, "l2_decap") == 0)
16095 l2_decap_conf.select_vlan = 0;
16096 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
16097 l2_decap_conf.select_vlan = 1;
16100 cmdline_parse_inst_t cmd_set_l2_decap = {
16101 .f = cmd_set_l2_decap_parsed,
16103 .help_str = "set l2_decap",
16105 (void *)&cmd_set_l2_decap_set,
16106 (void *)&cmd_set_l2_decap_l2_decap,
16111 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
16112 .f = cmd_set_l2_decap_parsed,
16114 .help_str = "set l2_decap-with-vlan",
16116 (void *)&cmd_set_l2_decap_set,
16117 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
16122 /** Set MPLSoGRE encapsulation details */
16123 struct cmd_set_mplsogre_encap_result {
16124 cmdline_fixed_string_t set;
16125 cmdline_fixed_string_t mplsogre;
16126 cmdline_fixed_string_t pos_token;
16127 cmdline_fixed_string_t ip_version;
16128 uint32_t vlan_present:1;
16130 cmdline_ipaddr_t ip_src;
16131 cmdline_ipaddr_t ip_dst;
16133 struct rte_ether_addr eth_src;
16134 struct rte_ether_addr eth_dst;
16137 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
16138 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
16140 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
16141 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
16143 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
16144 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16145 mplsogre, "mplsogre_encap-with-vlan");
16146 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
16147 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16148 pos_token, "ip-version");
16149 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
16150 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16151 ip_version, "ipv4#ipv6");
16152 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
16153 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16154 pos_token, "label");
16155 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
16156 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
16158 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
16159 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16160 pos_token, "ip-src");
16161 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
16162 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
16163 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
16164 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16165 pos_token, "ip-dst");
16166 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
16167 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
16168 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
16169 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16170 pos_token, "vlan-tci");
16171 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
16172 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
16174 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
16175 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16176 pos_token, "eth-src");
16177 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
16178 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16180 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
16181 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16182 pos_token, "eth-dst");
16183 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
16184 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16187 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
16188 __rte_unused struct cmdline *cl,
16189 __rte_unused void *data)
16191 struct cmd_set_mplsogre_encap_result *res = parsed_result;
16193 uint32_t mplsogre_label;
16196 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
16199 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
16200 mplsogre_encap_conf.select_vlan = 0;
16201 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
16202 mplsogre_encap_conf.select_vlan = 1;
16203 if (strcmp(res->ip_version, "ipv4") == 0)
16204 mplsogre_encap_conf.select_ipv4 = 1;
16205 else if (strcmp(res->ip_version, "ipv6") == 0)
16206 mplsogre_encap_conf.select_ipv4 = 0;
16209 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
16210 if (mplsogre_encap_conf.select_ipv4) {
16211 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
16212 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
16214 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
16215 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
16217 if (mplsogre_encap_conf.select_vlan)
16218 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16219 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
16220 RTE_ETHER_ADDR_LEN);
16221 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16222 RTE_ETHER_ADDR_LEN);
16225 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
16226 .f = cmd_set_mplsogre_encap_parsed,
16228 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
16229 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
16230 " eth-dst <eth-dst>",
16232 (void *)&cmd_set_mplsogre_encap_set,
16233 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
16234 (void *)&cmd_set_mplsogre_encap_ip_version,
16235 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16236 (void *)&cmd_set_mplsogre_encap_label,
16237 (void *)&cmd_set_mplsogre_encap_label_value,
16238 (void *)&cmd_set_mplsogre_encap_ip_src,
16239 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16240 (void *)&cmd_set_mplsogre_encap_ip_dst,
16241 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16242 (void *)&cmd_set_mplsogre_encap_eth_src,
16243 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16244 (void *)&cmd_set_mplsogre_encap_eth_dst,
16245 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16250 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16251 .f = cmd_set_mplsogre_encap_parsed,
16253 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16254 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16255 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16257 (void *)&cmd_set_mplsogre_encap_set,
16258 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16259 (void *)&cmd_set_mplsogre_encap_ip_version,
16260 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16261 (void *)&cmd_set_mplsogre_encap_label,
16262 (void *)&cmd_set_mplsogre_encap_label_value,
16263 (void *)&cmd_set_mplsogre_encap_ip_src,
16264 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16265 (void *)&cmd_set_mplsogre_encap_ip_dst,
16266 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16267 (void *)&cmd_set_mplsogre_encap_vlan,
16268 (void *)&cmd_set_mplsogre_encap_vlan_value,
16269 (void *)&cmd_set_mplsogre_encap_eth_src,
16270 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16271 (void *)&cmd_set_mplsogre_encap_eth_dst,
16272 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16277 /** Set MPLSoGRE decapsulation details */
16278 struct cmd_set_mplsogre_decap_result {
16279 cmdline_fixed_string_t set;
16280 cmdline_fixed_string_t mplsogre;
16281 cmdline_fixed_string_t pos_token;
16282 cmdline_fixed_string_t ip_version;
16283 uint32_t vlan_present:1;
16286 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16287 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16289 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16290 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16292 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16293 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16294 mplsogre, "mplsogre_decap-with-vlan");
16295 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16296 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16297 pos_token, "ip-version");
16298 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16299 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16300 ip_version, "ipv4#ipv6");
16302 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16303 __rte_unused struct cmdline *cl,
16304 __rte_unused void *data)
16306 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16308 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16309 mplsogre_decap_conf.select_vlan = 0;
16310 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16311 mplsogre_decap_conf.select_vlan = 1;
16312 if (strcmp(res->ip_version, "ipv4") == 0)
16313 mplsogre_decap_conf.select_ipv4 = 1;
16314 else if (strcmp(res->ip_version, "ipv6") == 0)
16315 mplsogre_decap_conf.select_ipv4 = 0;
16318 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16319 .f = cmd_set_mplsogre_decap_parsed,
16321 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16323 (void *)&cmd_set_mplsogre_decap_set,
16324 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16325 (void *)&cmd_set_mplsogre_decap_ip_version,
16326 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16331 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16332 .f = cmd_set_mplsogre_decap_parsed,
16334 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16336 (void *)&cmd_set_mplsogre_decap_set,
16337 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16338 (void *)&cmd_set_mplsogre_decap_ip_version,
16339 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16344 /** Set MPLSoUDP encapsulation details */
16345 struct cmd_set_mplsoudp_encap_result {
16346 cmdline_fixed_string_t set;
16347 cmdline_fixed_string_t mplsoudp;
16348 cmdline_fixed_string_t pos_token;
16349 cmdline_fixed_string_t ip_version;
16350 uint32_t vlan_present:1;
16354 cmdline_ipaddr_t ip_src;
16355 cmdline_ipaddr_t ip_dst;
16357 struct rte_ether_addr eth_src;
16358 struct rte_ether_addr eth_dst;
16361 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16362 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16364 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16365 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16367 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16368 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16369 mplsoudp, "mplsoudp_encap-with-vlan");
16370 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16371 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16372 pos_token, "ip-version");
16373 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16374 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16375 ip_version, "ipv4#ipv6");
16376 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16377 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16378 pos_token, "label");
16379 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16380 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16382 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16383 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16384 pos_token, "udp-src");
16385 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16386 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16388 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16389 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16390 pos_token, "udp-dst");
16391 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16392 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16394 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16395 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16396 pos_token, "ip-src");
16397 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16398 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16399 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16400 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16401 pos_token, "ip-dst");
16402 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16403 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16404 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16405 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16406 pos_token, "vlan-tci");
16407 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16408 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16410 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16411 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16412 pos_token, "eth-src");
16413 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16414 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16416 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16417 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16418 pos_token, "eth-dst");
16419 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16420 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16423 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16424 __rte_unused struct cmdline *cl,
16425 __rte_unused void *data)
16427 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16429 uint32_t mplsoudp_label;
16432 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16435 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16436 mplsoudp_encap_conf.select_vlan = 0;
16437 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16438 mplsoudp_encap_conf.select_vlan = 1;
16439 if (strcmp(res->ip_version, "ipv4") == 0)
16440 mplsoudp_encap_conf.select_ipv4 = 1;
16441 else if (strcmp(res->ip_version, "ipv6") == 0)
16442 mplsoudp_encap_conf.select_ipv4 = 0;
16445 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16446 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16447 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16448 if (mplsoudp_encap_conf.select_ipv4) {
16449 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16450 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16452 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16453 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16455 if (mplsoudp_encap_conf.select_vlan)
16456 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16457 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16458 RTE_ETHER_ADDR_LEN);
16459 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16460 RTE_ETHER_ADDR_LEN);
16463 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16464 .f = cmd_set_mplsoudp_encap_parsed,
16466 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16467 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16468 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16470 (void *)&cmd_set_mplsoudp_encap_set,
16471 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16472 (void *)&cmd_set_mplsoudp_encap_ip_version,
16473 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16474 (void *)&cmd_set_mplsoudp_encap_label,
16475 (void *)&cmd_set_mplsoudp_encap_label_value,
16476 (void *)&cmd_set_mplsoudp_encap_udp_src,
16477 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16478 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16479 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16480 (void *)&cmd_set_mplsoudp_encap_ip_src,
16481 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16482 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16483 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16484 (void *)&cmd_set_mplsoudp_encap_eth_src,
16485 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16486 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16487 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16492 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16493 .f = cmd_set_mplsoudp_encap_parsed,
16495 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16496 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16497 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16498 " eth-src <eth-src> eth-dst <eth-dst>",
16500 (void *)&cmd_set_mplsoudp_encap_set,
16501 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16502 (void *)&cmd_set_mplsoudp_encap_ip_version,
16503 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16504 (void *)&cmd_set_mplsoudp_encap_label,
16505 (void *)&cmd_set_mplsoudp_encap_label_value,
16506 (void *)&cmd_set_mplsoudp_encap_udp_src,
16507 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16508 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16509 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16510 (void *)&cmd_set_mplsoudp_encap_ip_src,
16511 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16512 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16513 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16514 (void *)&cmd_set_mplsoudp_encap_vlan,
16515 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16516 (void *)&cmd_set_mplsoudp_encap_eth_src,
16517 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16518 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16519 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16524 /** Set MPLSoUDP decapsulation details */
16525 struct cmd_set_mplsoudp_decap_result {
16526 cmdline_fixed_string_t set;
16527 cmdline_fixed_string_t mplsoudp;
16528 cmdline_fixed_string_t pos_token;
16529 cmdline_fixed_string_t ip_version;
16530 uint32_t vlan_present:1;
16533 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16534 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16536 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16537 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16539 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16540 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16541 mplsoudp, "mplsoudp_decap-with-vlan");
16542 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16543 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16544 pos_token, "ip-version");
16545 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16546 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16547 ip_version, "ipv4#ipv6");
16549 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16550 __rte_unused struct cmdline *cl,
16551 __rte_unused void *data)
16553 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16555 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16556 mplsoudp_decap_conf.select_vlan = 0;
16557 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16558 mplsoudp_decap_conf.select_vlan = 1;
16559 if (strcmp(res->ip_version, "ipv4") == 0)
16560 mplsoudp_decap_conf.select_ipv4 = 1;
16561 else if (strcmp(res->ip_version, "ipv6") == 0)
16562 mplsoudp_decap_conf.select_ipv4 = 0;
16565 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16566 .f = cmd_set_mplsoudp_decap_parsed,
16568 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16570 (void *)&cmd_set_mplsoudp_decap_set,
16571 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16572 (void *)&cmd_set_mplsoudp_decap_ip_version,
16573 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16578 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16579 .f = cmd_set_mplsoudp_decap_parsed,
16581 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16583 (void *)&cmd_set_mplsoudp_decap_set,
16584 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16585 (void *)&cmd_set_mplsoudp_decap_ip_version,
16586 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16591 /* Strict link priority scheduling mode setting */
16593 cmd_strict_link_prio_parsed(
16594 void *parsed_result,
16595 __rte_unused struct cmdline *cl,
16596 __rte_unused void *data)
16598 struct cmd_vf_tc_bw_result *res = parsed_result;
16599 int ret = -ENOTSUP;
16601 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16604 #ifdef RTE_LIBRTE_I40E_PMD
16605 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16612 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16615 printf("invalid port_id %d\n", res->port_id);
16618 printf("function not implemented\n");
16621 printf("programming error: (%s)\n", strerror(-ret));
16625 cmdline_parse_inst_t cmd_strict_link_prio = {
16626 .f = cmd_strict_link_prio_parsed,
16628 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16630 (void *)&cmd_vf_tc_bw_set,
16631 (void *)&cmd_vf_tc_bw_tx,
16632 (void *)&cmd_vf_tc_bw_strict_link_prio,
16633 (void *)&cmd_vf_tc_bw_port_id,
16634 (void *)&cmd_vf_tc_bw_tc_map,
16639 /* Load dynamic device personalization*/
16640 struct cmd_ddp_add_result {
16641 cmdline_fixed_string_t ddp;
16642 cmdline_fixed_string_t add;
16647 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16648 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16649 cmdline_parse_token_string_t cmd_ddp_add_add =
16650 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16651 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16652 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16653 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16654 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16657 cmd_ddp_add_parsed(
16658 void *parsed_result,
16659 __rte_unused struct cmdline *cl,
16660 __rte_unused void *data)
16662 struct cmd_ddp_add_result *res = parsed_result;
16668 int ret = -ENOTSUP;
16670 if (!all_ports_stopped()) {
16671 printf("Please stop all ports first\n");
16675 filepath = strdup(res->filepath);
16676 if (filepath == NULL) {
16677 printf("Failed to allocate memory\n");
16680 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16682 buff = open_file(file_fld[0], &size);
16684 free((void *)filepath);
16688 #ifdef RTE_LIBRTE_I40E_PMD
16689 if (ret == -ENOTSUP)
16690 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16692 RTE_PMD_I40E_PKG_OP_WR_ADD);
16695 if (ret == -EEXIST)
16696 printf("Profile has already existed.\n");
16698 printf("Failed to load profile.\n");
16699 else if (file_num == 2)
16700 save_file(file_fld[1], buff, size);
16703 free((void *)filepath);
16706 cmdline_parse_inst_t cmd_ddp_add = {
16707 .f = cmd_ddp_add_parsed,
16709 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16711 (void *)&cmd_ddp_add_ddp,
16712 (void *)&cmd_ddp_add_add,
16713 (void *)&cmd_ddp_add_port_id,
16714 (void *)&cmd_ddp_add_filepath,
16719 /* Delete dynamic device personalization*/
16720 struct cmd_ddp_del_result {
16721 cmdline_fixed_string_t ddp;
16722 cmdline_fixed_string_t del;
16727 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16728 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16729 cmdline_parse_token_string_t cmd_ddp_del_del =
16730 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16731 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16732 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16733 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16734 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16737 cmd_ddp_del_parsed(
16738 void *parsed_result,
16739 __rte_unused struct cmdline *cl,
16740 __rte_unused void *data)
16742 struct cmd_ddp_del_result *res = parsed_result;
16745 int ret = -ENOTSUP;
16747 if (!all_ports_stopped()) {
16748 printf("Please stop all ports first\n");
16752 buff = open_file(res->filepath, &size);
16756 #ifdef RTE_LIBRTE_I40E_PMD
16757 if (ret == -ENOTSUP)
16758 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16760 RTE_PMD_I40E_PKG_OP_WR_DEL);
16763 if (ret == -EACCES)
16764 printf("Profile does not exist.\n");
16766 printf("Failed to delete profile.\n");
16771 cmdline_parse_inst_t cmd_ddp_del = {
16772 .f = cmd_ddp_del_parsed,
16774 .help_str = "ddp del <port_id> <backup_profile_path>",
16776 (void *)&cmd_ddp_del_ddp,
16777 (void *)&cmd_ddp_del_del,
16778 (void *)&cmd_ddp_del_port_id,
16779 (void *)&cmd_ddp_del_filepath,
16784 /* Get dynamic device personalization profile info */
16785 struct cmd_ddp_info_result {
16786 cmdline_fixed_string_t ddp;
16787 cmdline_fixed_string_t get;
16788 cmdline_fixed_string_t info;
16792 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16793 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16794 cmdline_parse_token_string_t cmd_ddp_info_get =
16795 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16796 cmdline_parse_token_string_t cmd_ddp_info_info =
16797 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16798 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16799 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16802 cmd_ddp_info_parsed(
16803 void *parsed_result,
16804 __rte_unused struct cmdline *cl,
16805 __rte_unused void *data)
16807 struct cmd_ddp_info_result *res = parsed_result;
16810 int ret = -ENOTSUP;
16811 #ifdef RTE_LIBRTE_I40E_PMD
16814 uint32_t buff_size = 0;
16815 struct rte_pmd_i40e_profile_info info;
16816 uint32_t dev_num = 0;
16817 struct rte_pmd_i40e_ddp_device_id *devs;
16818 uint32_t proto_num = 0;
16819 struct rte_pmd_i40e_proto_info *proto = NULL;
16820 uint32_t pctype_num = 0;
16821 struct rte_pmd_i40e_ptype_info *pctype;
16822 uint32_t ptype_num = 0;
16823 struct rte_pmd_i40e_ptype_info *ptype;
16828 pkg = open_file(res->filepath, &pkg_size);
16832 #ifdef RTE_LIBRTE_I40E_PMD
16833 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16834 (uint8_t *)&info, sizeof(info),
16835 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16837 printf("Global Track id: 0x%x\n", info.track_id);
16838 printf("Global Version: %d.%d.%d.%d\n",
16839 info.version.major,
16840 info.version.minor,
16841 info.version.update,
16842 info.version.draft);
16843 printf("Global Package name: %s\n\n", info.name);
16846 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16847 (uint8_t *)&info, sizeof(info),
16848 RTE_PMD_I40E_PKG_INFO_HEADER);
16850 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16851 printf("i40e Profile Version: %d.%d.%d.%d\n",
16852 info.version.major,
16853 info.version.minor,
16854 info.version.update,
16855 info.version.draft);
16856 printf("i40e Profile name: %s\n\n", info.name);
16859 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16860 (uint8_t *)&buff_size, sizeof(buff_size),
16861 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16862 if (!ret && buff_size) {
16863 buff = (uint8_t *)malloc(buff_size);
16865 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16867 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16869 printf("Package Notes:\n%s\n\n", buff);
16874 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16875 (uint8_t *)&dev_num, sizeof(dev_num),
16876 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16877 if (!ret && dev_num) {
16878 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16879 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16881 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16882 (uint8_t *)devs, buff_size,
16883 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16885 printf("List of supported devices:\n");
16886 for (i = 0; i < dev_num; i++) {
16887 printf(" %04X:%04X %04X:%04X\n",
16888 devs[i].vendor_dev_id >> 16,
16889 devs[i].vendor_dev_id & 0xFFFF,
16890 devs[i].sub_vendor_dev_id >> 16,
16891 devs[i].sub_vendor_dev_id & 0xFFFF);
16899 /* get information about protocols and packet types */
16900 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16901 (uint8_t *)&proto_num, sizeof(proto_num),
16902 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16903 if (ret || !proto_num)
16904 goto no_print_return;
16906 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16907 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16909 goto no_print_return;
16911 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16913 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16915 printf("List of used protocols:\n");
16916 for (i = 0; i < proto_num; i++)
16917 printf(" %2u: %s\n", proto[i].proto_id,
16921 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16922 (uint8_t *)&pctype_num, sizeof(pctype_num),
16923 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16924 if (ret || !pctype_num)
16925 goto no_print_pctypes;
16927 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16928 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16930 goto no_print_pctypes;
16932 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16934 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16937 goto no_print_pctypes;
16940 printf("List of defined packet classification types:\n");
16941 for (i = 0; i < pctype_num; i++) {
16942 printf(" %2u:", pctype[i].ptype_id);
16943 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16944 proto_id = pctype[i].protocols[j];
16945 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16946 for (n = 0; n < proto_num; n++) {
16947 if (proto[n].proto_id == proto_id) {
16948 printf(" %s", proto[n].name);
16961 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16963 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16964 if (ret || !ptype_num)
16965 goto no_print_return;
16967 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16968 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16970 goto no_print_return;
16972 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16974 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16977 goto no_print_return;
16979 printf("List of defined packet types:\n");
16980 for (i = 0; i < ptype_num; i++) {
16981 printf(" %2u:", ptype[i].ptype_id);
16982 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16983 proto_id = ptype[i].protocols[j];
16984 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16985 for (n = 0; n < proto_num; n++) {
16986 if (proto[n].proto_id == proto_id) {
16987 printf(" %s", proto[n].name);
17003 if (ret == -ENOTSUP)
17004 printf("Function not supported in PMD driver\n");
17008 cmdline_parse_inst_t cmd_ddp_get_info = {
17009 .f = cmd_ddp_info_parsed,
17011 .help_str = "ddp get info <profile_path>",
17013 (void *)&cmd_ddp_info_ddp,
17014 (void *)&cmd_ddp_info_get,
17015 (void *)&cmd_ddp_info_info,
17016 (void *)&cmd_ddp_info_filepath,
17021 /* Get dynamic device personalization profile info list*/
17022 #define PROFILE_INFO_SIZE 48
17023 #define MAX_PROFILE_NUM 16
17025 struct cmd_ddp_get_list_result {
17026 cmdline_fixed_string_t ddp;
17027 cmdline_fixed_string_t get;
17028 cmdline_fixed_string_t list;
17032 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
17033 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
17034 cmdline_parse_token_string_t cmd_ddp_get_list_get =
17035 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
17036 cmdline_parse_token_string_t cmd_ddp_get_list_list =
17037 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
17038 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
17039 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
17042 cmd_ddp_get_list_parsed(
17043 __rte_unused void *parsed_result,
17044 __rte_unused struct cmdline *cl,
17045 __rte_unused void *data)
17047 #ifdef RTE_LIBRTE_I40E_PMD
17048 struct cmd_ddp_get_list_result *res = parsed_result;
17049 struct rte_pmd_i40e_profile_list *p_list;
17050 struct rte_pmd_i40e_profile_info *p_info;
17055 int ret = -ENOTSUP;
17057 #ifdef RTE_LIBRTE_I40E_PMD
17058 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
17059 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
17061 printf("%s: Failed to malloc buffer\n", __func__);
17065 if (ret == -ENOTSUP)
17066 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
17067 (uint8_t *)p_list, size);
17070 p_num = p_list->p_count;
17071 printf("Profile number is: %d\n\n", p_num);
17073 for (i = 0; i < p_num; i++) {
17074 p_info = &p_list->p_info[i];
17075 printf("Profile %d:\n", i);
17076 printf("Track id: 0x%x\n", p_info->track_id);
17077 printf("Version: %d.%d.%d.%d\n",
17078 p_info->version.major,
17079 p_info->version.minor,
17080 p_info->version.update,
17081 p_info->version.draft);
17082 printf("Profile name: %s\n\n", p_info->name);
17090 printf("Failed to get ddp list\n");
17093 cmdline_parse_inst_t cmd_ddp_get_list = {
17094 .f = cmd_ddp_get_list_parsed,
17096 .help_str = "ddp get list <port_id>",
17098 (void *)&cmd_ddp_get_list_ddp,
17099 (void *)&cmd_ddp_get_list_get,
17100 (void *)&cmd_ddp_get_list_list,
17101 (void *)&cmd_ddp_get_list_port_id,
17106 /* Configure input set */
17107 struct cmd_cfg_input_set_result {
17108 cmdline_fixed_string_t port;
17109 cmdline_fixed_string_t cfg;
17111 cmdline_fixed_string_t pctype;
17113 cmdline_fixed_string_t inset_type;
17114 cmdline_fixed_string_t opt;
17115 cmdline_fixed_string_t field;
17120 cmd_cfg_input_set_parsed(
17121 __rte_unused void *parsed_result,
17122 __rte_unused struct cmdline *cl,
17123 __rte_unused void *data)
17125 #ifdef RTE_LIBRTE_I40E_PMD
17126 struct cmd_cfg_input_set_result *res = parsed_result;
17127 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17128 struct rte_pmd_i40e_inset inset;
17130 int ret = -ENOTSUP;
17132 if (!all_ports_stopped()) {
17133 printf("Please stop all ports first\n");
17137 #ifdef RTE_LIBRTE_I40E_PMD
17138 if (!strcmp(res->inset_type, "hash_inset"))
17139 inset_type = INSET_HASH;
17140 else if (!strcmp(res->inset_type, "fdir_inset"))
17141 inset_type = INSET_FDIR;
17142 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17143 inset_type = INSET_FDIR_FLX;
17144 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
17145 &inset, inset_type);
17147 printf("Failed to get input set.\n");
17151 if (!strcmp(res->opt, "get")) {
17152 ret = rte_pmd_i40e_inset_field_get(inset.inset,
17155 printf("Field index %d is enabled.\n", res->field_idx);
17157 printf("Field index %d is disabled.\n", res->field_idx);
17159 } else if (!strcmp(res->opt, "set"))
17160 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
17162 else if (!strcmp(res->opt, "clear"))
17163 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
17166 printf("Failed to configure input set field.\n");
17170 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17171 &inset, inset_type);
17173 printf("Failed to set input set.\n");
17178 if (ret == -ENOTSUP)
17179 printf("Function not supported\n");
17182 cmdline_parse_token_string_t cmd_cfg_input_set_port =
17183 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17185 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
17186 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17188 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
17189 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17191 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
17192 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17194 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
17195 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17197 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
17198 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17200 "hash_inset#fdir_inset#fdir_flx_inset");
17201 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
17202 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17203 opt, "get#set#clear");
17204 cmdline_parse_token_string_t cmd_cfg_input_set_field =
17205 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17207 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
17208 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17211 cmdline_parse_inst_t cmd_cfg_input_set = {
17212 .f = cmd_cfg_input_set_parsed,
17214 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17215 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
17217 (void *)&cmd_cfg_input_set_port,
17218 (void *)&cmd_cfg_input_set_cfg,
17219 (void *)&cmd_cfg_input_set_port_id,
17220 (void *)&cmd_cfg_input_set_pctype,
17221 (void *)&cmd_cfg_input_set_pctype_id,
17222 (void *)&cmd_cfg_input_set_inset_type,
17223 (void *)&cmd_cfg_input_set_opt,
17224 (void *)&cmd_cfg_input_set_field,
17225 (void *)&cmd_cfg_input_set_field_idx,
17230 /* Clear input set */
17231 struct cmd_clear_input_set_result {
17232 cmdline_fixed_string_t port;
17233 cmdline_fixed_string_t cfg;
17235 cmdline_fixed_string_t pctype;
17237 cmdline_fixed_string_t inset_type;
17238 cmdline_fixed_string_t clear;
17239 cmdline_fixed_string_t all;
17243 cmd_clear_input_set_parsed(
17244 __rte_unused void *parsed_result,
17245 __rte_unused struct cmdline *cl,
17246 __rte_unused void *data)
17248 #ifdef RTE_LIBRTE_I40E_PMD
17249 struct cmd_clear_input_set_result *res = parsed_result;
17250 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17251 struct rte_pmd_i40e_inset inset;
17253 int ret = -ENOTSUP;
17255 if (!all_ports_stopped()) {
17256 printf("Please stop all ports first\n");
17260 #ifdef RTE_LIBRTE_I40E_PMD
17261 if (!strcmp(res->inset_type, "hash_inset"))
17262 inset_type = INSET_HASH;
17263 else if (!strcmp(res->inset_type, "fdir_inset"))
17264 inset_type = INSET_FDIR;
17265 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17266 inset_type = INSET_FDIR_FLX;
17268 memset(&inset, 0, sizeof(inset));
17270 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17271 &inset, inset_type);
17273 printf("Failed to clear input set.\n");
17279 if (ret == -ENOTSUP)
17280 printf("Function not supported\n");
17283 cmdline_parse_token_string_t cmd_clear_input_set_port =
17284 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17286 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17287 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17289 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17290 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17292 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17293 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17295 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17296 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17298 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17299 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17301 "hash_inset#fdir_inset#fdir_flx_inset");
17302 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17303 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17305 cmdline_parse_token_string_t cmd_clear_input_set_all =
17306 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17309 cmdline_parse_inst_t cmd_clear_input_set = {
17310 .f = cmd_clear_input_set_parsed,
17312 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17313 "fdir_inset|fdir_flx_inset clear all",
17315 (void *)&cmd_clear_input_set_port,
17316 (void *)&cmd_clear_input_set_cfg,
17317 (void *)&cmd_clear_input_set_port_id,
17318 (void *)&cmd_clear_input_set_pctype,
17319 (void *)&cmd_clear_input_set_pctype_id,
17320 (void *)&cmd_clear_input_set_inset_type,
17321 (void *)&cmd_clear_input_set_clear,
17322 (void *)&cmd_clear_input_set_all,
17327 /* show vf stats */
17329 /* Common result structure for show vf stats */
17330 struct cmd_show_vf_stats_result {
17331 cmdline_fixed_string_t show;
17332 cmdline_fixed_string_t vf;
17333 cmdline_fixed_string_t stats;
17338 /* Common CLI fields show vf stats*/
17339 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17340 TOKEN_STRING_INITIALIZER
17341 (struct cmd_show_vf_stats_result,
17343 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17344 TOKEN_STRING_INITIALIZER
17345 (struct cmd_show_vf_stats_result,
17347 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17348 TOKEN_STRING_INITIALIZER
17349 (struct cmd_show_vf_stats_result,
17351 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17352 TOKEN_NUM_INITIALIZER
17353 (struct cmd_show_vf_stats_result,
17355 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17356 TOKEN_NUM_INITIALIZER
17357 (struct cmd_show_vf_stats_result,
17361 cmd_show_vf_stats_parsed(
17362 void *parsed_result,
17363 __rte_unused struct cmdline *cl,
17364 __rte_unused void *data)
17366 struct cmd_show_vf_stats_result *res = parsed_result;
17367 struct rte_eth_stats stats;
17368 int ret = -ENOTSUP;
17369 static const char *nic_stats_border = "########################";
17371 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17374 memset(&stats, 0, sizeof(stats));
17376 #ifdef RTE_LIBRTE_I40E_PMD
17377 if (ret == -ENOTSUP)
17378 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17382 #ifdef RTE_LIBRTE_BNXT_PMD
17383 if (ret == -ENOTSUP)
17384 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17393 printf("invalid vf_id %d\n", res->vf_id);
17396 printf("invalid port_id %d\n", res->port_id);
17399 printf("function not implemented\n");
17402 printf("programming error: (%s)\n", strerror(-ret));
17405 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17406 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17408 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17410 stats.ipackets, stats.imissed, stats.ibytes);
17411 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17412 printf(" RX-nombuf: %-10"PRIu64"\n",
17414 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17416 stats.opackets, stats.oerrors, stats.obytes);
17418 printf(" %s############################%s\n",
17419 nic_stats_border, nic_stats_border);
17422 cmdline_parse_inst_t cmd_show_vf_stats = {
17423 .f = cmd_show_vf_stats_parsed,
17425 .help_str = "show vf stats <port_id> <vf_id>",
17427 (void *)&cmd_show_vf_stats_show,
17428 (void *)&cmd_show_vf_stats_vf,
17429 (void *)&cmd_show_vf_stats_stats,
17430 (void *)&cmd_show_vf_stats_port_id,
17431 (void *)&cmd_show_vf_stats_vf_id,
17436 /* clear vf stats */
17438 /* Common result structure for clear vf stats */
17439 struct cmd_clear_vf_stats_result {
17440 cmdline_fixed_string_t clear;
17441 cmdline_fixed_string_t vf;
17442 cmdline_fixed_string_t stats;
17447 /* Common CLI fields clear vf stats*/
17448 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17449 TOKEN_STRING_INITIALIZER
17450 (struct cmd_clear_vf_stats_result,
17452 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17453 TOKEN_STRING_INITIALIZER
17454 (struct cmd_clear_vf_stats_result,
17456 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17457 TOKEN_STRING_INITIALIZER
17458 (struct cmd_clear_vf_stats_result,
17460 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17461 TOKEN_NUM_INITIALIZER
17462 (struct cmd_clear_vf_stats_result,
17464 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17465 TOKEN_NUM_INITIALIZER
17466 (struct cmd_clear_vf_stats_result,
17470 cmd_clear_vf_stats_parsed(
17471 void *parsed_result,
17472 __rte_unused struct cmdline *cl,
17473 __rte_unused void *data)
17475 struct cmd_clear_vf_stats_result *res = parsed_result;
17476 int ret = -ENOTSUP;
17478 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17481 #ifdef RTE_LIBRTE_I40E_PMD
17482 if (ret == -ENOTSUP)
17483 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17486 #ifdef RTE_LIBRTE_BNXT_PMD
17487 if (ret == -ENOTSUP)
17488 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17496 printf("invalid vf_id %d\n", res->vf_id);
17499 printf("invalid port_id %d\n", res->port_id);
17502 printf("function not implemented\n");
17505 printf("programming error: (%s)\n", strerror(-ret));
17509 cmdline_parse_inst_t cmd_clear_vf_stats = {
17510 .f = cmd_clear_vf_stats_parsed,
17512 .help_str = "clear vf stats <port_id> <vf_id>",
17514 (void *)&cmd_clear_vf_stats_clear,
17515 (void *)&cmd_clear_vf_stats_vf,
17516 (void *)&cmd_clear_vf_stats_stats,
17517 (void *)&cmd_clear_vf_stats_port_id,
17518 (void *)&cmd_clear_vf_stats_vf_id,
17523 /* port config pctype mapping reset */
17525 /* Common result structure for port config pctype mapping reset */
17526 struct cmd_pctype_mapping_reset_result {
17527 cmdline_fixed_string_t port;
17528 cmdline_fixed_string_t config;
17530 cmdline_fixed_string_t pctype;
17531 cmdline_fixed_string_t mapping;
17532 cmdline_fixed_string_t reset;
17535 /* Common CLI fields for port config pctype mapping reset*/
17536 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17537 TOKEN_STRING_INITIALIZER
17538 (struct cmd_pctype_mapping_reset_result,
17540 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17541 TOKEN_STRING_INITIALIZER
17542 (struct cmd_pctype_mapping_reset_result,
17544 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17545 TOKEN_NUM_INITIALIZER
17546 (struct cmd_pctype_mapping_reset_result,
17548 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17549 TOKEN_STRING_INITIALIZER
17550 (struct cmd_pctype_mapping_reset_result,
17552 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17553 TOKEN_STRING_INITIALIZER
17554 (struct cmd_pctype_mapping_reset_result,
17555 mapping, "mapping");
17556 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17557 TOKEN_STRING_INITIALIZER
17558 (struct cmd_pctype_mapping_reset_result,
17562 cmd_pctype_mapping_reset_parsed(
17563 void *parsed_result,
17564 __rte_unused struct cmdline *cl,
17565 __rte_unused void *data)
17567 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17568 int ret = -ENOTSUP;
17570 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17573 #ifdef RTE_LIBRTE_I40E_PMD
17574 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17581 printf("invalid port_id %d\n", res->port_id);
17584 printf("function not implemented\n");
17587 printf("programming error: (%s)\n", strerror(-ret));
17591 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17592 .f = cmd_pctype_mapping_reset_parsed,
17594 .help_str = "port config <port_id> pctype mapping reset",
17596 (void *)&cmd_pctype_mapping_reset_port,
17597 (void *)&cmd_pctype_mapping_reset_config,
17598 (void *)&cmd_pctype_mapping_reset_port_id,
17599 (void *)&cmd_pctype_mapping_reset_pctype,
17600 (void *)&cmd_pctype_mapping_reset_mapping,
17601 (void *)&cmd_pctype_mapping_reset_reset,
17606 /* show port pctype mapping */
17608 /* Common result structure for show port pctype mapping */
17609 struct cmd_pctype_mapping_get_result {
17610 cmdline_fixed_string_t show;
17611 cmdline_fixed_string_t port;
17613 cmdline_fixed_string_t pctype;
17614 cmdline_fixed_string_t mapping;
17617 /* Common CLI fields for pctype mapping get */
17618 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17619 TOKEN_STRING_INITIALIZER
17620 (struct cmd_pctype_mapping_get_result,
17622 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17623 TOKEN_STRING_INITIALIZER
17624 (struct cmd_pctype_mapping_get_result,
17626 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17627 TOKEN_NUM_INITIALIZER
17628 (struct cmd_pctype_mapping_get_result,
17630 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17631 TOKEN_STRING_INITIALIZER
17632 (struct cmd_pctype_mapping_get_result,
17634 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17635 TOKEN_STRING_INITIALIZER
17636 (struct cmd_pctype_mapping_get_result,
17637 mapping, "mapping");
17640 cmd_pctype_mapping_get_parsed(
17641 void *parsed_result,
17642 __rte_unused struct cmdline *cl,
17643 __rte_unused void *data)
17645 struct cmd_pctype_mapping_get_result *res = parsed_result;
17646 int ret = -ENOTSUP;
17647 #ifdef RTE_LIBRTE_I40E_PMD
17648 struct rte_pmd_i40e_flow_type_mapping
17649 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17650 int i, j, first_pctype;
17653 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17656 #ifdef RTE_LIBRTE_I40E_PMD
17657 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17664 printf("invalid port_id %d\n", res->port_id);
17667 printf("function not implemented\n");
17670 printf("programming error: (%s)\n", strerror(-ret));
17674 #ifdef RTE_LIBRTE_I40E_PMD
17675 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17676 if (mapping[i].pctype != 0ULL) {
17679 printf("pctype: ");
17680 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17681 if (mapping[i].pctype & (1ULL << j)) {
17682 printf(first_pctype ?
17683 "%02d" : ",%02d", j);
17687 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17693 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17694 .f = cmd_pctype_mapping_get_parsed,
17696 .help_str = "show port <port_id> pctype mapping",
17698 (void *)&cmd_pctype_mapping_get_show,
17699 (void *)&cmd_pctype_mapping_get_port,
17700 (void *)&cmd_pctype_mapping_get_port_id,
17701 (void *)&cmd_pctype_mapping_get_pctype,
17702 (void *)&cmd_pctype_mapping_get_mapping,
17707 /* port config pctype mapping update */
17709 /* Common result structure for port config pctype mapping update */
17710 struct cmd_pctype_mapping_update_result {
17711 cmdline_fixed_string_t port;
17712 cmdline_fixed_string_t config;
17714 cmdline_fixed_string_t pctype;
17715 cmdline_fixed_string_t mapping;
17716 cmdline_fixed_string_t update;
17717 cmdline_fixed_string_t pctype_list;
17718 uint16_t flow_type;
17721 /* Common CLI fields for pctype mapping update*/
17722 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17723 TOKEN_STRING_INITIALIZER
17724 (struct cmd_pctype_mapping_update_result,
17726 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17727 TOKEN_STRING_INITIALIZER
17728 (struct cmd_pctype_mapping_update_result,
17730 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17731 TOKEN_NUM_INITIALIZER
17732 (struct cmd_pctype_mapping_update_result,
17734 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17735 TOKEN_STRING_INITIALIZER
17736 (struct cmd_pctype_mapping_update_result,
17738 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17739 TOKEN_STRING_INITIALIZER
17740 (struct cmd_pctype_mapping_update_result,
17741 mapping, "mapping");
17742 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17743 TOKEN_STRING_INITIALIZER
17744 (struct cmd_pctype_mapping_update_result,
17746 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17747 TOKEN_STRING_INITIALIZER
17748 (struct cmd_pctype_mapping_update_result,
17749 pctype_list, NULL);
17750 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17751 TOKEN_NUM_INITIALIZER
17752 (struct cmd_pctype_mapping_update_result,
17753 flow_type, UINT16);
17756 cmd_pctype_mapping_update_parsed(
17757 void *parsed_result,
17758 __rte_unused struct cmdline *cl,
17759 __rte_unused void *data)
17761 struct cmd_pctype_mapping_update_result *res = parsed_result;
17762 int ret = -ENOTSUP;
17763 #ifdef RTE_LIBRTE_I40E_PMD
17764 struct rte_pmd_i40e_flow_type_mapping mapping;
17766 unsigned int nb_item;
17767 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17770 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17773 #ifdef RTE_LIBRTE_I40E_PMD
17774 nb_item = parse_item_list(res->pctype_list, "pctypes",
17775 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17776 mapping.flow_type = res->flow_type;
17777 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17778 mapping.pctype |= (1ULL << pctype_list[i]);
17779 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17789 printf("invalid pctype or flow type\n");
17792 printf("invalid port_id %d\n", res->port_id);
17795 printf("function not implemented\n");
17798 printf("programming error: (%s)\n", strerror(-ret));
17802 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17803 .f = cmd_pctype_mapping_update_parsed,
17805 .help_str = "port config <port_id> pctype mapping update"
17806 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17808 (void *)&cmd_pctype_mapping_update_port,
17809 (void *)&cmd_pctype_mapping_update_config,
17810 (void *)&cmd_pctype_mapping_update_port_id,
17811 (void *)&cmd_pctype_mapping_update_pctype,
17812 (void *)&cmd_pctype_mapping_update_mapping,
17813 (void *)&cmd_pctype_mapping_update_update,
17814 (void *)&cmd_pctype_mapping_update_pc_type,
17815 (void *)&cmd_pctype_mapping_update_flow_type,
17820 /* ptype mapping get */
17822 /* Common result structure for ptype mapping get */
17823 struct cmd_ptype_mapping_get_result {
17824 cmdline_fixed_string_t ptype;
17825 cmdline_fixed_string_t mapping;
17826 cmdline_fixed_string_t get;
17828 uint8_t valid_only;
17831 /* Common CLI fields for ptype mapping get */
17832 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17833 TOKEN_STRING_INITIALIZER
17834 (struct cmd_ptype_mapping_get_result,
17836 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17837 TOKEN_STRING_INITIALIZER
17838 (struct cmd_ptype_mapping_get_result,
17839 mapping, "mapping");
17840 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17841 TOKEN_STRING_INITIALIZER
17842 (struct cmd_ptype_mapping_get_result,
17844 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17845 TOKEN_NUM_INITIALIZER
17846 (struct cmd_ptype_mapping_get_result,
17848 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17849 TOKEN_NUM_INITIALIZER
17850 (struct cmd_ptype_mapping_get_result,
17851 valid_only, UINT8);
17854 cmd_ptype_mapping_get_parsed(
17855 void *parsed_result,
17856 __rte_unused struct cmdline *cl,
17857 __rte_unused void *data)
17859 struct cmd_ptype_mapping_get_result *res = parsed_result;
17860 int ret = -ENOTSUP;
17861 #ifdef RTE_LIBRTE_I40E_PMD
17862 int max_ptype_num = 256;
17863 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17868 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17871 #ifdef RTE_LIBRTE_I40E_PMD
17872 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17883 printf("invalid port_id %d\n", res->port_id);
17886 printf("function not implemented\n");
17889 printf("programming error: (%s)\n", strerror(-ret));
17892 #ifdef RTE_LIBRTE_I40E_PMD
17894 for (i = 0; i < count; i++)
17895 printf("%3d\t0x%08x\n",
17896 mapping[i].hw_ptype, mapping[i].sw_ptype);
17901 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17902 .f = cmd_ptype_mapping_get_parsed,
17904 .help_str = "ptype mapping get <port_id> <valid_only>",
17906 (void *)&cmd_ptype_mapping_get_ptype,
17907 (void *)&cmd_ptype_mapping_get_mapping,
17908 (void *)&cmd_ptype_mapping_get_get,
17909 (void *)&cmd_ptype_mapping_get_port_id,
17910 (void *)&cmd_ptype_mapping_get_valid_only,
17915 /* ptype mapping replace */
17917 /* Common result structure for ptype mapping replace */
17918 struct cmd_ptype_mapping_replace_result {
17919 cmdline_fixed_string_t ptype;
17920 cmdline_fixed_string_t mapping;
17921 cmdline_fixed_string_t replace;
17928 /* Common CLI fields for ptype mapping replace */
17929 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17930 TOKEN_STRING_INITIALIZER
17931 (struct cmd_ptype_mapping_replace_result,
17933 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17934 TOKEN_STRING_INITIALIZER
17935 (struct cmd_ptype_mapping_replace_result,
17936 mapping, "mapping");
17937 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17938 TOKEN_STRING_INITIALIZER
17939 (struct cmd_ptype_mapping_replace_result,
17940 replace, "replace");
17941 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17942 TOKEN_NUM_INITIALIZER
17943 (struct cmd_ptype_mapping_replace_result,
17945 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17946 TOKEN_NUM_INITIALIZER
17947 (struct cmd_ptype_mapping_replace_result,
17949 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17950 TOKEN_NUM_INITIALIZER
17951 (struct cmd_ptype_mapping_replace_result,
17953 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17954 TOKEN_NUM_INITIALIZER
17955 (struct cmd_ptype_mapping_replace_result,
17959 cmd_ptype_mapping_replace_parsed(
17960 void *parsed_result,
17961 __rte_unused struct cmdline *cl,
17962 __rte_unused void *data)
17964 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17965 int ret = -ENOTSUP;
17967 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17970 #ifdef RTE_LIBRTE_I40E_PMD
17971 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17981 printf("invalid ptype 0x%8x or 0x%8x\n",
17982 res->target, res->pkt_type);
17985 printf("invalid port_id %d\n", res->port_id);
17988 printf("function not implemented\n");
17991 printf("programming error: (%s)\n", strerror(-ret));
17995 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17996 .f = cmd_ptype_mapping_replace_parsed,
17999 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
18001 (void *)&cmd_ptype_mapping_replace_ptype,
18002 (void *)&cmd_ptype_mapping_replace_mapping,
18003 (void *)&cmd_ptype_mapping_replace_replace,
18004 (void *)&cmd_ptype_mapping_replace_port_id,
18005 (void *)&cmd_ptype_mapping_replace_target,
18006 (void *)&cmd_ptype_mapping_replace_mask,
18007 (void *)&cmd_ptype_mapping_replace_pkt_type,
18012 /* ptype mapping reset */
18014 /* Common result structure for ptype mapping reset */
18015 struct cmd_ptype_mapping_reset_result {
18016 cmdline_fixed_string_t ptype;
18017 cmdline_fixed_string_t mapping;
18018 cmdline_fixed_string_t reset;
18022 /* Common CLI fields for ptype mapping reset*/
18023 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
18024 TOKEN_STRING_INITIALIZER
18025 (struct cmd_ptype_mapping_reset_result,
18027 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
18028 TOKEN_STRING_INITIALIZER
18029 (struct cmd_ptype_mapping_reset_result,
18030 mapping, "mapping");
18031 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
18032 TOKEN_STRING_INITIALIZER
18033 (struct cmd_ptype_mapping_reset_result,
18035 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
18036 TOKEN_NUM_INITIALIZER
18037 (struct cmd_ptype_mapping_reset_result,
18041 cmd_ptype_mapping_reset_parsed(
18042 void *parsed_result,
18043 __rte_unused struct cmdline *cl,
18044 __rte_unused void *data)
18046 struct cmd_ptype_mapping_reset_result *res = parsed_result;
18047 int ret = -ENOTSUP;
18049 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18052 #ifdef RTE_LIBRTE_I40E_PMD
18053 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
18060 printf("invalid port_id %d\n", res->port_id);
18063 printf("function not implemented\n");
18066 printf("programming error: (%s)\n", strerror(-ret));
18070 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
18071 .f = cmd_ptype_mapping_reset_parsed,
18073 .help_str = "ptype mapping reset <port_id>",
18075 (void *)&cmd_ptype_mapping_reset_ptype,
18076 (void *)&cmd_ptype_mapping_reset_mapping,
18077 (void *)&cmd_ptype_mapping_reset_reset,
18078 (void *)&cmd_ptype_mapping_reset_port_id,
18083 /* ptype mapping update */
18085 /* Common result structure for ptype mapping update */
18086 struct cmd_ptype_mapping_update_result {
18087 cmdline_fixed_string_t ptype;
18088 cmdline_fixed_string_t mapping;
18089 cmdline_fixed_string_t reset;
18095 /* Common CLI fields for ptype mapping update*/
18096 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
18097 TOKEN_STRING_INITIALIZER
18098 (struct cmd_ptype_mapping_update_result,
18100 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
18101 TOKEN_STRING_INITIALIZER
18102 (struct cmd_ptype_mapping_update_result,
18103 mapping, "mapping");
18104 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
18105 TOKEN_STRING_INITIALIZER
18106 (struct cmd_ptype_mapping_update_result,
18108 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
18109 TOKEN_NUM_INITIALIZER
18110 (struct cmd_ptype_mapping_update_result,
18112 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
18113 TOKEN_NUM_INITIALIZER
18114 (struct cmd_ptype_mapping_update_result,
18116 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
18117 TOKEN_NUM_INITIALIZER
18118 (struct cmd_ptype_mapping_update_result,
18122 cmd_ptype_mapping_update_parsed(
18123 void *parsed_result,
18124 __rte_unused struct cmdline *cl,
18125 __rte_unused void *data)
18127 struct cmd_ptype_mapping_update_result *res = parsed_result;
18128 int ret = -ENOTSUP;
18129 #ifdef RTE_LIBRTE_I40E_PMD
18130 struct rte_pmd_i40e_ptype_mapping mapping;
18132 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18135 #ifdef RTE_LIBRTE_I40E_PMD
18136 mapping.hw_ptype = res->hw_ptype;
18137 mapping.sw_ptype = res->sw_ptype;
18138 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
18148 printf("invalid ptype 0x%8x\n", res->sw_ptype);
18151 printf("invalid port_id %d\n", res->port_id);
18154 printf("function not implemented\n");
18157 printf("programming error: (%s)\n", strerror(-ret));
18161 cmdline_parse_inst_t cmd_ptype_mapping_update = {
18162 .f = cmd_ptype_mapping_update_parsed,
18164 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
18166 (void *)&cmd_ptype_mapping_update_ptype,
18167 (void *)&cmd_ptype_mapping_update_mapping,
18168 (void *)&cmd_ptype_mapping_update_update,
18169 (void *)&cmd_ptype_mapping_update_port_id,
18170 (void *)&cmd_ptype_mapping_update_hw_ptype,
18171 (void *)&cmd_ptype_mapping_update_sw_ptype,
18176 /* Common result structure for file commands */
18177 struct cmd_cmdfile_result {
18178 cmdline_fixed_string_t load;
18179 cmdline_fixed_string_t filename;
18182 /* Common CLI fields for file commands */
18183 cmdline_parse_token_string_t cmd_load_cmdfile =
18184 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
18185 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
18186 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
18189 cmd_load_from_file_parsed(
18190 void *parsed_result,
18191 __rte_unused struct cmdline *cl,
18192 __rte_unused void *data)
18194 struct cmd_cmdfile_result *res = parsed_result;
18196 cmdline_read_from_file(res->filename);
18199 cmdline_parse_inst_t cmd_load_from_file = {
18200 .f = cmd_load_from_file_parsed,
18202 .help_str = "load <filename>",
18204 (void *)&cmd_load_cmdfile,
18205 (void *)&cmd_load_cmdfile_filename,
18210 /* Get Rx offloads capabilities */
18211 struct cmd_rx_offload_get_capa_result {
18212 cmdline_fixed_string_t show;
18213 cmdline_fixed_string_t port;
18215 cmdline_fixed_string_t rx_offload;
18216 cmdline_fixed_string_t capabilities;
18219 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
18220 TOKEN_STRING_INITIALIZER
18221 (struct cmd_rx_offload_get_capa_result,
18223 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
18224 TOKEN_STRING_INITIALIZER
18225 (struct cmd_rx_offload_get_capa_result,
18227 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
18228 TOKEN_NUM_INITIALIZER
18229 (struct cmd_rx_offload_get_capa_result,
18231 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
18232 TOKEN_STRING_INITIALIZER
18233 (struct cmd_rx_offload_get_capa_result,
18234 rx_offload, "rx_offload");
18235 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
18236 TOKEN_STRING_INITIALIZER
18237 (struct cmd_rx_offload_get_capa_result,
18238 capabilities, "capabilities");
18241 print_rx_offloads(uint64_t offloads)
18243 uint64_t single_offload;
18251 begin = __builtin_ctzll(offloads);
18252 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18254 single_offload = 1ULL << begin;
18255 for (bit = begin; bit < end; bit++) {
18256 if (offloads & single_offload)
18258 rte_eth_dev_rx_offload_name(single_offload));
18259 single_offload <<= 1;
18264 cmd_rx_offload_get_capa_parsed(
18265 void *parsed_result,
18266 __rte_unused struct cmdline *cl,
18267 __rte_unused void *data)
18269 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18270 struct rte_eth_dev_info dev_info;
18271 portid_t port_id = res->port_id;
18272 uint64_t queue_offloads;
18273 uint64_t port_offloads;
18276 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18280 queue_offloads = dev_info.rx_queue_offload_capa;
18281 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18283 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18284 printf(" Per Queue :");
18285 print_rx_offloads(queue_offloads);
18288 printf(" Per Port :");
18289 print_rx_offloads(port_offloads);
18293 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18294 .f = cmd_rx_offload_get_capa_parsed,
18296 .help_str = "show port <port_id> rx_offload capabilities",
18298 (void *)&cmd_rx_offload_get_capa_show,
18299 (void *)&cmd_rx_offload_get_capa_port,
18300 (void *)&cmd_rx_offload_get_capa_port_id,
18301 (void *)&cmd_rx_offload_get_capa_rx_offload,
18302 (void *)&cmd_rx_offload_get_capa_capabilities,
18307 /* Get Rx offloads configuration */
18308 struct cmd_rx_offload_get_configuration_result {
18309 cmdline_fixed_string_t show;
18310 cmdline_fixed_string_t port;
18312 cmdline_fixed_string_t rx_offload;
18313 cmdline_fixed_string_t configuration;
18316 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18317 TOKEN_STRING_INITIALIZER
18318 (struct cmd_rx_offload_get_configuration_result,
18320 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18321 TOKEN_STRING_INITIALIZER
18322 (struct cmd_rx_offload_get_configuration_result,
18324 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18325 TOKEN_NUM_INITIALIZER
18326 (struct cmd_rx_offload_get_configuration_result,
18328 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18329 TOKEN_STRING_INITIALIZER
18330 (struct cmd_rx_offload_get_configuration_result,
18331 rx_offload, "rx_offload");
18332 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18333 TOKEN_STRING_INITIALIZER
18334 (struct cmd_rx_offload_get_configuration_result,
18335 configuration, "configuration");
18338 cmd_rx_offload_get_configuration_parsed(
18339 void *parsed_result,
18340 __rte_unused struct cmdline *cl,
18341 __rte_unused void *data)
18343 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18344 struct rte_eth_dev_info dev_info;
18345 portid_t port_id = res->port_id;
18346 struct rte_port *port = &ports[port_id];
18347 uint64_t port_offloads;
18348 uint64_t queue_offloads;
18349 uint16_t nb_rx_queues;
18353 printf("Rx Offloading Configuration of port %d :\n", port_id);
18355 port_offloads = port->dev_conf.rxmode.offloads;
18357 print_rx_offloads(port_offloads);
18360 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18364 nb_rx_queues = dev_info.nb_rx_queues;
18365 for (q = 0; q < nb_rx_queues; q++) {
18366 queue_offloads = port->rx_conf[q].offloads;
18367 printf(" Queue[%2d] :", q);
18368 print_rx_offloads(queue_offloads);
18374 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18375 .f = cmd_rx_offload_get_configuration_parsed,
18377 .help_str = "show port <port_id> rx_offload configuration",
18379 (void *)&cmd_rx_offload_get_configuration_show,
18380 (void *)&cmd_rx_offload_get_configuration_port,
18381 (void *)&cmd_rx_offload_get_configuration_port_id,
18382 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18383 (void *)&cmd_rx_offload_get_configuration_configuration,
18388 /* Enable/Disable a per port offloading */
18389 struct cmd_config_per_port_rx_offload_result {
18390 cmdline_fixed_string_t port;
18391 cmdline_fixed_string_t config;
18393 cmdline_fixed_string_t rx_offload;
18394 cmdline_fixed_string_t offload;
18395 cmdline_fixed_string_t on_off;
18398 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18399 TOKEN_STRING_INITIALIZER
18400 (struct cmd_config_per_port_rx_offload_result,
18402 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18403 TOKEN_STRING_INITIALIZER
18404 (struct cmd_config_per_port_rx_offload_result,
18406 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18407 TOKEN_NUM_INITIALIZER
18408 (struct cmd_config_per_port_rx_offload_result,
18410 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18411 TOKEN_STRING_INITIALIZER
18412 (struct cmd_config_per_port_rx_offload_result,
18413 rx_offload, "rx_offload");
18414 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18415 TOKEN_STRING_INITIALIZER
18416 (struct cmd_config_per_port_rx_offload_result,
18417 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18418 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18419 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18420 "scatter#timestamp#security#keep_crc#rss_hash");
18421 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18422 TOKEN_STRING_INITIALIZER
18423 (struct cmd_config_per_port_rx_offload_result,
18427 search_rx_offload(const char *name)
18429 uint64_t single_offload;
18430 const char *single_name;
18434 single_offload = 1;
18435 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18436 single_name = rte_eth_dev_rx_offload_name(single_offload);
18437 if (!strcasecmp(single_name, name)) {
18441 single_offload <<= 1;
18445 return single_offload;
18451 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18452 __rte_unused struct cmdline *cl,
18453 __rte_unused void *data)
18455 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18456 portid_t port_id = res->port_id;
18457 struct rte_eth_dev_info dev_info;
18458 struct rte_port *port = &ports[port_id];
18459 uint64_t single_offload;
18460 uint16_t nb_rx_queues;
18464 if (port->port_status != RTE_PORT_STOPPED) {
18465 printf("Error: Can't config offload when Port %d "
18466 "is not stopped\n", port_id);
18470 single_offload = search_rx_offload(res->offload);
18471 if (single_offload == 0) {
18472 printf("Unknown offload name: %s\n", res->offload);
18476 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18480 nb_rx_queues = dev_info.nb_rx_queues;
18481 if (!strcmp(res->on_off, "on")) {
18482 port->dev_conf.rxmode.offloads |= single_offload;
18483 for (q = 0; q < nb_rx_queues; q++)
18484 port->rx_conf[q].offloads |= single_offload;
18486 port->dev_conf.rxmode.offloads &= ~single_offload;
18487 for (q = 0; q < nb_rx_queues; q++)
18488 port->rx_conf[q].offloads &= ~single_offload;
18491 cmd_reconfig_device_queue(port_id, 1, 1);
18494 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18495 .f = cmd_config_per_port_rx_offload_parsed,
18497 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18498 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18499 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18500 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18503 (void *)&cmd_config_per_port_rx_offload_result_port,
18504 (void *)&cmd_config_per_port_rx_offload_result_config,
18505 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18506 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18507 (void *)&cmd_config_per_port_rx_offload_result_offload,
18508 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18513 /* Enable/Disable a per queue offloading */
18514 struct cmd_config_per_queue_rx_offload_result {
18515 cmdline_fixed_string_t port;
18517 cmdline_fixed_string_t rxq;
18519 cmdline_fixed_string_t rx_offload;
18520 cmdline_fixed_string_t offload;
18521 cmdline_fixed_string_t on_off;
18524 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18525 TOKEN_STRING_INITIALIZER
18526 (struct cmd_config_per_queue_rx_offload_result,
18528 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18529 TOKEN_NUM_INITIALIZER
18530 (struct cmd_config_per_queue_rx_offload_result,
18532 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18533 TOKEN_STRING_INITIALIZER
18534 (struct cmd_config_per_queue_rx_offload_result,
18536 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18537 TOKEN_NUM_INITIALIZER
18538 (struct cmd_config_per_queue_rx_offload_result,
18540 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18541 TOKEN_STRING_INITIALIZER
18542 (struct cmd_config_per_queue_rx_offload_result,
18543 rx_offload, "rx_offload");
18544 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18545 TOKEN_STRING_INITIALIZER
18546 (struct cmd_config_per_queue_rx_offload_result,
18547 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18548 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18549 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18550 "scatter#timestamp#security#keep_crc");
18551 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18552 TOKEN_STRING_INITIALIZER
18553 (struct cmd_config_per_queue_rx_offload_result,
18557 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18558 __rte_unused struct cmdline *cl,
18559 __rte_unused void *data)
18561 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18562 struct rte_eth_dev_info dev_info;
18563 portid_t port_id = res->port_id;
18564 uint16_t queue_id = res->queue_id;
18565 struct rte_port *port = &ports[port_id];
18566 uint64_t single_offload;
18569 if (port->port_status != RTE_PORT_STOPPED) {
18570 printf("Error: Can't config offload when Port %d "
18571 "is not stopped\n", port_id);
18575 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18579 if (queue_id >= dev_info.nb_rx_queues) {
18580 printf("Error: input queue_id should be 0 ... "
18581 "%d\n", dev_info.nb_rx_queues - 1);
18585 single_offload = search_rx_offload(res->offload);
18586 if (single_offload == 0) {
18587 printf("Unknown offload name: %s\n", res->offload);
18591 if (!strcmp(res->on_off, "on"))
18592 port->rx_conf[queue_id].offloads |= single_offload;
18594 port->rx_conf[queue_id].offloads &= ~single_offload;
18596 cmd_reconfig_device_queue(port_id, 1, 1);
18599 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18600 .f = cmd_config_per_queue_rx_offload_parsed,
18602 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18603 "vlan_strip|ipv4_cksum|"
18604 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18605 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18606 "jumbo_frame|scatter|timestamp|security|keep_crc "
18609 (void *)&cmd_config_per_queue_rx_offload_result_port,
18610 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18611 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18612 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18613 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18614 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18615 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18620 /* Get Tx offloads capabilities */
18621 struct cmd_tx_offload_get_capa_result {
18622 cmdline_fixed_string_t show;
18623 cmdline_fixed_string_t port;
18625 cmdline_fixed_string_t tx_offload;
18626 cmdline_fixed_string_t capabilities;
18629 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18630 TOKEN_STRING_INITIALIZER
18631 (struct cmd_tx_offload_get_capa_result,
18633 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18634 TOKEN_STRING_INITIALIZER
18635 (struct cmd_tx_offload_get_capa_result,
18637 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18638 TOKEN_NUM_INITIALIZER
18639 (struct cmd_tx_offload_get_capa_result,
18641 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18642 TOKEN_STRING_INITIALIZER
18643 (struct cmd_tx_offload_get_capa_result,
18644 tx_offload, "tx_offload");
18645 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18646 TOKEN_STRING_INITIALIZER
18647 (struct cmd_tx_offload_get_capa_result,
18648 capabilities, "capabilities");
18651 print_tx_offloads(uint64_t offloads)
18653 uint64_t single_offload;
18661 begin = __builtin_ctzll(offloads);
18662 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18664 single_offload = 1ULL << begin;
18665 for (bit = begin; bit < end; bit++) {
18666 if (offloads & single_offload)
18668 rte_eth_dev_tx_offload_name(single_offload));
18669 single_offload <<= 1;
18674 cmd_tx_offload_get_capa_parsed(
18675 void *parsed_result,
18676 __rte_unused struct cmdline *cl,
18677 __rte_unused void *data)
18679 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18680 struct rte_eth_dev_info dev_info;
18681 portid_t port_id = res->port_id;
18682 uint64_t queue_offloads;
18683 uint64_t port_offloads;
18686 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18690 queue_offloads = dev_info.tx_queue_offload_capa;
18691 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18693 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18694 printf(" Per Queue :");
18695 print_tx_offloads(queue_offloads);
18698 printf(" Per Port :");
18699 print_tx_offloads(port_offloads);
18703 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18704 .f = cmd_tx_offload_get_capa_parsed,
18706 .help_str = "show port <port_id> tx_offload capabilities",
18708 (void *)&cmd_tx_offload_get_capa_show,
18709 (void *)&cmd_tx_offload_get_capa_port,
18710 (void *)&cmd_tx_offload_get_capa_port_id,
18711 (void *)&cmd_tx_offload_get_capa_tx_offload,
18712 (void *)&cmd_tx_offload_get_capa_capabilities,
18717 /* Get Tx offloads configuration */
18718 struct cmd_tx_offload_get_configuration_result {
18719 cmdline_fixed_string_t show;
18720 cmdline_fixed_string_t port;
18722 cmdline_fixed_string_t tx_offload;
18723 cmdline_fixed_string_t configuration;
18726 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18727 TOKEN_STRING_INITIALIZER
18728 (struct cmd_tx_offload_get_configuration_result,
18730 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18731 TOKEN_STRING_INITIALIZER
18732 (struct cmd_tx_offload_get_configuration_result,
18734 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18735 TOKEN_NUM_INITIALIZER
18736 (struct cmd_tx_offload_get_configuration_result,
18738 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18739 TOKEN_STRING_INITIALIZER
18740 (struct cmd_tx_offload_get_configuration_result,
18741 tx_offload, "tx_offload");
18742 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18743 TOKEN_STRING_INITIALIZER
18744 (struct cmd_tx_offload_get_configuration_result,
18745 configuration, "configuration");
18748 cmd_tx_offload_get_configuration_parsed(
18749 void *parsed_result,
18750 __rte_unused struct cmdline *cl,
18751 __rte_unused void *data)
18753 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18754 struct rte_eth_dev_info dev_info;
18755 portid_t port_id = res->port_id;
18756 struct rte_port *port = &ports[port_id];
18757 uint64_t port_offloads;
18758 uint64_t queue_offloads;
18759 uint16_t nb_tx_queues;
18763 printf("Tx Offloading Configuration of port %d :\n", port_id);
18765 port_offloads = port->dev_conf.txmode.offloads;
18767 print_tx_offloads(port_offloads);
18770 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18774 nb_tx_queues = dev_info.nb_tx_queues;
18775 for (q = 0; q < nb_tx_queues; q++) {
18776 queue_offloads = port->tx_conf[q].offloads;
18777 printf(" Queue[%2d] :", q);
18778 print_tx_offloads(queue_offloads);
18784 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18785 .f = cmd_tx_offload_get_configuration_parsed,
18787 .help_str = "show port <port_id> tx_offload configuration",
18789 (void *)&cmd_tx_offload_get_configuration_show,
18790 (void *)&cmd_tx_offload_get_configuration_port,
18791 (void *)&cmd_tx_offload_get_configuration_port_id,
18792 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18793 (void *)&cmd_tx_offload_get_configuration_configuration,
18798 /* Enable/Disable a per port offloading */
18799 struct cmd_config_per_port_tx_offload_result {
18800 cmdline_fixed_string_t port;
18801 cmdline_fixed_string_t config;
18803 cmdline_fixed_string_t tx_offload;
18804 cmdline_fixed_string_t offload;
18805 cmdline_fixed_string_t on_off;
18808 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18809 TOKEN_STRING_INITIALIZER
18810 (struct cmd_config_per_port_tx_offload_result,
18812 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18813 TOKEN_STRING_INITIALIZER
18814 (struct cmd_config_per_port_tx_offload_result,
18816 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18817 TOKEN_NUM_INITIALIZER
18818 (struct cmd_config_per_port_tx_offload_result,
18820 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18821 TOKEN_STRING_INITIALIZER
18822 (struct cmd_config_per_port_tx_offload_result,
18823 tx_offload, "tx_offload");
18824 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18825 TOKEN_STRING_INITIALIZER
18826 (struct cmd_config_per_port_tx_offload_result,
18827 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18828 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18829 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18830 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18831 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18832 "send_on_timestamp");
18833 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18834 TOKEN_STRING_INITIALIZER
18835 (struct cmd_config_per_port_tx_offload_result,
18839 search_tx_offload(const char *name)
18841 uint64_t single_offload;
18842 const char *single_name;
18846 single_offload = 1;
18847 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18848 single_name = rte_eth_dev_tx_offload_name(single_offload);
18849 if (single_name == NULL)
18851 if (!strcasecmp(single_name, name)) {
18854 } else if (!strcasecmp(single_name, "UNKNOWN"))
18856 single_offload <<= 1;
18860 return single_offload;
18866 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18867 __rte_unused struct cmdline *cl,
18868 __rte_unused void *data)
18870 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18871 portid_t port_id = res->port_id;
18872 struct rte_eth_dev_info dev_info;
18873 struct rte_port *port = &ports[port_id];
18874 uint64_t single_offload;
18875 uint16_t nb_tx_queues;
18879 if (port->port_status != RTE_PORT_STOPPED) {
18880 printf("Error: Can't config offload when Port %d "
18881 "is not stopped\n", port_id);
18885 single_offload = search_tx_offload(res->offload);
18886 if (single_offload == 0) {
18887 printf("Unknown offload name: %s\n", res->offload);
18891 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18895 nb_tx_queues = dev_info.nb_tx_queues;
18896 if (!strcmp(res->on_off, "on")) {
18897 port->dev_conf.txmode.offloads |= single_offload;
18898 for (q = 0; q < nb_tx_queues; q++)
18899 port->tx_conf[q].offloads |= single_offload;
18901 port->dev_conf.txmode.offloads &= ~single_offload;
18902 for (q = 0; q < nb_tx_queues; q++)
18903 port->tx_conf[q].offloads &= ~single_offload;
18906 cmd_reconfig_device_queue(port_id, 1, 1);
18909 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18910 .f = cmd_config_per_port_tx_offload_parsed,
18912 .help_str = "port config <port_id> tx_offload "
18913 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18914 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18915 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18916 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18917 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18918 "send_on_timestamp on|off",
18920 (void *)&cmd_config_per_port_tx_offload_result_port,
18921 (void *)&cmd_config_per_port_tx_offload_result_config,
18922 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18923 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18924 (void *)&cmd_config_per_port_tx_offload_result_offload,
18925 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18930 /* Enable/Disable a per queue offloading */
18931 struct cmd_config_per_queue_tx_offload_result {
18932 cmdline_fixed_string_t port;
18934 cmdline_fixed_string_t txq;
18936 cmdline_fixed_string_t tx_offload;
18937 cmdline_fixed_string_t offload;
18938 cmdline_fixed_string_t on_off;
18941 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18942 TOKEN_STRING_INITIALIZER
18943 (struct cmd_config_per_queue_tx_offload_result,
18945 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18946 TOKEN_NUM_INITIALIZER
18947 (struct cmd_config_per_queue_tx_offload_result,
18949 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18950 TOKEN_STRING_INITIALIZER
18951 (struct cmd_config_per_queue_tx_offload_result,
18953 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18954 TOKEN_NUM_INITIALIZER
18955 (struct cmd_config_per_queue_tx_offload_result,
18957 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18958 TOKEN_STRING_INITIALIZER
18959 (struct cmd_config_per_queue_tx_offload_result,
18960 tx_offload, "tx_offload");
18961 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18962 TOKEN_STRING_INITIALIZER
18963 (struct cmd_config_per_queue_tx_offload_result,
18964 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18965 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18966 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18967 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18968 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18969 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18970 TOKEN_STRING_INITIALIZER
18971 (struct cmd_config_per_queue_tx_offload_result,
18975 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18976 __rte_unused struct cmdline *cl,
18977 __rte_unused void *data)
18979 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18980 struct rte_eth_dev_info dev_info;
18981 portid_t port_id = res->port_id;
18982 uint16_t queue_id = res->queue_id;
18983 struct rte_port *port = &ports[port_id];
18984 uint64_t single_offload;
18987 if (port->port_status != RTE_PORT_STOPPED) {
18988 printf("Error: Can't config offload when Port %d "
18989 "is not stopped\n", port_id);
18993 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18997 if (queue_id >= dev_info.nb_tx_queues) {
18998 printf("Error: input queue_id should be 0 ... "
18999 "%d\n", dev_info.nb_tx_queues - 1);
19003 single_offload = search_tx_offload(res->offload);
19004 if (single_offload == 0) {
19005 printf("Unknown offload name: %s\n", res->offload);
19009 if (!strcmp(res->on_off, "on"))
19010 port->tx_conf[queue_id].offloads |= single_offload;
19012 port->tx_conf[queue_id].offloads &= ~single_offload;
19014 cmd_reconfig_device_queue(port_id, 1, 1);
19017 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
19018 .f = cmd_config_per_queue_tx_offload_parsed,
19020 .help_str = "port <port_id> txq <queue_id> tx_offload "
19021 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
19022 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
19023 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
19024 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
19025 "mt_lockfree|multi_segs|mbuf_fast_free|security "
19028 (void *)&cmd_config_per_queue_tx_offload_result_port,
19029 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
19030 (void *)&cmd_config_per_queue_tx_offload_result_txq,
19031 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
19032 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
19033 (void *)&cmd_config_per_queue_tx_offload_result_offload,
19034 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
19039 /* *** configure tx_metadata for specific port *** */
19040 struct cmd_config_tx_metadata_specific_result {
19041 cmdline_fixed_string_t port;
19042 cmdline_fixed_string_t keyword;
19044 cmdline_fixed_string_t item;
19049 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
19050 __rte_unused struct cmdline *cl,
19051 __rte_unused void *data)
19053 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
19055 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
19057 ports[res->port_id].tx_metadata = res->value;
19058 /* Add/remove callback to insert valid metadata in every Tx packet. */
19059 if (ports[res->port_id].tx_metadata)
19060 add_tx_md_callback(res->port_id);
19062 remove_tx_md_callback(res->port_id);
19063 rte_flow_dynf_metadata_register();
19066 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
19067 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19069 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
19070 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19071 keyword, "config");
19072 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
19073 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19075 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
19076 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19077 item, "tx_metadata");
19078 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
19079 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19082 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
19083 .f = cmd_config_tx_metadata_specific_parsed,
19085 .help_str = "port config <port_id> tx_metadata <value>",
19087 (void *)&cmd_config_tx_metadata_specific_port,
19088 (void *)&cmd_config_tx_metadata_specific_keyword,
19089 (void *)&cmd_config_tx_metadata_specific_id,
19090 (void *)&cmd_config_tx_metadata_specific_item,
19091 (void *)&cmd_config_tx_metadata_specific_value,
19096 /* *** set dynf *** */
19097 struct cmd_config_tx_dynf_specific_result {
19098 cmdline_fixed_string_t port;
19099 cmdline_fixed_string_t keyword;
19101 cmdline_fixed_string_t item;
19102 cmdline_fixed_string_t name;
19103 cmdline_fixed_string_t value;
19107 cmd_config_dynf_specific_parsed(void *parsed_result,
19108 __rte_unused struct cmdline *cl,
19109 __rte_unused void *data)
19111 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
19112 struct rte_mbuf_dynflag desc_flag;
19114 uint64_t old_port_flags;
19116 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
19118 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
19120 if (strlcpy(desc_flag.name, res->name,
19121 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
19122 printf("Flag name too long\n");
19125 desc_flag.flags = 0;
19126 flag = rte_mbuf_dynflag_register(&desc_flag);
19128 printf("Can't register flag\n");
19131 strcpy(dynf_names[flag], desc_flag.name);
19133 old_port_flags = ports[res->port_id].mbuf_dynf;
19134 if (!strcmp(res->value, "set")) {
19135 ports[res->port_id].mbuf_dynf |= 1UL << flag;
19136 if (old_port_flags == 0)
19137 add_tx_dynf_callback(res->port_id);
19139 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
19140 if (ports[res->port_id].mbuf_dynf == 0)
19141 remove_tx_dynf_callback(res->port_id);
19145 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
19146 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19148 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
19149 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19150 keyword, "config");
19151 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
19152 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19154 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
19155 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19157 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
19158 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19160 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
19161 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19162 value, "set#clear");
19164 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
19165 .f = cmd_config_dynf_specific_parsed,
19167 .help_str = "port config <port id> dynf <name> set|clear",
19169 (void *)&cmd_config_tx_dynf_specific_port,
19170 (void *)&cmd_config_tx_dynf_specific_keyword,
19171 (void *)&cmd_config_tx_dynf_specific_port_id,
19172 (void *)&cmd_config_tx_dynf_specific_item,
19173 (void *)&cmd_config_tx_dynf_specific_name,
19174 (void *)&cmd_config_tx_dynf_specific_value,
19179 /* *** display tx_metadata per port configuration *** */
19180 struct cmd_show_tx_metadata_result {
19181 cmdline_fixed_string_t cmd_show;
19182 cmdline_fixed_string_t cmd_port;
19183 cmdline_fixed_string_t cmd_keyword;
19188 cmd_show_tx_metadata_parsed(void *parsed_result,
19189 __rte_unused struct cmdline *cl,
19190 __rte_unused void *data)
19192 struct cmd_show_tx_metadata_result *res = parsed_result;
19194 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19195 printf("invalid port id %u\n", res->cmd_pid);
19198 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
19199 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
19200 ports[res->cmd_pid].tx_metadata);
19204 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
19205 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19207 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
19208 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19210 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
19211 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
19213 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
19214 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19215 cmd_keyword, "tx_metadata");
19217 cmdline_parse_inst_t cmd_show_tx_metadata = {
19218 .f = cmd_show_tx_metadata_parsed,
19220 .help_str = "show port <port_id> tx_metadata",
19222 (void *)&cmd_show_tx_metadata_show,
19223 (void *)&cmd_show_tx_metadata_port,
19224 (void *)&cmd_show_tx_metadata_pid,
19225 (void *)&cmd_show_tx_metadata_keyword,
19230 /* *** show fec capability per port configuration *** */
19231 struct cmd_show_fec_capability_result {
19232 cmdline_fixed_string_t cmd_show;
19233 cmdline_fixed_string_t cmd_port;
19234 cmdline_fixed_string_t cmd_fec;
19235 cmdline_fixed_string_t cmd_keyword;
19240 cmd_show_fec_capability_parsed(void *parsed_result,
19241 __rte_unused struct cmdline *cl,
19242 __rte_unused void *data)
19244 #define FEC_CAP_NUM 2
19245 struct cmd_show_fec_capability_result *res = parsed_result;
19246 struct rte_eth_fec_capa speed_fec_capa[FEC_CAP_NUM];
19247 unsigned int num = FEC_CAP_NUM;
19248 unsigned int ret_num;
19251 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19252 printf("Invalid port id %u\n", res->cmd_pid);
19256 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
19257 if (ret == -ENOTSUP) {
19258 printf("Function not implemented\n");
19260 } else if (ret < 0) {
19261 printf("Get FEC capability failed\n");
19265 ret_num = (unsigned int)ret;
19266 show_fec_capability(ret_num, speed_fec_capa);
19269 cmdline_parse_token_string_t cmd_show_fec_capability_show =
19270 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19272 cmdline_parse_token_string_t cmd_show_fec_capability_port =
19273 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19275 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
19276 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
19278 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
19279 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19281 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
19282 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19283 cmd_keyword, "capabilities");
19285 cmdline_parse_inst_t cmd_show_capability = {
19286 .f = cmd_show_fec_capability_parsed,
19288 .help_str = "show port <port_id> fec capabilities",
19290 (void *)&cmd_show_fec_capability_show,
19291 (void *)&cmd_show_fec_capability_port,
19292 (void *)&cmd_show_fec_capability_pid,
19293 (void *)&cmd_show_fec_capability_fec,
19294 (void *)&cmd_show_fec_capability_keyword,
19299 /* *** show fec mode per port configuration *** */
19300 struct cmd_show_fec_metadata_result {
19301 cmdline_fixed_string_t cmd_show;
19302 cmdline_fixed_string_t cmd_port;
19303 cmdline_fixed_string_t cmd_keyword;
19308 cmd_show_fec_mode_parsed(void *parsed_result,
19309 __rte_unused struct cmdline *cl,
19310 __rte_unused void *data)
19312 #define FEC_NAME_SIZE 16
19313 struct cmd_show_fec_metadata_result *res = parsed_result;
19315 char buf[FEC_NAME_SIZE];
19318 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19319 printf("Invalid port id %u\n", res->cmd_pid);
19322 ret = rte_eth_fec_get(res->cmd_pid, &mode);
19323 if (ret == -ENOTSUP) {
19324 printf("Function not implemented\n");
19326 } else if (ret < 0) {
19327 printf("Get FEC mode failed\n");
19332 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
19333 strlcpy(buf, "off", sizeof(buf));
19335 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
19336 strlcpy(buf, "auto", sizeof(buf));
19338 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
19339 strlcpy(buf, "baser", sizeof(buf));
19341 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
19342 strlcpy(buf, "rs", sizeof(buf));
19348 printf("%s\n", buf);
19351 cmdline_parse_token_string_t cmd_show_fec_mode_show =
19352 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
19354 cmdline_parse_token_string_t cmd_show_fec_mode_port =
19355 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
19357 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
19358 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
19360 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
19361 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
19362 cmd_keyword, "fec_mode");
19364 cmdline_parse_inst_t cmd_show_fec_mode = {
19365 .f = cmd_show_fec_mode_parsed,
19367 .help_str = "show port <port_id> fec_mode",
19369 (void *)&cmd_show_fec_mode_show,
19370 (void *)&cmd_show_fec_mode_port,
19371 (void *)&cmd_show_fec_mode_pid,
19372 (void *)&cmd_show_fec_mode_keyword,
19377 /* *** set fec mode per port configuration *** */
19378 struct cmd_set_port_fec_mode {
19379 cmdline_fixed_string_t set;
19380 cmdline_fixed_string_t port;
19382 cmdline_fixed_string_t fec_mode;
19383 cmdline_fixed_string_t fec_value;
19386 /* Common CLI fields for set fec mode */
19387 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
19388 TOKEN_STRING_INITIALIZER
19389 (struct cmd_set_port_fec_mode,
19391 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
19392 TOKEN_STRING_INITIALIZER
19393 (struct cmd_set_port_fec_mode,
19395 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
19396 TOKEN_NUM_INITIALIZER
19397 (struct cmd_set_port_fec_mode,
19399 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
19400 TOKEN_STRING_INITIALIZER
19401 (struct cmd_set_port_fec_mode,
19402 fec_mode, "fec_mode");
19403 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
19404 TOKEN_STRING_INITIALIZER
19405 (struct cmd_set_port_fec_mode,
19409 cmd_set_port_fec_mode_parsed(
19410 void *parsed_result,
19411 __rte_unused struct cmdline *cl,
19412 __rte_unused void *data)
19414 struct cmd_set_port_fec_mode *res = parsed_result;
19415 uint16_t port_id = res->port_id;
19419 ret = parse_fec_mode(res->fec_value, &mode);
19421 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
19426 ret = rte_eth_fec_set(port_id, mode);
19427 if (ret == -ENOTSUP) {
19428 printf("Function not implemented\n");
19430 } else if (ret < 0) {
19431 printf("Set FEC mode failed\n");
19436 cmdline_parse_inst_t cmd_set_fec_mode = {
19437 .f = cmd_set_port_fec_mode_parsed,
19439 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
19441 (void *)&cmd_set_port_fec_mode_set,
19442 (void *)&cmd_set_port_fec_mode_port,
19443 (void *)&cmd_set_port_fec_mode_port_id,
19444 (void *)&cmd_set_port_fec_mode_str,
19445 (void *)&cmd_set_port_fec_mode_value,
19450 /* show port supported ptypes */
19452 /* Common result structure for show port ptypes */
19453 struct cmd_show_port_supported_ptypes_result {
19454 cmdline_fixed_string_t show;
19455 cmdline_fixed_string_t port;
19457 cmdline_fixed_string_t ptypes;
19460 /* Common CLI fields for show port ptypes */
19461 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
19462 TOKEN_STRING_INITIALIZER
19463 (struct cmd_show_port_supported_ptypes_result,
19465 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
19466 TOKEN_STRING_INITIALIZER
19467 (struct cmd_show_port_supported_ptypes_result,
19469 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19470 TOKEN_NUM_INITIALIZER
19471 (struct cmd_show_port_supported_ptypes_result,
19473 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19474 TOKEN_STRING_INITIALIZER
19475 (struct cmd_show_port_supported_ptypes_result,
19479 cmd_show_port_supported_ptypes_parsed(
19480 void *parsed_result,
19481 __rte_unused struct cmdline *cl,
19482 __rte_unused void *data)
19484 #define RSVD_PTYPE_MASK 0xf0000000
19485 #define MAX_PTYPES_PER_LAYER 16
19486 #define LTYPE_NAMESIZE 32
19487 #define PTYPE_NAMESIZE 256
19488 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19489 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19490 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19491 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19492 uint16_t port_id = res->port_id;
19495 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19499 while (ptype_mask != RSVD_PTYPE_MASK) {
19501 switch (ptype_mask) {
19502 case RTE_PTYPE_L2_MASK:
19503 strlcpy(ltype, "L2", sizeof(ltype));
19505 case RTE_PTYPE_L3_MASK:
19506 strlcpy(ltype, "L3", sizeof(ltype));
19508 case RTE_PTYPE_L4_MASK:
19509 strlcpy(ltype, "L4", sizeof(ltype));
19511 case RTE_PTYPE_TUNNEL_MASK:
19512 strlcpy(ltype, "Tunnel", sizeof(ltype));
19514 case RTE_PTYPE_INNER_L2_MASK:
19515 strlcpy(ltype, "Inner L2", sizeof(ltype));
19517 case RTE_PTYPE_INNER_L3_MASK:
19518 strlcpy(ltype, "Inner L3", sizeof(ltype));
19520 case RTE_PTYPE_INNER_L4_MASK:
19521 strlcpy(ltype, "Inner L4", sizeof(ltype));
19527 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19528 ptype_mask, ptypes,
19529 MAX_PTYPES_PER_LAYER);
19532 printf("Supported %s ptypes:\n", ltype);
19534 printf("%s ptypes unsupported\n", ltype);
19536 for (i = 0; i < ret; ++i) {
19537 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19538 printf("%s\n", buf);
19545 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19546 .f = cmd_show_port_supported_ptypes_parsed,
19548 .help_str = "show port <port_id> ptypes",
19550 (void *)&cmd_show_port_supported_ptypes_show,
19551 (void *)&cmd_show_port_supported_ptypes_port,
19552 (void *)&cmd_show_port_supported_ptypes_port_id,
19553 (void *)&cmd_show_port_supported_ptypes_ptypes,
19558 /* *** display rx/tx descriptor status *** */
19559 struct cmd_show_rx_tx_desc_status_result {
19560 cmdline_fixed_string_t cmd_show;
19561 cmdline_fixed_string_t cmd_port;
19562 cmdline_fixed_string_t cmd_keyword;
19563 cmdline_fixed_string_t cmd_desc;
19564 cmdline_fixed_string_t cmd_status;
19571 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19572 __rte_unused struct cmdline *cl,
19573 __rte_unused void *data)
19575 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19578 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19579 printf("invalid port id %u\n", res->cmd_pid);
19583 if (!strcmp(res->cmd_keyword, "rxq")) {
19584 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19587 printf("Invalid queueid = %d\n", res->cmd_qid);
19590 if (rc == RTE_ETH_RX_DESC_AVAIL)
19591 printf("Desc status = AVAILABLE\n");
19592 else if (rc == RTE_ETH_RX_DESC_DONE)
19593 printf("Desc status = DONE\n");
19595 printf("Desc status = UNAVAILABLE\n");
19596 } else if (!strcmp(res->cmd_keyword, "txq")) {
19597 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19600 printf("Invalid queueid = %d\n", res->cmd_qid);
19603 if (rc == RTE_ETH_TX_DESC_FULL)
19604 printf("Desc status = FULL\n");
19605 else if (rc == RTE_ETH_TX_DESC_DONE)
19606 printf("Desc status = DONE\n");
19608 printf("Desc status = UNAVAILABLE\n");
19612 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19613 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19615 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19616 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19618 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19619 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19621 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19622 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19623 cmd_keyword, "rxq#txq");
19624 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19625 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19627 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19628 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19630 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19631 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19633 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19634 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19635 cmd_status, "status");
19636 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19637 .f = cmd_show_rx_tx_desc_status_parsed,
19639 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19642 (void *)&cmd_show_rx_tx_desc_status_show,
19643 (void *)&cmd_show_rx_tx_desc_status_port,
19644 (void *)&cmd_show_rx_tx_desc_status_pid,
19645 (void *)&cmd_show_rx_tx_desc_status_keyword,
19646 (void *)&cmd_show_rx_tx_desc_status_qid,
19647 (void *)&cmd_show_rx_tx_desc_status_desc,
19648 (void *)&cmd_show_rx_tx_desc_status_did,
19649 (void *)&cmd_show_rx_tx_desc_status_status,
19654 /* Common result structure for set port ptypes */
19655 struct cmd_set_port_ptypes_result {
19656 cmdline_fixed_string_t set;
19657 cmdline_fixed_string_t port;
19659 cmdline_fixed_string_t ptype_mask;
19663 /* Common CLI fields for set port ptypes */
19664 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19665 TOKEN_STRING_INITIALIZER
19666 (struct cmd_set_port_ptypes_result,
19668 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19669 TOKEN_STRING_INITIALIZER
19670 (struct cmd_set_port_ptypes_result,
19672 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19673 TOKEN_NUM_INITIALIZER
19674 (struct cmd_set_port_ptypes_result,
19676 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19677 TOKEN_STRING_INITIALIZER
19678 (struct cmd_set_port_ptypes_result,
19679 ptype_mask, "ptype_mask");
19680 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19681 TOKEN_NUM_INITIALIZER
19682 (struct cmd_set_port_ptypes_result,
19686 cmd_set_port_ptypes_parsed(
19687 void *parsed_result,
19688 __rte_unused struct cmdline *cl,
19689 __rte_unused void *data)
19691 struct cmd_set_port_ptypes_result *res = parsed_result;
19692 #define PTYPE_NAMESIZE 256
19693 char ptype_name[PTYPE_NAMESIZE];
19694 uint16_t port_id = res->port_id;
19695 uint32_t ptype_mask = res->mask;
19698 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19701 printf("Port %d doesn't support any ptypes.\n", port_id);
19705 uint32_t ptypes[ret];
19707 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19709 printf("Unable to set requested ptypes for Port %d\n", port_id);
19713 printf("Successfully set following ptypes for Port %d\n", port_id);
19714 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19715 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19716 printf("%s\n", ptype_name);
19719 clear_ptypes = false;
19722 cmdline_parse_inst_t cmd_set_port_ptypes = {
19723 .f = cmd_set_port_ptypes_parsed,
19725 .help_str = "set port <port_id> ptype_mask <mask>",
19727 (void *)&cmd_set_port_ptypes_set,
19728 (void *)&cmd_set_port_ptypes_port,
19729 (void *)&cmd_set_port_ptypes_port_id,
19730 (void *)&cmd_set_port_ptypes_mask_str,
19731 (void *)&cmd_set_port_ptypes_mask_u32,
19736 /* *** display mac addresses added to a port *** */
19737 struct cmd_showport_macs_result {
19738 cmdline_fixed_string_t cmd_show;
19739 cmdline_fixed_string_t cmd_port;
19740 cmdline_fixed_string_t cmd_keyword;
19745 cmd_showport_macs_parsed(void *parsed_result,
19746 __rte_unused struct cmdline *cl,
19747 __rte_unused void *data)
19749 struct cmd_showport_macs_result *res = parsed_result;
19751 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19754 if (!strcmp(res->cmd_keyword, "macs"))
19755 show_macs(res->cmd_pid);
19756 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19757 show_mcast_macs(res->cmd_pid);
19760 cmdline_parse_token_string_t cmd_showport_macs_show =
19761 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19763 cmdline_parse_token_string_t cmd_showport_macs_port =
19764 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19766 cmdline_parse_token_num_t cmd_showport_macs_pid =
19767 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19769 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19770 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19771 cmd_keyword, "macs#mcast_macs");
19773 cmdline_parse_inst_t cmd_showport_macs = {
19774 .f = cmd_showport_macs_parsed,
19776 .help_str = "show port <port_id> macs|mcast_macs",
19778 (void *)&cmd_showport_macs_show,
19779 (void *)&cmd_showport_macs_port,
19780 (void *)&cmd_showport_macs_pid,
19781 (void *)&cmd_showport_macs_keyword,
19786 /* ******************************************************************************** */
19788 /* list of instructions */
19789 cmdline_parse_ctx_t main_ctx[] = {
19790 (cmdline_parse_inst_t *)&cmd_help_brief,
19791 (cmdline_parse_inst_t *)&cmd_help_long,
19792 (cmdline_parse_inst_t *)&cmd_quit,
19793 (cmdline_parse_inst_t *)&cmd_load_from_file,
19794 (cmdline_parse_inst_t *)&cmd_showport,
19795 (cmdline_parse_inst_t *)&cmd_showqueue,
19796 (cmdline_parse_inst_t *)&cmd_showeeprom,
19797 (cmdline_parse_inst_t *)&cmd_showportall,
19798 (cmdline_parse_inst_t *)&cmd_showdevice,
19799 (cmdline_parse_inst_t *)&cmd_showcfg,
19800 (cmdline_parse_inst_t *)&cmd_showfwdall,
19801 (cmdline_parse_inst_t *)&cmd_start,
19802 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19803 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19804 (cmdline_parse_inst_t *)&cmd_set_link_up,
19805 (cmdline_parse_inst_t *)&cmd_set_link_down,
19806 (cmdline_parse_inst_t *)&cmd_reset,
19807 (cmdline_parse_inst_t *)&cmd_set_numbers,
19808 (cmdline_parse_inst_t *)&cmd_set_log,
19809 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19810 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19811 (cmdline_parse_inst_t *)&cmd_set_txtimes,
19812 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19813 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19814 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19815 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19816 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19817 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19818 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19819 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19820 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19821 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19822 (cmdline_parse_inst_t *)&cmd_set_link_check,
19823 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19824 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19825 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19826 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19827 #ifdef RTE_LIBRTE_PMD_BOND
19828 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19829 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19830 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19831 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19832 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19833 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19834 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19835 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19836 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19837 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19838 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19840 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19841 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19842 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19843 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19844 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19845 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19846 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19847 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19848 (cmdline_parse_inst_t *)&cmd_csum_set,
19849 (cmdline_parse_inst_t *)&cmd_csum_show,
19850 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19851 (cmdline_parse_inst_t *)&cmd_tso_set,
19852 (cmdline_parse_inst_t *)&cmd_tso_show,
19853 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19854 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19855 (cmdline_parse_inst_t *)&cmd_gro_enable,
19856 (cmdline_parse_inst_t *)&cmd_gro_flush,
19857 (cmdline_parse_inst_t *)&cmd_gro_show,
19858 (cmdline_parse_inst_t *)&cmd_gso_enable,
19859 (cmdline_parse_inst_t *)&cmd_gso_size,
19860 (cmdline_parse_inst_t *)&cmd_gso_show,
19861 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19862 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19863 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19864 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19865 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19866 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19867 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19868 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19869 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19870 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19871 (cmdline_parse_inst_t *)&cmd_config_dcb,
19872 (cmdline_parse_inst_t *)&cmd_read_reg,
19873 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19874 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19875 (cmdline_parse_inst_t *)&cmd_write_reg,
19876 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19877 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19878 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19879 (cmdline_parse_inst_t *)&cmd_stop,
19880 (cmdline_parse_inst_t *)&cmd_mac_addr,
19881 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19882 (cmdline_parse_inst_t *)&cmd_set_qmap,
19883 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19884 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
19885 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
19886 (cmdline_parse_inst_t *)&cmd_operate_port,
19887 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19888 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19889 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19890 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19891 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19892 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19893 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19894 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19895 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19896 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19897 (cmdline_parse_inst_t *)&cmd_config_mtu,
19898 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19899 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19900 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19901 (cmdline_parse_inst_t *)&cmd_config_rss,
19902 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19903 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19904 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19905 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19906 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19907 (cmdline_parse_inst_t *)&cmd_showport_reta,
19908 (cmdline_parse_inst_t *)&cmd_showport_macs,
19909 (cmdline_parse_inst_t *)&cmd_config_burst,
19910 (cmdline_parse_inst_t *)&cmd_config_thresh,
19911 (cmdline_parse_inst_t *)&cmd_config_threshold,
19912 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19913 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19914 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19915 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19916 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19917 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19918 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19919 (cmdline_parse_inst_t *)&cmd_global_config,
19920 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19921 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19922 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19923 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19924 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19925 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19926 (cmdline_parse_inst_t *)&cmd_dump,
19927 (cmdline_parse_inst_t *)&cmd_dump_one,
19928 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19929 (cmdline_parse_inst_t *)&cmd_syn_filter,
19930 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19931 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19932 (cmdline_parse_inst_t *)&cmd_flex_filter,
19933 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19934 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19935 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19936 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19937 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19938 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19939 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19940 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19941 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19942 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19943 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19944 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19945 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19946 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19947 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19948 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19949 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19950 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19951 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19952 (cmdline_parse_inst_t *)&cmd_flow,
19953 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19954 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19955 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19956 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19957 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19958 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19959 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19960 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19961 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19962 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19963 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19964 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19965 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19966 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19967 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19968 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19969 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19970 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19971 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19972 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19973 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19974 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19975 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19976 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19977 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19978 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19979 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19980 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19981 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19982 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19983 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19984 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19985 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19986 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19987 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19988 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19989 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19990 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19991 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19992 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19993 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19994 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19995 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19996 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19997 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19998 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19999 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
20000 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
20001 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
20002 (cmdline_parse_inst_t *)&cmd_set_vxlan,
20003 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
20004 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
20005 (cmdline_parse_inst_t *)&cmd_set_nvgre,
20006 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
20007 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
20008 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
20009 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
20010 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
20011 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
20012 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
20013 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
20014 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
20015 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
20016 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
20017 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
20018 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
20019 (cmdline_parse_inst_t *)&cmd_ddp_add,
20020 (cmdline_parse_inst_t *)&cmd_ddp_del,
20021 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
20022 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
20023 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
20024 (cmdline_parse_inst_t *)&cmd_clear_input_set,
20025 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
20026 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
20027 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
20028 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
20029 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
20030 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
20031 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
20032 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
20034 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
20035 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
20036 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
20037 (cmdline_parse_inst_t *)&cmd_queue_region,
20038 (cmdline_parse_inst_t *)&cmd_region_flowtype,
20039 (cmdline_parse_inst_t *)&cmd_user_priority_region,
20040 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
20041 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
20042 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
20043 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
20044 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
20045 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
20046 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
20047 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
20048 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
20049 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
20050 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
20051 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
20052 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
20053 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
20054 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
20055 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
20056 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
20057 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
20058 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
20059 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
20060 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
20061 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
20062 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
20063 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
20064 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
20065 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
20066 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
20067 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
20068 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
20069 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
20070 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
20071 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
20072 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
20073 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
20074 #ifdef RTE_LIBRTE_BPF
20075 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
20076 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
20078 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
20079 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
20080 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
20081 (cmdline_parse_inst_t *)&cmd_set_raw,
20082 (cmdline_parse_inst_t *)&cmd_show_set_raw,
20083 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
20084 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
20085 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
20086 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
20087 (cmdline_parse_inst_t *)&cmd_show_capability,
20091 /* read cmdline commands from file */
20093 cmdline_read_from_file(const char *filename)
20095 struct cmdline *cl;
20097 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
20099 printf("Failed to create file based cmdline context: %s\n",
20104 cmdline_interact(cl);
20109 printf("Read CLI commands from %s\n", filename);
20112 /* prompt function, called from main on MASTER lcore */
20116 /* initialize non-constant commands */
20117 cmd_set_fwd_mode_init();
20118 cmd_set_fwd_retry_mode_init();
20120 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
20121 if (testpmd_cl == NULL)
20123 cmdline_interact(testpmd_cl);
20124 cmdline_stdin_exit(testpmd_cl);
20130 if (testpmd_cl != NULL)
20131 cmdline_quit(testpmd_cl);
20135 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
20137 if (id == (portid_t)RTE_PORT_ALL) {
20140 RTE_ETH_FOREACH_DEV(pid) {
20141 /* check if need_reconfig has been set to 1 */
20142 if (ports[pid].need_reconfig == 0)
20143 ports[pid].need_reconfig = dev;
20144 /* check if need_reconfig_queues has been set to 1 */
20145 if (ports[pid].need_reconfig_queues == 0)
20146 ports[pid].need_reconfig_queues = queue;
20148 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
20149 /* check if need_reconfig has been set to 1 */
20150 if (ports[id].need_reconfig == 0)
20151 ports[id].need_reconfig = dev;
20152 /* check if need_reconfig_queues has been set to 1 */
20153 if (ports[id].need_reconfig_queues == 0)
20154 ports[id].need_reconfig_queues = queue;