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>
54 #include <rte_eth_bond.h>
55 #include <rte_eth_bond_8023ad.h>
57 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
58 #include <rte_pmd_dpaa.h>
61 #include <rte_pmd_ixgbe.h>
64 #include <rte_pmd_i40e.h>
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|rxoffs|rxpkts|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 rxoffs (x[,y]*)\n"
298 " Set the offset of each packet segment on"
299 " receiving if split feature is engaged."
300 " Affects only the queues configured with split"
303 "set rxpkts (x[,y]*)\n"
304 " Set the length of each segment to scatter"
305 " packets on receiving if split feature is engaged."
306 " Affects only the queues configured with split"
309 "set txpkts (x[,y]*)\n"
310 " Set the length of each segment of TXONLY"
311 " and optionally CSUM packets.\n\n"
313 "set txsplit (off|on|rand)\n"
314 " Set the split policy for the TX packets."
315 " Right now only applicable for CSUM and TXONLY"
318 "set txtimes (x, y)\n"
319 " Set the scheduling on timestamps"
320 " timings for the TXONLY mode\n\n"
322 "set corelist (x[,y]*)\n"
323 " Set the list of forwarding cores.\n\n"
325 "set portlist (x[,y]*)\n"
326 " Set the list of forwarding ports.\n\n"
328 "set port setup on (iterator|event)\n"
329 " Select how attached port is retrieved for setup.\n\n"
331 "set tx loopback (port_id) (on|off)\n"
332 " Enable or disable tx loopback.\n\n"
334 "set all queues drop (port_id) (on|off)\n"
335 " Set drop enable bit for all queues.\n\n"
337 "set vf split drop (port_id) (vf_id) (on|off)\n"
338 " Set split drop enable bit for a VF from the PF.\n\n"
340 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
341 " Set MAC antispoof for a VF from the PF.\n\n"
343 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
344 " Enable MACsec offload.\n\n"
346 "set macsec offload (port_id) off\n"
347 " Disable MACsec offload.\n\n"
349 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
350 " Configure MACsec secure connection (SC).\n\n"
352 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
353 " Configure MACsec secure association (SA).\n\n"
355 "set vf broadcast (port_id) (vf_id) (on|off)\n"
356 " Set VF broadcast for a VF from the PF.\n\n"
358 "vlan set stripq (on|off) (port_id,queue_id)\n"
359 " Set the VLAN strip for a queue on a port.\n\n"
361 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
362 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
364 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
365 " Set VLAN insert for a VF from the PF.\n\n"
367 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
368 " Set VLAN antispoof for a VF from the PF.\n\n"
370 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
371 " Set VLAN tag for a VF from the PF.\n\n"
373 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
374 " Set a VF's max bandwidth(Mbps).\n\n"
376 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
377 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
379 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
380 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
382 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
383 " Set some TCs' strict link priority mode on a physical port.\n\n"
385 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
386 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
388 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
389 " Set the VLAN strip or filter or qinq strip or extend\n\n"
391 "vlan set (inner|outer) tpid (value) (port_id)\n"
392 " Set the VLAN TPID for Packet Filtering on"
395 "rx_vlan add (vlan_id|all) (port_id)\n"
396 " Add a vlan_id, or all identifiers, to the set"
397 " of VLAN identifiers filtered by port_id.\n\n"
399 "rx_vlan rm (vlan_id|all) (port_id)\n"
400 " Remove a vlan_id, or all identifiers, from the set"
401 " of VLAN identifiers filtered by port_id.\n\n"
403 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
404 " Add a vlan_id, to the set of VLAN identifiers"
405 "filtered for VF(s) from port_id.\n\n"
407 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
408 " Remove a vlan_id, to the set of VLAN identifiers"
409 "filtered for VF(s) from port_id.\n\n"
411 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
412 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
413 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
414 " add a tunnel filter of a port.\n\n"
416 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
417 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
418 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
419 " remove a tunnel filter of a port.\n\n"
421 "rx_vxlan_port add (udp_port) (port_id)\n"
422 " Add an UDP port for VXLAN packet filter on a port\n\n"
424 "rx_vxlan_port rm (udp_port) (port_id)\n"
425 " Remove an UDP port for VXLAN packet filter on a port\n\n"
427 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
428 " Set hardware insertion of VLAN IDs (single or double VLAN "
429 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
431 "tx_vlan set pvid port_id vlan_id (on|off)\n"
432 " Set port based TX VLAN insertion.\n\n"
434 "tx_vlan reset (port_id)\n"
435 " Disable hardware insertion of a VLAN header in"
436 " packets sent on a port.\n\n"
438 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
439 " Select hardware or software calculation of the"
440 " checksum when transmitting a packet using the"
441 " csum forward engine.\n"
442 " ip|udp|tcp|sctp always concern the inner layer.\n"
443 " outer-ip concerns the outer IP layer in"
444 " outer-udp concerns the outer UDP layer in"
445 " case the packet is recognized as a tunnel packet by"
446 " the forward engine (vxlan, gre and ipip are supported)\n"
447 " Please check the NIC datasheet for HW limits.\n\n"
449 "csum parse-tunnel (on|off) (tx_port_id)\n"
450 " If disabled, treat tunnel packets as non-tunneled"
451 " packets (treat inner headers as payload). The port\n"
452 " argument is the port used for TX in csum forward"
455 "csum show (port_id)\n"
456 " Display tx checksum offload configuration\n\n"
458 "tso set (segsize) (portid)\n"
459 " Enable TCP Segmentation Offload in csum forward"
461 " Please check the NIC datasheet for HW limits.\n\n"
464 " Display the status of TCP Segmentation Offload.\n\n"
466 "set port (port_id) gro on|off\n"
467 " Enable or disable Generic Receive Offload in"
468 " csum forwarding engine.\n\n"
470 "show port (port_id) gro\n"
471 " Display GRO configuration.\n\n"
473 "set gro flush (cycles)\n"
474 " Set the cycle to flush GROed packets from"
475 " reassembly tables.\n\n"
477 "set port (port_id) gso (on|off)"
478 " Enable or disable Generic Segmentation Offload in"
479 " csum forwarding engine.\n\n"
481 "set gso segsz (length)\n"
482 " Set max packet length for output GSO segments,"
483 " including packet header and payload.\n\n"
485 "show port (port_id) gso\n"
486 " Show GSO configuration.\n\n"
489 " Set packet forwarding mode.\n\n"
491 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
492 " Add a MAC address on port_id.\n\n"
494 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
495 " Remove a MAC address from port_id.\n\n"
497 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
498 " Set the default MAC address for port_id.\n\n"
500 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
501 " Add a MAC address for a VF on the port.\n\n"
503 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
504 " Set the MAC address for a VF from the PF.\n\n"
506 "set eth-peer (port_id) (peer_addr)\n"
507 " set the peer address for certain port.\n\n"
509 "set port (port_id) uta (mac_address|all) (on|off)\n"
510 " Add/Remove a or all unicast hash filter(s)"
513 "set promisc (port_id|all) (on|off)\n"
514 " Set the promiscuous mode on port_id, or all.\n\n"
516 "set allmulti (port_id|all) (on|off)\n"
517 " Set the allmulti mode on port_id, or all.\n\n"
519 "set vf promisc (port_id) (vf_id) (on|off)\n"
520 " Set unicast promiscuous mode for a VF from the PF.\n\n"
522 "set vf allmulti (port_id) (vf_id) (on|off)\n"
523 " Set multicast promiscuous mode for a VF from the PF.\n\n"
525 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
526 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
527 " (on|off) autoneg (on|off) (port_id)\n"
528 "set flow_ctrl rx (on|off) (portid)\n"
529 "set flow_ctrl tx (on|off) (portid)\n"
530 "set flow_ctrl high_water (high_water) (portid)\n"
531 "set flow_ctrl low_water (low_water) (portid)\n"
532 "set flow_ctrl pause_time (pause_time) (portid)\n"
533 "set flow_ctrl send_xon (send_xon) (portid)\n"
534 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
535 "set flow_ctrl autoneg (on|off) (port_id)\n"
536 " Set the link flow control parameter on a port.\n\n"
538 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
539 " (low_water) (pause_time) (priority) (port_id)\n"
540 " Set the priority flow control parameter on a"
543 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
544 " Set statistics mapping (qmapping 0..15) for RX/TX"
546 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
547 " on port 0 to mapping 5.\n\n"
549 "set xstats-hide-zero on|off\n"
550 " Set the option to hide the zero values"
551 " for xstats display.\n"
553 "set record-core-cycles on|off\n"
554 " Set the option to enable measurement of CPU cycles.\n"
556 "set record-burst-stats on|off\n"
557 " Set the option to enable display of RX and TX bursts.\n"
559 "set port (port_id) vf (vf_id) rx|tx on|off\n"
560 " Enable/Disable a VF receive/tranmit from a port\n\n"
562 "set port (port_id) vf (vf_id) (mac_addr)"
563 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
564 " Add/Remove unicast or multicast MAC addr filter"
567 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
569 " AUPE:accepts untagged VLAN;"
570 "ROPE:accept unicast hash\n\n"
571 " BAM:accepts broadcast packets;"
572 "MPE:accepts all multicast packets\n\n"
573 " Enable/Disable a VF receive mode of a port\n\n"
575 "set port (port_id) queue (queue_id) rate (rate_num)\n"
576 " Set rate limit for a queue of a port\n\n"
578 "set port (port_id) vf (vf_id) rate (rate_num) "
579 "queue_mask (queue_mask_value)\n"
580 " Set rate limit for queues in VF of a port\n\n"
582 "set port (port_id) mirror-rule (rule_id)"
583 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
584 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
585 " Set pool or vlan type mirror rule on a port.\n"
586 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
587 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
590 "set port (port_id) mirror-rule (rule_id)"
591 " (uplink-mirror|downlink-mirror) dst-pool"
592 " (pool_id) (on|off)\n"
593 " Set uplink or downlink type mirror rule on a port.\n"
594 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
595 " 0 on' enable mirror income traffic to pool 0.\n\n"
597 "reset port (port_id) mirror-rule (rule_id)\n"
598 " Reset a mirror rule.\n\n"
600 "set flush_rx (on|off)\n"
601 " Flush (default) or don't flush RX streams before"
602 " forwarding. Mainly used with PCAP drivers.\n\n"
604 "set bypass mode (normal|bypass|isolate) (port_id)\n"
605 " Set the bypass mode for the lowest port on bypass enabled"
608 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
609 "mode (normal|bypass|isolate) (port_id)\n"
610 " Set the event required to initiate specified bypass mode for"
611 " the lowest port on a bypass enabled NIC where:\n"
612 " timeout = enable bypass after watchdog timeout.\n"
613 " os_on = enable bypass when OS/board is powered on.\n"
614 " os_off = enable bypass when OS/board is powered off.\n"
615 " power_on = enable bypass when power supply is turned on.\n"
616 " power_off = enable bypass when power supply is turned off."
619 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
620 " Set the bypass watchdog timeout to 'n' seconds"
621 " where 0 = instant.\n\n"
623 "show bypass config (port_id)\n"
624 " Show the bypass configuration for a bypass enabled NIC"
625 " using the lowest port on the NIC.\n\n"
628 "create bonded device (mode) (socket)\n"
629 " Create a new bonded device with specific bonding mode and socket.\n\n"
631 "add bonding slave (slave_id) (port_id)\n"
632 " Add a slave device to a bonded device.\n\n"
634 "remove bonding slave (slave_id) (port_id)\n"
635 " Remove a slave device from a bonded device.\n\n"
637 "set bonding mode (value) (port_id)\n"
638 " Set the bonding mode on a bonded device.\n\n"
640 "set bonding primary (slave_id) (port_id)\n"
641 " Set the primary slave for a bonded device.\n\n"
643 "show bonding config (port_id)\n"
644 " Show the bonding config for port_id.\n\n"
646 "set bonding mac_addr (port_id) (address)\n"
647 " Set the MAC address of a bonded device.\n\n"
649 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
650 " Set Aggregation mode for IEEE802.3AD (mode 4)"
652 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
653 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
655 "set bonding mon_period (port_id) (value)\n"
656 " Set the bonding link status monitoring polling period in ms.\n\n"
658 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
659 " Enable/disable dedicated queues for LACP control traffic.\n\n"
662 "set link-up port (port_id)\n"
663 " Set link up for a port.\n\n"
665 "set link-down port (port_id)\n"
666 " Set link down for a port.\n\n"
668 "E-tag set insertion on port-tag-id (value)"
669 " port (port_id) vf (vf_id)\n"
670 " Enable E-tag insertion for a VF on a port\n\n"
672 "E-tag set insertion off port (port_id) vf (vf_id)\n"
673 " Disable E-tag insertion for a VF on a port\n\n"
675 "E-tag set stripping (on|off) port (port_id)\n"
676 " Enable/disable E-tag stripping on a port\n\n"
678 "E-tag set forwarding (on|off) port (port_id)\n"
679 " Enable/disable E-tag based forwarding"
682 "E-tag set filter add e-tag-id (value) dst-pool"
683 " (pool_id) port (port_id)\n"
684 " Add an E-tag forwarding filter on a port\n\n"
686 "E-tag set filter del e-tag-id (value) port (port_id)\n"
687 " Delete an E-tag forwarding filter on a port\n\n"
689 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
690 " Load a profile package on a port\n\n"
692 "ddp del (port_id) (backup_profile_path)\n"
693 " Delete a profile package from a port\n\n"
695 "ptype mapping get (port_id) (valid_only)\n"
696 " Get ptype mapping on a port\n\n"
698 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
699 " Replace target with the pkt_type in ptype mapping\n\n"
701 "ptype mapping reset (port_id)\n"
702 " Reset ptype mapping on a port\n\n"
704 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
705 " Update a ptype mapping item on a port\n\n"
707 "set port (port_id) ptype_mask (ptype_mask)\n"
708 " set packet types classification for a specific port\n\n"
710 "set port (port_id) queue-region region_id (value) "
711 "queue_start_index (value) queue_num (value)\n"
712 " Set a queue region on a port\n\n"
714 "set port (port_id) queue-region region_id (value) "
716 " Set a flowtype region index on a port\n\n"
718 "set port (port_id) queue-region UP (value) region_id (value)\n"
719 " Set the mapping of User Priority to "
720 "queue region on a port\n\n"
722 "set port (port_id) queue-region flush (on|off)\n"
723 " flush all queue region related configuration\n\n"
725 "show port meter cap (port_id)\n"
726 " Show port meter capability information\n\n"
728 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
729 " meter profile add - srtcm rfc 2697\n\n"
731 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
732 " meter profile add - trtcm rfc 2698\n\n"
734 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
735 " meter profile add - trtcm rfc 4115\n\n"
737 "del port meter profile (port_id) (profile_id)\n"
738 " meter profile delete\n\n"
740 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
741 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
742 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
743 "(dscp_tbl_entry63)]\n"
746 "enable port meter (port_id) (mtr_id)\n"
749 "disable port meter (port_id) (mtr_id)\n"
752 "del port meter (port_id) (mtr_id)\n"
755 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
756 " meter update meter profile\n\n"
758 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
759 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
760 " update meter dscp table entries\n\n"
762 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
763 "(action0) [(action1) (action2)]\n"
764 " meter update policer action\n\n"
766 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
767 " meter update stats\n\n"
769 "show port (port_id) queue-region\n"
770 " show all queue region related configuration info\n\n"
772 "set port (port_id) fec_mode auto|off|rs|baser\n"
773 " set fec mode for a specific port\n\n"
775 , list_pkt_forwarding_modes()
779 if (show_all || !strcmp(res->section, "ports")) {
785 "----------------\n\n"
787 "port start (port_id|all)\n"
788 " Start all ports or port_id.\n\n"
790 "port stop (port_id|all)\n"
791 " Stop all ports or port_id.\n\n"
793 "port close (port_id|all)\n"
794 " Close all ports or port_id.\n\n"
796 "port reset (port_id|all)\n"
797 " Reset all ports or port_id.\n\n"
799 "port attach (ident)\n"
800 " Attach physical or virtual dev by pci address or virtual device name\n\n"
802 "port detach (port_id)\n"
803 " Detach physical or virtual dev by port_id\n\n"
805 "port config (port_id|all)"
806 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
807 " duplex (half|full|auto)\n"
808 " Set speed and duplex for all ports or port_id\n\n"
810 "port config (port_id|all) loopback (mode)\n"
811 " Set loopback mode for all ports or port_id\n\n"
813 "port config all (rxq|txq|rxd|txd) (value)\n"
814 " Set number for rxq/txq/rxd/txd.\n\n"
816 "port config all max-pkt-len (value)\n"
817 " Set the max packet length.\n\n"
819 "port config all max-lro-pkt-size (value)\n"
820 " Set the max LRO aggregated packet size.\n\n"
822 "port config all drop-en (on|off)\n"
823 " Enable or disable packet drop on all RX queues of all ports when no "
824 "receive buffers available.\n\n"
826 "port config all rss (all|default|ip|tcp|udp|sctp|"
827 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|level-default|"
828 "level-outer|level-inner|<flowtype_id>)\n"
829 " Set the RSS mode.\n\n"
831 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
832 " Set the RSS redirection table.\n\n"
834 "port config (port_id) dcb vt (on|off) (traffic_class)"
836 " Set the DCB mode.\n\n"
838 "port config all burst (value)\n"
839 " Set the number of packets per burst.\n\n"
841 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
843 " Set the ring prefetch/host/writeback threshold"
844 " for tx/rx queue.\n\n"
846 "port config all (txfreet|txrst|rxfreet) (value)\n"
847 " Set free threshold for rx/tx, or set"
848 " tx rs bit threshold.\n\n"
849 "port config mtu X value\n"
850 " Set the MTU of port X to a given value\n\n"
852 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
853 " Set a rx/tx queue's ring size configuration, the new"
854 " value will take effect after command that (re-)start the port"
855 " or command that setup the specific queue\n\n"
857 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
858 " Start/stop a rx/tx queue of port X. Only take effect"
859 " when port X is started\n\n"
861 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
862 " Switch on/off a deferred start of port X rx/tx queue. Only"
863 " take effect when port X is stopped.\n\n"
865 "port (port_id) (rxq|txq) (queue_id) setup\n"
866 " Setup a rx/tx queue of port X.\n\n"
868 "port config (port_id|all) l2-tunnel E-tag ether-type"
870 " Set the value of E-tag ether-type.\n\n"
872 "port config (port_id|all) l2-tunnel E-tag"
873 " (enable|disable)\n"
874 " Enable/disable the E-tag support.\n\n"
876 "port config (port_id) pctype mapping reset\n"
877 " Reset flow type to pctype mapping on a port\n\n"
879 "port config (port_id) pctype mapping update"
880 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
881 " Update a flow type to pctype mapping item on a port\n\n"
883 "port config (port_id) pctype (pctype_id) hash_inset|"
884 "fdir_inset|fdir_flx_inset get|set|clear field\n"
886 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
888 "port config (port_id) pctype (pctype_id) hash_inset|"
889 "fdir_inset|fdir_flx_inset clear all"
890 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
892 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
893 " Add/remove UDP tunnel port for tunneling offload\n\n"
895 "port config <port_id> rx_offload vlan_strip|"
896 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
897 "outer_ipv4_cksum|macsec_strip|header_split|"
898 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
899 "buffer_split|timestamp|security|keep_crc on|off\n"
900 " Enable or disable a per port Rx offloading"
901 " on all Rx queues of a port\n\n"
903 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
904 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
905 "outer_ipv4_cksum|macsec_strip|header_split|"
906 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
907 "buffer_split|timestamp|security|keep_crc on|off\n"
908 " Enable or disable a per queue Rx offloading"
909 " only on a specific Rx queue\n\n"
911 "port config (port_id) tx_offload vlan_insert|"
912 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
913 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
914 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
915 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
917 " Enable or disable a per port Tx offloading"
918 " on all Tx queues of a port\n\n"
920 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
921 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
922 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
923 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
924 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
926 " Enable or disable a per queue Tx offloading"
927 " only on a specific Tx queue\n\n"
929 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
930 " Load an eBPF program as a callback"
931 " for particular RX/TX queue\n\n"
933 "bpf-unload rx|tx (port) (queue)\n"
934 " Unload previously loaded eBPF program"
935 " for particular RX/TX queue\n\n"
937 "port config (port_id) tx_metadata (value)\n"
938 " Set Tx metadata value per port. Testpmd will add this value"
939 " to any Tx packet sent from this port\n\n"
941 "port config (port_id) dynf (name) set|clear\n"
942 " Register a dynf and Set/clear this flag on Tx. "
943 "Testpmd will set this value to any Tx packet "
944 "sent from this port\n\n"
948 if (show_all || !strcmp(res->section, "registers")) {
956 "read reg (port_id) (address)\n"
957 " Display value of a port register.\n\n"
959 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
960 " Display a port register bit field.\n\n"
962 "read regbit (port_id) (address) (bit_x)\n"
963 " Display a single port register bit.\n\n"
965 "write reg (port_id) (address) (value)\n"
966 " Set value of a port register.\n\n"
968 "write regfield (port_id) (address) (bit_x) (bit_y)"
970 " Set bit field of a port register.\n\n"
972 "write regbit (port_id) (address) (bit_x) (value)\n"
973 " Set single bit value of a port register.\n\n"
976 if (show_all || !strcmp(res->section, "filters")) {
984 "ethertype_filter (port_id) (add|del)"
985 " (mac_addr|mac_ignr) (mac_address) ethertype"
986 " (ether_type) (drop|fwd) queue (queue_id)\n"
987 " Add/Del an ethertype filter.\n\n"
989 "2tuple_filter (port_id) (add|del)"
990 " dst_port (dst_port_value) protocol (protocol_value)"
991 " mask (mask_value) tcp_flags (tcp_flags_value)"
992 " priority (prio_value) queue (queue_id)\n"
993 " Add/Del a 2tuple filter.\n\n"
995 "5tuple_filter (port_id) (add|del)"
996 " dst_ip (dst_address) src_ip (src_address)"
997 " dst_port (dst_port_value) src_port (src_port_value)"
998 " protocol (protocol_value)"
999 " mask (mask_value) tcp_flags (tcp_flags_value)"
1000 " priority (prio_value) queue (queue_id)\n"
1001 " Add/Del a 5tuple filter.\n\n"
1003 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
1004 " Add/Del syn filter.\n\n"
1006 "flex_filter (port_id) (add|del) len (len_value)"
1007 " bytes (bytes_value) mask (mask_value)"
1008 " priority (prio_value) queue (queue_id)\n"
1009 " Add/Del a flex filter.\n\n"
1011 "flow_director_filter (port_id) mode IP (add|del|update)"
1012 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
1013 " src (src_ip_address) dst (dst_ip_address)"
1014 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
1015 " vlan (vlan_value) flexbytes (flexbytes_value)"
1016 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1017 " fd_id (fd_id_value)\n"
1018 " Add/Del an IP type flow director filter.\n\n"
1020 "flow_director_filter (port_id) mode IP (add|del|update)"
1021 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
1022 " src (src_ip_address) (src_port)"
1023 " dst (dst_ip_address) (dst_port)"
1024 " tos (tos_value) ttl (ttl_value)"
1025 " vlan (vlan_value) flexbytes (flexbytes_value)"
1026 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1027 " fd_id (fd_id_value)\n"
1028 " Add/Del an UDP/TCP type flow director filter.\n\n"
1030 "flow_director_filter (port_id) mode IP (add|del|update)"
1031 " flow (ipv4-sctp|ipv6-sctp)"
1032 " src (src_ip_address) (src_port)"
1033 " dst (dst_ip_address) (dst_port)"
1034 " tag (verification_tag) "
1035 " tos (tos_value) ttl (ttl_value)"
1036 " vlan (vlan_value)"
1037 " flexbytes (flexbytes_value) (drop|fwd)"
1038 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1039 " Add/Del a SCTP type flow director filter.\n\n"
1041 "flow_director_filter (port_id) mode IP (add|del|update)"
1042 " flow l2_payload ether (ethertype)"
1043 " flexbytes (flexbytes_value) (drop|fwd)"
1044 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1045 " Add/Del a l2 payload type flow director filter.\n\n"
1047 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1048 " mac (mac_address) vlan (vlan_value)"
1049 " flexbytes (flexbytes_value) (drop|fwd)"
1050 " queue (queue_id) fd_id (fd_id_value)\n"
1051 " Add/Del a MAC-VLAN flow director filter.\n\n"
1053 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1054 " mac (mac_address) vlan (vlan_value)"
1055 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1056 " flexbytes (flexbytes_value) (drop|fwd)"
1057 " queue (queue_id) fd_id (fd_id_value)\n"
1058 " Add/Del a Tunnel flow director filter.\n\n"
1060 "flow_director_filter (port_id) mode raw (add|del|update)"
1061 " flow (flow_id) (drop|fwd) queue (queue_id)"
1062 " fd_id (fd_id_value) packet (packet file name)\n"
1063 " Add/Del a raw type flow director filter.\n\n"
1065 "flush_flow_director (port_id)\n"
1066 " Flush all flow director entries of a device.\n\n"
1068 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1069 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1070 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1071 " Set flow director IP mask.\n\n"
1073 "flow_director_mask (port_id) mode MAC-VLAN"
1074 " vlan (vlan_value)\n"
1075 " Set flow director MAC-VLAN mask.\n\n"
1077 "flow_director_mask (port_id) mode Tunnel"
1078 " vlan (vlan_value) mac (mac_value)"
1079 " tunnel-type (tunnel_type_value)"
1080 " tunnel-id (tunnel_id_value)\n"
1081 " Set flow director Tunnel mask.\n\n"
1083 "flow_director_flex_mask (port_id)"
1084 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1085 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1087 " Configure mask of flex payload.\n\n"
1089 "flow_director_flex_payload (port_id)"
1090 " (raw|l2|l3|l4) (config)\n"
1091 " Configure flex payload selection.\n\n"
1093 "get_sym_hash_ena_per_port (port_id)\n"
1094 " get symmetric hash enable configuration per port.\n\n"
1096 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1097 " set symmetric hash enable configuration per port"
1098 " to enable or disable.\n\n"
1100 "get_hash_global_config (port_id)\n"
1101 " Get the global configurations of hash filters.\n\n"
1103 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1104 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1105 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1106 " (enable|disable)\n"
1107 " Set the global configurations of hash filters.\n\n"
1109 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1110 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1111 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1112 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1113 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1114 "ipv6-next-header|udp-src-port|udp-dst-port|"
1115 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1116 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1117 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1118 "fld-8th|none) (select|add)\n"
1119 " Set the input set for hash.\n\n"
1121 "set_fdir_input_set (port_id) "
1122 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1123 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1124 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1125 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1126 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1127 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1128 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1130 " Set the input set for FDir.\n\n"
1132 "flow validate {port_id}"
1133 " [group {group_id}] [priority {level}]"
1134 " [ingress] [egress]"
1135 " pattern {item} [/ {item} [...]] / end"
1136 " actions {action} [/ {action} [...]] / end\n"
1137 " Check whether a flow rule can be created.\n\n"
1139 "flow create {port_id}"
1140 " [group {group_id}] [priority {level}]"
1141 " [ingress] [egress]"
1142 " pattern {item} [/ {item} [...]] / end"
1143 " actions {action} [/ {action} [...]] / end\n"
1144 " Create a flow rule.\n\n"
1146 "flow destroy {port_id} rule {rule_id} [...]\n"
1147 " Destroy specific flow rules.\n\n"
1149 "flow flush {port_id}\n"
1150 " Destroy all flow rules.\n\n"
1152 "flow query {port_id} {rule_id} {action}\n"
1153 " Query an existing flow rule.\n\n"
1155 "flow list {port_id} [group {group_id}] [...]\n"
1156 " List existing flow rules sorted by priority,"
1157 " filtered by group identifiers.\n\n"
1159 "flow isolate {port_id} {boolean}\n"
1160 " Restrict ingress traffic to the defined"
1163 "flow aged {port_id} [destroy]\n"
1164 " List and destroy aged flows"
1167 "flow shared_action {port_id} create"
1168 " [action_id {shared_action_id}]"
1169 " [ingress] [egress]"
1170 " action {action} / end\n"
1171 " Create shared action.\n\n"
1173 "flow shared_action {port_id} update"
1174 " {shared_action_id} action {action} / end\n"
1175 " Update shared action.\n\n"
1177 "flow shared_action {port_id} destroy"
1178 " action_id {shared_action_id} [...]\n"
1179 " Destroy specific shared actions.\n\n"
1181 "flow shared_action {port_id} query"
1182 " {shared_action_id}\n"
1183 " Query an existing shared action.\n\n"
1185 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1186 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1187 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1188 " Configure the VXLAN encapsulation for flows.\n\n"
1190 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1191 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1192 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1193 " eth-dst (eth-dst)\n"
1194 " Configure the VXLAN encapsulation for flows.\n\n"
1196 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1197 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1198 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1199 " eth-dst (eth-dst)\n"
1200 " Configure the VXLAN encapsulation for flows.\n\n"
1202 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1203 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1205 " Configure the NVGRE encapsulation for flows.\n\n"
1207 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1208 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1209 " eth-src (eth-src) eth-dst (eth-dst)\n"
1210 " Configure the NVGRE encapsulation for flows.\n\n"
1212 "set raw_encap {flow items}\n"
1213 " Configure the encapsulation with raw data.\n\n"
1215 "set raw_decap {flow items}\n"
1216 " Configure the decapsulation with raw data.\n\n"
1221 if (show_all || !strcmp(res->section, "traffic_management")) {
1225 "Traffic Management:\n"
1227 "show port tm cap (port_id)\n"
1228 " Display the port TM capability.\n\n"
1230 "show port tm level cap (port_id) (level_id)\n"
1231 " Display the port TM hierarchical level capability.\n\n"
1233 "show port tm node cap (port_id) (node_id)\n"
1234 " Display the port TM node capability.\n\n"
1236 "show port tm node type (port_id) (node_id)\n"
1237 " Display the port TM node type.\n\n"
1239 "show port tm node stats (port_id) (node_id) (clear)\n"
1240 " Display the port TM node stats.\n\n"
1242 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1243 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1244 " (packet_length_adjust) (packet_mode)\n"
1245 " Add port tm node private shaper profile.\n\n"
1247 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1248 " Delete port tm node private shaper profile.\n\n"
1250 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1251 " (shaper_profile_id)\n"
1252 " Add/update port tm node shared shaper.\n\n"
1254 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1255 " Delete port tm node shared shaper.\n\n"
1257 "set port tm node shaper profile (port_id) (node_id)"
1258 " (shaper_profile_id)\n"
1259 " Set port tm node shaper profile.\n\n"
1261 "add port tm node wred profile (port_id) (wred_profile_id)"
1262 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1263 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1264 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1265 " Add port tm node wred profile.\n\n"
1267 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1268 " Delete port tm node wred profile.\n\n"
1270 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1271 " (priority) (weight) (level_id) (shaper_profile_id)"
1272 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1273 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1274 " Add port tm nonleaf node.\n\n"
1276 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1277 " (priority) (weight) (level_id) (shaper_profile_id)"
1278 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1279 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1280 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1282 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1283 " (priority) (weight) (level_id) (shaper_profile_id)"
1284 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1285 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1286 " Add port tm leaf node.\n\n"
1288 "del port tm node (port_id) (node_id)\n"
1289 " Delete port tm node.\n\n"
1291 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1292 " (priority) (weight)\n"
1293 " Set port tm node parent.\n\n"
1295 "suspend port tm node (port_id) (node_id)"
1296 " Suspend tm node.\n\n"
1298 "resume port tm node (port_id) (node_id)"
1299 " Resume tm node.\n\n"
1301 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1302 " Commit tm hierarchy.\n\n"
1304 "set port tm mark ip_ecn (port) (green) (yellow)"
1306 " Enables/Disables the traffic management marking"
1307 " for IP ECN (Explicit Congestion Notification)"
1308 " packets on a given port\n\n"
1310 "set port tm mark ip_dscp (port) (green) (yellow)"
1312 " Enables/Disables the traffic management marking"
1313 " on the port for IP dscp packets\n\n"
1315 "set port tm mark vlan_dei (port) (green) (yellow)"
1317 " Enables/Disables the traffic management marking"
1318 " on the port for VLAN packets with DEI enabled\n\n"
1322 if (show_all || !strcmp(res->section, "devices")) {
1326 "Device Operations:\n"
1328 "device detach (identifier)\n"
1329 " Detach device by identifier.\n\n"
1335 cmdline_parse_token_string_t cmd_help_long_help =
1336 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1338 cmdline_parse_token_string_t cmd_help_long_section =
1339 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1340 "all#control#display#config#"
1341 "ports#registers#filters#traffic_management#devices");
1343 cmdline_parse_inst_t cmd_help_long = {
1344 .f = cmd_help_long_parsed,
1346 .help_str = "help all|control|display|config|ports|register|"
1347 "filters|traffic_management|devices: "
1350 (void *)&cmd_help_long_help,
1351 (void *)&cmd_help_long_section,
1357 /* *** start/stop/close all ports *** */
1358 struct cmd_operate_port_result {
1359 cmdline_fixed_string_t keyword;
1360 cmdline_fixed_string_t name;
1361 cmdline_fixed_string_t value;
1364 static void cmd_operate_port_parsed(void *parsed_result,
1365 __rte_unused struct cmdline *cl,
1366 __rte_unused void *data)
1368 struct cmd_operate_port_result *res = parsed_result;
1370 if (!strcmp(res->name, "start"))
1371 start_port(RTE_PORT_ALL);
1372 else if (!strcmp(res->name, "stop"))
1373 stop_port(RTE_PORT_ALL);
1374 else if (!strcmp(res->name, "close"))
1375 close_port(RTE_PORT_ALL);
1376 else if (!strcmp(res->name, "reset"))
1377 reset_port(RTE_PORT_ALL);
1379 printf("Unknown parameter\n");
1382 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1383 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1385 cmdline_parse_token_string_t cmd_operate_port_all_port =
1386 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1387 "start#stop#close#reset");
1388 cmdline_parse_token_string_t cmd_operate_port_all_all =
1389 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1391 cmdline_parse_inst_t cmd_operate_port = {
1392 .f = cmd_operate_port_parsed,
1394 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1396 (void *)&cmd_operate_port_all_cmd,
1397 (void *)&cmd_operate_port_all_port,
1398 (void *)&cmd_operate_port_all_all,
1403 /* *** start/stop/close specific port *** */
1404 struct cmd_operate_specific_port_result {
1405 cmdline_fixed_string_t keyword;
1406 cmdline_fixed_string_t name;
1410 static void cmd_operate_specific_port_parsed(void *parsed_result,
1411 __rte_unused struct cmdline *cl,
1412 __rte_unused void *data)
1414 struct cmd_operate_specific_port_result *res = parsed_result;
1416 if (!strcmp(res->name, "start"))
1417 start_port(res->value);
1418 else if (!strcmp(res->name, "stop"))
1419 stop_port(res->value);
1420 else if (!strcmp(res->name, "close"))
1421 close_port(res->value);
1422 else if (!strcmp(res->name, "reset"))
1423 reset_port(res->value);
1425 printf("Unknown parameter\n");
1428 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1429 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1431 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1432 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1433 name, "start#stop#close#reset");
1434 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1435 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1438 cmdline_parse_inst_t cmd_operate_specific_port = {
1439 .f = cmd_operate_specific_port_parsed,
1441 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1443 (void *)&cmd_operate_specific_port_cmd,
1444 (void *)&cmd_operate_specific_port_port,
1445 (void *)&cmd_operate_specific_port_id,
1450 /* *** enable port setup (after attach) via iterator or event *** */
1451 struct cmd_set_port_setup_on_result {
1452 cmdline_fixed_string_t set;
1453 cmdline_fixed_string_t port;
1454 cmdline_fixed_string_t setup;
1455 cmdline_fixed_string_t on;
1456 cmdline_fixed_string_t mode;
1459 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1460 __rte_unused struct cmdline *cl,
1461 __rte_unused void *data)
1463 struct cmd_set_port_setup_on_result *res = parsed_result;
1465 if (strcmp(res->mode, "event") == 0)
1466 setup_on_probe_event = true;
1467 else if (strcmp(res->mode, "iterator") == 0)
1468 setup_on_probe_event = false;
1470 printf("Unknown mode\n");
1473 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1474 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1476 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1477 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1479 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1480 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1482 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1483 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1485 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1486 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1487 mode, "iterator#event");
1489 cmdline_parse_inst_t cmd_set_port_setup_on = {
1490 .f = cmd_set_port_setup_on_parsed,
1492 .help_str = "set port setup on iterator|event",
1494 (void *)&cmd_set_port_setup_on_set,
1495 (void *)&cmd_set_port_setup_on_port,
1496 (void *)&cmd_set_port_setup_on_setup,
1497 (void *)&cmd_set_port_setup_on_on,
1498 (void *)&cmd_set_port_setup_on_mode,
1503 /* *** attach a specified port *** */
1504 struct cmd_operate_attach_port_result {
1505 cmdline_fixed_string_t port;
1506 cmdline_fixed_string_t keyword;
1507 cmdline_multi_string_t identifier;
1510 static void cmd_operate_attach_port_parsed(void *parsed_result,
1511 __rte_unused struct cmdline *cl,
1512 __rte_unused void *data)
1514 struct cmd_operate_attach_port_result *res = parsed_result;
1516 if (!strcmp(res->keyword, "attach"))
1517 attach_port(res->identifier);
1519 printf("Unknown parameter\n");
1522 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1523 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1525 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1526 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1528 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1529 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1530 identifier, TOKEN_STRING_MULTI);
1532 cmdline_parse_inst_t cmd_operate_attach_port = {
1533 .f = cmd_operate_attach_port_parsed,
1535 .help_str = "port attach <identifier>: "
1536 "(identifier: pci address or virtual dev name)",
1538 (void *)&cmd_operate_attach_port_port,
1539 (void *)&cmd_operate_attach_port_keyword,
1540 (void *)&cmd_operate_attach_port_identifier,
1545 /* *** detach a specified port *** */
1546 struct cmd_operate_detach_port_result {
1547 cmdline_fixed_string_t port;
1548 cmdline_fixed_string_t keyword;
1552 static void cmd_operate_detach_port_parsed(void *parsed_result,
1553 __rte_unused struct cmdline *cl,
1554 __rte_unused void *data)
1556 struct cmd_operate_detach_port_result *res = parsed_result;
1558 if (!strcmp(res->keyword, "detach")) {
1559 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1560 detach_port_device(res->port_id);
1562 printf("Unknown parameter\n");
1566 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1567 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1569 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1570 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1572 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1573 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1576 cmdline_parse_inst_t cmd_operate_detach_port = {
1577 .f = cmd_operate_detach_port_parsed,
1579 .help_str = "port detach <port_id>",
1581 (void *)&cmd_operate_detach_port_port,
1582 (void *)&cmd_operate_detach_port_keyword,
1583 (void *)&cmd_operate_detach_port_port_id,
1588 /* *** detach device by identifier *** */
1589 struct cmd_operate_detach_device_result {
1590 cmdline_fixed_string_t device;
1591 cmdline_fixed_string_t keyword;
1592 cmdline_fixed_string_t identifier;
1595 static void cmd_operate_detach_device_parsed(void *parsed_result,
1596 __rte_unused struct cmdline *cl,
1597 __rte_unused void *data)
1599 struct cmd_operate_detach_device_result *res = parsed_result;
1601 if (!strcmp(res->keyword, "detach"))
1602 detach_devargs(res->identifier);
1604 printf("Unknown parameter\n");
1607 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1608 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1610 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1611 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1613 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1614 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1617 cmdline_parse_inst_t cmd_operate_detach_device = {
1618 .f = cmd_operate_detach_device_parsed,
1620 .help_str = "device detach <identifier>:"
1621 "(identifier: pci address or virtual dev name)",
1623 (void *)&cmd_operate_detach_device_device,
1624 (void *)&cmd_operate_detach_device_keyword,
1625 (void *)&cmd_operate_detach_device_identifier,
1629 /* *** configure speed for all ports *** */
1630 struct cmd_config_speed_all {
1631 cmdline_fixed_string_t port;
1632 cmdline_fixed_string_t keyword;
1633 cmdline_fixed_string_t all;
1634 cmdline_fixed_string_t item1;
1635 cmdline_fixed_string_t item2;
1636 cmdline_fixed_string_t value1;
1637 cmdline_fixed_string_t value2;
1641 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1646 if (!strcmp(duplexstr, "half")) {
1647 duplex = ETH_LINK_HALF_DUPLEX;
1648 } else if (!strcmp(duplexstr, "full")) {
1649 duplex = ETH_LINK_FULL_DUPLEX;
1650 } else if (!strcmp(duplexstr, "auto")) {
1651 duplex = ETH_LINK_FULL_DUPLEX;
1653 printf("Unknown duplex parameter\n");
1657 if (!strcmp(speedstr, "10")) {
1658 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1659 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1660 } else if (!strcmp(speedstr, "100")) {
1661 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1662 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1664 if (duplex != ETH_LINK_FULL_DUPLEX) {
1665 printf("Invalid speed/duplex parameters\n");
1668 if (!strcmp(speedstr, "1000")) {
1669 *speed = ETH_LINK_SPEED_1G;
1670 } else if (!strcmp(speedstr, "10000")) {
1671 *speed = ETH_LINK_SPEED_10G;
1672 } else if (!strcmp(speedstr, "25000")) {
1673 *speed = ETH_LINK_SPEED_25G;
1674 } else if (!strcmp(speedstr, "40000")) {
1675 *speed = ETH_LINK_SPEED_40G;
1676 } else if (!strcmp(speedstr, "50000")) {
1677 *speed = ETH_LINK_SPEED_50G;
1678 } else if (!strcmp(speedstr, "100000")) {
1679 *speed = ETH_LINK_SPEED_100G;
1680 } else if (!strcmp(speedstr, "200000")) {
1681 *speed = ETH_LINK_SPEED_200G;
1682 } else if (!strcmp(speedstr, "auto")) {
1683 *speed = ETH_LINK_SPEED_AUTONEG;
1685 printf("Unknown speed parameter\n");
1694 cmd_config_speed_all_parsed(void *parsed_result,
1695 __rte_unused struct cmdline *cl,
1696 __rte_unused void *data)
1698 struct cmd_config_speed_all *res = parsed_result;
1699 uint32_t link_speed;
1702 if (!all_ports_stopped()) {
1703 printf("Please stop all ports first\n");
1707 if (parse_and_check_speed_duplex(res->value1, res->value2,
1711 RTE_ETH_FOREACH_DEV(pid) {
1712 ports[pid].dev_conf.link_speeds = link_speed;
1715 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1718 cmdline_parse_token_string_t cmd_config_speed_all_port =
1719 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1720 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1721 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1723 cmdline_parse_token_string_t cmd_config_speed_all_all =
1724 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1725 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1726 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1727 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1728 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1729 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1730 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1731 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1732 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1733 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1736 cmdline_parse_inst_t cmd_config_speed_all = {
1737 .f = cmd_config_speed_all_parsed,
1739 .help_str = "port config all speed "
1740 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1743 (void *)&cmd_config_speed_all_port,
1744 (void *)&cmd_config_speed_all_keyword,
1745 (void *)&cmd_config_speed_all_all,
1746 (void *)&cmd_config_speed_all_item1,
1747 (void *)&cmd_config_speed_all_value1,
1748 (void *)&cmd_config_speed_all_item2,
1749 (void *)&cmd_config_speed_all_value2,
1754 /* *** configure speed for specific port *** */
1755 struct cmd_config_speed_specific {
1756 cmdline_fixed_string_t port;
1757 cmdline_fixed_string_t keyword;
1759 cmdline_fixed_string_t item1;
1760 cmdline_fixed_string_t item2;
1761 cmdline_fixed_string_t value1;
1762 cmdline_fixed_string_t value2;
1766 cmd_config_speed_specific_parsed(void *parsed_result,
1767 __rte_unused struct cmdline *cl,
1768 __rte_unused void *data)
1770 struct cmd_config_speed_specific *res = parsed_result;
1771 uint32_t link_speed;
1773 if (!all_ports_stopped()) {
1774 printf("Please stop all ports first\n");
1778 if (port_id_is_invalid(res->id, ENABLED_WARN))
1781 if (parse_and_check_speed_duplex(res->value1, res->value2,
1785 ports[res->id].dev_conf.link_speeds = link_speed;
1787 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1791 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1792 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1794 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1795 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1797 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1798 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1799 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1800 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1802 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1803 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1804 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1805 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1806 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1808 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1809 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1812 cmdline_parse_inst_t cmd_config_speed_specific = {
1813 .f = cmd_config_speed_specific_parsed,
1815 .help_str = "port config <port_id> speed "
1816 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1819 (void *)&cmd_config_speed_specific_port,
1820 (void *)&cmd_config_speed_specific_keyword,
1821 (void *)&cmd_config_speed_specific_id,
1822 (void *)&cmd_config_speed_specific_item1,
1823 (void *)&cmd_config_speed_specific_value1,
1824 (void *)&cmd_config_speed_specific_item2,
1825 (void *)&cmd_config_speed_specific_value2,
1830 /* *** configure loopback for all ports *** */
1831 struct cmd_config_loopback_all {
1832 cmdline_fixed_string_t port;
1833 cmdline_fixed_string_t keyword;
1834 cmdline_fixed_string_t all;
1835 cmdline_fixed_string_t item;
1840 cmd_config_loopback_all_parsed(void *parsed_result,
1841 __rte_unused struct cmdline *cl,
1842 __rte_unused void *data)
1844 struct cmd_config_loopback_all *res = parsed_result;
1847 if (!all_ports_stopped()) {
1848 printf("Please stop all ports first\n");
1852 RTE_ETH_FOREACH_DEV(pid) {
1853 ports[pid].dev_conf.lpbk_mode = res->mode;
1856 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1859 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1860 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1861 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1862 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1864 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1865 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1866 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1867 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1869 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1870 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1872 cmdline_parse_inst_t cmd_config_loopback_all = {
1873 .f = cmd_config_loopback_all_parsed,
1875 .help_str = "port config all loopback <mode>",
1877 (void *)&cmd_config_loopback_all_port,
1878 (void *)&cmd_config_loopback_all_keyword,
1879 (void *)&cmd_config_loopback_all_all,
1880 (void *)&cmd_config_loopback_all_item,
1881 (void *)&cmd_config_loopback_all_mode,
1886 /* *** configure loopback for specific port *** */
1887 struct cmd_config_loopback_specific {
1888 cmdline_fixed_string_t port;
1889 cmdline_fixed_string_t keyword;
1891 cmdline_fixed_string_t item;
1896 cmd_config_loopback_specific_parsed(void *parsed_result,
1897 __rte_unused struct cmdline *cl,
1898 __rte_unused void *data)
1900 struct cmd_config_loopback_specific *res = parsed_result;
1902 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1905 if (!port_is_stopped(res->port_id)) {
1906 printf("Please stop port %u first\n", res->port_id);
1910 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1912 cmd_reconfig_device_queue(res->port_id, 1, 1);
1916 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1917 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1919 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1920 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1922 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1923 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1925 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1926 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1928 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1929 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1932 cmdline_parse_inst_t cmd_config_loopback_specific = {
1933 .f = cmd_config_loopback_specific_parsed,
1935 .help_str = "port config <port_id> loopback <mode>",
1937 (void *)&cmd_config_loopback_specific_port,
1938 (void *)&cmd_config_loopback_specific_keyword,
1939 (void *)&cmd_config_loopback_specific_id,
1940 (void *)&cmd_config_loopback_specific_item,
1941 (void *)&cmd_config_loopback_specific_mode,
1946 /* *** configure txq/rxq, txd/rxd *** */
1947 struct cmd_config_rx_tx {
1948 cmdline_fixed_string_t port;
1949 cmdline_fixed_string_t keyword;
1950 cmdline_fixed_string_t all;
1951 cmdline_fixed_string_t name;
1956 cmd_config_rx_tx_parsed(void *parsed_result,
1957 __rte_unused struct cmdline *cl,
1958 __rte_unused void *data)
1960 struct cmd_config_rx_tx *res = parsed_result;
1962 if (!all_ports_stopped()) {
1963 printf("Please stop all ports first\n");
1966 if (!strcmp(res->name, "rxq")) {
1967 if (!res->value && !nb_txq) {
1968 printf("Warning: Either rx or tx queues should be non zero\n");
1971 if (check_nb_rxq(res->value) != 0)
1973 nb_rxq = res->value;
1975 else if (!strcmp(res->name, "txq")) {
1976 if (!res->value && !nb_rxq) {
1977 printf("Warning: Either rx or tx queues should be non zero\n");
1980 if (check_nb_txq(res->value) != 0)
1982 nb_txq = res->value;
1984 else if (!strcmp(res->name, "rxd")) {
1985 if (check_nb_rxd(res->value) != 0)
1987 nb_rxd = res->value;
1988 } else if (!strcmp(res->name, "txd")) {
1989 if (check_nb_txd(res->value) != 0)
1992 nb_txd = res->value;
1994 printf("Unknown parameter\n");
2002 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2005 cmdline_parse_token_string_t cmd_config_rx_tx_port =
2006 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
2007 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
2008 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
2009 cmdline_parse_token_string_t cmd_config_rx_tx_all =
2010 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
2011 cmdline_parse_token_string_t cmd_config_rx_tx_name =
2012 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
2014 cmdline_parse_token_num_t cmd_config_rx_tx_value =
2015 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
2017 cmdline_parse_inst_t cmd_config_rx_tx = {
2018 .f = cmd_config_rx_tx_parsed,
2020 .help_str = "port config all rxq|txq|rxd|txd <value>",
2022 (void *)&cmd_config_rx_tx_port,
2023 (void *)&cmd_config_rx_tx_keyword,
2024 (void *)&cmd_config_rx_tx_all,
2025 (void *)&cmd_config_rx_tx_name,
2026 (void *)&cmd_config_rx_tx_value,
2031 /* *** config max packet length *** */
2032 struct cmd_config_max_pkt_len_result {
2033 cmdline_fixed_string_t port;
2034 cmdline_fixed_string_t keyword;
2035 cmdline_fixed_string_t all;
2036 cmdline_fixed_string_t name;
2041 cmd_config_max_pkt_len_parsed(void *parsed_result,
2042 __rte_unused struct cmdline *cl,
2043 __rte_unused void *data)
2045 struct cmd_config_max_pkt_len_result *res = parsed_result;
2048 if (!all_ports_stopped()) {
2049 printf("Please stop all ports first\n");
2053 RTE_ETH_FOREACH_DEV(pid) {
2054 struct rte_port *port = &ports[pid];
2055 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
2057 if (!strcmp(res->name, "max-pkt-len")) {
2058 if (res->value < RTE_ETHER_MIN_LEN) {
2059 printf("max-pkt-len can not be less than %d\n",
2063 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2066 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2067 if (res->value > RTE_ETHER_MAX_LEN)
2068 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2070 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2071 port->dev_conf.rxmode.offloads = rx_offloads;
2073 printf("Unknown parameter\n");
2080 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2083 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2084 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2086 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2087 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2089 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2090 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2092 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2093 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2095 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2096 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2099 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2100 .f = cmd_config_max_pkt_len_parsed,
2102 .help_str = "port config all max-pkt-len <value>",
2104 (void *)&cmd_config_max_pkt_len_port,
2105 (void *)&cmd_config_max_pkt_len_keyword,
2106 (void *)&cmd_config_max_pkt_len_all,
2107 (void *)&cmd_config_max_pkt_len_name,
2108 (void *)&cmd_config_max_pkt_len_value,
2113 /* *** config max LRO aggregated packet size *** */
2114 struct cmd_config_max_lro_pkt_size_result {
2115 cmdline_fixed_string_t port;
2116 cmdline_fixed_string_t keyword;
2117 cmdline_fixed_string_t all;
2118 cmdline_fixed_string_t name;
2123 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2124 __rte_unused struct cmdline *cl,
2125 __rte_unused void *data)
2127 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2130 if (!all_ports_stopped()) {
2131 printf("Please stop all ports first\n");
2135 RTE_ETH_FOREACH_DEV(pid) {
2136 struct rte_port *port = &ports[pid];
2138 if (!strcmp(res->name, "max-lro-pkt-size")) {
2140 port->dev_conf.rxmode.max_lro_pkt_size)
2143 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2145 printf("Unknown parameter\n");
2152 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2155 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2156 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2158 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2159 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2161 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2162 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2164 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2165 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2166 name, "max-lro-pkt-size");
2167 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2168 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2171 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2172 .f = cmd_config_max_lro_pkt_size_parsed,
2174 .help_str = "port config all max-lro-pkt-size <value>",
2176 (void *)&cmd_config_max_lro_pkt_size_port,
2177 (void *)&cmd_config_max_lro_pkt_size_keyword,
2178 (void *)&cmd_config_max_lro_pkt_size_all,
2179 (void *)&cmd_config_max_lro_pkt_size_name,
2180 (void *)&cmd_config_max_lro_pkt_size_value,
2185 /* *** configure port MTU *** */
2186 struct cmd_config_mtu_result {
2187 cmdline_fixed_string_t port;
2188 cmdline_fixed_string_t keyword;
2189 cmdline_fixed_string_t mtu;
2195 cmd_config_mtu_parsed(void *parsed_result,
2196 __rte_unused struct cmdline *cl,
2197 __rte_unused void *data)
2199 struct cmd_config_mtu_result *res = parsed_result;
2201 if (res->value < RTE_ETHER_MIN_LEN) {
2202 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2205 port_mtu_set(res->port_id, res->value);
2208 cmdline_parse_token_string_t cmd_config_mtu_port =
2209 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2211 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2212 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2214 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2215 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2217 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2218 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2219 cmdline_parse_token_num_t cmd_config_mtu_value =
2220 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2222 cmdline_parse_inst_t cmd_config_mtu = {
2223 .f = cmd_config_mtu_parsed,
2225 .help_str = "port config mtu <port_id> <value>",
2227 (void *)&cmd_config_mtu_port,
2228 (void *)&cmd_config_mtu_keyword,
2229 (void *)&cmd_config_mtu_mtu,
2230 (void *)&cmd_config_mtu_port_id,
2231 (void *)&cmd_config_mtu_value,
2236 /* *** configure rx mode *** */
2237 struct cmd_config_rx_mode_flag {
2238 cmdline_fixed_string_t port;
2239 cmdline_fixed_string_t keyword;
2240 cmdline_fixed_string_t all;
2241 cmdline_fixed_string_t name;
2242 cmdline_fixed_string_t value;
2246 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2247 __rte_unused struct cmdline *cl,
2248 __rte_unused void *data)
2250 struct cmd_config_rx_mode_flag *res = parsed_result;
2252 if (!all_ports_stopped()) {
2253 printf("Please stop all ports first\n");
2257 if (!strcmp(res->name, "drop-en")) {
2258 if (!strcmp(res->value, "on"))
2260 else if (!strcmp(res->value, "off"))
2263 printf("Unknown parameter\n");
2267 printf("Unknown parameter\n");
2273 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2276 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2277 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2278 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2279 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2281 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2282 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2283 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2284 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2286 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2287 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2290 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2291 .f = cmd_config_rx_mode_flag_parsed,
2293 .help_str = "port config all drop-en on|off",
2295 (void *)&cmd_config_rx_mode_flag_port,
2296 (void *)&cmd_config_rx_mode_flag_keyword,
2297 (void *)&cmd_config_rx_mode_flag_all,
2298 (void *)&cmd_config_rx_mode_flag_name,
2299 (void *)&cmd_config_rx_mode_flag_value,
2304 /* *** configure rss *** */
2305 struct cmd_config_rss {
2306 cmdline_fixed_string_t port;
2307 cmdline_fixed_string_t keyword;
2308 cmdline_fixed_string_t all;
2309 cmdline_fixed_string_t name;
2310 cmdline_fixed_string_t value;
2314 cmd_config_rss_parsed(void *parsed_result,
2315 __rte_unused struct cmdline *cl,
2316 __rte_unused void *data)
2318 struct cmd_config_rss *res = parsed_result;
2319 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2320 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2321 int use_default = 0;
2322 int all_updated = 1;
2327 if (!strcmp(res->value, "all"))
2328 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2329 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2330 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2331 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU;
2332 else if (!strcmp(res->value, "eth"))
2333 rss_conf.rss_hf = ETH_RSS_ETH;
2334 else if (!strcmp(res->value, "vlan"))
2335 rss_conf.rss_hf = ETH_RSS_VLAN;
2336 else if (!strcmp(res->value, "ip"))
2337 rss_conf.rss_hf = ETH_RSS_IP;
2338 else if (!strcmp(res->value, "udp"))
2339 rss_conf.rss_hf = ETH_RSS_UDP;
2340 else if (!strcmp(res->value, "tcp"))
2341 rss_conf.rss_hf = ETH_RSS_TCP;
2342 else if (!strcmp(res->value, "sctp"))
2343 rss_conf.rss_hf = ETH_RSS_SCTP;
2344 else if (!strcmp(res->value, "ether"))
2345 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2346 else if (!strcmp(res->value, "port"))
2347 rss_conf.rss_hf = ETH_RSS_PORT;
2348 else if (!strcmp(res->value, "vxlan"))
2349 rss_conf.rss_hf = ETH_RSS_VXLAN;
2350 else if (!strcmp(res->value, "geneve"))
2351 rss_conf.rss_hf = ETH_RSS_GENEVE;
2352 else if (!strcmp(res->value, "nvgre"))
2353 rss_conf.rss_hf = ETH_RSS_NVGRE;
2354 else if (!strcmp(res->value, "l3-pre32"))
2355 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2356 else if (!strcmp(res->value, "l3-pre40"))
2357 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2358 else if (!strcmp(res->value, "l3-pre48"))
2359 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2360 else if (!strcmp(res->value, "l3-pre56"))
2361 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2362 else if (!strcmp(res->value, "l3-pre64"))
2363 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2364 else if (!strcmp(res->value, "l3-pre96"))
2365 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2366 else if (!strcmp(res->value, "l3-src-only"))
2367 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2368 else if (!strcmp(res->value, "l3-dst-only"))
2369 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2370 else if (!strcmp(res->value, "l4-src-only"))
2371 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2372 else if (!strcmp(res->value, "l4-dst-only"))
2373 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2374 else if (!strcmp(res->value, "l2-src-only"))
2375 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2376 else if (!strcmp(res->value, "l2-dst-only"))
2377 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2378 else if (!strcmp(res->value, "l2tpv3"))
2379 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2380 else if (!strcmp(res->value, "esp"))
2381 rss_conf.rss_hf = ETH_RSS_ESP;
2382 else if (!strcmp(res->value, "ah"))
2383 rss_conf.rss_hf = ETH_RSS_AH;
2384 else if (!strcmp(res->value, "pfcp"))
2385 rss_conf.rss_hf = ETH_RSS_PFCP;
2386 else if (!strcmp(res->value, "pppoe"))
2387 rss_conf.rss_hf = ETH_RSS_PPPOE;
2388 else if (!strcmp(res->value, "gtpu"))
2389 rss_conf.rss_hf = ETH_RSS_GTPU;
2390 else if (!strcmp(res->value, "none"))
2391 rss_conf.rss_hf = 0;
2392 else if (!strcmp(res->value, "level-default")) {
2393 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2394 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2395 } else if (!strcmp(res->value, "level-outer")) {
2396 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2397 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2398 } else if (!strcmp(res->value, "level-inner")) {
2399 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2400 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2401 } else if (!strcmp(res->value, "default"))
2403 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2404 atoi(res->value) < 64)
2405 rss_conf.rss_hf = 1ULL << atoi(res->value);
2407 printf("Unknown parameter\n");
2410 rss_conf.rss_key = NULL;
2411 /* Update global configuration for RSS types. */
2412 RTE_ETH_FOREACH_DEV(i) {
2413 struct rte_eth_rss_conf local_rss_conf;
2415 ret = eth_dev_info_get_print_err(i, &dev_info);
2420 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2422 local_rss_conf = rss_conf;
2423 local_rss_conf.rss_hf = rss_conf.rss_hf &
2424 dev_info.flow_type_rss_offloads;
2425 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2426 printf("Port %u modified RSS hash function based on hardware support,"
2427 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2428 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2430 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2433 printf("Configuration of RSS hash at ethernet port %d "
2434 "failed with error (%d): %s.\n",
2435 i, -diag, strerror(-diag));
2438 if (all_updated && !use_default) {
2439 rss_hf = rss_conf.rss_hf;
2440 printf("rss_hf %#"PRIx64"\n", rss_hf);
2444 cmdline_parse_token_string_t cmd_config_rss_port =
2445 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2446 cmdline_parse_token_string_t cmd_config_rss_keyword =
2447 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2448 cmdline_parse_token_string_t cmd_config_rss_all =
2449 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2450 cmdline_parse_token_string_t cmd_config_rss_name =
2451 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2452 cmdline_parse_token_string_t cmd_config_rss_value =
2453 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2455 cmdline_parse_inst_t cmd_config_rss = {
2456 .f = cmd_config_rss_parsed,
2458 .help_str = "port config all rss "
2459 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2460 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|level-default|"
2461 "level-outer|level-inner|<flowtype_id>",
2463 (void *)&cmd_config_rss_port,
2464 (void *)&cmd_config_rss_keyword,
2465 (void *)&cmd_config_rss_all,
2466 (void *)&cmd_config_rss_name,
2467 (void *)&cmd_config_rss_value,
2472 /* *** configure rss hash key *** */
2473 struct cmd_config_rss_hash_key {
2474 cmdline_fixed_string_t port;
2475 cmdline_fixed_string_t config;
2477 cmdline_fixed_string_t rss_hash_key;
2478 cmdline_fixed_string_t rss_type;
2479 cmdline_fixed_string_t key;
2483 hexa_digit_to_value(char hexa_digit)
2485 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2486 return (uint8_t) (hexa_digit - '0');
2487 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2488 return (uint8_t) ((hexa_digit - 'a') + 10);
2489 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2490 return (uint8_t) ((hexa_digit - 'A') + 10);
2491 /* Invalid hexa digit */
2496 parse_and_check_key_hexa_digit(char *key, int idx)
2500 hexa_v = hexa_digit_to_value(key[idx]);
2502 printf("invalid key: character %c at position %d is not a "
2503 "valid hexa digit\n", key[idx], idx);
2508 cmd_config_rss_hash_key_parsed(void *parsed_result,
2509 __rte_unused struct cmdline *cl,
2510 __rte_unused void *data)
2512 struct cmd_config_rss_hash_key *res = parsed_result;
2513 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2517 struct rte_eth_dev_info dev_info;
2518 uint8_t hash_key_size;
2522 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2526 if (dev_info.hash_key_size > 0 &&
2527 dev_info.hash_key_size <= sizeof(hash_key))
2528 hash_key_size = dev_info.hash_key_size;
2530 printf("dev_info did not provide a valid hash key size\n");
2533 /* Check the length of the RSS hash key */
2534 key_len = strlen(res->key);
2535 if (key_len != (hash_key_size * 2)) {
2536 printf("key length: %d invalid - key must be a string of %d"
2537 " hexa-decimal numbers\n",
2538 (int) key_len, hash_key_size * 2);
2541 /* Translate RSS hash key into binary representation */
2542 for (i = 0; i < hash_key_size; i++) {
2543 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2546 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2549 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2551 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2555 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2556 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2557 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2558 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2560 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2561 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2562 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2563 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2564 rss_hash_key, "rss-hash-key");
2565 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2566 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2567 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2568 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2569 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2570 "ipv6-tcp-ex#ipv6-udp-ex#"
2571 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2572 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2573 "l2tpv3#esp#ah#pfcp#pppoe#gtpu");
2574 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2575 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2577 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2578 .f = cmd_config_rss_hash_key_parsed,
2580 .help_str = "port config <port_id> rss-hash-key "
2581 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2582 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2583 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2584 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2585 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2586 "l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2587 "<string of hex digits (variable length, NIC dependent)>",
2589 (void *)&cmd_config_rss_hash_key_port,
2590 (void *)&cmd_config_rss_hash_key_config,
2591 (void *)&cmd_config_rss_hash_key_port_id,
2592 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2593 (void *)&cmd_config_rss_hash_key_rss_type,
2594 (void *)&cmd_config_rss_hash_key_value,
2599 /* *** configure port rxq/txq ring size *** */
2600 struct cmd_config_rxtx_ring_size {
2601 cmdline_fixed_string_t port;
2602 cmdline_fixed_string_t config;
2604 cmdline_fixed_string_t rxtxq;
2606 cmdline_fixed_string_t rsize;
2611 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2612 __rte_unused struct cmdline *cl,
2613 __rte_unused void *data)
2615 struct cmd_config_rxtx_ring_size *res = parsed_result;
2616 struct rte_port *port;
2619 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2622 if (res->portid == (portid_t)RTE_PORT_ALL) {
2623 printf("Invalid port id\n");
2627 port = &ports[res->portid];
2629 if (!strcmp(res->rxtxq, "rxq"))
2631 else if (!strcmp(res->rxtxq, "txq"))
2634 printf("Unknown parameter\n");
2638 if (isrx && rx_queue_id_is_invalid(res->qid))
2640 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2643 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2644 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2650 port->nb_rx_desc[res->qid] = res->size;
2652 port->nb_tx_desc[res->qid] = res->size;
2654 cmd_reconfig_device_queue(res->portid, 0, 1);
2657 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2658 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2660 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2661 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2663 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2664 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2666 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2667 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2669 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2670 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2672 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2673 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2674 rsize, "ring_size");
2675 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2676 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2679 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2680 .f = cmd_config_rxtx_ring_size_parsed,
2682 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2684 (void *)&cmd_config_rxtx_ring_size_port,
2685 (void *)&cmd_config_rxtx_ring_size_config,
2686 (void *)&cmd_config_rxtx_ring_size_portid,
2687 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2688 (void *)&cmd_config_rxtx_ring_size_qid,
2689 (void *)&cmd_config_rxtx_ring_size_rsize,
2690 (void *)&cmd_config_rxtx_ring_size_size,
2695 /* *** configure port rxq/txq start/stop *** */
2696 struct cmd_config_rxtx_queue {
2697 cmdline_fixed_string_t port;
2699 cmdline_fixed_string_t rxtxq;
2701 cmdline_fixed_string_t opname;
2705 cmd_config_rxtx_queue_parsed(void *parsed_result,
2706 __rte_unused struct cmdline *cl,
2707 __rte_unused void *data)
2709 struct cmd_config_rxtx_queue *res = parsed_result;
2714 if (test_done == 0) {
2715 printf("Please stop forwarding first\n");
2719 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2722 if (port_is_started(res->portid) != 1) {
2723 printf("Please start port %u first\n", res->portid);
2727 if (!strcmp(res->rxtxq, "rxq"))
2729 else if (!strcmp(res->rxtxq, "txq"))
2732 printf("Unknown parameter\n");
2736 if (isrx && rx_queue_id_is_invalid(res->qid))
2738 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2741 if (!strcmp(res->opname, "start"))
2743 else if (!strcmp(res->opname, "stop"))
2746 printf("Unknown parameter\n");
2750 if (isstart && isrx)
2751 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2752 else if (!isstart && isrx)
2753 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2754 else if (isstart && !isrx)
2755 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2757 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2759 if (ret == -ENOTSUP)
2760 printf("Function not supported in PMD driver\n");
2763 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2764 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2765 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2766 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2767 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2768 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2769 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2770 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2771 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2772 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2775 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2776 .f = cmd_config_rxtx_queue_parsed,
2778 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2780 (void *)&cmd_config_rxtx_queue_port,
2781 (void *)&cmd_config_rxtx_queue_portid,
2782 (void *)&cmd_config_rxtx_queue_rxtxq,
2783 (void *)&cmd_config_rxtx_queue_qid,
2784 (void *)&cmd_config_rxtx_queue_opname,
2789 /* *** configure port rxq/txq deferred start on/off *** */
2790 struct cmd_config_deferred_start_rxtx_queue {
2791 cmdline_fixed_string_t port;
2793 cmdline_fixed_string_t rxtxq;
2795 cmdline_fixed_string_t opname;
2796 cmdline_fixed_string_t state;
2800 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2801 __rte_unused struct cmdline *cl,
2802 __rte_unused void *data)
2804 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2805 struct rte_port *port;
2808 uint8_t needreconfig = 0;
2810 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2813 if (port_is_started(res->port_id) != 0) {
2814 printf("Please stop port %u first\n", res->port_id);
2818 port = &ports[res->port_id];
2820 isrx = !strcmp(res->rxtxq, "rxq");
2822 if (isrx && rx_queue_id_is_invalid(res->qid))
2824 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2827 ison = !strcmp(res->state, "on");
2829 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2830 port->rx_conf[res->qid].rx_deferred_start = ison;
2832 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2833 port->tx_conf[res->qid].tx_deferred_start = ison;
2838 cmd_reconfig_device_queue(res->port_id, 0, 1);
2841 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2842 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2844 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2845 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2847 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2848 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2850 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2851 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2853 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2854 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2855 opname, "deferred_start");
2856 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2857 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2860 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2861 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2863 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2865 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2866 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2867 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2868 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2869 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2870 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2875 /* *** configure port rxq/txq setup *** */
2876 struct cmd_setup_rxtx_queue {
2877 cmdline_fixed_string_t port;
2879 cmdline_fixed_string_t rxtxq;
2881 cmdline_fixed_string_t setup;
2884 /* Common CLI fields for queue setup */
2885 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2886 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2887 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2888 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2889 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2890 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2891 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2892 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2893 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2894 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2897 cmd_setup_rxtx_queue_parsed(
2898 void *parsed_result,
2899 __rte_unused struct cmdline *cl,
2900 __rte_unused void *data)
2902 struct cmd_setup_rxtx_queue *res = parsed_result;
2903 struct rte_port *port;
2904 struct rte_mempool *mp;
2905 unsigned int socket_id;
2909 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2912 if (res->portid == (portid_t)RTE_PORT_ALL) {
2913 printf("Invalid port id\n");
2917 if (!strcmp(res->rxtxq, "rxq"))
2919 else if (!strcmp(res->rxtxq, "txq"))
2922 printf("Unknown parameter\n");
2926 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2927 printf("Invalid rx queue\n");
2929 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2930 printf("Invalid tx queue\n");
2934 port = &ports[res->portid];
2936 socket_id = rxring_numa[res->portid];
2937 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2938 socket_id = port->socket_id;
2940 mp = mbuf_pool_find(socket_id, 0);
2942 printf("Failed to setup RX queue: "
2943 "No mempool allocation"
2944 " on the socket %d\n",
2945 rxring_numa[res->portid]);
2948 ret = rx_queue_setup(res->portid,
2950 port->nb_rx_desc[res->qid],
2952 &port->rx_conf[res->qid],
2955 printf("Failed to setup RX queue\n");
2957 socket_id = txring_numa[res->portid];
2958 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2959 socket_id = port->socket_id;
2961 ret = rte_eth_tx_queue_setup(res->portid,
2963 port->nb_tx_desc[res->qid],
2965 &port->tx_conf[res->qid]);
2967 printf("Failed to setup TX queue\n");
2971 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2972 .f = cmd_setup_rxtx_queue_parsed,
2974 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2976 (void *)&cmd_setup_rxtx_queue_port,
2977 (void *)&cmd_setup_rxtx_queue_portid,
2978 (void *)&cmd_setup_rxtx_queue_rxtxq,
2979 (void *)&cmd_setup_rxtx_queue_qid,
2980 (void *)&cmd_setup_rxtx_queue_setup,
2986 /* *** Configure RSS RETA *** */
2987 struct cmd_config_rss_reta {
2988 cmdline_fixed_string_t port;
2989 cmdline_fixed_string_t keyword;
2991 cmdline_fixed_string_t name;
2992 cmdline_fixed_string_t list_name;
2993 cmdline_fixed_string_t list_of_items;
2997 parse_reta_config(const char *str,
2998 struct rte_eth_rss_reta_entry64 *reta_conf,
2999 uint16_t nb_entries)
3003 uint16_t hash_index, idx, shift;
3006 const char *p, *p0 = str;
3013 unsigned long int_fld[_NUM_FLD];
3014 char *str_fld[_NUM_FLD];
3016 while ((p = strchr(p0,'(')) != NULL) {
3018 if((p0 = strchr(p,')')) == NULL)
3022 if(size >= sizeof(s))
3025 snprintf(s, sizeof(s), "%.*s", size, p);
3026 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
3028 for (i = 0; i < _NUM_FLD; i++) {
3030 int_fld[i] = strtoul(str_fld[i], &end, 0);
3031 if (errno != 0 || end == str_fld[i] ||
3036 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
3037 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
3039 if (hash_index >= nb_entries) {
3040 printf("Invalid RETA hash index=%d\n", hash_index);
3044 idx = hash_index / RTE_RETA_GROUP_SIZE;
3045 shift = hash_index % RTE_RETA_GROUP_SIZE;
3046 reta_conf[idx].mask |= (1ULL << shift);
3047 reta_conf[idx].reta[shift] = nb_queue;
3054 cmd_set_rss_reta_parsed(void *parsed_result,
3055 __rte_unused struct cmdline *cl,
3056 __rte_unused void *data)
3059 struct rte_eth_dev_info dev_info;
3060 struct rte_eth_rss_reta_entry64 reta_conf[8];
3061 struct cmd_config_rss_reta *res = parsed_result;
3063 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3067 if (dev_info.reta_size == 0) {
3068 printf("Redirection table size is 0 which is "
3069 "invalid for RSS\n");
3072 printf("The reta size of port %d is %u\n",
3073 res->port_id, dev_info.reta_size);
3074 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3075 printf("Currently do not support more than %u entries of "
3076 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3080 memset(reta_conf, 0, sizeof(reta_conf));
3081 if (!strcmp(res->list_name, "reta")) {
3082 if (parse_reta_config(res->list_of_items, reta_conf,
3083 dev_info.reta_size)) {
3084 printf("Invalid RSS Redirection Table "
3085 "config entered\n");
3088 ret = rte_eth_dev_rss_reta_update(res->port_id,
3089 reta_conf, dev_info.reta_size);
3091 printf("Bad redirection table parameter, "
3092 "return code = %d \n", ret);
3096 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3097 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3098 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3099 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3100 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3101 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3102 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3103 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3104 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3105 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3106 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3107 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3109 cmdline_parse_inst_t cmd_config_rss_reta = {
3110 .f = cmd_set_rss_reta_parsed,
3112 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3114 (void *)&cmd_config_rss_reta_port,
3115 (void *)&cmd_config_rss_reta_keyword,
3116 (void *)&cmd_config_rss_reta_port_id,
3117 (void *)&cmd_config_rss_reta_name,
3118 (void *)&cmd_config_rss_reta_list_name,
3119 (void *)&cmd_config_rss_reta_list_of_items,
3124 /* *** SHOW PORT RETA INFO *** */
3125 struct cmd_showport_reta {
3126 cmdline_fixed_string_t show;
3127 cmdline_fixed_string_t port;
3129 cmdline_fixed_string_t rss;
3130 cmdline_fixed_string_t reta;
3132 cmdline_fixed_string_t list_of_items;
3136 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3137 uint16_t nb_entries,
3141 const char *p, *p0 = str;
3146 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3147 RTE_RETA_GROUP_SIZE;
3150 p = strchr(p0, '(');
3154 p0 = strchr(p, ')');
3158 if (size >= sizeof(s)) {
3159 printf("The string size exceeds the internal buffer size\n");
3162 snprintf(s, sizeof(s), "%.*s", size, p);
3163 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3164 if (ret <= 0 || ret != num) {
3165 printf("The bits of masks do not match the number of "
3166 "reta entries: %u\n", num);
3169 for (i = 0; i < ret; i++)
3170 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3176 cmd_showport_reta_parsed(void *parsed_result,
3177 __rte_unused struct cmdline *cl,
3178 __rte_unused void *data)
3180 struct cmd_showport_reta *res = parsed_result;
3181 struct rte_eth_rss_reta_entry64 reta_conf[8];
3182 struct rte_eth_dev_info dev_info;
3183 uint16_t max_reta_size;
3186 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3190 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3191 if (res->size == 0 || res->size > max_reta_size) {
3192 printf("Invalid redirection table size: %u (1-%u)\n",
3193 res->size, max_reta_size);
3197 memset(reta_conf, 0, sizeof(reta_conf));
3198 if (showport_parse_reta_config(reta_conf, res->size,
3199 res->list_of_items) < 0) {
3200 printf("Invalid string: %s for reta masks\n",
3201 res->list_of_items);
3204 port_rss_reta_info(res->port_id, reta_conf, res->size);
3207 cmdline_parse_token_string_t cmd_showport_reta_show =
3208 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3209 cmdline_parse_token_string_t cmd_showport_reta_port =
3210 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3211 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3212 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3213 cmdline_parse_token_string_t cmd_showport_reta_rss =
3214 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3215 cmdline_parse_token_string_t cmd_showport_reta_reta =
3216 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3217 cmdline_parse_token_num_t cmd_showport_reta_size =
3218 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3219 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3220 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3221 list_of_items, NULL);
3223 cmdline_parse_inst_t cmd_showport_reta = {
3224 .f = cmd_showport_reta_parsed,
3226 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3228 (void *)&cmd_showport_reta_show,
3229 (void *)&cmd_showport_reta_port,
3230 (void *)&cmd_showport_reta_port_id,
3231 (void *)&cmd_showport_reta_rss,
3232 (void *)&cmd_showport_reta_reta,
3233 (void *)&cmd_showport_reta_size,
3234 (void *)&cmd_showport_reta_list_of_items,
3239 /* *** Show RSS hash configuration *** */
3240 struct cmd_showport_rss_hash {
3241 cmdline_fixed_string_t show;
3242 cmdline_fixed_string_t port;
3244 cmdline_fixed_string_t rss_hash;
3245 cmdline_fixed_string_t rss_type;
3246 cmdline_fixed_string_t key; /* optional argument */
3249 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3250 __rte_unused struct cmdline *cl,
3253 struct cmd_showport_rss_hash *res = parsed_result;
3255 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3258 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3259 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3260 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3261 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3262 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3263 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3264 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3265 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3267 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3268 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3270 cmdline_parse_inst_t cmd_showport_rss_hash = {
3271 .f = cmd_showport_rss_hash_parsed,
3273 .help_str = "show port <port_id> rss-hash",
3275 (void *)&cmd_showport_rss_hash_show,
3276 (void *)&cmd_showport_rss_hash_port,
3277 (void *)&cmd_showport_rss_hash_port_id,
3278 (void *)&cmd_showport_rss_hash_rss_hash,
3283 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3284 .f = cmd_showport_rss_hash_parsed,
3286 .help_str = "show port <port_id> rss-hash key",
3288 (void *)&cmd_showport_rss_hash_show,
3289 (void *)&cmd_showport_rss_hash_port,
3290 (void *)&cmd_showport_rss_hash_port_id,
3291 (void *)&cmd_showport_rss_hash_rss_hash,
3292 (void *)&cmd_showport_rss_hash_rss_key,
3297 /* *** Configure DCB *** */
3298 struct cmd_config_dcb {
3299 cmdline_fixed_string_t port;
3300 cmdline_fixed_string_t config;
3302 cmdline_fixed_string_t dcb;
3303 cmdline_fixed_string_t vt;
3304 cmdline_fixed_string_t vt_en;
3306 cmdline_fixed_string_t pfc;
3307 cmdline_fixed_string_t pfc_en;
3311 cmd_config_dcb_parsed(void *parsed_result,
3312 __rte_unused struct cmdline *cl,
3313 __rte_unused void *data)
3315 struct cmd_config_dcb *res = parsed_result;
3316 portid_t port_id = res->port_id;
3317 struct rte_port *port;
3321 port = &ports[port_id];
3322 /** Check if the port is not started **/
3323 if (port->port_status != RTE_PORT_STOPPED) {
3324 printf("Please stop port %d first\n", port_id);
3328 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3329 printf("The invalid number of traffic class,"
3330 " only 4 or 8 allowed.\n");
3334 if (nb_fwd_lcores < res->num_tcs) {
3335 printf("nb_cores shouldn't be less than number of TCs.\n");
3338 if (!strncmp(res->pfc_en, "on", 2))
3343 /* DCB in VT mode */
3344 if (!strncmp(res->vt_en, "on", 2))
3345 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3346 (enum rte_eth_nb_tcs)res->num_tcs,
3349 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3350 (enum rte_eth_nb_tcs)res->num_tcs,
3355 printf("Cannot initialize network ports.\n");
3359 cmd_reconfig_device_queue(port_id, 1, 1);
3362 cmdline_parse_token_string_t cmd_config_dcb_port =
3363 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3364 cmdline_parse_token_string_t cmd_config_dcb_config =
3365 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3366 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3367 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3368 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3369 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3370 cmdline_parse_token_string_t cmd_config_dcb_vt =
3371 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3372 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3373 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3374 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3375 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3376 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3377 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3378 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3379 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3381 cmdline_parse_inst_t cmd_config_dcb = {
3382 .f = cmd_config_dcb_parsed,
3384 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3386 (void *)&cmd_config_dcb_port,
3387 (void *)&cmd_config_dcb_config,
3388 (void *)&cmd_config_dcb_port_id,
3389 (void *)&cmd_config_dcb_dcb,
3390 (void *)&cmd_config_dcb_vt,
3391 (void *)&cmd_config_dcb_vt_en,
3392 (void *)&cmd_config_dcb_num_tcs,
3393 (void *)&cmd_config_dcb_pfc,
3394 (void *)&cmd_config_dcb_pfc_en,
3399 /* *** configure number of packets per burst *** */
3400 struct cmd_config_burst {
3401 cmdline_fixed_string_t port;
3402 cmdline_fixed_string_t keyword;
3403 cmdline_fixed_string_t all;
3404 cmdline_fixed_string_t name;
3409 cmd_config_burst_parsed(void *parsed_result,
3410 __rte_unused struct cmdline *cl,
3411 __rte_unused void *data)
3413 struct cmd_config_burst *res = parsed_result;
3414 struct rte_eth_dev_info dev_info;
3415 uint16_t rec_nb_pkts;
3418 if (!all_ports_stopped()) {
3419 printf("Please stop all ports first\n");
3423 if (!strcmp(res->name, "burst")) {
3424 if (res->value == 0) {
3425 /* If user gives a value of zero, query the PMD for
3426 * its recommended Rx burst size. Testpmd uses a single
3427 * size for all ports, so assume all ports are the same
3428 * NIC model and use the values from Port 0.
3430 ret = eth_dev_info_get_print_err(0, &dev_info);
3434 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3436 if (rec_nb_pkts == 0) {
3437 printf("PMD does not recommend a burst size.\n"
3438 "User provided value must be between"
3439 " 1 and %d\n", MAX_PKT_BURST);
3441 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3442 printf("PMD recommended burst size of %d"
3443 " exceeds maximum value of %d\n",
3444 rec_nb_pkts, MAX_PKT_BURST);
3447 printf("Using PMD-provided burst value of %d\n",
3449 nb_pkt_per_burst = rec_nb_pkts;
3450 } else if (res->value > MAX_PKT_BURST) {
3451 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3454 nb_pkt_per_burst = res->value;
3456 printf("Unknown parameter\n");
3462 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3465 cmdline_parse_token_string_t cmd_config_burst_port =
3466 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3467 cmdline_parse_token_string_t cmd_config_burst_keyword =
3468 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3469 cmdline_parse_token_string_t cmd_config_burst_all =
3470 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3471 cmdline_parse_token_string_t cmd_config_burst_name =
3472 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3473 cmdline_parse_token_num_t cmd_config_burst_value =
3474 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3476 cmdline_parse_inst_t cmd_config_burst = {
3477 .f = cmd_config_burst_parsed,
3479 .help_str = "port config all burst <value>",
3481 (void *)&cmd_config_burst_port,
3482 (void *)&cmd_config_burst_keyword,
3483 (void *)&cmd_config_burst_all,
3484 (void *)&cmd_config_burst_name,
3485 (void *)&cmd_config_burst_value,
3490 /* *** configure rx/tx queues *** */
3491 struct cmd_config_thresh {
3492 cmdline_fixed_string_t port;
3493 cmdline_fixed_string_t keyword;
3494 cmdline_fixed_string_t all;
3495 cmdline_fixed_string_t name;
3500 cmd_config_thresh_parsed(void *parsed_result,
3501 __rte_unused struct cmdline *cl,
3502 __rte_unused void *data)
3504 struct cmd_config_thresh *res = parsed_result;
3506 if (!all_ports_stopped()) {
3507 printf("Please stop all ports first\n");
3511 if (!strcmp(res->name, "txpt"))
3512 tx_pthresh = res->value;
3513 else if(!strcmp(res->name, "txht"))
3514 tx_hthresh = res->value;
3515 else if(!strcmp(res->name, "txwt"))
3516 tx_wthresh = res->value;
3517 else if(!strcmp(res->name, "rxpt"))
3518 rx_pthresh = res->value;
3519 else if(!strcmp(res->name, "rxht"))
3520 rx_hthresh = res->value;
3521 else if(!strcmp(res->name, "rxwt"))
3522 rx_wthresh = res->value;
3524 printf("Unknown parameter\n");
3530 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3533 cmdline_parse_token_string_t cmd_config_thresh_port =
3534 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3535 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3536 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3537 cmdline_parse_token_string_t cmd_config_thresh_all =
3538 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3539 cmdline_parse_token_string_t cmd_config_thresh_name =
3540 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3541 "txpt#txht#txwt#rxpt#rxht#rxwt");
3542 cmdline_parse_token_num_t cmd_config_thresh_value =
3543 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3545 cmdline_parse_inst_t cmd_config_thresh = {
3546 .f = cmd_config_thresh_parsed,
3548 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3550 (void *)&cmd_config_thresh_port,
3551 (void *)&cmd_config_thresh_keyword,
3552 (void *)&cmd_config_thresh_all,
3553 (void *)&cmd_config_thresh_name,
3554 (void *)&cmd_config_thresh_value,
3559 /* *** configure free/rs threshold *** */
3560 struct cmd_config_threshold {
3561 cmdline_fixed_string_t port;
3562 cmdline_fixed_string_t keyword;
3563 cmdline_fixed_string_t all;
3564 cmdline_fixed_string_t name;
3569 cmd_config_threshold_parsed(void *parsed_result,
3570 __rte_unused struct cmdline *cl,
3571 __rte_unused void *data)
3573 struct cmd_config_threshold *res = parsed_result;
3575 if (!all_ports_stopped()) {
3576 printf("Please stop all ports first\n");
3580 if (!strcmp(res->name, "txfreet"))
3581 tx_free_thresh = res->value;
3582 else if (!strcmp(res->name, "txrst"))
3583 tx_rs_thresh = res->value;
3584 else if (!strcmp(res->name, "rxfreet"))
3585 rx_free_thresh = res->value;
3587 printf("Unknown parameter\n");
3593 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3596 cmdline_parse_token_string_t cmd_config_threshold_port =
3597 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3598 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3599 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3601 cmdline_parse_token_string_t cmd_config_threshold_all =
3602 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3603 cmdline_parse_token_string_t cmd_config_threshold_name =
3604 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3605 "txfreet#txrst#rxfreet");
3606 cmdline_parse_token_num_t cmd_config_threshold_value =
3607 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3609 cmdline_parse_inst_t cmd_config_threshold = {
3610 .f = cmd_config_threshold_parsed,
3612 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3614 (void *)&cmd_config_threshold_port,
3615 (void *)&cmd_config_threshold_keyword,
3616 (void *)&cmd_config_threshold_all,
3617 (void *)&cmd_config_threshold_name,
3618 (void *)&cmd_config_threshold_value,
3624 struct cmd_stop_result {
3625 cmdline_fixed_string_t stop;
3628 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3629 __rte_unused struct cmdline *cl,
3630 __rte_unused void *data)
3632 stop_packet_forwarding();
3635 cmdline_parse_token_string_t cmd_stop_stop =
3636 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3638 cmdline_parse_inst_t cmd_stop = {
3639 .f = cmd_stop_parsed,
3641 .help_str = "stop: Stop packet forwarding",
3643 (void *)&cmd_stop_stop,
3648 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3651 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3652 unsigned int *parsed_items, int check_unique_values)
3654 unsigned int nb_item;
3662 * First parse all items in the list and store their value.
3667 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3669 if ((c >= '0') && (c <= '9')) {
3670 value = (unsigned int) (value * 10 + (c - '0'));
3675 printf("character %c is not a decimal digit\n", c);
3679 printf("No valid value before comma\n");
3682 if (nb_item < max_items) {
3683 parsed_items[nb_item] = value;
3689 if (nb_item >= max_items) {
3690 printf("Number of %s = %u > %u (maximum items)\n",
3691 item_name, nb_item + 1, max_items);
3694 parsed_items[nb_item++] = value;
3695 if (! check_unique_values)
3699 * Then, check that all values in the list are differents.
3700 * No optimization here...
3702 for (i = 0; i < nb_item; i++) {
3703 for (j = i + 1; j < nb_item; j++) {
3704 if (parsed_items[j] == parsed_items[i]) {
3705 printf("duplicated %s %u at index %u and %u\n",
3706 item_name, parsed_items[i], i, j);
3714 struct cmd_set_list_result {
3715 cmdline_fixed_string_t cmd_keyword;
3716 cmdline_fixed_string_t list_name;
3717 cmdline_fixed_string_t list_of_items;
3720 static void cmd_set_list_parsed(void *parsed_result,
3721 __rte_unused struct cmdline *cl,
3722 __rte_unused void *data)
3724 struct cmd_set_list_result *res;
3726 unsigned int lcorelist[RTE_MAX_LCORE];
3727 unsigned int portlist[RTE_MAX_ETHPORTS];
3729 unsigned int nb_item;
3731 if (test_done == 0) {
3732 printf("Please stop forwarding first\n");
3736 res = parsed_result;
3737 if (!strcmp(res->list_name, "corelist")) {
3738 nb_item = parse_item_list(res->list_of_items, "core",
3740 parsed_items.lcorelist, 1);
3742 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3747 if (!strcmp(res->list_name, "portlist")) {
3748 nb_item = parse_item_list(res->list_of_items, "port",
3750 parsed_items.portlist, 1);
3752 set_fwd_ports_list(parsed_items.portlist, nb_item);
3758 cmdline_parse_token_string_t cmd_set_list_keyword =
3759 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3761 cmdline_parse_token_string_t cmd_set_list_name =
3762 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3763 "corelist#portlist");
3764 cmdline_parse_token_string_t cmd_set_list_of_items =
3765 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3768 cmdline_parse_inst_t cmd_set_fwd_list = {
3769 .f = cmd_set_list_parsed,
3771 .help_str = "set corelist|portlist <list0[,list1]*>",
3773 (void *)&cmd_set_list_keyword,
3774 (void *)&cmd_set_list_name,
3775 (void *)&cmd_set_list_of_items,
3780 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3782 struct cmd_setmask_result {
3783 cmdline_fixed_string_t set;
3784 cmdline_fixed_string_t mask;
3788 static void cmd_set_mask_parsed(void *parsed_result,
3789 __rte_unused struct cmdline *cl,
3790 __rte_unused void *data)
3792 struct cmd_setmask_result *res = parsed_result;
3794 if (test_done == 0) {
3795 printf("Please stop forwarding first\n");
3798 if (!strcmp(res->mask, "coremask")) {
3799 set_fwd_lcores_mask(res->hexavalue);
3801 } else if (!strcmp(res->mask, "portmask")) {
3802 set_fwd_ports_mask(res->hexavalue);
3807 cmdline_parse_token_string_t cmd_setmask_set =
3808 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3809 cmdline_parse_token_string_t cmd_setmask_mask =
3810 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3811 "coremask#portmask");
3812 cmdline_parse_token_num_t cmd_setmask_value =
3813 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3815 cmdline_parse_inst_t cmd_set_fwd_mask = {
3816 .f = cmd_set_mask_parsed,
3818 .help_str = "set coremask|portmask <hexadecimal value>",
3820 (void *)&cmd_setmask_set,
3821 (void *)&cmd_setmask_mask,
3822 (void *)&cmd_setmask_value,
3828 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3830 struct cmd_set_result {
3831 cmdline_fixed_string_t set;
3832 cmdline_fixed_string_t what;
3836 static void cmd_set_parsed(void *parsed_result,
3837 __rte_unused struct cmdline *cl,
3838 __rte_unused void *data)
3840 struct cmd_set_result *res = parsed_result;
3841 if (!strcmp(res->what, "nbport")) {
3842 set_fwd_ports_number(res->value);
3844 } else if (!strcmp(res->what, "nbcore")) {
3845 set_fwd_lcores_number(res->value);
3847 } else if (!strcmp(res->what, "burst"))
3848 set_nb_pkt_per_burst(res->value);
3849 else if (!strcmp(res->what, "verbose"))
3850 set_verbose_level(res->value);
3853 cmdline_parse_token_string_t cmd_set_set =
3854 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3855 cmdline_parse_token_string_t cmd_set_what =
3856 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3857 "nbport#nbcore#burst#verbose");
3858 cmdline_parse_token_num_t cmd_set_value =
3859 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3861 cmdline_parse_inst_t cmd_set_numbers = {
3862 .f = cmd_set_parsed,
3864 .help_str = "set nbport|nbcore|burst|verbose <value>",
3866 (void *)&cmd_set_set,
3867 (void *)&cmd_set_what,
3868 (void *)&cmd_set_value,
3873 /* *** SET LOG LEVEL CONFIGURATION *** */
3875 struct cmd_set_log_result {
3876 cmdline_fixed_string_t set;
3877 cmdline_fixed_string_t log;
3878 cmdline_fixed_string_t type;
3883 cmd_set_log_parsed(void *parsed_result,
3884 __rte_unused struct cmdline *cl,
3885 __rte_unused void *data)
3887 struct cmd_set_log_result *res;
3890 res = parsed_result;
3891 if (!strcmp(res->type, "global"))
3892 rte_log_set_global_level(res->level);
3894 ret = rte_log_set_level_regexp(res->type, res->level);
3896 printf("Unable to set log level\n");
3900 cmdline_parse_token_string_t cmd_set_log_set =
3901 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3902 cmdline_parse_token_string_t cmd_set_log_log =
3903 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3904 cmdline_parse_token_string_t cmd_set_log_type =
3905 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3906 cmdline_parse_token_num_t cmd_set_log_level =
3907 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3909 cmdline_parse_inst_t cmd_set_log = {
3910 .f = cmd_set_log_parsed,
3912 .help_str = "set log global|<type> <level>",
3914 (void *)&cmd_set_log_set,
3915 (void *)&cmd_set_log_log,
3916 (void *)&cmd_set_log_type,
3917 (void *)&cmd_set_log_level,
3922 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3924 struct cmd_set_rxoffs_result {
3925 cmdline_fixed_string_t cmd_keyword;
3926 cmdline_fixed_string_t rxoffs;
3927 cmdline_fixed_string_t seg_offsets;
3931 cmd_set_rxoffs_parsed(void *parsed_result,
3932 __rte_unused struct cmdline *cl,
3933 __rte_unused void *data)
3935 struct cmd_set_rxoffs_result *res;
3936 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3937 unsigned int nb_segs;
3939 res = parsed_result;
3940 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3941 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3943 set_rx_pkt_offsets(seg_offsets, nb_segs);
3946 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3947 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3948 cmd_keyword, "set");
3949 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3950 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3952 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3953 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3956 cmdline_parse_inst_t cmd_set_rxoffs = {
3957 .f = cmd_set_rxoffs_parsed,
3959 .help_str = "set rxoffs <len0[,len1]*>",
3961 (void *)&cmd_set_rxoffs_keyword,
3962 (void *)&cmd_set_rxoffs_name,
3963 (void *)&cmd_set_rxoffs_offsets,
3968 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3970 struct cmd_set_rxpkts_result {
3971 cmdline_fixed_string_t cmd_keyword;
3972 cmdline_fixed_string_t rxpkts;
3973 cmdline_fixed_string_t seg_lengths;
3977 cmd_set_rxpkts_parsed(void *parsed_result,
3978 __rte_unused struct cmdline *cl,
3979 __rte_unused void *data)
3981 struct cmd_set_rxpkts_result *res;
3982 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3983 unsigned int nb_segs;
3985 res = parsed_result;
3986 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3987 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3989 set_rx_pkt_segments(seg_lengths, nb_segs);
3992 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3993 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3994 cmd_keyword, "set");
3995 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3996 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3998 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3999 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4002 cmdline_parse_inst_t cmd_set_rxpkts = {
4003 .f = cmd_set_rxpkts_parsed,
4005 .help_str = "set rxpkts <len0[,len1]*>",
4007 (void *)&cmd_set_rxpkts_keyword,
4008 (void *)&cmd_set_rxpkts_name,
4009 (void *)&cmd_set_rxpkts_lengths,
4014 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
4016 struct cmd_set_txpkts_result {
4017 cmdline_fixed_string_t cmd_keyword;
4018 cmdline_fixed_string_t txpkts;
4019 cmdline_fixed_string_t seg_lengths;
4023 cmd_set_txpkts_parsed(void *parsed_result,
4024 __rte_unused struct cmdline *cl,
4025 __rte_unused void *data)
4027 struct cmd_set_txpkts_result *res;
4028 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4029 unsigned int nb_segs;
4031 res = parsed_result;
4032 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4033 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4035 set_tx_pkt_segments(seg_lengths, nb_segs);
4038 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4039 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4040 cmd_keyword, "set");
4041 cmdline_parse_token_string_t cmd_set_txpkts_name =
4042 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4044 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4045 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4048 cmdline_parse_inst_t cmd_set_txpkts = {
4049 .f = cmd_set_txpkts_parsed,
4051 .help_str = "set txpkts <len0[,len1]*>",
4053 (void *)&cmd_set_txpkts_keyword,
4054 (void *)&cmd_set_txpkts_name,
4055 (void *)&cmd_set_txpkts_lengths,
4060 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4062 struct cmd_set_txsplit_result {
4063 cmdline_fixed_string_t cmd_keyword;
4064 cmdline_fixed_string_t txsplit;
4065 cmdline_fixed_string_t mode;
4069 cmd_set_txsplit_parsed(void *parsed_result,
4070 __rte_unused struct cmdline *cl,
4071 __rte_unused void *data)
4073 struct cmd_set_txsplit_result *res;
4075 res = parsed_result;
4076 set_tx_pkt_split(res->mode);
4079 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4080 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4081 cmd_keyword, "set");
4082 cmdline_parse_token_string_t cmd_set_txsplit_name =
4083 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4084 txsplit, "txsplit");
4085 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4086 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4089 cmdline_parse_inst_t cmd_set_txsplit = {
4090 .f = cmd_set_txsplit_parsed,
4092 .help_str = "set txsplit on|off|rand",
4094 (void *)&cmd_set_txsplit_keyword,
4095 (void *)&cmd_set_txsplit_name,
4096 (void *)&cmd_set_txsplit_mode,
4101 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4103 struct cmd_set_txtimes_result {
4104 cmdline_fixed_string_t cmd_keyword;
4105 cmdline_fixed_string_t txtimes;
4106 cmdline_fixed_string_t tx_times;
4110 cmd_set_txtimes_parsed(void *parsed_result,
4111 __rte_unused struct cmdline *cl,
4112 __rte_unused void *data)
4114 struct cmd_set_txtimes_result *res;
4115 unsigned int tx_times[2] = {0, 0};
4116 unsigned int n_times;
4118 res = parsed_result;
4119 n_times = parse_item_list(res->tx_times, "tx times",
4122 set_tx_pkt_times(tx_times);
4125 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4126 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4127 cmd_keyword, "set");
4128 cmdline_parse_token_string_t cmd_set_txtimes_name =
4129 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4130 txtimes, "txtimes");
4131 cmdline_parse_token_string_t cmd_set_txtimes_value =
4132 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4135 cmdline_parse_inst_t cmd_set_txtimes = {
4136 .f = cmd_set_txtimes_parsed,
4138 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4140 (void *)&cmd_set_txtimes_keyword,
4141 (void *)&cmd_set_txtimes_name,
4142 (void *)&cmd_set_txtimes_value,
4147 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4148 struct cmd_rx_vlan_filter_all_result {
4149 cmdline_fixed_string_t rx_vlan;
4150 cmdline_fixed_string_t what;
4151 cmdline_fixed_string_t all;
4156 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4157 __rte_unused struct cmdline *cl,
4158 __rte_unused void *data)
4160 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4162 if (!strcmp(res->what, "add"))
4163 rx_vlan_all_filter_set(res->port_id, 1);
4165 rx_vlan_all_filter_set(res->port_id, 0);
4168 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4169 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4170 rx_vlan, "rx_vlan");
4171 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4172 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4174 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4175 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4177 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4178 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4181 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4182 .f = cmd_rx_vlan_filter_all_parsed,
4184 .help_str = "rx_vlan add|rm all <port_id>: "
4185 "Add/Remove all identifiers to/from the set of VLAN "
4186 "identifiers filtered by a port",
4188 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4189 (void *)&cmd_rx_vlan_filter_all_what,
4190 (void *)&cmd_rx_vlan_filter_all_all,
4191 (void *)&cmd_rx_vlan_filter_all_portid,
4196 /* *** VLAN OFFLOAD SET ON A PORT *** */
4197 struct cmd_vlan_offload_result {
4198 cmdline_fixed_string_t vlan;
4199 cmdline_fixed_string_t set;
4200 cmdline_fixed_string_t vlan_type;
4201 cmdline_fixed_string_t what;
4202 cmdline_fixed_string_t on;
4203 cmdline_fixed_string_t port_id;
4207 cmd_vlan_offload_parsed(void *parsed_result,
4208 __rte_unused struct cmdline *cl,
4209 __rte_unused void *data)
4212 struct cmd_vlan_offload_result *res = parsed_result;
4215 portid_t port_id = 0;
4219 len = strnlen(str, STR_TOKEN_SIZE);
4221 /* Get port_id first */
4229 tmp = strtoul(str, NULL, 0);
4230 /* If port_id greater that what portid_t can represent, return */
4231 if(tmp >= RTE_MAX_ETHPORTS)
4233 port_id = (portid_t)tmp;
4235 if (!strcmp(res->on, "on"))
4240 if (!strcmp(res->what, "strip"))
4241 rx_vlan_strip_set(port_id, on);
4242 else if(!strcmp(res->what, "stripq")){
4243 uint16_t queue_id = 0;
4245 /* No queue_id, return */
4247 printf("must specify (port,queue_id)\n");
4250 tmp = strtoul(str + i + 1, NULL, 0);
4251 /* If queue_id greater that what 16-bits can represent, return */
4255 queue_id = (uint16_t)tmp;
4256 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4258 else if (!strcmp(res->what, "filter"))
4259 rx_vlan_filter_set(port_id, on);
4260 else if (!strcmp(res->what, "qinq_strip"))
4261 rx_vlan_qinq_strip_set(port_id, on);
4263 vlan_extend_set(port_id, on);
4268 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4269 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4271 cmdline_parse_token_string_t cmd_vlan_offload_set =
4272 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4274 cmdline_parse_token_string_t cmd_vlan_offload_what =
4275 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4276 what, "strip#filter#qinq_strip#extend#stripq");
4277 cmdline_parse_token_string_t cmd_vlan_offload_on =
4278 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4280 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4281 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4284 cmdline_parse_inst_t cmd_vlan_offload = {
4285 .f = cmd_vlan_offload_parsed,
4287 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4288 "<port_id[,queue_id]>: "
4289 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4291 (void *)&cmd_vlan_offload_vlan,
4292 (void *)&cmd_vlan_offload_set,
4293 (void *)&cmd_vlan_offload_what,
4294 (void *)&cmd_vlan_offload_on,
4295 (void *)&cmd_vlan_offload_portid,
4300 /* *** VLAN TPID SET ON A PORT *** */
4301 struct cmd_vlan_tpid_result {
4302 cmdline_fixed_string_t vlan;
4303 cmdline_fixed_string_t set;
4304 cmdline_fixed_string_t vlan_type;
4305 cmdline_fixed_string_t what;
4311 cmd_vlan_tpid_parsed(void *parsed_result,
4312 __rte_unused struct cmdline *cl,
4313 __rte_unused void *data)
4315 struct cmd_vlan_tpid_result *res = parsed_result;
4316 enum rte_vlan_type vlan_type;
4318 if (!strcmp(res->vlan_type, "inner"))
4319 vlan_type = ETH_VLAN_TYPE_INNER;
4320 else if (!strcmp(res->vlan_type, "outer"))
4321 vlan_type = ETH_VLAN_TYPE_OUTER;
4323 printf("Unknown vlan type\n");
4326 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4329 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4330 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4332 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4333 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4335 cmdline_parse_token_string_t cmd_vlan_type =
4336 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4337 vlan_type, "inner#outer");
4338 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4339 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4341 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4342 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4344 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4345 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4348 cmdline_parse_inst_t cmd_vlan_tpid = {
4349 .f = cmd_vlan_tpid_parsed,
4351 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4352 "Set the VLAN Ether type",
4354 (void *)&cmd_vlan_tpid_vlan,
4355 (void *)&cmd_vlan_tpid_set,
4356 (void *)&cmd_vlan_type,
4357 (void *)&cmd_vlan_tpid_what,
4358 (void *)&cmd_vlan_tpid_tpid,
4359 (void *)&cmd_vlan_tpid_portid,
4364 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4365 struct cmd_rx_vlan_filter_result {
4366 cmdline_fixed_string_t rx_vlan;
4367 cmdline_fixed_string_t what;
4373 cmd_rx_vlan_filter_parsed(void *parsed_result,
4374 __rte_unused struct cmdline *cl,
4375 __rte_unused void *data)
4377 struct cmd_rx_vlan_filter_result *res = parsed_result;
4379 if (!strcmp(res->what, "add"))
4380 rx_vft_set(res->port_id, res->vlan_id, 1);
4382 rx_vft_set(res->port_id, res->vlan_id, 0);
4385 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4386 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4387 rx_vlan, "rx_vlan");
4388 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4389 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4391 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4392 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4394 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4395 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4398 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4399 .f = cmd_rx_vlan_filter_parsed,
4401 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4402 "Add/Remove a VLAN identifier to/from the set of VLAN "
4403 "identifiers filtered by a port",
4405 (void *)&cmd_rx_vlan_filter_rx_vlan,
4406 (void *)&cmd_rx_vlan_filter_what,
4407 (void *)&cmd_rx_vlan_filter_vlanid,
4408 (void *)&cmd_rx_vlan_filter_portid,
4413 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4414 struct cmd_tx_vlan_set_result {
4415 cmdline_fixed_string_t tx_vlan;
4416 cmdline_fixed_string_t set;
4422 cmd_tx_vlan_set_parsed(void *parsed_result,
4423 __rte_unused struct cmdline *cl,
4424 __rte_unused void *data)
4426 struct cmd_tx_vlan_set_result *res = parsed_result;
4428 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4431 if (!port_is_stopped(res->port_id)) {
4432 printf("Please stop port %d first\n", res->port_id);
4436 tx_vlan_set(res->port_id, res->vlan_id);
4438 cmd_reconfig_device_queue(res->port_id, 1, 1);
4441 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4442 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4443 tx_vlan, "tx_vlan");
4444 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4445 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4447 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4448 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4450 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4451 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4454 cmdline_parse_inst_t cmd_tx_vlan_set = {
4455 .f = cmd_tx_vlan_set_parsed,
4457 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4458 "Enable hardware insertion of a single VLAN header "
4459 "with a given TAG Identifier in packets sent on a port",
4461 (void *)&cmd_tx_vlan_set_tx_vlan,
4462 (void *)&cmd_tx_vlan_set_set,
4463 (void *)&cmd_tx_vlan_set_portid,
4464 (void *)&cmd_tx_vlan_set_vlanid,
4469 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4470 struct cmd_tx_vlan_set_qinq_result {
4471 cmdline_fixed_string_t tx_vlan;
4472 cmdline_fixed_string_t set;
4475 uint16_t vlan_id_outer;
4479 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4480 __rte_unused struct cmdline *cl,
4481 __rte_unused void *data)
4483 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4485 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4488 if (!port_is_stopped(res->port_id)) {
4489 printf("Please stop port %d first\n", res->port_id);
4493 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4495 cmd_reconfig_device_queue(res->port_id, 1, 1);
4498 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4499 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4500 tx_vlan, "tx_vlan");
4501 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4502 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4504 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4505 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4507 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4508 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4510 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4511 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4512 vlan_id_outer, UINT16);
4514 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4515 .f = cmd_tx_vlan_set_qinq_parsed,
4517 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4518 "Enable hardware insertion of double VLAN header "
4519 "with given TAG Identifiers in packets sent on a port",
4521 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4522 (void *)&cmd_tx_vlan_set_qinq_set,
4523 (void *)&cmd_tx_vlan_set_qinq_portid,
4524 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4525 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4530 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4531 struct cmd_tx_vlan_set_pvid_result {
4532 cmdline_fixed_string_t tx_vlan;
4533 cmdline_fixed_string_t set;
4534 cmdline_fixed_string_t pvid;
4537 cmdline_fixed_string_t mode;
4541 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4542 __rte_unused struct cmdline *cl,
4543 __rte_unused void *data)
4545 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4547 if (strcmp(res->mode, "on") == 0)
4548 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4550 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4553 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4554 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4555 tx_vlan, "tx_vlan");
4556 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4557 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4559 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4560 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4562 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4563 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4565 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4566 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4568 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4569 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4572 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4573 .f = cmd_tx_vlan_set_pvid_parsed,
4575 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4577 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4578 (void *)&cmd_tx_vlan_set_pvid_set,
4579 (void *)&cmd_tx_vlan_set_pvid_pvid,
4580 (void *)&cmd_tx_vlan_set_pvid_port_id,
4581 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4582 (void *)&cmd_tx_vlan_set_pvid_mode,
4587 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4588 struct cmd_tx_vlan_reset_result {
4589 cmdline_fixed_string_t tx_vlan;
4590 cmdline_fixed_string_t reset;
4595 cmd_tx_vlan_reset_parsed(void *parsed_result,
4596 __rte_unused struct cmdline *cl,
4597 __rte_unused void *data)
4599 struct cmd_tx_vlan_reset_result *res = parsed_result;
4601 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4604 if (!port_is_stopped(res->port_id)) {
4605 printf("Please stop port %d first\n", res->port_id);
4609 tx_vlan_reset(res->port_id);
4611 cmd_reconfig_device_queue(res->port_id, 1, 1);
4614 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4615 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4616 tx_vlan, "tx_vlan");
4617 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4618 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4620 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4621 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4624 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4625 .f = cmd_tx_vlan_reset_parsed,
4627 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4628 "VLAN header in packets sent on a port",
4630 (void *)&cmd_tx_vlan_reset_tx_vlan,
4631 (void *)&cmd_tx_vlan_reset_reset,
4632 (void *)&cmd_tx_vlan_reset_portid,
4638 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4639 struct cmd_csum_result {
4640 cmdline_fixed_string_t csum;
4641 cmdline_fixed_string_t mode;
4642 cmdline_fixed_string_t proto;
4643 cmdline_fixed_string_t hwsw;
4648 csum_show(int port_id)
4650 struct rte_eth_dev_info dev_info;
4651 uint64_t tx_offloads;
4654 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4655 printf("Parse tunnel is %s\n",
4656 (ports[port_id].parse_tunnel) ? "on" : "off");
4657 printf("IP checksum offload is %s\n",
4658 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4659 printf("UDP checksum offload is %s\n",
4660 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4661 printf("TCP checksum offload is %s\n",
4662 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4663 printf("SCTP checksum offload is %s\n",
4664 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4665 printf("Outer-Ip checksum offload is %s\n",
4666 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4667 printf("Outer-Udp checksum offload is %s\n",
4668 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4670 /* display warnings if configuration is not supported by the NIC */
4671 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4675 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4676 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4677 printf("Warning: hardware IP checksum enabled but not "
4678 "supported by port %d\n", port_id);
4680 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4681 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4682 printf("Warning: hardware UDP checksum enabled but not "
4683 "supported by port %d\n", port_id);
4685 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4686 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4687 printf("Warning: hardware TCP checksum enabled but not "
4688 "supported by port %d\n", port_id);
4690 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4691 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4692 printf("Warning: hardware SCTP checksum enabled but not "
4693 "supported by port %d\n", port_id);
4695 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4696 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4697 printf("Warning: hardware outer IP checksum enabled but not "
4698 "supported by port %d\n", port_id);
4700 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4701 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4703 printf("Warning: hardware outer UDP checksum enabled but not "
4704 "supported by port %d\n", port_id);
4709 cmd_config_queue_tx_offloads(struct rte_port *port)
4713 /* Apply queue tx offloads configuration */
4714 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4715 port->tx_conf[k].offloads =
4716 port->dev_conf.txmode.offloads;
4720 cmd_csum_parsed(void *parsed_result,
4721 __rte_unused struct cmdline *cl,
4722 __rte_unused void *data)
4724 struct cmd_csum_result *res = parsed_result;
4726 uint64_t csum_offloads = 0;
4727 struct rte_eth_dev_info dev_info;
4730 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4731 printf("invalid port %d\n", res->port_id);
4734 if (!port_is_stopped(res->port_id)) {
4735 printf("Please stop port %d first\n", res->port_id);
4739 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4743 if (!strcmp(res->mode, "set")) {
4745 if (!strcmp(res->hwsw, "hw"))
4748 if (!strcmp(res->proto, "ip")) {
4749 if (hw == 0 || (dev_info.tx_offload_capa &
4750 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4751 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4753 printf("IP checksum offload is not supported "
4754 "by port %u\n", res->port_id);
4756 } else if (!strcmp(res->proto, "udp")) {
4757 if (hw == 0 || (dev_info.tx_offload_capa &
4758 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4759 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4761 printf("UDP checksum offload is not supported "
4762 "by port %u\n", res->port_id);
4764 } else if (!strcmp(res->proto, "tcp")) {
4765 if (hw == 0 || (dev_info.tx_offload_capa &
4766 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4767 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4769 printf("TCP checksum offload is not supported "
4770 "by port %u\n", res->port_id);
4772 } else if (!strcmp(res->proto, "sctp")) {
4773 if (hw == 0 || (dev_info.tx_offload_capa &
4774 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4775 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4777 printf("SCTP checksum offload is not supported "
4778 "by port %u\n", res->port_id);
4780 } else if (!strcmp(res->proto, "outer-ip")) {
4781 if (hw == 0 || (dev_info.tx_offload_capa &
4782 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4784 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4786 printf("Outer IP checksum offload is not "
4787 "supported by port %u\n", res->port_id);
4789 } else if (!strcmp(res->proto, "outer-udp")) {
4790 if (hw == 0 || (dev_info.tx_offload_capa &
4791 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4793 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4795 printf("Outer UDP checksum offload is not "
4796 "supported by port %u\n", res->port_id);
4801 ports[res->port_id].dev_conf.txmode.offloads |=
4804 ports[res->port_id].dev_conf.txmode.offloads &=
4807 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4809 csum_show(res->port_id);
4811 cmd_reconfig_device_queue(res->port_id, 1, 1);
4814 cmdline_parse_token_string_t cmd_csum_csum =
4815 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4817 cmdline_parse_token_string_t cmd_csum_mode =
4818 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4820 cmdline_parse_token_string_t cmd_csum_proto =
4821 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4822 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4823 cmdline_parse_token_string_t cmd_csum_hwsw =
4824 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4826 cmdline_parse_token_num_t cmd_csum_portid =
4827 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4830 cmdline_parse_inst_t cmd_csum_set = {
4831 .f = cmd_csum_parsed,
4833 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4834 "Enable/Disable hardware calculation of L3/L4 checksum when "
4835 "using csum forward engine",
4837 (void *)&cmd_csum_csum,
4838 (void *)&cmd_csum_mode,
4839 (void *)&cmd_csum_proto,
4840 (void *)&cmd_csum_hwsw,
4841 (void *)&cmd_csum_portid,
4846 cmdline_parse_token_string_t cmd_csum_mode_show =
4847 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4850 cmdline_parse_inst_t cmd_csum_show = {
4851 .f = cmd_csum_parsed,
4853 .help_str = "csum show <port_id>: Show checksum offload configuration",
4855 (void *)&cmd_csum_csum,
4856 (void *)&cmd_csum_mode_show,
4857 (void *)&cmd_csum_portid,
4862 /* Enable/disable tunnel parsing */
4863 struct cmd_csum_tunnel_result {
4864 cmdline_fixed_string_t csum;
4865 cmdline_fixed_string_t parse;
4866 cmdline_fixed_string_t onoff;
4871 cmd_csum_tunnel_parsed(void *parsed_result,
4872 __rte_unused struct cmdline *cl,
4873 __rte_unused void *data)
4875 struct cmd_csum_tunnel_result *res = parsed_result;
4877 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4880 if (!strcmp(res->onoff, "on"))
4881 ports[res->port_id].parse_tunnel = 1;
4883 ports[res->port_id].parse_tunnel = 0;
4885 csum_show(res->port_id);
4888 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4889 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4891 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4892 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4893 parse, "parse-tunnel");
4894 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4895 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4897 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4898 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4901 cmdline_parse_inst_t cmd_csum_tunnel = {
4902 .f = cmd_csum_tunnel_parsed,
4904 .help_str = "csum parse-tunnel on|off <port_id>: "
4905 "Enable/Disable parsing of tunnels for csum engine",
4907 (void *)&cmd_csum_tunnel_csum,
4908 (void *)&cmd_csum_tunnel_parse,
4909 (void *)&cmd_csum_tunnel_onoff,
4910 (void *)&cmd_csum_tunnel_portid,
4915 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4916 struct cmd_tso_set_result {
4917 cmdline_fixed_string_t tso;
4918 cmdline_fixed_string_t mode;
4924 cmd_tso_set_parsed(void *parsed_result,
4925 __rte_unused struct cmdline *cl,
4926 __rte_unused void *data)
4928 struct cmd_tso_set_result *res = parsed_result;
4929 struct rte_eth_dev_info dev_info;
4932 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4934 if (!port_is_stopped(res->port_id)) {
4935 printf("Please stop port %d first\n", res->port_id);
4939 if (!strcmp(res->mode, "set"))
4940 ports[res->port_id].tso_segsz = res->tso_segsz;
4942 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4946 if ((ports[res->port_id].tso_segsz != 0) &&
4947 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4948 printf("Error: TSO is not supported by port %d\n",
4953 if (ports[res->port_id].tso_segsz == 0) {
4954 ports[res->port_id].dev_conf.txmode.offloads &=
4955 ~DEV_TX_OFFLOAD_TCP_TSO;
4956 printf("TSO for non-tunneled packets is disabled\n");
4958 ports[res->port_id].dev_conf.txmode.offloads |=
4959 DEV_TX_OFFLOAD_TCP_TSO;
4960 printf("TSO segment size for non-tunneled packets is %d\n",
4961 ports[res->port_id].tso_segsz);
4963 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4965 /* display warnings if configuration is not supported by the NIC */
4966 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4970 if ((ports[res->port_id].tso_segsz != 0) &&
4971 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4972 printf("Warning: TSO enabled but not "
4973 "supported by port %d\n", res->port_id);
4976 cmd_reconfig_device_queue(res->port_id, 1, 1);
4979 cmdline_parse_token_string_t cmd_tso_set_tso =
4980 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4982 cmdline_parse_token_string_t cmd_tso_set_mode =
4983 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4985 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4986 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4988 cmdline_parse_token_num_t cmd_tso_set_portid =
4989 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4992 cmdline_parse_inst_t cmd_tso_set = {
4993 .f = cmd_tso_set_parsed,
4995 .help_str = "tso set <tso_segsz> <port_id>: "
4996 "Set TSO segment size of non-tunneled packets for csum engine "
4999 (void *)&cmd_tso_set_tso,
5000 (void *)&cmd_tso_set_mode,
5001 (void *)&cmd_tso_set_tso_segsz,
5002 (void *)&cmd_tso_set_portid,
5007 cmdline_parse_token_string_t cmd_tso_show_mode =
5008 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5012 cmdline_parse_inst_t cmd_tso_show = {
5013 .f = cmd_tso_set_parsed,
5015 .help_str = "tso show <port_id>: "
5016 "Show TSO segment size of non-tunneled packets for csum engine",
5018 (void *)&cmd_tso_set_tso,
5019 (void *)&cmd_tso_show_mode,
5020 (void *)&cmd_tso_set_portid,
5025 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5026 struct cmd_tunnel_tso_set_result {
5027 cmdline_fixed_string_t tso;
5028 cmdline_fixed_string_t mode;
5033 static struct rte_eth_dev_info
5034 check_tunnel_tso_nic_support(portid_t port_id)
5036 struct rte_eth_dev_info dev_info;
5038 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5041 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
5042 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
5043 "not enabled for port %d\n", port_id);
5044 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
5045 printf("Warning: GRE TUNNEL TSO not supported therefore "
5046 "not enabled for port %d\n", port_id);
5047 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
5048 printf("Warning: IPIP TUNNEL TSO not supported therefore "
5049 "not enabled for port %d\n", port_id);
5050 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
5051 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
5052 "not enabled for port %d\n", port_id);
5053 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
5054 printf("Warning: IP TUNNEL TSO not supported therefore "
5055 "not enabled for port %d\n", port_id);
5056 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
5057 printf("Warning: UDP TUNNEL TSO not supported therefore "
5058 "not enabled for port %d\n", port_id);
5063 cmd_tunnel_tso_set_parsed(void *parsed_result,
5064 __rte_unused struct cmdline *cl,
5065 __rte_unused void *data)
5067 struct cmd_tunnel_tso_set_result *res = parsed_result;
5068 struct rte_eth_dev_info dev_info;
5070 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5072 if (!port_is_stopped(res->port_id)) {
5073 printf("Please stop port %d first\n", res->port_id);
5077 if (!strcmp(res->mode, "set"))
5078 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5080 dev_info = check_tunnel_tso_nic_support(res->port_id);
5081 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5082 ports[res->port_id].dev_conf.txmode.offloads &=
5083 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5084 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5085 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5086 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5087 DEV_TX_OFFLOAD_IP_TNL_TSO |
5088 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5089 printf("TSO for tunneled packets is disabled\n");
5091 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5092 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5093 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5094 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5095 DEV_TX_OFFLOAD_IP_TNL_TSO |
5096 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5098 ports[res->port_id].dev_conf.txmode.offloads |=
5099 (tso_offloads & dev_info.tx_offload_capa);
5100 printf("TSO segment size for tunneled packets is %d\n",
5101 ports[res->port_id].tunnel_tso_segsz);
5103 /* Below conditions are needed to make it work:
5104 * (1) tunnel TSO is supported by the NIC;
5105 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5107 * (3) for tunneled pkts with outer L3 of IPv4,
5108 * "csum set outer-ip" must be set to hw, because after tso,
5109 * total_len of outer IP header is changed, and the checksum
5110 * of outer IP header calculated by sw should be wrong; that
5111 * is not necessary for IPv6 tunneled pkts because there's no
5112 * checksum in IP header anymore.
5115 if (!ports[res->port_id].parse_tunnel)
5116 printf("Warning: csum parse_tunnel must be set "
5117 "so that tunneled packets are recognized\n");
5118 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5119 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5120 printf("Warning: csum set outer-ip must be set to hw "
5121 "if outer L3 is IPv4; not necessary for IPv6\n");
5124 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5125 cmd_reconfig_device_queue(res->port_id, 1, 1);
5128 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5129 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5131 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5132 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5134 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5135 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5137 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5138 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5141 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5142 .f = cmd_tunnel_tso_set_parsed,
5144 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5145 "Set TSO segment size of tunneled packets for csum engine "
5148 (void *)&cmd_tunnel_tso_set_tso,
5149 (void *)&cmd_tunnel_tso_set_mode,
5150 (void *)&cmd_tunnel_tso_set_tso_segsz,
5151 (void *)&cmd_tunnel_tso_set_portid,
5156 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5157 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5161 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5162 .f = cmd_tunnel_tso_set_parsed,
5164 .help_str = "tunnel_tso show <port_id> "
5165 "Show TSO segment size of tunneled packets for csum engine",
5167 (void *)&cmd_tunnel_tso_set_tso,
5168 (void *)&cmd_tunnel_tso_show_mode,
5169 (void *)&cmd_tunnel_tso_set_portid,
5174 /* *** SET GRO FOR A PORT *** */
5175 struct cmd_gro_enable_result {
5176 cmdline_fixed_string_t cmd_set;
5177 cmdline_fixed_string_t cmd_port;
5178 cmdline_fixed_string_t cmd_keyword;
5179 cmdline_fixed_string_t cmd_onoff;
5184 cmd_gro_enable_parsed(void *parsed_result,
5185 __rte_unused struct cmdline *cl,
5186 __rte_unused void *data)
5188 struct cmd_gro_enable_result *res;
5190 res = parsed_result;
5191 if (!strcmp(res->cmd_keyword, "gro"))
5192 setup_gro(res->cmd_onoff, res->cmd_pid);
5195 cmdline_parse_token_string_t cmd_gro_enable_set =
5196 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5198 cmdline_parse_token_string_t cmd_gro_enable_port =
5199 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5200 cmd_keyword, "port");
5201 cmdline_parse_token_num_t cmd_gro_enable_pid =
5202 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5204 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5205 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5206 cmd_keyword, "gro");
5207 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5208 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5209 cmd_onoff, "on#off");
5211 cmdline_parse_inst_t cmd_gro_enable = {
5212 .f = cmd_gro_enable_parsed,
5214 .help_str = "set port <port_id> gro on|off",
5216 (void *)&cmd_gro_enable_set,
5217 (void *)&cmd_gro_enable_port,
5218 (void *)&cmd_gro_enable_pid,
5219 (void *)&cmd_gro_enable_keyword,
5220 (void *)&cmd_gro_enable_onoff,
5225 /* *** DISPLAY GRO CONFIGURATION *** */
5226 struct cmd_gro_show_result {
5227 cmdline_fixed_string_t cmd_show;
5228 cmdline_fixed_string_t cmd_port;
5229 cmdline_fixed_string_t cmd_keyword;
5234 cmd_gro_show_parsed(void *parsed_result,
5235 __rte_unused struct cmdline *cl,
5236 __rte_unused void *data)
5238 struct cmd_gro_show_result *res;
5240 res = parsed_result;
5241 if (!strcmp(res->cmd_keyword, "gro"))
5242 show_gro(res->cmd_pid);
5245 cmdline_parse_token_string_t cmd_gro_show_show =
5246 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5248 cmdline_parse_token_string_t cmd_gro_show_port =
5249 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5251 cmdline_parse_token_num_t cmd_gro_show_pid =
5252 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5254 cmdline_parse_token_string_t cmd_gro_show_keyword =
5255 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5256 cmd_keyword, "gro");
5258 cmdline_parse_inst_t cmd_gro_show = {
5259 .f = cmd_gro_show_parsed,
5261 .help_str = "show port <port_id> gro",
5263 (void *)&cmd_gro_show_show,
5264 (void *)&cmd_gro_show_port,
5265 (void *)&cmd_gro_show_pid,
5266 (void *)&cmd_gro_show_keyword,
5271 /* *** SET FLUSH CYCLES FOR GRO *** */
5272 struct cmd_gro_flush_result {
5273 cmdline_fixed_string_t cmd_set;
5274 cmdline_fixed_string_t cmd_keyword;
5275 cmdline_fixed_string_t cmd_flush;
5280 cmd_gro_flush_parsed(void *parsed_result,
5281 __rte_unused struct cmdline *cl,
5282 __rte_unused void *data)
5284 struct cmd_gro_flush_result *res;
5286 res = parsed_result;
5287 if ((!strcmp(res->cmd_keyword, "gro")) &&
5288 (!strcmp(res->cmd_flush, "flush")))
5289 setup_gro_flush_cycles(res->cmd_cycles);
5292 cmdline_parse_token_string_t cmd_gro_flush_set =
5293 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5295 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5296 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5297 cmd_keyword, "gro");
5298 cmdline_parse_token_string_t cmd_gro_flush_flush =
5299 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5300 cmd_flush, "flush");
5301 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5302 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5305 cmdline_parse_inst_t cmd_gro_flush = {
5306 .f = cmd_gro_flush_parsed,
5308 .help_str = "set gro flush <cycles>",
5310 (void *)&cmd_gro_flush_set,
5311 (void *)&cmd_gro_flush_keyword,
5312 (void *)&cmd_gro_flush_flush,
5313 (void *)&cmd_gro_flush_cycles,
5318 /* *** ENABLE/DISABLE GSO *** */
5319 struct cmd_gso_enable_result {
5320 cmdline_fixed_string_t cmd_set;
5321 cmdline_fixed_string_t cmd_port;
5322 cmdline_fixed_string_t cmd_keyword;
5323 cmdline_fixed_string_t cmd_mode;
5328 cmd_gso_enable_parsed(void *parsed_result,
5329 __rte_unused struct cmdline *cl,
5330 __rte_unused void *data)
5332 struct cmd_gso_enable_result *res;
5334 res = parsed_result;
5335 if (!strcmp(res->cmd_keyword, "gso"))
5336 setup_gso(res->cmd_mode, res->cmd_pid);
5339 cmdline_parse_token_string_t cmd_gso_enable_set =
5340 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5342 cmdline_parse_token_string_t cmd_gso_enable_port =
5343 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5345 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5346 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5347 cmd_keyword, "gso");
5348 cmdline_parse_token_string_t cmd_gso_enable_mode =
5349 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5350 cmd_mode, "on#off");
5351 cmdline_parse_token_num_t cmd_gso_enable_pid =
5352 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5355 cmdline_parse_inst_t cmd_gso_enable = {
5356 .f = cmd_gso_enable_parsed,
5358 .help_str = "set port <port_id> gso on|off",
5360 (void *)&cmd_gso_enable_set,
5361 (void *)&cmd_gso_enable_port,
5362 (void *)&cmd_gso_enable_pid,
5363 (void *)&cmd_gso_enable_keyword,
5364 (void *)&cmd_gso_enable_mode,
5369 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5370 struct cmd_gso_size_result {
5371 cmdline_fixed_string_t cmd_set;
5372 cmdline_fixed_string_t cmd_keyword;
5373 cmdline_fixed_string_t cmd_segsz;
5378 cmd_gso_size_parsed(void *parsed_result,
5379 __rte_unused struct cmdline *cl,
5380 __rte_unused void *data)
5382 struct cmd_gso_size_result *res = parsed_result;
5384 if (test_done == 0) {
5385 printf("Before setting GSO segsz, please first"
5386 " stop forwarding\n");
5390 if (!strcmp(res->cmd_keyword, "gso") &&
5391 !strcmp(res->cmd_segsz, "segsz")) {
5392 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5393 printf("gso_size should be larger than %zu."
5394 " Please input a legal value\n",
5395 RTE_GSO_SEG_SIZE_MIN);
5397 gso_max_segment_size = res->cmd_size;
5401 cmdline_parse_token_string_t cmd_gso_size_set =
5402 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5404 cmdline_parse_token_string_t cmd_gso_size_keyword =
5405 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5406 cmd_keyword, "gso");
5407 cmdline_parse_token_string_t cmd_gso_size_segsz =
5408 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5409 cmd_segsz, "segsz");
5410 cmdline_parse_token_num_t cmd_gso_size_size =
5411 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5414 cmdline_parse_inst_t cmd_gso_size = {
5415 .f = cmd_gso_size_parsed,
5417 .help_str = "set gso segsz <length>",
5419 (void *)&cmd_gso_size_set,
5420 (void *)&cmd_gso_size_keyword,
5421 (void *)&cmd_gso_size_segsz,
5422 (void *)&cmd_gso_size_size,
5427 /* *** SHOW GSO CONFIGURATION *** */
5428 struct cmd_gso_show_result {
5429 cmdline_fixed_string_t cmd_show;
5430 cmdline_fixed_string_t cmd_port;
5431 cmdline_fixed_string_t cmd_keyword;
5436 cmd_gso_show_parsed(void *parsed_result,
5437 __rte_unused struct cmdline *cl,
5438 __rte_unused void *data)
5440 struct cmd_gso_show_result *res = parsed_result;
5442 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5443 printf("invalid port id %u\n", res->cmd_pid);
5446 if (!strcmp(res->cmd_keyword, "gso")) {
5447 if (gso_ports[res->cmd_pid].enable) {
5448 printf("Max GSO'd packet size: %uB\n"
5449 "Supported GSO types: TCP/IPv4, "
5450 "UDP/IPv4, VxLAN with inner "
5451 "TCP/IPv4 packet, GRE with inner "
5452 "TCP/IPv4 packet\n",
5453 gso_max_segment_size);
5455 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5459 cmdline_parse_token_string_t cmd_gso_show_show =
5460 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5462 cmdline_parse_token_string_t cmd_gso_show_port =
5463 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5465 cmdline_parse_token_string_t cmd_gso_show_keyword =
5466 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5467 cmd_keyword, "gso");
5468 cmdline_parse_token_num_t cmd_gso_show_pid =
5469 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5472 cmdline_parse_inst_t cmd_gso_show = {
5473 .f = cmd_gso_show_parsed,
5475 .help_str = "show port <port_id> gso",
5477 (void *)&cmd_gso_show_show,
5478 (void *)&cmd_gso_show_port,
5479 (void *)&cmd_gso_show_pid,
5480 (void *)&cmd_gso_show_keyword,
5485 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5486 struct cmd_set_flush_rx {
5487 cmdline_fixed_string_t set;
5488 cmdline_fixed_string_t flush_rx;
5489 cmdline_fixed_string_t mode;
5493 cmd_set_flush_rx_parsed(void *parsed_result,
5494 __rte_unused struct cmdline *cl,
5495 __rte_unused void *data)
5497 struct cmd_set_flush_rx *res = parsed_result;
5498 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5501 cmdline_parse_token_string_t cmd_setflushrx_set =
5502 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5504 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5505 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5506 flush_rx, "flush_rx");
5507 cmdline_parse_token_string_t cmd_setflushrx_mode =
5508 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5512 cmdline_parse_inst_t cmd_set_flush_rx = {
5513 .f = cmd_set_flush_rx_parsed,
5514 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5517 (void *)&cmd_setflushrx_set,
5518 (void *)&cmd_setflushrx_flush_rx,
5519 (void *)&cmd_setflushrx_mode,
5524 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5525 struct cmd_set_link_check {
5526 cmdline_fixed_string_t set;
5527 cmdline_fixed_string_t link_check;
5528 cmdline_fixed_string_t mode;
5532 cmd_set_link_check_parsed(void *parsed_result,
5533 __rte_unused struct cmdline *cl,
5534 __rte_unused void *data)
5536 struct cmd_set_link_check *res = parsed_result;
5537 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5540 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5541 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5543 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5544 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5545 link_check, "link_check");
5546 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5547 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5551 cmdline_parse_inst_t cmd_set_link_check = {
5552 .f = cmd_set_link_check_parsed,
5553 .help_str = "set link_check on|off: Enable/Disable link status check "
5554 "when starting/stopping a port",
5557 (void *)&cmd_setlinkcheck_set,
5558 (void *)&cmd_setlinkcheck_link_check,
5559 (void *)&cmd_setlinkcheck_mode,
5564 /* *** SET NIC BYPASS MODE *** */
5565 struct cmd_set_bypass_mode_result {
5566 cmdline_fixed_string_t set;
5567 cmdline_fixed_string_t bypass;
5568 cmdline_fixed_string_t mode;
5569 cmdline_fixed_string_t value;
5574 cmd_set_bypass_mode_parsed(void *parsed_result,
5575 __rte_unused struct cmdline *cl,
5576 __rte_unused void *data)
5578 struct cmd_set_bypass_mode_result *res = parsed_result;
5579 portid_t port_id = res->port_id;
5580 int32_t rc = -EINVAL;
5582 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5583 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5585 if (!strcmp(res->value, "bypass"))
5586 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5587 else if (!strcmp(res->value, "isolate"))
5588 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5590 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5592 /* Set the bypass mode for the relevant port. */
5593 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5596 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5599 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5600 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5602 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5603 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5605 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5606 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5608 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5609 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5610 value, "normal#bypass#isolate");
5611 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5612 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5615 cmdline_parse_inst_t cmd_set_bypass_mode = {
5616 .f = cmd_set_bypass_mode_parsed,
5617 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5618 "Set the NIC bypass mode for port_id",
5621 (void *)&cmd_setbypass_mode_set,
5622 (void *)&cmd_setbypass_mode_bypass,
5623 (void *)&cmd_setbypass_mode_mode,
5624 (void *)&cmd_setbypass_mode_value,
5625 (void *)&cmd_setbypass_mode_port,
5630 /* *** SET NIC BYPASS EVENT *** */
5631 struct cmd_set_bypass_event_result {
5632 cmdline_fixed_string_t set;
5633 cmdline_fixed_string_t bypass;
5634 cmdline_fixed_string_t event;
5635 cmdline_fixed_string_t event_value;
5636 cmdline_fixed_string_t mode;
5637 cmdline_fixed_string_t mode_value;
5642 cmd_set_bypass_event_parsed(void *parsed_result,
5643 __rte_unused struct cmdline *cl,
5644 __rte_unused void *data)
5646 int32_t rc = -EINVAL;
5647 struct cmd_set_bypass_event_result *res = parsed_result;
5648 portid_t port_id = res->port_id;
5650 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5651 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5652 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5654 if (!strcmp(res->event_value, "timeout"))
5655 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5656 else if (!strcmp(res->event_value, "os_on"))
5657 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5658 else if (!strcmp(res->event_value, "os_off"))
5659 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5660 else if (!strcmp(res->event_value, "power_on"))
5661 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5662 else if (!strcmp(res->event_value, "power_off"))
5663 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5665 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5667 if (!strcmp(res->mode_value, "bypass"))
5668 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5669 else if (!strcmp(res->mode_value, "isolate"))
5670 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5672 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5674 /* Set the watchdog timeout. */
5675 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5678 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5679 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5683 printf("Failed to set timeout value %u "
5684 "for port %d, errto code: %d.\n",
5685 bypass_timeout, port_id, rc);
5689 /* Set the bypass event to transition to bypass mode. */
5690 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5695 printf("\t Failed to set bypass event for port = %d.\n",
5699 cmdline_parse_token_string_t cmd_setbypass_event_set =
5700 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5702 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5703 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5705 cmdline_parse_token_string_t cmd_setbypass_event_event =
5706 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5708 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5709 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5710 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5711 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5712 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5714 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5715 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5716 mode_value, "normal#bypass#isolate");
5717 cmdline_parse_token_num_t cmd_setbypass_event_port =
5718 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5721 cmdline_parse_inst_t cmd_set_bypass_event = {
5722 .f = cmd_set_bypass_event_parsed,
5723 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5724 "power_off mode normal|bypass|isolate <port_id>: "
5725 "Set the NIC bypass event mode for port_id",
5728 (void *)&cmd_setbypass_event_set,
5729 (void *)&cmd_setbypass_event_bypass,
5730 (void *)&cmd_setbypass_event_event,
5731 (void *)&cmd_setbypass_event_event_value,
5732 (void *)&cmd_setbypass_event_mode,
5733 (void *)&cmd_setbypass_event_mode_value,
5734 (void *)&cmd_setbypass_event_port,
5740 /* *** SET NIC BYPASS TIMEOUT *** */
5741 struct cmd_set_bypass_timeout_result {
5742 cmdline_fixed_string_t set;
5743 cmdline_fixed_string_t bypass;
5744 cmdline_fixed_string_t timeout;
5745 cmdline_fixed_string_t value;
5749 cmd_set_bypass_timeout_parsed(void *parsed_result,
5750 __rte_unused struct cmdline *cl,
5751 __rte_unused void *data)
5753 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5755 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5756 if (!strcmp(res->value, "1.5"))
5757 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5758 else if (!strcmp(res->value, "2"))
5759 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5760 else if (!strcmp(res->value, "3"))
5761 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5762 else if (!strcmp(res->value, "4"))
5763 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5764 else if (!strcmp(res->value, "8"))
5765 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5766 else if (!strcmp(res->value, "16"))
5767 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5768 else if (!strcmp(res->value, "32"))
5769 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5771 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5775 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5776 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5778 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5779 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5781 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5782 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5783 timeout, "timeout");
5784 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5785 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5786 value, "0#1.5#2#3#4#8#16#32");
5788 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5789 .f = cmd_set_bypass_timeout_parsed,
5790 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5791 "Set the NIC bypass watchdog timeout in seconds",
5794 (void *)&cmd_setbypass_timeout_set,
5795 (void *)&cmd_setbypass_timeout_bypass,
5796 (void *)&cmd_setbypass_timeout_timeout,
5797 (void *)&cmd_setbypass_timeout_value,
5802 /* *** SHOW NIC BYPASS MODE *** */
5803 struct cmd_show_bypass_config_result {
5804 cmdline_fixed_string_t show;
5805 cmdline_fixed_string_t bypass;
5806 cmdline_fixed_string_t config;
5811 cmd_show_bypass_config_parsed(void *parsed_result,
5812 __rte_unused struct cmdline *cl,
5813 __rte_unused void *data)
5815 struct cmd_show_bypass_config_result *res = parsed_result;
5816 portid_t port_id = res->port_id;
5818 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5819 uint32_t event_mode;
5820 uint32_t bypass_mode;
5821 uint32_t timeout = bypass_timeout;
5824 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5825 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5826 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5827 {"UNKNOWN", "normal", "bypass", "isolate"};
5828 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5836 /* Display the bypass mode.*/
5837 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5838 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5842 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5843 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5845 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5848 /* Display the bypass timeout.*/
5849 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5850 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5852 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5854 /* Display the bypass events and associated modes. */
5855 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5857 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5858 printf("\tFailed to get bypass mode for event = %s\n",
5861 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5862 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5864 printf("\tbypass event: %-16s = %s\n", events[i],
5870 printf("\tFailed to get bypass configuration for port = %d\n",
5874 cmdline_parse_token_string_t cmd_showbypass_config_show =
5875 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5877 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5878 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5880 cmdline_parse_token_string_t cmd_showbypass_config_config =
5881 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5883 cmdline_parse_token_num_t cmd_showbypass_config_port =
5884 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5887 cmdline_parse_inst_t cmd_show_bypass_config = {
5888 .f = cmd_show_bypass_config_parsed,
5889 .help_str = "show bypass config <port_id>: "
5890 "Show the NIC bypass config for port_id",
5893 (void *)&cmd_showbypass_config_show,
5894 (void *)&cmd_showbypass_config_bypass,
5895 (void *)&cmd_showbypass_config_config,
5896 (void *)&cmd_showbypass_config_port,
5902 /* *** SET BONDING MODE *** */
5903 struct cmd_set_bonding_mode_result {
5904 cmdline_fixed_string_t set;
5905 cmdline_fixed_string_t bonding;
5906 cmdline_fixed_string_t mode;
5911 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5912 __rte_unused struct cmdline *cl,
5913 __rte_unused void *data)
5915 struct cmd_set_bonding_mode_result *res = parsed_result;
5916 portid_t port_id = res->port_id;
5918 /* Set the bonding mode for the relevant port. */
5919 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5920 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5923 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5924 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5926 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5927 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5928 bonding, "bonding");
5929 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5930 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5932 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5933 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5935 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5936 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5939 cmdline_parse_inst_t cmd_set_bonding_mode = {
5940 .f = cmd_set_bonding_mode_parsed,
5941 .help_str = "set bonding mode <mode_value> <port_id>: "
5942 "Set the bonding mode for port_id",
5945 (void *) &cmd_setbonding_mode_set,
5946 (void *) &cmd_setbonding_mode_bonding,
5947 (void *) &cmd_setbonding_mode_mode,
5948 (void *) &cmd_setbonding_mode_value,
5949 (void *) &cmd_setbonding_mode_port,
5954 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5955 struct cmd_set_bonding_lacp_dedicated_queues_result {
5956 cmdline_fixed_string_t set;
5957 cmdline_fixed_string_t bonding;
5958 cmdline_fixed_string_t lacp;
5959 cmdline_fixed_string_t dedicated_queues;
5961 cmdline_fixed_string_t mode;
5964 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5965 __rte_unused struct cmdline *cl,
5966 __rte_unused void *data)
5968 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5969 portid_t port_id = res->port_id;
5970 struct rte_port *port;
5972 port = &ports[port_id];
5974 /** Check if the port is not started **/
5975 if (port->port_status != RTE_PORT_STOPPED) {
5976 printf("Please stop port %d first\n", port_id);
5980 if (!strcmp(res->mode, "enable")) {
5981 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5982 printf("Dedicate queues for LACP control packets"
5985 printf("Enabling dedicate queues for LACP control "
5986 "packets on port %d failed\n", port_id);
5987 } else if (!strcmp(res->mode, "disable")) {
5988 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5989 printf("Dedicated queues for LACP control packets "
5992 printf("Disabling dedicated queues for LACP control "
5993 "traffic on port %d failed\n", port_id);
5997 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5998 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6000 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
6001 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6002 bonding, "bonding");
6003 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
6004 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6006 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
6007 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6008 dedicated_queues, "dedicated_queues");
6009 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6010 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6012 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6013 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6014 mode, "enable#disable");
6016 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6017 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6018 .help_str = "set bonding lacp dedicated_queues <port_id> "
6020 "Enable/disable dedicated queues for LACP control traffic for port_id",
6023 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
6024 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6025 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6026 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6027 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6028 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6033 /* *** SET BALANCE XMIT POLICY *** */
6034 struct cmd_set_bonding_balance_xmit_policy_result {
6035 cmdline_fixed_string_t set;
6036 cmdline_fixed_string_t bonding;
6037 cmdline_fixed_string_t balance_xmit_policy;
6039 cmdline_fixed_string_t policy;
6042 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6043 __rte_unused struct cmdline *cl,
6044 __rte_unused void *data)
6046 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6047 portid_t port_id = res->port_id;
6050 if (!strcmp(res->policy, "l2")) {
6051 policy = BALANCE_XMIT_POLICY_LAYER2;
6052 } else if (!strcmp(res->policy, "l23")) {
6053 policy = BALANCE_XMIT_POLICY_LAYER23;
6054 } else if (!strcmp(res->policy, "l34")) {
6055 policy = BALANCE_XMIT_POLICY_LAYER34;
6057 printf("\t Invalid xmit policy selection");
6061 /* Set the bonding mode for the relevant port. */
6062 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6063 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
6068 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6069 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6071 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6072 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6073 bonding, "bonding");
6074 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6075 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6076 balance_xmit_policy, "balance_xmit_policy");
6077 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6078 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6080 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6081 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6082 policy, "l2#l23#l34");
6084 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6085 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6086 .help_str = "set bonding balance_xmit_policy <port_id> "
6088 "Set the bonding balance_xmit_policy for port_id",
6091 (void *)&cmd_setbonding_balance_xmit_policy_set,
6092 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6093 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6094 (void *)&cmd_setbonding_balance_xmit_policy_port,
6095 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6100 /* *** SHOW NIC BONDING CONFIGURATION *** */
6101 struct cmd_show_bonding_config_result {
6102 cmdline_fixed_string_t show;
6103 cmdline_fixed_string_t bonding;
6104 cmdline_fixed_string_t config;
6108 static void cmd_show_bonding_config_parsed(void *parsed_result,
6109 __rte_unused struct cmdline *cl,
6110 __rte_unused void *data)
6112 struct cmd_show_bonding_config_result *res = parsed_result;
6113 int bonding_mode, agg_mode;
6114 portid_t slaves[RTE_MAX_ETHPORTS];
6115 int num_slaves, num_active_slaves;
6118 portid_t port_id = res->port_id;
6120 /* Display the bonding mode.*/
6121 bonding_mode = rte_eth_bond_mode_get(port_id);
6122 if (bonding_mode < 0) {
6123 printf("\tFailed to get bonding mode for port = %d\n", port_id);
6126 printf("\tBonding mode: %d\n", bonding_mode);
6128 if (bonding_mode == BONDING_MODE_BALANCE) {
6129 int balance_xmit_policy;
6131 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6132 if (balance_xmit_policy < 0) {
6133 printf("\tFailed to get balance xmit policy for port = %d\n",
6137 printf("\tBalance Xmit Policy: ");
6139 switch (balance_xmit_policy) {
6140 case BALANCE_XMIT_POLICY_LAYER2:
6141 printf("BALANCE_XMIT_POLICY_LAYER2");
6143 case BALANCE_XMIT_POLICY_LAYER23:
6144 printf("BALANCE_XMIT_POLICY_LAYER23");
6146 case BALANCE_XMIT_POLICY_LAYER34:
6147 printf("BALANCE_XMIT_POLICY_LAYER34");
6154 if (bonding_mode == BONDING_MODE_8023AD) {
6155 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6156 printf("\tIEEE802.3AD Aggregator Mode: ");
6159 printf("bandwidth");
6171 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6173 if (num_slaves < 0) {
6174 printf("\tFailed to get slave list for port = %d\n", port_id);
6177 if (num_slaves > 0) {
6178 printf("\tSlaves (%d): [", num_slaves);
6179 for (i = 0; i < num_slaves - 1; i++)
6180 printf("%d ", slaves[i]);
6182 printf("%d]\n", slaves[num_slaves - 1]);
6184 printf("\tSlaves: []\n");
6188 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6191 if (num_active_slaves < 0) {
6192 printf("\tFailed to get active slave list for port = %d\n", port_id);
6195 if (num_active_slaves > 0) {
6196 printf("\tActive Slaves (%d): [", num_active_slaves);
6197 for (i = 0; i < num_active_slaves - 1; i++)
6198 printf("%d ", slaves[i]);
6200 printf("%d]\n", slaves[num_active_slaves - 1]);
6203 printf("\tActive Slaves: []\n");
6207 primary_id = rte_eth_bond_primary_get(port_id);
6208 if (primary_id < 0) {
6209 printf("\tFailed to get primary slave for port = %d\n", port_id);
6212 printf("\tPrimary: [%d]\n", primary_id);
6216 cmdline_parse_token_string_t cmd_showbonding_config_show =
6217 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6219 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6220 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6221 bonding, "bonding");
6222 cmdline_parse_token_string_t cmd_showbonding_config_config =
6223 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6225 cmdline_parse_token_num_t cmd_showbonding_config_port =
6226 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6229 cmdline_parse_inst_t cmd_show_bonding_config = {
6230 .f = cmd_show_bonding_config_parsed,
6231 .help_str = "show bonding config <port_id>: "
6232 "Show the bonding config for port_id",
6235 (void *)&cmd_showbonding_config_show,
6236 (void *)&cmd_showbonding_config_bonding,
6237 (void *)&cmd_showbonding_config_config,
6238 (void *)&cmd_showbonding_config_port,
6243 /* *** SET BONDING PRIMARY *** */
6244 struct cmd_set_bonding_primary_result {
6245 cmdline_fixed_string_t set;
6246 cmdline_fixed_string_t bonding;
6247 cmdline_fixed_string_t primary;
6252 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6253 __rte_unused struct cmdline *cl,
6254 __rte_unused void *data)
6256 struct cmd_set_bonding_primary_result *res = parsed_result;
6257 portid_t master_port_id = res->port_id;
6258 portid_t slave_port_id = res->slave_id;
6260 /* Set the primary slave for a bonded device. */
6261 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6262 printf("\t Failed to set primary slave for port = %d.\n",
6269 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6270 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6272 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6273 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6274 bonding, "bonding");
6275 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6276 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6277 primary, "primary");
6278 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6279 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6281 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6282 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6285 cmdline_parse_inst_t cmd_set_bonding_primary = {
6286 .f = cmd_set_bonding_primary_parsed,
6287 .help_str = "set bonding primary <slave_id> <port_id>: "
6288 "Set the primary slave for port_id",
6291 (void *)&cmd_setbonding_primary_set,
6292 (void *)&cmd_setbonding_primary_bonding,
6293 (void *)&cmd_setbonding_primary_primary,
6294 (void *)&cmd_setbonding_primary_slave,
6295 (void *)&cmd_setbonding_primary_port,
6300 /* *** ADD SLAVE *** */
6301 struct cmd_add_bonding_slave_result {
6302 cmdline_fixed_string_t add;
6303 cmdline_fixed_string_t bonding;
6304 cmdline_fixed_string_t slave;
6309 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6310 __rte_unused struct cmdline *cl,
6311 __rte_unused void *data)
6313 struct cmd_add_bonding_slave_result *res = parsed_result;
6314 portid_t master_port_id = res->port_id;
6315 portid_t slave_port_id = res->slave_id;
6317 /* add the slave for a bonded device. */
6318 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6319 printf("\t Failed to add slave %d to master port = %d.\n",
6320 slave_port_id, master_port_id);
6324 set_port_slave_flag(slave_port_id);
6327 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6328 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6330 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6331 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6332 bonding, "bonding");
6333 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6334 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6336 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6337 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6339 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6340 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6343 cmdline_parse_inst_t cmd_add_bonding_slave = {
6344 .f = cmd_add_bonding_slave_parsed,
6345 .help_str = "add bonding slave <slave_id> <port_id>: "
6346 "Add a slave device to a bonded device",
6349 (void *)&cmd_addbonding_slave_add,
6350 (void *)&cmd_addbonding_slave_bonding,
6351 (void *)&cmd_addbonding_slave_slave,
6352 (void *)&cmd_addbonding_slave_slaveid,
6353 (void *)&cmd_addbonding_slave_port,
6358 /* *** REMOVE SLAVE *** */
6359 struct cmd_remove_bonding_slave_result {
6360 cmdline_fixed_string_t remove;
6361 cmdline_fixed_string_t bonding;
6362 cmdline_fixed_string_t slave;
6367 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6368 __rte_unused struct cmdline *cl,
6369 __rte_unused void *data)
6371 struct cmd_remove_bonding_slave_result *res = parsed_result;
6372 portid_t master_port_id = res->port_id;
6373 portid_t slave_port_id = res->slave_id;
6375 /* remove the slave from a bonded device. */
6376 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6377 printf("\t Failed to remove slave %d from master port = %d.\n",
6378 slave_port_id, master_port_id);
6382 clear_port_slave_flag(slave_port_id);
6385 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6386 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6388 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6389 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6390 bonding, "bonding");
6391 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6392 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6394 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6395 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6397 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6398 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6401 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6402 .f = cmd_remove_bonding_slave_parsed,
6403 .help_str = "remove bonding slave <slave_id> <port_id>: "
6404 "Remove a slave device from a bonded device",
6407 (void *)&cmd_removebonding_slave_remove,
6408 (void *)&cmd_removebonding_slave_bonding,
6409 (void *)&cmd_removebonding_slave_slave,
6410 (void *)&cmd_removebonding_slave_slaveid,
6411 (void *)&cmd_removebonding_slave_port,
6416 /* *** CREATE BONDED DEVICE *** */
6417 struct cmd_create_bonded_device_result {
6418 cmdline_fixed_string_t create;
6419 cmdline_fixed_string_t bonded;
6420 cmdline_fixed_string_t device;
6425 static int bond_dev_num = 0;
6427 static void cmd_create_bonded_device_parsed(void *parsed_result,
6428 __rte_unused struct cmdline *cl,
6429 __rte_unused void *data)
6431 struct cmd_create_bonded_device_result *res = parsed_result;
6432 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6436 if (test_done == 0) {
6437 printf("Please stop forwarding first\n");
6441 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6444 /* Create a new bonded device. */
6445 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6447 printf("\t Failed to create bonded device.\n");
6450 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6453 /* Update number of ports */
6454 nb_ports = rte_eth_dev_count_avail();
6455 reconfig(port_id, res->socket);
6456 ret = rte_eth_promiscuous_enable(port_id);
6458 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6459 port_id, rte_strerror(-ret));
6461 ports[port_id].need_setup = 0;
6462 ports[port_id].port_status = RTE_PORT_STOPPED;
6467 cmdline_parse_token_string_t cmd_createbonded_device_create =
6468 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6470 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6471 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6473 cmdline_parse_token_string_t cmd_createbonded_device_device =
6474 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6476 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6477 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6479 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6480 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6483 cmdline_parse_inst_t cmd_create_bonded_device = {
6484 .f = cmd_create_bonded_device_parsed,
6485 .help_str = "create bonded device <mode> <socket>: "
6486 "Create a new bonded device with specific bonding mode and socket",
6489 (void *)&cmd_createbonded_device_create,
6490 (void *)&cmd_createbonded_device_bonded,
6491 (void *)&cmd_createbonded_device_device,
6492 (void *)&cmd_createbonded_device_mode,
6493 (void *)&cmd_createbonded_device_socket,
6498 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6499 struct cmd_set_bond_mac_addr_result {
6500 cmdline_fixed_string_t set;
6501 cmdline_fixed_string_t bonding;
6502 cmdline_fixed_string_t mac_addr;
6504 struct rte_ether_addr address;
6507 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6508 __rte_unused struct cmdline *cl,
6509 __rte_unused void *data)
6511 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6514 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6517 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6519 /* check the return value and print it if is < 0 */
6521 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6524 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6525 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6526 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6527 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6529 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6530 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6532 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6533 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6535 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6536 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6538 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6539 .f = cmd_set_bond_mac_addr_parsed,
6541 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6543 (void *)&cmd_set_bond_mac_addr_set,
6544 (void *)&cmd_set_bond_mac_addr_bonding,
6545 (void *)&cmd_set_bond_mac_addr_mac,
6546 (void *)&cmd_set_bond_mac_addr_portnum,
6547 (void *)&cmd_set_bond_mac_addr_addr,
6553 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6554 struct cmd_set_bond_mon_period_result {
6555 cmdline_fixed_string_t set;
6556 cmdline_fixed_string_t bonding;
6557 cmdline_fixed_string_t mon_period;
6562 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6563 __rte_unused struct cmdline *cl,
6564 __rte_unused void *data)
6566 struct cmd_set_bond_mon_period_result *res = parsed_result;
6569 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6571 /* check the return value and print it if is < 0 */
6573 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6576 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6577 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6579 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6580 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6581 bonding, "bonding");
6582 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6583 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6584 mon_period, "mon_period");
6585 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6586 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6588 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6589 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6592 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6593 .f = cmd_set_bond_mon_period_parsed,
6595 .help_str = "set bonding mon_period <port_id> <period_ms>",
6597 (void *)&cmd_set_bond_mon_period_set,
6598 (void *)&cmd_set_bond_mon_period_bonding,
6599 (void *)&cmd_set_bond_mon_period_mon_period,
6600 (void *)&cmd_set_bond_mon_period_portnum,
6601 (void *)&cmd_set_bond_mon_period_period_ms,
6608 struct cmd_set_bonding_agg_mode_policy_result {
6609 cmdline_fixed_string_t set;
6610 cmdline_fixed_string_t bonding;
6611 cmdline_fixed_string_t agg_mode;
6613 cmdline_fixed_string_t policy;
6618 cmd_set_bonding_agg_mode(void *parsed_result,
6619 __rte_unused struct cmdline *cl,
6620 __rte_unused void *data)
6622 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6623 uint8_t policy = AGG_BANDWIDTH;
6625 if (!strcmp(res->policy, "bandwidth"))
6626 policy = AGG_BANDWIDTH;
6627 else if (!strcmp(res->policy, "stable"))
6628 policy = AGG_STABLE;
6629 else if (!strcmp(res->policy, "count"))
6632 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6636 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6637 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6639 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6640 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6641 bonding, "bonding");
6643 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6644 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6645 agg_mode, "agg_mode");
6647 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6648 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6651 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6652 TOKEN_STRING_INITIALIZER(
6653 struct cmd_set_bonding_balance_xmit_policy_result,
6654 policy, "stable#bandwidth#count");
6656 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6657 .f = cmd_set_bonding_agg_mode,
6659 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6661 (void *)&cmd_set_bonding_agg_mode_set,
6662 (void *)&cmd_set_bonding_agg_mode_bonding,
6663 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6664 (void *)&cmd_set_bonding_agg_mode_portnum,
6665 (void *)&cmd_set_bonding_agg_mode_policy_string,
6671 #endif /* RTE_NET_BOND */
6673 /* *** SET FORWARDING MODE *** */
6674 struct cmd_set_fwd_mode_result {
6675 cmdline_fixed_string_t set;
6676 cmdline_fixed_string_t fwd;
6677 cmdline_fixed_string_t mode;
6680 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6681 __rte_unused struct cmdline *cl,
6682 __rte_unused void *data)
6684 struct cmd_set_fwd_mode_result *res = parsed_result;
6687 set_pkt_forwarding_mode(res->mode);
6690 cmdline_parse_token_string_t cmd_setfwd_set =
6691 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6692 cmdline_parse_token_string_t cmd_setfwd_fwd =
6693 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6694 cmdline_parse_token_string_t cmd_setfwd_mode =
6695 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6696 "" /* defined at init */);
6698 cmdline_parse_inst_t cmd_set_fwd_mode = {
6699 .f = cmd_set_fwd_mode_parsed,
6701 .help_str = NULL, /* defined at init */
6703 (void *)&cmd_setfwd_set,
6704 (void *)&cmd_setfwd_fwd,
6705 (void *)&cmd_setfwd_mode,
6710 static void cmd_set_fwd_mode_init(void)
6713 static char token[128];
6714 static char help[256];
6715 cmdline_parse_token_string_t *token_struct;
6717 modes = list_pkt_forwarding_modes();
6718 snprintf(help, sizeof(help), "set fwd %s: "
6719 "Set packet forwarding mode", modes);
6720 cmd_set_fwd_mode.help_str = help;
6722 /* string token separator is # */
6723 for (c = token; *modes != '\0'; modes++)
6728 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6729 token_struct->string_data.str = token;
6732 /* *** SET RETRY FORWARDING MODE *** */
6733 struct cmd_set_fwd_retry_mode_result {
6734 cmdline_fixed_string_t set;
6735 cmdline_fixed_string_t fwd;
6736 cmdline_fixed_string_t mode;
6737 cmdline_fixed_string_t retry;
6740 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6741 __rte_unused struct cmdline *cl,
6742 __rte_unused void *data)
6744 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6747 set_pkt_forwarding_mode(res->mode);
6750 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6751 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6753 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6754 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6756 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6757 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6759 "" /* defined at init */);
6760 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6761 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6764 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6765 .f = cmd_set_fwd_retry_mode_parsed,
6767 .help_str = NULL, /* defined at init */
6769 (void *)&cmd_setfwd_retry_set,
6770 (void *)&cmd_setfwd_retry_fwd,
6771 (void *)&cmd_setfwd_retry_mode,
6772 (void *)&cmd_setfwd_retry_retry,
6777 static void cmd_set_fwd_retry_mode_init(void)
6780 static char token[128];
6781 static char help[256];
6782 cmdline_parse_token_string_t *token_struct;
6784 modes = list_pkt_forwarding_retry_modes();
6785 snprintf(help, sizeof(help), "set fwd %s retry: "
6786 "Set packet forwarding mode with retry", modes);
6787 cmd_set_fwd_retry_mode.help_str = help;
6789 /* string token separator is # */
6790 for (c = token; *modes != '\0'; modes++)
6795 token_struct = (cmdline_parse_token_string_t *)
6796 cmd_set_fwd_retry_mode.tokens[2];
6797 token_struct->string_data.str = token;
6800 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6801 struct cmd_set_burst_tx_retry_result {
6802 cmdline_fixed_string_t set;
6803 cmdline_fixed_string_t burst;
6804 cmdline_fixed_string_t tx;
6805 cmdline_fixed_string_t delay;
6807 cmdline_fixed_string_t retry;
6811 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6812 __rte_unused struct cmdline *cl,
6813 __rte_unused void *data)
6815 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6817 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6818 && !strcmp(res->tx, "tx")) {
6819 if (!strcmp(res->delay, "delay"))
6820 burst_tx_delay_time = res->time;
6821 if (!strcmp(res->retry, "retry"))
6822 burst_tx_retry_num = res->retry_num;
6827 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6828 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6829 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6830 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6832 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6833 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6834 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6835 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6836 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6837 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6838 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6839 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6840 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6841 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6843 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6844 .f = cmd_set_burst_tx_retry_parsed,
6845 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6847 (void *)&cmd_set_burst_tx_retry_set,
6848 (void *)&cmd_set_burst_tx_retry_burst,
6849 (void *)&cmd_set_burst_tx_retry_tx,
6850 (void *)&cmd_set_burst_tx_retry_delay,
6851 (void *)&cmd_set_burst_tx_retry_time,
6852 (void *)&cmd_set_burst_tx_retry_retry,
6853 (void *)&cmd_set_burst_tx_retry_retry_num,
6858 /* *** SET PROMISC MODE *** */
6859 struct cmd_set_promisc_mode_result {
6860 cmdline_fixed_string_t set;
6861 cmdline_fixed_string_t promisc;
6862 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6863 uint16_t port_num; /* valid if "allports" argument == 0 */
6864 cmdline_fixed_string_t mode;
6867 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6868 __rte_unused struct cmdline *cl,
6871 struct cmd_set_promisc_mode_result *res = parsed_result;
6875 if (!strcmp(res->mode, "on"))
6882 RTE_ETH_FOREACH_DEV(i)
6883 eth_set_promisc_mode(i, enable);
6885 eth_set_promisc_mode(res->port_num, enable);
6889 cmdline_parse_token_string_t cmd_setpromisc_set =
6890 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6891 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6892 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6894 cmdline_parse_token_string_t cmd_setpromisc_portall =
6895 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6897 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6898 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6900 cmdline_parse_token_string_t cmd_setpromisc_mode =
6901 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6904 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6905 .f = cmd_set_promisc_mode_parsed,
6907 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6909 (void *)&cmd_setpromisc_set,
6910 (void *)&cmd_setpromisc_promisc,
6911 (void *)&cmd_setpromisc_portall,
6912 (void *)&cmd_setpromisc_mode,
6917 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6918 .f = cmd_set_promisc_mode_parsed,
6920 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6922 (void *)&cmd_setpromisc_set,
6923 (void *)&cmd_setpromisc_promisc,
6924 (void *)&cmd_setpromisc_portnum,
6925 (void *)&cmd_setpromisc_mode,
6930 /* *** SET ALLMULTI MODE *** */
6931 struct cmd_set_allmulti_mode_result {
6932 cmdline_fixed_string_t set;
6933 cmdline_fixed_string_t allmulti;
6934 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6935 uint16_t port_num; /* valid if "allports" argument == 0 */
6936 cmdline_fixed_string_t mode;
6939 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6940 __rte_unused struct cmdline *cl,
6943 struct cmd_set_allmulti_mode_result *res = parsed_result;
6947 if (!strcmp(res->mode, "on"))
6954 RTE_ETH_FOREACH_DEV(i) {
6955 eth_set_allmulticast_mode(i, enable);
6959 eth_set_allmulticast_mode(res->port_num, enable);
6963 cmdline_parse_token_string_t cmd_setallmulti_set =
6964 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6965 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6966 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6968 cmdline_parse_token_string_t cmd_setallmulti_portall =
6969 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6971 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6972 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6974 cmdline_parse_token_string_t cmd_setallmulti_mode =
6975 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6978 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6979 .f = cmd_set_allmulti_mode_parsed,
6981 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6983 (void *)&cmd_setallmulti_set,
6984 (void *)&cmd_setallmulti_allmulti,
6985 (void *)&cmd_setallmulti_portall,
6986 (void *)&cmd_setallmulti_mode,
6991 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6992 .f = cmd_set_allmulti_mode_parsed,
6994 .help_str = "set allmulti <port_id> on|off: "
6995 "Set allmulti mode on port_id",
6997 (void *)&cmd_setallmulti_set,
6998 (void *)&cmd_setallmulti_allmulti,
6999 (void *)&cmd_setallmulti_portnum,
7000 (void *)&cmd_setallmulti_mode,
7005 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7006 struct cmd_link_flow_ctrl_set_result {
7007 cmdline_fixed_string_t set;
7008 cmdline_fixed_string_t flow_ctrl;
7009 cmdline_fixed_string_t rx;
7010 cmdline_fixed_string_t rx_lfc_mode;
7011 cmdline_fixed_string_t tx;
7012 cmdline_fixed_string_t tx_lfc_mode;
7013 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7014 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7015 cmdline_fixed_string_t autoneg_str;
7016 cmdline_fixed_string_t autoneg;
7017 cmdline_fixed_string_t hw_str;
7018 uint32_t high_water;
7019 cmdline_fixed_string_t lw_str;
7021 cmdline_fixed_string_t pt_str;
7022 uint16_t pause_time;
7023 cmdline_fixed_string_t xon_str;
7028 cmdline_parse_token_string_t cmd_lfc_set_set =
7029 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7031 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7032 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7033 flow_ctrl, "flow_ctrl");
7034 cmdline_parse_token_string_t cmd_lfc_set_rx =
7035 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7037 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7038 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7039 rx_lfc_mode, "on#off");
7040 cmdline_parse_token_string_t cmd_lfc_set_tx =
7041 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7043 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7044 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7045 tx_lfc_mode, "on#off");
7046 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7047 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7048 hw_str, "high_water");
7049 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7050 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7051 high_water, UINT32);
7052 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7053 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7054 lw_str, "low_water");
7055 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7056 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7058 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7059 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7060 pt_str, "pause_time");
7061 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7062 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7063 pause_time, UINT16);
7064 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7065 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7066 xon_str, "send_xon");
7067 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7068 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7070 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7071 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7072 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7073 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7074 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7075 mac_ctrl_frame_fwd_mode, "on#off");
7076 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7077 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7078 autoneg_str, "autoneg");
7079 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7080 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7082 cmdline_parse_token_num_t cmd_lfc_set_portid =
7083 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7086 /* forward declaration */
7088 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7091 cmdline_parse_inst_t cmd_link_flow_control_set = {
7092 .f = cmd_link_flow_ctrl_set_parsed,
7094 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7095 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7096 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7098 (void *)&cmd_lfc_set_set,
7099 (void *)&cmd_lfc_set_flow_ctrl,
7100 (void *)&cmd_lfc_set_rx,
7101 (void *)&cmd_lfc_set_rx_mode,
7102 (void *)&cmd_lfc_set_tx,
7103 (void *)&cmd_lfc_set_tx_mode,
7104 (void *)&cmd_lfc_set_high_water,
7105 (void *)&cmd_lfc_set_low_water,
7106 (void *)&cmd_lfc_set_pause_time,
7107 (void *)&cmd_lfc_set_send_xon,
7108 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7109 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7110 (void *)&cmd_lfc_set_autoneg_str,
7111 (void *)&cmd_lfc_set_autoneg,
7112 (void *)&cmd_lfc_set_portid,
7117 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7118 .f = cmd_link_flow_ctrl_set_parsed,
7119 .data = (void *)&cmd_link_flow_control_set_rx,
7120 .help_str = "set flow_ctrl rx on|off <port_id>: "
7121 "Change rx flow control parameter",
7123 (void *)&cmd_lfc_set_set,
7124 (void *)&cmd_lfc_set_flow_ctrl,
7125 (void *)&cmd_lfc_set_rx,
7126 (void *)&cmd_lfc_set_rx_mode,
7127 (void *)&cmd_lfc_set_portid,
7132 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7133 .f = cmd_link_flow_ctrl_set_parsed,
7134 .data = (void *)&cmd_link_flow_control_set_tx,
7135 .help_str = "set flow_ctrl tx on|off <port_id>: "
7136 "Change tx flow control parameter",
7138 (void *)&cmd_lfc_set_set,
7139 (void *)&cmd_lfc_set_flow_ctrl,
7140 (void *)&cmd_lfc_set_tx,
7141 (void *)&cmd_lfc_set_tx_mode,
7142 (void *)&cmd_lfc_set_portid,
7147 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7148 .f = cmd_link_flow_ctrl_set_parsed,
7149 .data = (void *)&cmd_link_flow_control_set_hw,
7150 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7151 "Change high water flow control parameter",
7153 (void *)&cmd_lfc_set_set,
7154 (void *)&cmd_lfc_set_flow_ctrl,
7155 (void *)&cmd_lfc_set_high_water_str,
7156 (void *)&cmd_lfc_set_high_water,
7157 (void *)&cmd_lfc_set_portid,
7162 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7163 .f = cmd_link_flow_ctrl_set_parsed,
7164 .data = (void *)&cmd_link_flow_control_set_lw,
7165 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7166 "Change low water flow control parameter",
7168 (void *)&cmd_lfc_set_set,
7169 (void *)&cmd_lfc_set_flow_ctrl,
7170 (void *)&cmd_lfc_set_low_water_str,
7171 (void *)&cmd_lfc_set_low_water,
7172 (void *)&cmd_lfc_set_portid,
7177 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7178 .f = cmd_link_flow_ctrl_set_parsed,
7179 .data = (void *)&cmd_link_flow_control_set_pt,
7180 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7181 "Change pause time flow control parameter",
7183 (void *)&cmd_lfc_set_set,
7184 (void *)&cmd_lfc_set_flow_ctrl,
7185 (void *)&cmd_lfc_set_pause_time_str,
7186 (void *)&cmd_lfc_set_pause_time,
7187 (void *)&cmd_lfc_set_portid,
7192 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7193 .f = cmd_link_flow_ctrl_set_parsed,
7194 .data = (void *)&cmd_link_flow_control_set_xon,
7195 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7196 "Change send_xon flow control parameter",
7198 (void *)&cmd_lfc_set_set,
7199 (void *)&cmd_lfc_set_flow_ctrl,
7200 (void *)&cmd_lfc_set_send_xon_str,
7201 (void *)&cmd_lfc_set_send_xon,
7202 (void *)&cmd_lfc_set_portid,
7207 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7208 .f = cmd_link_flow_ctrl_set_parsed,
7209 .data = (void *)&cmd_link_flow_control_set_macfwd,
7210 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7211 "Change mac ctrl fwd flow control parameter",
7213 (void *)&cmd_lfc_set_set,
7214 (void *)&cmd_lfc_set_flow_ctrl,
7215 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7216 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7217 (void *)&cmd_lfc_set_portid,
7222 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7223 .f = cmd_link_flow_ctrl_set_parsed,
7224 .data = (void *)&cmd_link_flow_control_set_autoneg,
7225 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7226 "Change autoneg flow control parameter",
7228 (void *)&cmd_lfc_set_set,
7229 (void *)&cmd_lfc_set_flow_ctrl,
7230 (void *)&cmd_lfc_set_autoneg_str,
7231 (void *)&cmd_lfc_set_autoneg,
7232 (void *)&cmd_lfc_set_portid,
7238 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7239 __rte_unused struct cmdline *cl,
7242 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7243 cmdline_parse_inst_t *cmd = data;
7244 struct rte_eth_fc_conf fc_conf;
7250 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7251 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7252 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7253 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7255 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7256 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7259 /* Partial command line, retrieve current configuration */
7261 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7263 printf("cannot get current flow ctrl parameters, return"
7264 "code = %d\n", ret);
7268 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7269 (fc_conf.mode == RTE_FC_FULL))
7271 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7272 (fc_conf.mode == RTE_FC_FULL))
7276 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7277 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7279 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7280 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7282 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7284 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7285 fc_conf.high_water = res->high_water;
7287 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7288 fc_conf.low_water = res->low_water;
7290 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7291 fc_conf.pause_time = res->pause_time;
7293 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7294 fc_conf.send_xon = res->send_xon;
7296 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7297 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7298 fc_conf.mac_ctrl_frame_fwd = 1;
7300 fc_conf.mac_ctrl_frame_fwd = 0;
7303 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7304 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7306 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7308 printf("bad flow contrl parameter, return code = %d \n", ret);
7311 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7312 struct cmd_priority_flow_ctrl_set_result {
7313 cmdline_fixed_string_t set;
7314 cmdline_fixed_string_t pfc_ctrl;
7315 cmdline_fixed_string_t rx;
7316 cmdline_fixed_string_t rx_pfc_mode;
7317 cmdline_fixed_string_t tx;
7318 cmdline_fixed_string_t tx_pfc_mode;
7319 uint32_t high_water;
7321 uint16_t pause_time;
7327 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7328 __rte_unused struct cmdline *cl,
7329 __rte_unused void *data)
7331 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7332 struct rte_eth_pfc_conf pfc_conf;
7333 int rx_fc_enable, tx_fc_enable;
7337 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7338 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7339 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7340 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7342 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7343 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7346 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7347 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7348 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7349 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7350 pfc_conf.fc.high_water = res->high_water;
7351 pfc_conf.fc.low_water = res->low_water;
7352 pfc_conf.fc.pause_time = res->pause_time;
7353 pfc_conf.priority = res->priority;
7355 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7357 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7360 cmdline_parse_token_string_t cmd_pfc_set_set =
7361 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7363 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7364 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7365 pfc_ctrl, "pfc_ctrl");
7366 cmdline_parse_token_string_t cmd_pfc_set_rx =
7367 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7369 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7370 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7371 rx_pfc_mode, "on#off");
7372 cmdline_parse_token_string_t cmd_pfc_set_tx =
7373 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7375 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7376 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7377 tx_pfc_mode, "on#off");
7378 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7379 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7380 high_water, UINT32);
7381 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7382 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7384 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7385 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7386 pause_time, UINT16);
7387 cmdline_parse_token_num_t cmd_pfc_set_priority =
7388 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7390 cmdline_parse_token_num_t cmd_pfc_set_portid =
7391 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7394 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7395 .f = cmd_priority_flow_ctrl_set_parsed,
7397 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7398 "<pause_time> <priority> <port_id>: "
7399 "Configure the Ethernet priority flow control",
7401 (void *)&cmd_pfc_set_set,
7402 (void *)&cmd_pfc_set_flow_ctrl,
7403 (void *)&cmd_pfc_set_rx,
7404 (void *)&cmd_pfc_set_rx_mode,
7405 (void *)&cmd_pfc_set_tx,
7406 (void *)&cmd_pfc_set_tx_mode,
7407 (void *)&cmd_pfc_set_high_water,
7408 (void *)&cmd_pfc_set_low_water,
7409 (void *)&cmd_pfc_set_pause_time,
7410 (void *)&cmd_pfc_set_priority,
7411 (void *)&cmd_pfc_set_portid,
7416 /* *** RESET CONFIGURATION *** */
7417 struct cmd_reset_result {
7418 cmdline_fixed_string_t reset;
7419 cmdline_fixed_string_t def;
7422 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7424 __rte_unused void *data)
7426 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7427 set_def_fwd_config();
7430 cmdline_parse_token_string_t cmd_reset_set =
7431 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7432 cmdline_parse_token_string_t cmd_reset_def =
7433 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7436 cmdline_parse_inst_t cmd_reset = {
7437 .f = cmd_reset_parsed,
7439 .help_str = "set default: Reset default forwarding configuration",
7441 (void *)&cmd_reset_set,
7442 (void *)&cmd_reset_def,
7447 /* *** START FORWARDING *** */
7448 struct cmd_start_result {
7449 cmdline_fixed_string_t start;
7452 cmdline_parse_token_string_t cmd_start_start =
7453 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7455 static void cmd_start_parsed(__rte_unused void *parsed_result,
7456 __rte_unused struct cmdline *cl,
7457 __rte_unused void *data)
7459 start_packet_forwarding(0);
7462 cmdline_parse_inst_t cmd_start = {
7463 .f = cmd_start_parsed,
7465 .help_str = "start: Start packet forwarding",
7467 (void *)&cmd_start_start,
7472 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7473 struct cmd_start_tx_first_result {
7474 cmdline_fixed_string_t start;
7475 cmdline_fixed_string_t tx_first;
7479 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7480 __rte_unused struct cmdline *cl,
7481 __rte_unused void *data)
7483 start_packet_forwarding(1);
7486 cmdline_parse_token_string_t cmd_start_tx_first_start =
7487 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7489 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7490 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7491 tx_first, "tx_first");
7493 cmdline_parse_inst_t cmd_start_tx_first = {
7494 .f = cmd_start_tx_first_parsed,
7496 .help_str = "start tx_first: Start packet forwarding, "
7497 "after sending 1 burst of packets",
7499 (void *)&cmd_start_tx_first_start,
7500 (void *)&cmd_start_tx_first_tx_first,
7505 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7506 struct cmd_start_tx_first_n_result {
7507 cmdline_fixed_string_t start;
7508 cmdline_fixed_string_t tx_first;
7513 cmd_start_tx_first_n_parsed(void *parsed_result,
7514 __rte_unused struct cmdline *cl,
7515 __rte_unused void *data)
7517 struct cmd_start_tx_first_n_result *res = parsed_result;
7519 start_packet_forwarding(res->tx_num);
7522 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7523 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7525 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7526 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7527 tx_first, "tx_first");
7528 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7529 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7532 cmdline_parse_inst_t cmd_start_tx_first_n = {
7533 .f = cmd_start_tx_first_n_parsed,
7535 .help_str = "start tx_first <num>: "
7536 "packet forwarding, after sending <num> bursts of packets",
7538 (void *)&cmd_start_tx_first_n_start,
7539 (void *)&cmd_start_tx_first_n_tx_first,
7540 (void *)&cmd_start_tx_first_n_tx_num,
7545 /* *** SET LINK UP *** */
7546 struct cmd_set_link_up_result {
7547 cmdline_fixed_string_t set;
7548 cmdline_fixed_string_t link_up;
7549 cmdline_fixed_string_t port;
7553 cmdline_parse_token_string_t cmd_set_link_up_set =
7554 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7555 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7556 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7558 cmdline_parse_token_string_t cmd_set_link_up_port =
7559 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7560 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7561 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7563 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7564 __rte_unused struct cmdline *cl,
7565 __rte_unused void *data)
7567 struct cmd_set_link_up_result *res = parsed_result;
7568 dev_set_link_up(res->port_id);
7571 cmdline_parse_inst_t cmd_set_link_up = {
7572 .f = cmd_set_link_up_parsed,
7574 .help_str = "set link-up port <port id>",
7576 (void *)&cmd_set_link_up_set,
7577 (void *)&cmd_set_link_up_link_up,
7578 (void *)&cmd_set_link_up_port,
7579 (void *)&cmd_set_link_up_port_id,
7584 /* *** SET LINK DOWN *** */
7585 struct cmd_set_link_down_result {
7586 cmdline_fixed_string_t set;
7587 cmdline_fixed_string_t link_down;
7588 cmdline_fixed_string_t port;
7592 cmdline_parse_token_string_t cmd_set_link_down_set =
7593 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7594 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7595 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7597 cmdline_parse_token_string_t cmd_set_link_down_port =
7598 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7599 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7600 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7602 static void cmd_set_link_down_parsed(
7603 __rte_unused void *parsed_result,
7604 __rte_unused struct cmdline *cl,
7605 __rte_unused void *data)
7607 struct cmd_set_link_down_result *res = parsed_result;
7608 dev_set_link_down(res->port_id);
7611 cmdline_parse_inst_t cmd_set_link_down = {
7612 .f = cmd_set_link_down_parsed,
7614 .help_str = "set link-down port <port id>",
7616 (void *)&cmd_set_link_down_set,
7617 (void *)&cmd_set_link_down_link_down,
7618 (void *)&cmd_set_link_down_port,
7619 (void *)&cmd_set_link_down_port_id,
7624 /* *** SHOW CFG *** */
7625 struct cmd_showcfg_result {
7626 cmdline_fixed_string_t show;
7627 cmdline_fixed_string_t cfg;
7628 cmdline_fixed_string_t what;
7631 static void cmd_showcfg_parsed(void *parsed_result,
7632 __rte_unused struct cmdline *cl,
7633 __rte_unused void *data)
7635 struct cmd_showcfg_result *res = parsed_result;
7636 if (!strcmp(res->what, "rxtx"))
7637 rxtx_config_display();
7638 else if (!strcmp(res->what, "cores"))
7639 fwd_lcores_config_display();
7640 else if (!strcmp(res->what, "fwd"))
7641 pkt_fwd_config_display(&cur_fwd_config);
7642 else if (!strcmp(res->what, "rxoffs"))
7643 show_rx_pkt_offsets();
7644 else if (!strcmp(res->what, "rxpkts"))
7645 show_rx_pkt_segments();
7646 else if (!strcmp(res->what, "txpkts"))
7647 show_tx_pkt_segments();
7648 else if (!strcmp(res->what, "txtimes"))
7649 show_tx_pkt_times();
7652 cmdline_parse_token_string_t cmd_showcfg_show =
7653 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7654 cmdline_parse_token_string_t cmd_showcfg_port =
7655 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7656 cmdline_parse_token_string_t cmd_showcfg_what =
7657 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7658 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7660 cmdline_parse_inst_t cmd_showcfg = {
7661 .f = cmd_showcfg_parsed,
7663 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7665 (void *)&cmd_showcfg_show,
7666 (void *)&cmd_showcfg_port,
7667 (void *)&cmd_showcfg_what,
7672 /* *** SHOW ALL PORT INFO *** */
7673 struct cmd_showportall_result {
7674 cmdline_fixed_string_t show;
7675 cmdline_fixed_string_t port;
7676 cmdline_fixed_string_t what;
7677 cmdline_fixed_string_t all;
7680 static void cmd_showportall_parsed(void *parsed_result,
7681 __rte_unused struct cmdline *cl,
7682 __rte_unused void *data)
7686 struct cmd_showportall_result *res = parsed_result;
7687 if (!strcmp(res->show, "clear")) {
7688 if (!strcmp(res->what, "stats"))
7689 RTE_ETH_FOREACH_DEV(i)
7691 else if (!strcmp(res->what, "xstats"))
7692 RTE_ETH_FOREACH_DEV(i)
7693 nic_xstats_clear(i);
7694 } else if (!strcmp(res->what, "info"))
7695 RTE_ETH_FOREACH_DEV(i)
7696 port_infos_display(i);
7697 else if (!strcmp(res->what, "summary")) {
7698 port_summary_header_display();
7699 RTE_ETH_FOREACH_DEV(i)
7700 port_summary_display(i);
7702 else if (!strcmp(res->what, "stats"))
7703 RTE_ETH_FOREACH_DEV(i)
7704 nic_stats_display(i);
7705 else if (!strcmp(res->what, "xstats"))
7706 RTE_ETH_FOREACH_DEV(i)
7707 nic_xstats_display(i);
7708 else if (!strcmp(res->what, "fdir"))
7709 RTE_ETH_FOREACH_DEV(i)
7711 else if (!strcmp(res->what, "stat_qmap"))
7712 RTE_ETH_FOREACH_DEV(i)
7713 nic_stats_mapping_display(i);
7714 else if (!strcmp(res->what, "dcb_tc"))
7715 RTE_ETH_FOREACH_DEV(i)
7716 port_dcb_info_display(i);
7717 else if (!strcmp(res->what, "cap"))
7718 RTE_ETH_FOREACH_DEV(i)
7719 port_offload_cap_display(i);
7722 cmdline_parse_token_string_t cmd_showportall_show =
7723 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7725 cmdline_parse_token_string_t cmd_showportall_port =
7726 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7727 cmdline_parse_token_string_t cmd_showportall_what =
7728 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7729 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7730 cmdline_parse_token_string_t cmd_showportall_all =
7731 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7732 cmdline_parse_inst_t cmd_showportall = {
7733 .f = cmd_showportall_parsed,
7735 .help_str = "show|clear port "
7736 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7738 (void *)&cmd_showportall_show,
7739 (void *)&cmd_showportall_port,
7740 (void *)&cmd_showportall_what,
7741 (void *)&cmd_showportall_all,
7746 /* *** SHOW PORT INFO *** */
7747 struct cmd_showport_result {
7748 cmdline_fixed_string_t show;
7749 cmdline_fixed_string_t port;
7750 cmdline_fixed_string_t what;
7754 static void cmd_showport_parsed(void *parsed_result,
7755 __rte_unused struct cmdline *cl,
7756 __rte_unused void *data)
7758 struct cmd_showport_result *res = parsed_result;
7759 if (!strcmp(res->show, "clear")) {
7760 if (!strcmp(res->what, "stats"))
7761 nic_stats_clear(res->portnum);
7762 else if (!strcmp(res->what, "xstats"))
7763 nic_xstats_clear(res->portnum);
7764 } else if (!strcmp(res->what, "info"))
7765 port_infos_display(res->portnum);
7766 else if (!strcmp(res->what, "summary")) {
7767 port_summary_header_display();
7768 port_summary_display(res->portnum);
7770 else if (!strcmp(res->what, "stats"))
7771 nic_stats_display(res->portnum);
7772 else if (!strcmp(res->what, "xstats"))
7773 nic_xstats_display(res->portnum);
7774 else if (!strcmp(res->what, "fdir"))
7775 fdir_get_infos(res->portnum);
7776 else if (!strcmp(res->what, "stat_qmap"))
7777 nic_stats_mapping_display(res->portnum);
7778 else if (!strcmp(res->what, "dcb_tc"))
7779 port_dcb_info_display(res->portnum);
7780 else if (!strcmp(res->what, "cap"))
7781 port_offload_cap_display(res->portnum);
7784 cmdline_parse_token_string_t cmd_showport_show =
7785 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7787 cmdline_parse_token_string_t cmd_showport_port =
7788 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7789 cmdline_parse_token_string_t cmd_showport_what =
7790 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7791 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7792 cmdline_parse_token_num_t cmd_showport_portnum =
7793 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7795 cmdline_parse_inst_t cmd_showport = {
7796 .f = cmd_showport_parsed,
7798 .help_str = "show|clear port "
7799 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7802 (void *)&cmd_showport_show,
7803 (void *)&cmd_showport_port,
7804 (void *)&cmd_showport_what,
7805 (void *)&cmd_showport_portnum,
7810 /* *** SHOW DEVICE INFO *** */
7811 struct cmd_showdevice_result {
7812 cmdline_fixed_string_t show;
7813 cmdline_fixed_string_t device;
7814 cmdline_fixed_string_t what;
7815 cmdline_fixed_string_t identifier;
7818 static void cmd_showdevice_parsed(void *parsed_result,
7819 __rte_unused struct cmdline *cl,
7820 __rte_unused void *data)
7822 struct cmd_showdevice_result *res = parsed_result;
7823 if (!strcmp(res->what, "info")) {
7824 if (!strcmp(res->identifier, "all"))
7825 device_infos_display(NULL);
7827 device_infos_display(res->identifier);
7831 cmdline_parse_token_string_t cmd_showdevice_show =
7832 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7834 cmdline_parse_token_string_t cmd_showdevice_device =
7835 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7836 cmdline_parse_token_string_t cmd_showdevice_what =
7837 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7839 cmdline_parse_token_string_t cmd_showdevice_identifier =
7840 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7843 cmdline_parse_inst_t cmd_showdevice = {
7844 .f = cmd_showdevice_parsed,
7846 .help_str = "show device info <identifier>|all",
7848 (void *)&cmd_showdevice_show,
7849 (void *)&cmd_showdevice_device,
7850 (void *)&cmd_showdevice_what,
7851 (void *)&cmd_showdevice_identifier,
7856 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7857 struct cmd_showeeprom_result {
7858 cmdline_fixed_string_t show;
7859 cmdline_fixed_string_t port;
7861 cmdline_fixed_string_t type;
7864 static void cmd_showeeprom_parsed(void *parsed_result,
7865 __rte_unused struct cmdline *cl,
7866 __rte_unused void *data)
7868 struct cmd_showeeprom_result *res = parsed_result;
7870 if (!strcmp(res->type, "eeprom"))
7871 port_eeprom_display(res->portnum);
7872 else if (!strcmp(res->type, "module_eeprom"))
7873 port_module_eeprom_display(res->portnum);
7875 printf("Unknown argument\n");
7878 cmdline_parse_token_string_t cmd_showeeprom_show =
7879 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7880 cmdline_parse_token_string_t cmd_showeeprom_port =
7881 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7882 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7883 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum, UINT16);
7884 cmdline_parse_token_string_t cmd_showeeprom_type =
7885 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7887 cmdline_parse_inst_t cmd_showeeprom = {
7888 .f = cmd_showeeprom_parsed,
7890 .help_str = "show port <port_id> module_eeprom|eeprom",
7892 (void *)&cmd_showeeprom_show,
7893 (void *)&cmd_showeeprom_port,
7894 (void *)&cmd_showeeprom_portnum,
7895 (void *)&cmd_showeeprom_type,
7900 /* *** SHOW QUEUE INFO *** */
7901 struct cmd_showqueue_result {
7902 cmdline_fixed_string_t show;
7903 cmdline_fixed_string_t type;
7904 cmdline_fixed_string_t what;
7910 cmd_showqueue_parsed(void *parsed_result,
7911 __rte_unused struct cmdline *cl,
7912 __rte_unused void *data)
7914 struct cmd_showqueue_result *res = parsed_result;
7916 if (!strcmp(res->type, "rxq"))
7917 rx_queue_infos_display(res->portnum, res->queuenum);
7918 else if (!strcmp(res->type, "txq"))
7919 tx_queue_infos_display(res->portnum, res->queuenum);
7922 cmdline_parse_token_string_t cmd_showqueue_show =
7923 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7924 cmdline_parse_token_string_t cmd_showqueue_type =
7925 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7926 cmdline_parse_token_string_t cmd_showqueue_what =
7927 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7928 cmdline_parse_token_num_t cmd_showqueue_portnum =
7929 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7930 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7931 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7933 cmdline_parse_inst_t cmd_showqueue = {
7934 .f = cmd_showqueue_parsed,
7936 .help_str = "show rxq|txq info <port_id> <queue_id>",
7938 (void *)&cmd_showqueue_show,
7939 (void *)&cmd_showqueue_type,
7940 (void *)&cmd_showqueue_what,
7941 (void *)&cmd_showqueue_portnum,
7942 (void *)&cmd_showqueue_queuenum,
7947 /* show/clear fwd engine statistics */
7949 cmdline_fixed_string_t action;
7950 cmdline_fixed_string_t fwd;
7951 cmdline_fixed_string_t stats;
7952 cmdline_fixed_string_t all;
7955 cmdline_parse_token_string_t cmd_fwd_action =
7956 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7957 cmdline_parse_token_string_t cmd_fwd_fwd =
7958 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7959 cmdline_parse_token_string_t cmd_fwd_stats =
7960 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7961 cmdline_parse_token_string_t cmd_fwd_all =
7962 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7965 cmd_showfwdall_parsed(void *parsed_result,
7966 __rte_unused struct cmdline *cl,
7967 __rte_unused void *data)
7969 struct fwd_result *res = parsed_result;
7971 if (!strcmp(res->action, "show"))
7972 fwd_stats_display();
7977 static cmdline_parse_inst_t cmd_showfwdall = {
7978 .f = cmd_showfwdall_parsed,
7980 .help_str = "show|clear fwd stats all",
7982 (void *)&cmd_fwd_action,
7983 (void *)&cmd_fwd_fwd,
7984 (void *)&cmd_fwd_stats,
7985 (void *)&cmd_fwd_all,
7990 /* *** READ PORT REGISTER *** */
7991 struct cmd_read_reg_result {
7992 cmdline_fixed_string_t read;
7993 cmdline_fixed_string_t reg;
7999 cmd_read_reg_parsed(void *parsed_result,
8000 __rte_unused struct cmdline *cl,
8001 __rte_unused void *data)
8003 struct cmd_read_reg_result *res = parsed_result;
8004 port_reg_display(res->port_id, res->reg_off);
8007 cmdline_parse_token_string_t cmd_read_reg_read =
8008 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8009 cmdline_parse_token_string_t cmd_read_reg_reg =
8010 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8011 cmdline_parse_token_num_t cmd_read_reg_port_id =
8012 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
8013 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8014 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
8016 cmdline_parse_inst_t cmd_read_reg = {
8017 .f = cmd_read_reg_parsed,
8019 .help_str = "read reg <port_id> <reg_off>",
8021 (void *)&cmd_read_reg_read,
8022 (void *)&cmd_read_reg_reg,
8023 (void *)&cmd_read_reg_port_id,
8024 (void *)&cmd_read_reg_reg_off,
8029 /* *** READ PORT REGISTER BIT FIELD *** */
8030 struct cmd_read_reg_bit_field_result {
8031 cmdline_fixed_string_t read;
8032 cmdline_fixed_string_t regfield;
8040 cmd_read_reg_bit_field_parsed(void *parsed_result,
8041 __rte_unused struct cmdline *cl,
8042 __rte_unused void *data)
8044 struct cmd_read_reg_bit_field_result *res = parsed_result;
8045 port_reg_bit_field_display(res->port_id, res->reg_off,
8046 res->bit1_pos, res->bit2_pos);
8049 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8050 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8052 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8053 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8054 regfield, "regfield");
8055 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8056 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8058 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8059 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8061 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8062 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8064 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8065 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8068 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8069 .f = cmd_read_reg_bit_field_parsed,
8071 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8072 "Read register bit field between bit_x and bit_y included",
8074 (void *)&cmd_read_reg_bit_field_read,
8075 (void *)&cmd_read_reg_bit_field_regfield,
8076 (void *)&cmd_read_reg_bit_field_port_id,
8077 (void *)&cmd_read_reg_bit_field_reg_off,
8078 (void *)&cmd_read_reg_bit_field_bit1_pos,
8079 (void *)&cmd_read_reg_bit_field_bit2_pos,
8084 /* *** READ PORT REGISTER BIT *** */
8085 struct cmd_read_reg_bit_result {
8086 cmdline_fixed_string_t read;
8087 cmdline_fixed_string_t regbit;
8094 cmd_read_reg_bit_parsed(void *parsed_result,
8095 __rte_unused struct cmdline *cl,
8096 __rte_unused void *data)
8098 struct cmd_read_reg_bit_result *res = parsed_result;
8099 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8102 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8103 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8104 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8105 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8107 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8108 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
8109 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8110 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
8111 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8112 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
8114 cmdline_parse_inst_t cmd_read_reg_bit = {
8115 .f = cmd_read_reg_bit_parsed,
8117 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8119 (void *)&cmd_read_reg_bit_read,
8120 (void *)&cmd_read_reg_bit_regbit,
8121 (void *)&cmd_read_reg_bit_port_id,
8122 (void *)&cmd_read_reg_bit_reg_off,
8123 (void *)&cmd_read_reg_bit_bit_pos,
8128 /* *** WRITE PORT REGISTER *** */
8129 struct cmd_write_reg_result {
8130 cmdline_fixed_string_t write;
8131 cmdline_fixed_string_t reg;
8138 cmd_write_reg_parsed(void *parsed_result,
8139 __rte_unused struct cmdline *cl,
8140 __rte_unused void *data)
8142 struct cmd_write_reg_result *res = parsed_result;
8143 port_reg_set(res->port_id, res->reg_off, res->value);
8146 cmdline_parse_token_string_t cmd_write_reg_write =
8147 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8148 cmdline_parse_token_string_t cmd_write_reg_reg =
8149 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8150 cmdline_parse_token_num_t cmd_write_reg_port_id =
8151 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
8152 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8153 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
8154 cmdline_parse_token_num_t cmd_write_reg_value =
8155 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
8157 cmdline_parse_inst_t cmd_write_reg = {
8158 .f = cmd_write_reg_parsed,
8160 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8162 (void *)&cmd_write_reg_write,
8163 (void *)&cmd_write_reg_reg,
8164 (void *)&cmd_write_reg_port_id,
8165 (void *)&cmd_write_reg_reg_off,
8166 (void *)&cmd_write_reg_value,
8171 /* *** WRITE PORT REGISTER BIT FIELD *** */
8172 struct cmd_write_reg_bit_field_result {
8173 cmdline_fixed_string_t write;
8174 cmdline_fixed_string_t regfield;
8183 cmd_write_reg_bit_field_parsed(void *parsed_result,
8184 __rte_unused struct cmdline *cl,
8185 __rte_unused void *data)
8187 struct cmd_write_reg_bit_field_result *res = parsed_result;
8188 port_reg_bit_field_set(res->port_id, res->reg_off,
8189 res->bit1_pos, res->bit2_pos, res->value);
8192 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8193 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8195 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8196 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8197 regfield, "regfield");
8198 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8199 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8201 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8202 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8204 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8205 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8207 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8208 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8210 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8211 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8214 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8215 .f = cmd_write_reg_bit_field_parsed,
8217 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8219 "Set register bit field between bit_x and bit_y included",
8221 (void *)&cmd_write_reg_bit_field_write,
8222 (void *)&cmd_write_reg_bit_field_regfield,
8223 (void *)&cmd_write_reg_bit_field_port_id,
8224 (void *)&cmd_write_reg_bit_field_reg_off,
8225 (void *)&cmd_write_reg_bit_field_bit1_pos,
8226 (void *)&cmd_write_reg_bit_field_bit2_pos,
8227 (void *)&cmd_write_reg_bit_field_value,
8232 /* *** WRITE PORT REGISTER BIT *** */
8233 struct cmd_write_reg_bit_result {
8234 cmdline_fixed_string_t write;
8235 cmdline_fixed_string_t regbit;
8243 cmd_write_reg_bit_parsed(void *parsed_result,
8244 __rte_unused struct cmdline *cl,
8245 __rte_unused void *data)
8247 struct cmd_write_reg_bit_result *res = parsed_result;
8248 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8251 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8252 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8254 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8255 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8257 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8258 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
8259 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8260 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
8261 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8262 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
8263 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8264 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
8266 cmdline_parse_inst_t cmd_write_reg_bit = {
8267 .f = cmd_write_reg_bit_parsed,
8269 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8272 (void *)&cmd_write_reg_bit_write,
8273 (void *)&cmd_write_reg_bit_regbit,
8274 (void *)&cmd_write_reg_bit_port_id,
8275 (void *)&cmd_write_reg_bit_reg_off,
8276 (void *)&cmd_write_reg_bit_bit_pos,
8277 (void *)&cmd_write_reg_bit_value,
8282 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8283 struct cmd_read_rxd_txd_result {
8284 cmdline_fixed_string_t read;
8285 cmdline_fixed_string_t rxd_txd;
8292 cmd_read_rxd_txd_parsed(void *parsed_result,
8293 __rte_unused struct cmdline *cl,
8294 __rte_unused void *data)
8296 struct cmd_read_rxd_txd_result *res = parsed_result;
8298 if (!strcmp(res->rxd_txd, "rxd"))
8299 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8300 else if (!strcmp(res->rxd_txd, "txd"))
8301 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8304 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8305 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8306 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8307 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8309 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8310 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8311 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8312 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8313 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8314 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8316 cmdline_parse_inst_t cmd_read_rxd_txd = {
8317 .f = cmd_read_rxd_txd_parsed,
8319 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8321 (void *)&cmd_read_rxd_txd_read,
8322 (void *)&cmd_read_rxd_txd_rxd_txd,
8323 (void *)&cmd_read_rxd_txd_port_id,
8324 (void *)&cmd_read_rxd_txd_queue_id,
8325 (void *)&cmd_read_rxd_txd_desc_id,
8331 struct cmd_quit_result {
8332 cmdline_fixed_string_t quit;
8335 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8337 __rte_unused void *data)
8342 cmdline_parse_token_string_t cmd_quit_quit =
8343 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8345 cmdline_parse_inst_t cmd_quit = {
8346 .f = cmd_quit_parsed,
8348 .help_str = "quit: Exit application",
8350 (void *)&cmd_quit_quit,
8355 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8356 struct cmd_mac_addr_result {
8357 cmdline_fixed_string_t mac_addr_cmd;
8358 cmdline_fixed_string_t what;
8360 struct rte_ether_addr address;
8363 static void cmd_mac_addr_parsed(void *parsed_result,
8364 __rte_unused struct cmdline *cl,
8365 __rte_unused void *data)
8367 struct cmd_mac_addr_result *res = parsed_result;
8370 if (strcmp(res->what, "add") == 0)
8371 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8372 else if (strcmp(res->what, "set") == 0)
8373 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8376 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8378 /* check the return value and print it if is < 0 */
8380 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8384 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8385 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8387 cmdline_parse_token_string_t cmd_mac_addr_what =
8388 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8390 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8391 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8393 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8394 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8396 cmdline_parse_inst_t cmd_mac_addr = {
8397 .f = cmd_mac_addr_parsed,
8399 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8400 "Add/Remove/Set MAC address on port_id",
8402 (void *)&cmd_mac_addr_cmd,
8403 (void *)&cmd_mac_addr_what,
8404 (void *)&cmd_mac_addr_portnum,
8405 (void *)&cmd_mac_addr_addr,
8410 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8411 struct cmd_eth_peer_result {
8412 cmdline_fixed_string_t set;
8413 cmdline_fixed_string_t eth_peer;
8415 cmdline_fixed_string_t peer_addr;
8418 static void cmd_set_eth_peer_parsed(void *parsed_result,
8419 __rte_unused struct cmdline *cl,
8420 __rte_unused void *data)
8422 struct cmd_eth_peer_result *res = parsed_result;
8424 if (test_done == 0) {
8425 printf("Please stop forwarding first\n");
8428 if (!strcmp(res->eth_peer, "eth-peer")) {
8429 set_fwd_eth_peer(res->port_id, res->peer_addr);
8433 cmdline_parse_token_string_t cmd_eth_peer_set =
8434 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8435 cmdline_parse_token_string_t cmd_eth_peer =
8436 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8437 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8438 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8439 cmdline_parse_token_string_t cmd_eth_peer_addr =
8440 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8442 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8443 .f = cmd_set_eth_peer_parsed,
8445 .help_str = "set eth-peer <port_id> <peer_mac>",
8447 (void *)&cmd_eth_peer_set,
8448 (void *)&cmd_eth_peer,
8449 (void *)&cmd_eth_peer_port_id,
8450 (void *)&cmd_eth_peer_addr,
8455 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8456 struct cmd_set_qmap_result {
8457 cmdline_fixed_string_t set;
8458 cmdline_fixed_string_t qmap;
8459 cmdline_fixed_string_t what;
8466 cmd_set_qmap_parsed(void *parsed_result,
8467 __rte_unused struct cmdline *cl,
8468 __rte_unused void *data)
8470 struct cmd_set_qmap_result *res = parsed_result;
8471 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8473 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8476 cmdline_parse_token_string_t cmd_setqmap_set =
8477 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8479 cmdline_parse_token_string_t cmd_setqmap_qmap =
8480 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8482 cmdline_parse_token_string_t cmd_setqmap_what =
8483 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8485 cmdline_parse_token_num_t cmd_setqmap_portid =
8486 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8488 cmdline_parse_token_num_t cmd_setqmap_queueid =
8489 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8491 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8492 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8495 cmdline_parse_inst_t cmd_set_qmap = {
8496 .f = cmd_set_qmap_parsed,
8498 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8499 "Set statistics mapping value on tx|rx queue_id of port_id",
8501 (void *)&cmd_setqmap_set,
8502 (void *)&cmd_setqmap_qmap,
8503 (void *)&cmd_setqmap_what,
8504 (void *)&cmd_setqmap_portid,
8505 (void *)&cmd_setqmap_queueid,
8506 (void *)&cmd_setqmap_mapvalue,
8511 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8512 struct cmd_set_xstats_hide_zero_result {
8513 cmdline_fixed_string_t keyword;
8514 cmdline_fixed_string_t name;
8515 cmdline_fixed_string_t on_off;
8519 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8520 __rte_unused struct cmdline *cl,
8521 __rte_unused void *data)
8523 struct cmd_set_xstats_hide_zero_result *res;
8524 uint16_t on_off = 0;
8526 res = parsed_result;
8527 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8528 set_xstats_hide_zero(on_off);
8531 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8532 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8534 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8535 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8536 name, "xstats-hide-zero");
8537 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8538 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8541 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8542 .f = cmd_set_xstats_hide_zero_parsed,
8544 .help_str = "set xstats-hide-zero on|off",
8546 (void *)&cmd_set_xstats_hide_zero_keyword,
8547 (void *)&cmd_set_xstats_hide_zero_name,
8548 (void *)&cmd_set_xstats_hide_zero_on_off,
8553 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8554 struct cmd_set_record_core_cycles_result {
8555 cmdline_fixed_string_t keyword;
8556 cmdline_fixed_string_t name;
8557 cmdline_fixed_string_t on_off;
8561 cmd_set_record_core_cycles_parsed(void *parsed_result,
8562 __rte_unused struct cmdline *cl,
8563 __rte_unused void *data)
8565 struct cmd_set_record_core_cycles_result *res;
8566 uint16_t on_off = 0;
8568 res = parsed_result;
8569 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8570 set_record_core_cycles(on_off);
8573 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8574 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8576 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8577 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8578 name, "record-core-cycles");
8579 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8580 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8583 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8584 .f = cmd_set_record_core_cycles_parsed,
8586 .help_str = "set record-core-cycles on|off",
8588 (void *)&cmd_set_record_core_cycles_keyword,
8589 (void *)&cmd_set_record_core_cycles_name,
8590 (void *)&cmd_set_record_core_cycles_on_off,
8595 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8596 struct cmd_set_record_burst_stats_result {
8597 cmdline_fixed_string_t keyword;
8598 cmdline_fixed_string_t name;
8599 cmdline_fixed_string_t on_off;
8603 cmd_set_record_burst_stats_parsed(void *parsed_result,
8604 __rte_unused struct cmdline *cl,
8605 __rte_unused void *data)
8607 struct cmd_set_record_burst_stats_result *res;
8608 uint16_t on_off = 0;
8610 res = parsed_result;
8611 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8612 set_record_burst_stats(on_off);
8615 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8616 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8618 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8619 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8620 name, "record-burst-stats");
8621 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8622 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8625 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8626 .f = cmd_set_record_burst_stats_parsed,
8628 .help_str = "set record-burst-stats on|off",
8630 (void *)&cmd_set_record_burst_stats_keyword,
8631 (void *)&cmd_set_record_burst_stats_name,
8632 (void *)&cmd_set_record_burst_stats_on_off,
8637 /* *** CONFIGURE UNICAST HASH TABLE *** */
8638 struct cmd_set_uc_hash_table {
8639 cmdline_fixed_string_t set;
8640 cmdline_fixed_string_t port;
8642 cmdline_fixed_string_t what;
8643 struct rte_ether_addr address;
8644 cmdline_fixed_string_t mode;
8648 cmd_set_uc_hash_parsed(void *parsed_result,
8649 __rte_unused struct cmdline *cl,
8650 __rte_unused void *data)
8653 struct cmd_set_uc_hash_table *res = parsed_result;
8655 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8657 if (strcmp(res->what, "uta") == 0)
8658 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8659 &res->address,(uint8_t)is_on);
8661 printf("bad unicast hash table parameter, return code = %d \n", ret);
8665 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8666 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8668 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8669 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8671 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8672 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8674 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8675 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8677 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8678 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8680 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8681 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8684 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8685 .f = cmd_set_uc_hash_parsed,
8687 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8689 (void *)&cmd_set_uc_hash_set,
8690 (void *)&cmd_set_uc_hash_port,
8691 (void *)&cmd_set_uc_hash_portid,
8692 (void *)&cmd_set_uc_hash_what,
8693 (void *)&cmd_set_uc_hash_mac,
8694 (void *)&cmd_set_uc_hash_mode,
8699 struct cmd_set_uc_all_hash_table {
8700 cmdline_fixed_string_t set;
8701 cmdline_fixed_string_t port;
8703 cmdline_fixed_string_t what;
8704 cmdline_fixed_string_t value;
8705 cmdline_fixed_string_t mode;
8709 cmd_set_uc_all_hash_parsed(void *parsed_result,
8710 __rte_unused struct cmdline *cl,
8711 __rte_unused void *data)
8714 struct cmd_set_uc_all_hash_table *res = parsed_result;
8716 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8718 if ((strcmp(res->what, "uta") == 0) &&
8719 (strcmp(res->value, "all") == 0))
8720 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8722 printf("bad unicast hash table parameter,"
8723 "return code = %d \n", ret);
8726 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8727 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8729 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8730 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8732 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8733 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8735 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8736 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8738 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8739 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8741 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8742 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8745 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8746 .f = cmd_set_uc_all_hash_parsed,
8748 .help_str = "set port <port_id> uta all on|off",
8750 (void *)&cmd_set_uc_all_hash_set,
8751 (void *)&cmd_set_uc_all_hash_port,
8752 (void *)&cmd_set_uc_all_hash_portid,
8753 (void *)&cmd_set_uc_all_hash_what,
8754 (void *)&cmd_set_uc_all_hash_value,
8755 (void *)&cmd_set_uc_all_hash_mode,
8760 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8761 struct cmd_set_vf_macvlan_filter {
8762 cmdline_fixed_string_t set;
8763 cmdline_fixed_string_t port;
8765 cmdline_fixed_string_t vf;
8767 struct rte_ether_addr address;
8768 cmdline_fixed_string_t filter_type;
8769 cmdline_fixed_string_t mode;
8773 cmd_set_vf_macvlan_parsed(void *parsed_result,
8774 __rte_unused struct cmdline *cl,
8775 __rte_unused void *data)
8778 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8779 struct rte_eth_mac_filter filter;
8781 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8783 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8785 /* set VF MAC filter */
8789 filter.dst_id = res->vf_id;
8791 if (!strcmp(res->filter_type, "exact-mac"))
8792 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8793 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8794 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8795 else if (!strcmp(res->filter_type, "hashmac"))
8796 filter.filter_type = RTE_MAC_HASH_MATCH;
8797 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8798 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8800 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8803 ret = rte_eth_dev_filter_ctrl(res->port_id,
8804 RTE_ETH_FILTER_MACVLAN,
8808 ret = rte_eth_dev_filter_ctrl(res->port_id,
8809 RTE_ETH_FILTER_MACVLAN,
8810 RTE_ETH_FILTER_DELETE,
8814 printf("bad set MAC hash parameter, return code = %d\n", ret);
8818 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8819 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8821 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8822 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8824 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8825 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8827 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8828 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8830 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8831 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8833 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8834 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8836 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8837 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8838 filter_type, "exact-mac#exact-mac-vlan"
8839 "#hashmac#hashmac-vlan");
8840 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8841 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8844 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8845 .f = cmd_set_vf_macvlan_parsed,
8847 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8848 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8849 "Exact match rule: exact match of MAC or MAC and VLAN; "
8850 "hash match rule: hash match of MAC and exact match of VLAN",
8852 (void *)&cmd_set_vf_macvlan_set,
8853 (void *)&cmd_set_vf_macvlan_port,
8854 (void *)&cmd_set_vf_macvlan_portid,
8855 (void *)&cmd_set_vf_macvlan_vf,
8856 (void *)&cmd_set_vf_macvlan_vf_id,
8857 (void *)&cmd_set_vf_macvlan_mac,
8858 (void *)&cmd_set_vf_macvlan_filter_type,
8859 (void *)&cmd_set_vf_macvlan_mode,
8864 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8865 struct cmd_set_vf_traffic {
8866 cmdline_fixed_string_t set;
8867 cmdline_fixed_string_t port;
8869 cmdline_fixed_string_t vf;
8871 cmdline_fixed_string_t what;
8872 cmdline_fixed_string_t mode;
8876 cmd_set_vf_traffic_parsed(void *parsed_result,
8877 __rte_unused struct cmdline *cl,
8878 __rte_unused void *data)
8880 struct cmd_set_vf_traffic *res = parsed_result;
8881 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8882 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8884 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8887 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8888 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8890 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8891 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8893 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8894 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8896 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8897 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8899 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8900 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8902 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8903 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8905 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8906 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8909 cmdline_parse_inst_t cmd_set_vf_traffic = {
8910 .f = cmd_set_vf_traffic_parsed,
8912 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8914 (void *)&cmd_setvf_traffic_set,
8915 (void *)&cmd_setvf_traffic_port,
8916 (void *)&cmd_setvf_traffic_portid,
8917 (void *)&cmd_setvf_traffic_vf,
8918 (void *)&cmd_setvf_traffic_vfid,
8919 (void *)&cmd_setvf_traffic_what,
8920 (void *)&cmd_setvf_traffic_mode,
8925 /* *** CONFIGURE VF RECEIVE MODE *** */
8926 struct cmd_set_vf_rxmode {
8927 cmdline_fixed_string_t set;
8928 cmdline_fixed_string_t port;
8930 cmdline_fixed_string_t vf;
8932 cmdline_fixed_string_t what;
8933 cmdline_fixed_string_t mode;
8934 cmdline_fixed_string_t on;
8938 cmd_set_vf_rxmode_parsed(void *parsed_result,
8939 __rte_unused struct cmdline *cl,
8940 __rte_unused void *data)
8943 uint16_t vf_rxmode = 0;
8944 struct cmd_set_vf_rxmode *res = parsed_result;
8946 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8947 if (!strcmp(res->what,"rxmode")) {
8948 if (!strcmp(res->mode, "AUPE"))
8949 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8950 else if (!strcmp(res->mode, "ROPE"))
8951 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8952 else if (!strcmp(res->mode, "BAM"))
8953 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8954 else if (!strncmp(res->mode, "MPE",3))
8955 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8958 RTE_SET_USED(is_on);
8960 #ifdef RTE_NET_IXGBE
8961 if (ret == -ENOTSUP)
8962 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8963 vf_rxmode, (uint8_t)is_on);
8966 if (ret == -ENOTSUP)
8967 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8968 vf_rxmode, (uint8_t)is_on);
8971 printf("bad VF receive mode parameter, return code = %d \n",
8975 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8976 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8978 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8979 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8981 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8982 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8984 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8985 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8987 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8988 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8990 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8991 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8993 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8994 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8995 mode, "AUPE#ROPE#BAM#MPE");
8996 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8997 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9000 cmdline_parse_inst_t cmd_set_vf_rxmode = {
9001 .f = cmd_set_vf_rxmode_parsed,
9003 .help_str = "set port <port_id> vf <vf_id> rxmode "
9004 "AUPE|ROPE|BAM|MPE on|off",
9006 (void *)&cmd_set_vf_rxmode_set,
9007 (void *)&cmd_set_vf_rxmode_port,
9008 (void *)&cmd_set_vf_rxmode_portid,
9009 (void *)&cmd_set_vf_rxmode_vf,
9010 (void *)&cmd_set_vf_rxmode_vfid,
9011 (void *)&cmd_set_vf_rxmode_what,
9012 (void *)&cmd_set_vf_rxmode_mode,
9013 (void *)&cmd_set_vf_rxmode_on,
9018 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
9019 struct cmd_vf_mac_addr_result {
9020 cmdline_fixed_string_t mac_addr_cmd;
9021 cmdline_fixed_string_t what;
9022 cmdline_fixed_string_t port;
9024 cmdline_fixed_string_t vf;
9026 struct rte_ether_addr address;
9029 static void cmd_vf_mac_addr_parsed(void *parsed_result,
9030 __rte_unused struct cmdline *cl,
9031 __rte_unused void *data)
9033 struct cmd_vf_mac_addr_result *res = parsed_result;
9036 if (strcmp(res->what, "add") != 0)
9040 if (ret == -ENOTSUP)
9041 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
9045 if (ret == -ENOTSUP)
9046 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9051 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9055 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9056 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9057 mac_addr_cmd,"mac_addr");
9058 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9059 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9061 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9062 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9064 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9065 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9067 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9068 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9070 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9071 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9073 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9074 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9077 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9078 .f = cmd_vf_mac_addr_parsed,
9080 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9081 "Add MAC address filtering for a VF on port_id",
9083 (void *)&cmd_vf_mac_addr_cmd,
9084 (void *)&cmd_vf_mac_addr_what,
9085 (void *)&cmd_vf_mac_addr_port,
9086 (void *)&cmd_vf_mac_addr_portnum,
9087 (void *)&cmd_vf_mac_addr_vf,
9088 (void *)&cmd_vf_mac_addr_vfnum,
9089 (void *)&cmd_vf_mac_addr_addr,
9094 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9095 struct cmd_vf_rx_vlan_filter {
9096 cmdline_fixed_string_t rx_vlan;
9097 cmdline_fixed_string_t what;
9099 cmdline_fixed_string_t port;
9101 cmdline_fixed_string_t vf;
9106 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9107 __rte_unused struct cmdline *cl,
9108 __rte_unused void *data)
9110 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9113 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9115 #ifdef RTE_NET_IXGBE
9116 if (ret == -ENOTSUP)
9117 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9118 res->vlan_id, res->vf_mask, is_add);
9121 if (ret == -ENOTSUP)
9122 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9123 res->vlan_id, res->vf_mask, is_add);
9126 if (ret == -ENOTSUP)
9127 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9128 res->vlan_id, res->vf_mask, is_add);
9135 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
9136 res->vlan_id, res->vf_mask);
9139 printf("invalid port_id %d\n", res->port_id);
9142 printf("function not implemented or supported\n");
9145 printf("programming error: (%s)\n", strerror(-ret));
9149 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9150 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9151 rx_vlan, "rx_vlan");
9152 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9153 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9155 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9156 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9158 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9159 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9161 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9162 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9164 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9165 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9167 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9168 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9171 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9172 .f = cmd_vf_rx_vlan_filter_parsed,
9174 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9175 "(vf_mask = hexadecimal VF mask)",
9177 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9178 (void *)&cmd_vf_rx_vlan_filter_what,
9179 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9180 (void *)&cmd_vf_rx_vlan_filter_port,
9181 (void *)&cmd_vf_rx_vlan_filter_portid,
9182 (void *)&cmd_vf_rx_vlan_filter_vf,
9183 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9188 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9189 struct cmd_queue_rate_limit_result {
9190 cmdline_fixed_string_t set;
9191 cmdline_fixed_string_t port;
9193 cmdline_fixed_string_t queue;
9195 cmdline_fixed_string_t rate;
9199 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9200 __rte_unused struct cmdline *cl,
9201 __rte_unused void *data)
9203 struct cmd_queue_rate_limit_result *res = parsed_result;
9206 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9207 && (strcmp(res->queue, "queue") == 0)
9208 && (strcmp(res->rate, "rate") == 0))
9209 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9212 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
9216 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9217 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9219 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9220 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9222 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9223 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9225 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9226 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9228 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9229 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9231 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9232 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9234 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9235 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9238 cmdline_parse_inst_t cmd_queue_rate_limit = {
9239 .f = cmd_queue_rate_limit_parsed,
9241 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9242 "Set rate limit for a queue on port_id",
9244 (void *)&cmd_queue_rate_limit_set,
9245 (void *)&cmd_queue_rate_limit_port,
9246 (void *)&cmd_queue_rate_limit_portnum,
9247 (void *)&cmd_queue_rate_limit_queue,
9248 (void *)&cmd_queue_rate_limit_queuenum,
9249 (void *)&cmd_queue_rate_limit_rate,
9250 (void *)&cmd_queue_rate_limit_ratenum,
9255 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9256 struct cmd_vf_rate_limit_result {
9257 cmdline_fixed_string_t set;
9258 cmdline_fixed_string_t port;
9260 cmdline_fixed_string_t vf;
9262 cmdline_fixed_string_t rate;
9264 cmdline_fixed_string_t q_msk;
9268 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9269 __rte_unused struct cmdline *cl,
9270 __rte_unused void *data)
9272 struct cmd_vf_rate_limit_result *res = parsed_result;
9275 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9276 && (strcmp(res->vf, "vf") == 0)
9277 && (strcmp(res->rate, "rate") == 0)
9278 && (strcmp(res->q_msk, "queue_mask") == 0))
9279 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9280 res->rate_num, res->q_msk_val);
9282 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9286 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9287 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9289 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9290 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9292 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9293 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9295 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9296 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9298 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9299 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9301 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9302 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9304 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9305 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9307 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9308 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9309 q_msk, "queue_mask");
9310 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9311 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9314 cmdline_parse_inst_t cmd_vf_rate_limit = {
9315 .f = cmd_vf_rate_limit_parsed,
9317 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9318 "queue_mask <queue_mask_value>: "
9319 "Set rate limit for queues of VF on port_id",
9321 (void *)&cmd_vf_rate_limit_set,
9322 (void *)&cmd_vf_rate_limit_port,
9323 (void *)&cmd_vf_rate_limit_portnum,
9324 (void *)&cmd_vf_rate_limit_vf,
9325 (void *)&cmd_vf_rate_limit_vfnum,
9326 (void *)&cmd_vf_rate_limit_rate,
9327 (void *)&cmd_vf_rate_limit_ratenum,
9328 (void *)&cmd_vf_rate_limit_q_msk,
9329 (void *)&cmd_vf_rate_limit_q_msk_val,
9334 /* *** ADD TUNNEL FILTER OF A PORT *** */
9335 struct cmd_tunnel_filter_result {
9336 cmdline_fixed_string_t cmd;
9337 cmdline_fixed_string_t what;
9339 struct rte_ether_addr outer_mac;
9340 struct rte_ether_addr inner_mac;
9341 cmdline_ipaddr_t ip_value;
9342 uint16_t inner_vlan;
9343 cmdline_fixed_string_t tunnel_type;
9344 cmdline_fixed_string_t filter_type;
9350 cmd_tunnel_filter_parsed(void *parsed_result,
9351 __rte_unused struct cmdline *cl,
9352 __rte_unused void *data)
9354 struct cmd_tunnel_filter_result *res = parsed_result;
9355 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
9358 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
9360 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
9361 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
9362 tunnel_filter_conf.inner_vlan = res->inner_vlan;
9364 if (res->ip_value.family == AF_INET) {
9365 tunnel_filter_conf.ip_addr.ipv4_addr =
9366 res->ip_value.addr.ipv4.s_addr;
9367 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
9369 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
9370 &(res->ip_value.addr.ipv6),
9371 sizeof(struct in6_addr));
9372 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
9375 if (!strcmp(res->filter_type, "imac-ivlan"))
9376 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
9377 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
9378 tunnel_filter_conf.filter_type =
9379 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
9380 else if (!strcmp(res->filter_type, "imac-tenid"))
9381 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
9382 else if (!strcmp(res->filter_type, "imac"))
9383 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
9384 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
9385 tunnel_filter_conf.filter_type =
9386 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
9387 else if (!strcmp(res->filter_type, "oip"))
9388 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9389 else if (!strcmp(res->filter_type, "iip"))
9390 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9392 printf("The filter type is not supported");
9396 if (!strcmp(res->tunnel_type, "vxlan"))
9397 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9398 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9399 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9400 else if (!strcmp(res->tunnel_type, "nvgre"))
9401 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9402 else if (!strcmp(res->tunnel_type, "ipingre"))
9403 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9405 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9409 tunnel_filter_conf.tenant_id = res->tenant_id;
9410 tunnel_filter_conf.queue_id = res->queue_num;
9411 if (!strcmp(res->what, "add"))
9412 ret = rte_eth_dev_filter_ctrl(res->port_id,
9413 RTE_ETH_FILTER_TUNNEL,
9415 &tunnel_filter_conf);
9417 ret = rte_eth_dev_filter_ctrl(res->port_id,
9418 RTE_ETH_FILTER_TUNNEL,
9419 RTE_ETH_FILTER_DELETE,
9420 &tunnel_filter_conf);
9422 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9426 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9427 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9428 cmd, "tunnel_filter");
9429 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9430 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9432 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9433 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9435 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9436 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9438 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9439 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9441 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9442 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9443 inner_vlan, UINT16);
9444 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9445 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9447 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9448 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9449 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9451 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9452 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9453 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9454 "imac#omac-imac-tenid");
9455 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9456 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9458 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9459 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9462 cmdline_parse_inst_t cmd_tunnel_filter = {
9463 .f = cmd_tunnel_filter_parsed,
9465 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9466 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9467 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9468 "<queue_id>: Add/Rm tunnel filter of a port",
9470 (void *)&cmd_tunnel_filter_cmd,
9471 (void *)&cmd_tunnel_filter_what,
9472 (void *)&cmd_tunnel_filter_port_id,
9473 (void *)&cmd_tunnel_filter_outer_mac,
9474 (void *)&cmd_tunnel_filter_inner_mac,
9475 (void *)&cmd_tunnel_filter_ip_value,
9476 (void *)&cmd_tunnel_filter_innner_vlan,
9477 (void *)&cmd_tunnel_filter_tunnel_type,
9478 (void *)&cmd_tunnel_filter_filter_type,
9479 (void *)&cmd_tunnel_filter_tenant_id,
9480 (void *)&cmd_tunnel_filter_queue_num,
9485 /* *** CONFIGURE TUNNEL UDP PORT *** */
9486 struct cmd_tunnel_udp_config {
9487 cmdline_fixed_string_t cmd;
9488 cmdline_fixed_string_t what;
9494 cmd_tunnel_udp_config_parsed(void *parsed_result,
9495 __rte_unused struct cmdline *cl,
9496 __rte_unused void *data)
9498 struct cmd_tunnel_udp_config *res = parsed_result;
9499 struct rte_eth_udp_tunnel tunnel_udp;
9502 tunnel_udp.udp_port = res->udp_port;
9504 if (!strcmp(res->cmd, "rx_vxlan_port"))
9505 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9507 if (!strcmp(res->what, "add"))
9508 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9511 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9515 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9518 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9519 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9520 cmd, "rx_vxlan_port");
9521 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9522 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9524 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9525 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9527 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9528 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9531 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9532 .f = cmd_tunnel_udp_config_parsed,
9534 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9535 "Add/Remove a tunneling UDP port filter",
9537 (void *)&cmd_tunnel_udp_config_cmd,
9538 (void *)&cmd_tunnel_udp_config_what,
9539 (void *)&cmd_tunnel_udp_config_udp_port,
9540 (void *)&cmd_tunnel_udp_config_port_id,
9545 struct cmd_config_tunnel_udp_port {
9546 cmdline_fixed_string_t port;
9547 cmdline_fixed_string_t config;
9549 cmdline_fixed_string_t udp_tunnel_port;
9550 cmdline_fixed_string_t action;
9551 cmdline_fixed_string_t tunnel_type;
9556 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9557 __rte_unused struct cmdline *cl,
9558 __rte_unused void *data)
9560 struct cmd_config_tunnel_udp_port *res = parsed_result;
9561 struct rte_eth_udp_tunnel tunnel_udp;
9564 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9567 tunnel_udp.udp_port = res->udp_port;
9569 if (!strcmp(res->tunnel_type, "vxlan")) {
9570 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9571 } else if (!strcmp(res->tunnel_type, "geneve")) {
9572 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9573 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9574 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9576 printf("Invalid tunnel type\n");
9580 if (!strcmp(res->action, "add"))
9581 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9584 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9588 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9591 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9592 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9594 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9595 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9597 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9598 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9600 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9601 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9604 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9605 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9607 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9608 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9609 "vxlan#geneve#vxlan-gpe");
9610 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9611 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9614 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9615 .f = cmd_cfg_tunnel_udp_port_parsed,
9617 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9619 (void *)&cmd_config_tunnel_udp_port_port,
9620 (void *)&cmd_config_tunnel_udp_port_config,
9621 (void *)&cmd_config_tunnel_udp_port_port_id,
9622 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9623 (void *)&cmd_config_tunnel_udp_port_action,
9624 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9625 (void *)&cmd_config_tunnel_udp_port_value,
9630 /* *** GLOBAL CONFIG *** */
9631 struct cmd_global_config_result {
9632 cmdline_fixed_string_t cmd;
9634 cmdline_fixed_string_t cfg_type;
9639 cmd_global_config_parsed(void *parsed_result,
9640 __rte_unused struct cmdline *cl,
9641 __rte_unused void *data)
9643 struct cmd_global_config_result *res = parsed_result;
9644 struct rte_eth_global_cfg conf;
9647 memset(&conf, 0, sizeof(conf));
9648 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9649 conf.cfg.gre_key_len = res->len;
9650 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9651 RTE_ETH_FILTER_SET, &conf);
9653 if (ret == -ENOTSUP)
9654 ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len);
9657 printf("Global config error\n");
9660 cmdline_parse_token_string_t cmd_global_config_cmd =
9661 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9663 cmdline_parse_token_num_t cmd_global_config_port_id =
9664 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9666 cmdline_parse_token_string_t cmd_global_config_type =
9667 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9668 cfg_type, "gre-key-len");
9669 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9670 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9673 cmdline_parse_inst_t cmd_global_config = {
9674 .f = cmd_global_config_parsed,
9675 .data = (void *)NULL,
9676 .help_str = "global_config <port_id> gre-key-len <key_len>",
9678 (void *)&cmd_global_config_cmd,
9679 (void *)&cmd_global_config_port_id,
9680 (void *)&cmd_global_config_type,
9681 (void *)&cmd_global_config_gre_key_len,
9686 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9687 struct cmd_set_mirror_mask_result {
9688 cmdline_fixed_string_t set;
9689 cmdline_fixed_string_t port;
9691 cmdline_fixed_string_t mirror;
9693 cmdline_fixed_string_t what;
9694 cmdline_fixed_string_t value;
9695 cmdline_fixed_string_t dstpool;
9697 cmdline_fixed_string_t on;
9700 cmdline_parse_token_string_t cmd_mirror_mask_set =
9701 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9703 cmdline_parse_token_string_t cmd_mirror_mask_port =
9704 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9706 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9707 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9709 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9710 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9711 mirror, "mirror-rule");
9712 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9713 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9715 cmdline_parse_token_string_t cmd_mirror_mask_what =
9716 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9717 what, "pool-mirror-up#pool-mirror-down"
9719 cmdline_parse_token_string_t cmd_mirror_mask_value =
9720 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9722 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9723 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9724 dstpool, "dst-pool");
9725 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9726 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9728 cmdline_parse_token_string_t cmd_mirror_mask_on =
9729 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9733 cmd_set_mirror_mask_parsed(void *parsed_result,
9734 __rte_unused struct cmdline *cl,
9735 __rte_unused void *data)
9738 struct cmd_set_mirror_mask_result *res = parsed_result;
9739 struct rte_eth_mirror_conf mr_conf;
9741 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9743 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9745 mr_conf.dst_pool = res->dstpool_id;
9747 if (!strcmp(res->what, "pool-mirror-up")) {
9748 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9749 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9750 } else if (!strcmp(res->what, "pool-mirror-down")) {
9751 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9752 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9753 } else if (!strcmp(res->what, "vlan-mirror")) {
9754 mr_conf.rule_type = ETH_MIRROR_VLAN;
9755 nb_item = parse_item_list(res->value, "vlan",
9756 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9760 for (i = 0; i < nb_item; i++) {
9761 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9762 printf("Invalid vlan_id: must be < 4096\n");
9766 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9767 mr_conf.vlan.vlan_mask |= 1ULL << i;
9771 if (!strcmp(res->on, "on"))
9772 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9775 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9778 printf("mirror rule add error: (%s)\n", strerror(-ret));
9781 cmdline_parse_inst_t cmd_set_mirror_mask = {
9782 .f = cmd_set_mirror_mask_parsed,
9784 .help_str = "set port <port_id> mirror-rule <rule_id> "
9785 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9786 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9788 (void *)&cmd_mirror_mask_set,
9789 (void *)&cmd_mirror_mask_port,
9790 (void *)&cmd_mirror_mask_portid,
9791 (void *)&cmd_mirror_mask_mirror,
9792 (void *)&cmd_mirror_mask_ruleid,
9793 (void *)&cmd_mirror_mask_what,
9794 (void *)&cmd_mirror_mask_value,
9795 (void *)&cmd_mirror_mask_dstpool,
9796 (void *)&cmd_mirror_mask_poolid,
9797 (void *)&cmd_mirror_mask_on,
9802 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9803 struct cmd_set_mirror_link_result {
9804 cmdline_fixed_string_t set;
9805 cmdline_fixed_string_t port;
9807 cmdline_fixed_string_t mirror;
9809 cmdline_fixed_string_t what;
9810 cmdline_fixed_string_t dstpool;
9812 cmdline_fixed_string_t on;
9815 cmdline_parse_token_string_t cmd_mirror_link_set =
9816 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9818 cmdline_parse_token_string_t cmd_mirror_link_port =
9819 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9821 cmdline_parse_token_num_t cmd_mirror_link_portid =
9822 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9824 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9825 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9826 mirror, "mirror-rule");
9827 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9828 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9830 cmdline_parse_token_string_t cmd_mirror_link_what =
9831 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9832 what, "uplink-mirror#downlink-mirror");
9833 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9834 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9835 dstpool, "dst-pool");
9836 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9837 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9839 cmdline_parse_token_string_t cmd_mirror_link_on =
9840 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9844 cmd_set_mirror_link_parsed(void *parsed_result,
9845 __rte_unused struct cmdline *cl,
9846 __rte_unused void *data)
9849 struct cmd_set_mirror_link_result *res = parsed_result;
9850 struct rte_eth_mirror_conf mr_conf;
9852 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9853 if (!strcmp(res->what, "uplink-mirror"))
9854 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9856 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9858 mr_conf.dst_pool = res->dstpool_id;
9860 if (!strcmp(res->on, "on"))
9861 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9864 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9867 /* check the return value and print it if is < 0 */
9869 printf("mirror rule add error: (%s)\n", strerror(-ret));
9873 cmdline_parse_inst_t cmd_set_mirror_link = {
9874 .f = cmd_set_mirror_link_parsed,
9876 .help_str = "set port <port_id> mirror-rule <rule_id> "
9877 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9879 (void *)&cmd_mirror_link_set,
9880 (void *)&cmd_mirror_link_port,
9881 (void *)&cmd_mirror_link_portid,
9882 (void *)&cmd_mirror_link_mirror,
9883 (void *)&cmd_mirror_link_ruleid,
9884 (void *)&cmd_mirror_link_what,
9885 (void *)&cmd_mirror_link_dstpool,
9886 (void *)&cmd_mirror_link_poolid,
9887 (void *)&cmd_mirror_link_on,
9892 /* *** RESET VM MIRROR RULE *** */
9893 struct cmd_rm_mirror_rule_result {
9894 cmdline_fixed_string_t reset;
9895 cmdline_fixed_string_t port;
9897 cmdline_fixed_string_t mirror;
9901 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9902 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9904 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9905 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9907 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9908 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9910 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9911 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9912 mirror, "mirror-rule");
9913 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9914 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9918 cmd_reset_mirror_rule_parsed(void *parsed_result,
9919 __rte_unused struct cmdline *cl,
9920 __rte_unused void *data)
9923 struct cmd_set_mirror_link_result *res = parsed_result;
9925 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9927 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9930 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9931 .f = cmd_reset_mirror_rule_parsed,
9933 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9935 (void *)&cmd_rm_mirror_rule_reset,
9936 (void *)&cmd_rm_mirror_rule_port,
9937 (void *)&cmd_rm_mirror_rule_portid,
9938 (void *)&cmd_rm_mirror_rule_mirror,
9939 (void *)&cmd_rm_mirror_rule_ruleid,
9944 /* ******************************************************************************** */
9946 struct cmd_dump_result {
9947 cmdline_fixed_string_t dump;
9951 dump_struct_sizes(void)
9953 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9954 DUMP_SIZE(struct rte_mbuf);
9955 DUMP_SIZE(struct rte_mempool);
9956 DUMP_SIZE(struct rte_ring);
9961 /* Dump the socket memory statistics on console */
9963 dump_socket_mem(FILE *f)
9965 struct rte_malloc_socket_stats socket_stats;
9970 unsigned int n_alloc = 0;
9971 unsigned int n_free = 0;
9972 static size_t last_allocs;
9973 static size_t last_total;
9976 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9977 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9978 !socket_stats.heap_totalsz_bytes)
9980 total += socket_stats.heap_totalsz_bytes;
9981 alloc += socket_stats.heap_allocsz_bytes;
9982 free += socket_stats.heap_freesz_bytes;
9983 n_alloc += socket_stats.alloc_count;
9984 n_free += socket_stats.free_count;
9986 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9988 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9989 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9990 (double)socket_stats.heap_allocsz_bytes * 100 /
9991 (double)socket_stats.heap_totalsz_bytes,
9992 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9993 socket_stats.alloc_count,
9994 socket_stats.free_count);
9997 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9998 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9999 (double)alloc * 100 / (double)total,
10000 (double)free / (1024 * 1024),
10003 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
10004 ((double)total - (double)last_total) / (1024 * 1024),
10005 (double)(alloc - (double)last_allocs) / 1024 / 1024);
10006 last_allocs = alloc;
10007 last_total = total;
10010 static void cmd_dump_parsed(void *parsed_result,
10011 __rte_unused struct cmdline *cl,
10012 __rte_unused void *data)
10014 struct cmd_dump_result *res = parsed_result;
10016 if (!strcmp(res->dump, "dump_physmem"))
10017 rte_dump_physmem_layout(stdout);
10018 else if (!strcmp(res->dump, "dump_socket_mem"))
10019 dump_socket_mem(stdout);
10020 else if (!strcmp(res->dump, "dump_memzone"))
10021 rte_memzone_dump(stdout);
10022 else if (!strcmp(res->dump, "dump_struct_sizes"))
10023 dump_struct_sizes();
10024 else if (!strcmp(res->dump, "dump_ring"))
10025 rte_ring_list_dump(stdout);
10026 else if (!strcmp(res->dump, "dump_mempool"))
10027 rte_mempool_list_dump(stdout);
10028 else if (!strcmp(res->dump, "dump_devargs"))
10029 rte_devargs_dump(stdout);
10030 else if (!strcmp(res->dump, "dump_log_types"))
10031 rte_log_dump(stdout);
10034 cmdline_parse_token_string_t cmd_dump_dump =
10035 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
10039 "dump_struct_sizes#"
10045 cmdline_parse_inst_t cmd_dump = {
10046 .f = cmd_dump_parsed, /* function to call */
10047 .data = NULL, /* 2nd arg of func */
10048 .help_str = "Dump status",
10049 .tokens = { /* token list, NULL terminated */
10050 (void *)&cmd_dump_dump,
10055 /* ******************************************************************************** */
10057 struct cmd_dump_one_result {
10058 cmdline_fixed_string_t dump;
10059 cmdline_fixed_string_t name;
10062 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
10063 __rte_unused void *data)
10065 struct cmd_dump_one_result *res = parsed_result;
10067 if (!strcmp(res->dump, "dump_ring")) {
10068 struct rte_ring *r;
10069 r = rte_ring_lookup(res->name);
10071 cmdline_printf(cl, "Cannot find ring\n");
10074 rte_ring_dump(stdout, r);
10075 } else if (!strcmp(res->dump, "dump_mempool")) {
10076 struct rte_mempool *mp;
10077 mp = rte_mempool_lookup(res->name);
10079 cmdline_printf(cl, "Cannot find mempool\n");
10082 rte_mempool_dump(stdout, mp);
10086 cmdline_parse_token_string_t cmd_dump_one_dump =
10087 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
10088 "dump_ring#dump_mempool");
10090 cmdline_parse_token_string_t cmd_dump_one_name =
10091 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
10093 cmdline_parse_inst_t cmd_dump_one = {
10094 .f = cmd_dump_one_parsed, /* function to call */
10095 .data = NULL, /* 2nd arg of func */
10096 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
10097 .tokens = { /* token list, NULL terminated */
10098 (void *)&cmd_dump_one_dump,
10099 (void *)&cmd_dump_one_name,
10104 /* *** Add/Del syn filter *** */
10105 struct cmd_syn_filter_result {
10106 cmdline_fixed_string_t filter;
10108 cmdline_fixed_string_t ops;
10109 cmdline_fixed_string_t priority;
10110 cmdline_fixed_string_t high;
10111 cmdline_fixed_string_t queue;
10116 cmd_syn_filter_parsed(void *parsed_result,
10117 __rte_unused struct cmdline *cl,
10118 __rte_unused void *data)
10120 struct cmd_syn_filter_result *res = parsed_result;
10121 struct rte_eth_syn_filter syn_filter;
10124 ret = rte_eth_dev_filter_supported(res->port_id,
10125 RTE_ETH_FILTER_SYN);
10127 printf("syn filter is not supported on port %u.\n",
10132 memset(&syn_filter, 0, sizeof(syn_filter));
10134 if (!strcmp(res->ops, "add")) {
10135 if (!strcmp(res->high, "high"))
10136 syn_filter.hig_pri = 1;
10138 syn_filter.hig_pri = 0;
10140 syn_filter.queue = res->queue_id;
10141 ret = rte_eth_dev_filter_ctrl(res->port_id,
10142 RTE_ETH_FILTER_SYN,
10143 RTE_ETH_FILTER_ADD,
10146 ret = rte_eth_dev_filter_ctrl(res->port_id,
10147 RTE_ETH_FILTER_SYN,
10148 RTE_ETH_FILTER_DELETE,
10152 printf("syn filter programming error: (%s)\n",
10156 cmdline_parse_token_string_t cmd_syn_filter_filter =
10157 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10158 filter, "syn_filter");
10159 cmdline_parse_token_num_t cmd_syn_filter_port_id =
10160 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
10162 cmdline_parse_token_string_t cmd_syn_filter_ops =
10163 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10165 cmdline_parse_token_string_t cmd_syn_filter_priority =
10166 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10167 priority, "priority");
10168 cmdline_parse_token_string_t cmd_syn_filter_high =
10169 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10171 cmdline_parse_token_string_t cmd_syn_filter_queue =
10172 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10174 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
10175 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
10178 cmdline_parse_inst_t cmd_syn_filter = {
10179 .f = cmd_syn_filter_parsed,
10181 .help_str = "syn_filter <port_id> add|del priority high|low queue "
10182 "<queue_id>: Add/Delete syn filter",
10184 (void *)&cmd_syn_filter_filter,
10185 (void *)&cmd_syn_filter_port_id,
10186 (void *)&cmd_syn_filter_ops,
10187 (void *)&cmd_syn_filter_priority,
10188 (void *)&cmd_syn_filter_high,
10189 (void *)&cmd_syn_filter_queue,
10190 (void *)&cmd_syn_filter_queue_id,
10195 /* *** queue region set *** */
10196 struct cmd_queue_region_result {
10197 cmdline_fixed_string_t set;
10198 cmdline_fixed_string_t port;
10200 cmdline_fixed_string_t cmd;
10201 cmdline_fixed_string_t region;
10203 cmdline_fixed_string_t queue_start_index;
10205 cmdline_fixed_string_t queue_num;
10206 uint8_t queue_num_value;
10210 cmd_queue_region_parsed(void *parsed_result,
10211 __rte_unused struct cmdline *cl,
10212 __rte_unused void *data)
10214 struct cmd_queue_region_result *res = parsed_result;
10215 int ret = -ENOTSUP;
10216 #ifdef RTE_NET_I40E
10217 struct rte_pmd_i40e_queue_region_conf region_conf;
10218 enum rte_pmd_i40e_queue_region_op op_type;
10221 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10224 #ifdef RTE_NET_I40E
10225 memset(®ion_conf, 0, sizeof(region_conf));
10226 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
10227 region_conf.region_id = res->region_id;
10228 region_conf.queue_num = res->queue_num_value;
10229 region_conf.queue_start_index = res->queue_id;
10231 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10232 op_type, ®ion_conf);
10239 printf("function not implemented or supported\n");
10242 printf("queue region config error: (%s)\n", strerror(-ret));
10246 cmdline_parse_token_string_t cmd_queue_region_set =
10247 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10249 cmdline_parse_token_string_t cmd_queue_region_port =
10250 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10251 cmdline_parse_token_num_t cmd_queue_region_port_id =
10252 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10254 cmdline_parse_token_string_t cmd_queue_region_cmd =
10255 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10256 cmd, "queue-region");
10257 cmdline_parse_token_string_t cmd_queue_region_id =
10258 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10259 region, "region_id");
10260 cmdline_parse_token_num_t cmd_queue_region_index =
10261 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10263 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10264 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10265 queue_start_index, "queue_start_index");
10266 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10267 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10269 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10270 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10271 queue_num, "queue_num");
10272 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10273 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10274 queue_num_value, UINT8);
10276 cmdline_parse_inst_t cmd_queue_region = {
10277 .f = cmd_queue_region_parsed,
10279 .help_str = "set port <port_id> queue-region region_id <value> "
10280 "queue_start_index <value> queue_num <value>: Set a queue region",
10282 (void *)&cmd_queue_region_set,
10283 (void *)&cmd_queue_region_port,
10284 (void *)&cmd_queue_region_port_id,
10285 (void *)&cmd_queue_region_cmd,
10286 (void *)&cmd_queue_region_id,
10287 (void *)&cmd_queue_region_index,
10288 (void *)&cmd_queue_region_queue_start_index,
10289 (void *)&cmd_queue_region_queue_id,
10290 (void *)&cmd_queue_region_queue_num,
10291 (void *)&cmd_queue_region_queue_num_value,
10296 /* *** queue region and flowtype set *** */
10297 struct cmd_region_flowtype_result {
10298 cmdline_fixed_string_t set;
10299 cmdline_fixed_string_t port;
10301 cmdline_fixed_string_t cmd;
10302 cmdline_fixed_string_t region;
10304 cmdline_fixed_string_t flowtype;
10305 uint8_t flowtype_id;
10309 cmd_region_flowtype_parsed(void *parsed_result,
10310 __rte_unused struct cmdline *cl,
10311 __rte_unused void *data)
10313 struct cmd_region_flowtype_result *res = parsed_result;
10314 int ret = -ENOTSUP;
10315 #ifdef RTE_NET_I40E
10316 struct rte_pmd_i40e_queue_region_conf region_conf;
10317 enum rte_pmd_i40e_queue_region_op op_type;
10320 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10323 #ifdef RTE_NET_I40E
10324 memset(®ion_conf, 0, sizeof(region_conf));
10326 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10327 region_conf.region_id = res->region_id;
10328 region_conf.hw_flowtype = res->flowtype_id;
10330 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10331 op_type, ®ion_conf);
10338 printf("function not implemented or supported\n");
10341 printf("region flowtype config error: (%s)\n", strerror(-ret));
10345 cmdline_parse_token_string_t cmd_region_flowtype_set =
10346 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10348 cmdline_parse_token_string_t cmd_region_flowtype_port =
10349 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10351 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10352 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10354 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10355 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10356 cmd, "queue-region");
10357 cmdline_parse_token_string_t cmd_region_flowtype_index =
10358 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10359 region, "region_id");
10360 cmdline_parse_token_num_t cmd_region_flowtype_id =
10361 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10363 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10364 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10365 flowtype, "flowtype");
10366 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10367 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10368 flowtype_id, UINT8);
10369 cmdline_parse_inst_t cmd_region_flowtype = {
10370 .f = cmd_region_flowtype_parsed,
10372 .help_str = "set port <port_id> queue-region region_id <value> "
10373 "flowtype <value>: Set a flowtype region index",
10375 (void *)&cmd_region_flowtype_set,
10376 (void *)&cmd_region_flowtype_port,
10377 (void *)&cmd_region_flowtype_port_index,
10378 (void *)&cmd_region_flowtype_cmd,
10379 (void *)&cmd_region_flowtype_index,
10380 (void *)&cmd_region_flowtype_id,
10381 (void *)&cmd_region_flowtype_flow_index,
10382 (void *)&cmd_region_flowtype_flow_id,
10387 /* *** User Priority (UP) to queue region (region_id) set *** */
10388 struct cmd_user_priority_region_result {
10389 cmdline_fixed_string_t set;
10390 cmdline_fixed_string_t port;
10392 cmdline_fixed_string_t cmd;
10393 cmdline_fixed_string_t user_priority;
10394 uint8_t user_priority_id;
10395 cmdline_fixed_string_t region;
10400 cmd_user_priority_region_parsed(void *parsed_result,
10401 __rte_unused struct cmdline *cl,
10402 __rte_unused void *data)
10404 struct cmd_user_priority_region_result *res = parsed_result;
10405 int ret = -ENOTSUP;
10406 #ifdef RTE_NET_I40E
10407 struct rte_pmd_i40e_queue_region_conf region_conf;
10408 enum rte_pmd_i40e_queue_region_op op_type;
10411 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10414 #ifdef RTE_NET_I40E
10415 memset(®ion_conf, 0, sizeof(region_conf));
10416 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10417 region_conf.user_priority = res->user_priority_id;
10418 region_conf.region_id = res->region_id;
10420 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10421 op_type, ®ion_conf);
10428 printf("function not implemented or supported\n");
10431 printf("user_priority region config error: (%s)\n",
10436 cmdline_parse_token_string_t cmd_user_priority_region_set =
10437 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10439 cmdline_parse_token_string_t cmd_user_priority_region_port =
10440 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10442 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10443 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10445 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10446 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10447 cmd, "queue-region");
10448 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10449 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10450 user_priority, "UP");
10451 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10452 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10453 user_priority_id, UINT8);
10454 cmdline_parse_token_string_t cmd_user_priority_region_region =
10455 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10456 region, "region_id");
10457 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10458 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10461 cmdline_parse_inst_t cmd_user_priority_region = {
10462 .f = cmd_user_priority_region_parsed,
10464 .help_str = "set port <port_id> queue-region UP <value> "
10465 "region_id <value>: Set the mapping of User Priority (UP) "
10466 "to queue region (region_id) ",
10468 (void *)&cmd_user_priority_region_set,
10469 (void *)&cmd_user_priority_region_port,
10470 (void *)&cmd_user_priority_region_port_index,
10471 (void *)&cmd_user_priority_region_cmd,
10472 (void *)&cmd_user_priority_region_UP,
10473 (void *)&cmd_user_priority_region_UP_id,
10474 (void *)&cmd_user_priority_region_region,
10475 (void *)&cmd_user_priority_region_region_id,
10480 /* *** flush all queue region related configuration *** */
10481 struct cmd_flush_queue_region_result {
10482 cmdline_fixed_string_t set;
10483 cmdline_fixed_string_t port;
10485 cmdline_fixed_string_t cmd;
10486 cmdline_fixed_string_t flush;
10487 cmdline_fixed_string_t what;
10491 cmd_flush_queue_region_parsed(void *parsed_result,
10492 __rte_unused struct cmdline *cl,
10493 __rte_unused void *data)
10495 struct cmd_flush_queue_region_result *res = parsed_result;
10496 int ret = -ENOTSUP;
10497 #ifdef RTE_NET_I40E
10498 struct rte_pmd_i40e_queue_region_conf region_conf;
10499 enum rte_pmd_i40e_queue_region_op op_type;
10502 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10505 #ifdef RTE_NET_I40E
10506 memset(®ion_conf, 0, sizeof(region_conf));
10508 if (strcmp(res->what, "on") == 0)
10509 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10511 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10513 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10514 op_type, ®ion_conf);
10521 printf("function not implemented or supported\n");
10524 printf("queue region config flush error: (%s)\n",
10529 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10530 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10532 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10533 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10535 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10536 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10538 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10539 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10540 cmd, "queue-region");
10541 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10542 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10544 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10545 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10548 cmdline_parse_inst_t cmd_flush_queue_region = {
10549 .f = cmd_flush_queue_region_parsed,
10551 .help_str = "set port <port_id> queue-region flush on|off"
10552 ": flush all queue region related configuration",
10554 (void *)&cmd_flush_queue_region_set,
10555 (void *)&cmd_flush_queue_region_port,
10556 (void *)&cmd_flush_queue_region_port_index,
10557 (void *)&cmd_flush_queue_region_cmd,
10558 (void *)&cmd_flush_queue_region_flush,
10559 (void *)&cmd_flush_queue_region_what,
10564 /* *** get all queue region related configuration info *** */
10565 struct cmd_show_queue_region_info {
10566 cmdline_fixed_string_t show;
10567 cmdline_fixed_string_t port;
10569 cmdline_fixed_string_t cmd;
10573 cmd_show_queue_region_info_parsed(void *parsed_result,
10574 __rte_unused struct cmdline *cl,
10575 __rte_unused void *data)
10577 struct cmd_show_queue_region_info *res = parsed_result;
10578 int ret = -ENOTSUP;
10579 #ifdef RTE_NET_I40E
10580 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10581 enum rte_pmd_i40e_queue_region_op op_type;
10584 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10587 #ifdef RTE_NET_I40E
10588 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10590 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10592 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10593 op_type, &rte_pmd_regions);
10595 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10602 printf("function not implemented or supported\n");
10605 printf("queue region config info show error: (%s)\n",
10610 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10611 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10613 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10614 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10616 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10617 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10619 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10620 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10621 cmd, "queue-region");
10623 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10624 .f = cmd_show_queue_region_info_parsed,
10626 .help_str = "show port <port_id> queue-region"
10627 ": show all queue region related configuration info",
10629 (void *)&cmd_show_queue_region_info_get,
10630 (void *)&cmd_show_queue_region_info_port,
10631 (void *)&cmd_show_queue_region_info_port_index,
10632 (void *)&cmd_show_queue_region_info_cmd,
10637 /* *** ADD/REMOVE A 2tuple FILTER *** */
10638 struct cmd_2tuple_filter_result {
10639 cmdline_fixed_string_t filter;
10641 cmdline_fixed_string_t ops;
10642 cmdline_fixed_string_t dst_port;
10643 uint16_t dst_port_value;
10644 cmdline_fixed_string_t protocol;
10645 uint8_t protocol_value;
10646 cmdline_fixed_string_t mask;
10647 uint8_t mask_value;
10648 cmdline_fixed_string_t tcp_flags;
10649 uint8_t tcp_flags_value;
10650 cmdline_fixed_string_t priority;
10651 uint8_t priority_value;
10652 cmdline_fixed_string_t queue;
10657 cmd_2tuple_filter_parsed(void *parsed_result,
10658 __rte_unused struct cmdline *cl,
10659 __rte_unused void *data)
10661 struct rte_eth_ntuple_filter filter;
10662 struct cmd_2tuple_filter_result *res = parsed_result;
10665 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10667 printf("ntuple filter is not supported on port %u.\n",
10672 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10674 filter.flags = RTE_2TUPLE_FLAGS;
10675 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10676 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10677 filter.proto = res->protocol_value;
10678 filter.priority = res->priority_value;
10679 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10680 printf("nonzero tcp_flags is only meaningful"
10681 " when protocol is TCP.\n");
10684 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10685 printf("invalid TCP flags.\n");
10689 if (res->tcp_flags_value != 0) {
10690 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10691 filter.tcp_flags = res->tcp_flags_value;
10694 /* need convert to big endian. */
10695 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10696 filter.queue = res->queue_id;
10698 if (!strcmp(res->ops, "add"))
10699 ret = rte_eth_dev_filter_ctrl(res->port_id,
10700 RTE_ETH_FILTER_NTUPLE,
10701 RTE_ETH_FILTER_ADD,
10704 ret = rte_eth_dev_filter_ctrl(res->port_id,
10705 RTE_ETH_FILTER_NTUPLE,
10706 RTE_ETH_FILTER_DELETE,
10709 printf("2tuple filter programming error: (%s)\n",
10714 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10715 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10716 filter, "2tuple_filter");
10717 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10718 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10720 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10721 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10723 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10724 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10725 dst_port, "dst_port");
10726 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10727 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10728 dst_port_value, UINT16);
10729 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10730 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10731 protocol, "protocol");
10732 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10733 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10734 protocol_value, UINT8);
10735 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10736 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10738 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10739 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10741 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10742 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10743 tcp_flags, "tcp_flags");
10744 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10745 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10746 tcp_flags_value, UINT8);
10747 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10748 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10749 priority, "priority");
10750 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10751 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10752 priority_value, UINT8);
10753 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10754 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10756 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10757 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10760 cmdline_parse_inst_t cmd_2tuple_filter = {
10761 .f = cmd_2tuple_filter_parsed,
10763 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10764 "<value> mask <value> tcp_flags <value> priority <value> queue "
10765 "<queue_id>: Add a 2tuple filter",
10767 (void *)&cmd_2tuple_filter_filter,
10768 (void *)&cmd_2tuple_filter_port_id,
10769 (void *)&cmd_2tuple_filter_ops,
10770 (void *)&cmd_2tuple_filter_dst_port,
10771 (void *)&cmd_2tuple_filter_dst_port_value,
10772 (void *)&cmd_2tuple_filter_protocol,
10773 (void *)&cmd_2tuple_filter_protocol_value,
10774 (void *)&cmd_2tuple_filter_mask,
10775 (void *)&cmd_2tuple_filter_mask_value,
10776 (void *)&cmd_2tuple_filter_tcp_flags,
10777 (void *)&cmd_2tuple_filter_tcp_flags_value,
10778 (void *)&cmd_2tuple_filter_priority,
10779 (void *)&cmd_2tuple_filter_priority_value,
10780 (void *)&cmd_2tuple_filter_queue,
10781 (void *)&cmd_2tuple_filter_queue_id,
10786 /* *** ADD/REMOVE A 5tuple FILTER *** */
10787 struct cmd_5tuple_filter_result {
10788 cmdline_fixed_string_t filter;
10790 cmdline_fixed_string_t ops;
10791 cmdline_fixed_string_t dst_ip;
10792 cmdline_ipaddr_t dst_ip_value;
10793 cmdline_fixed_string_t src_ip;
10794 cmdline_ipaddr_t src_ip_value;
10795 cmdline_fixed_string_t dst_port;
10796 uint16_t dst_port_value;
10797 cmdline_fixed_string_t src_port;
10798 uint16_t src_port_value;
10799 cmdline_fixed_string_t protocol;
10800 uint8_t protocol_value;
10801 cmdline_fixed_string_t mask;
10802 uint8_t mask_value;
10803 cmdline_fixed_string_t tcp_flags;
10804 uint8_t tcp_flags_value;
10805 cmdline_fixed_string_t priority;
10806 uint8_t priority_value;
10807 cmdline_fixed_string_t queue;
10812 cmd_5tuple_filter_parsed(void *parsed_result,
10813 __rte_unused struct cmdline *cl,
10814 __rte_unused void *data)
10816 struct rte_eth_ntuple_filter filter;
10817 struct cmd_5tuple_filter_result *res = parsed_result;
10820 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10822 printf("ntuple filter is not supported on port %u.\n",
10827 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10829 filter.flags = RTE_5TUPLE_FLAGS;
10830 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10831 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10832 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10833 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10834 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10835 filter.proto = res->protocol_value;
10836 filter.priority = res->priority_value;
10837 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10838 printf("nonzero tcp_flags is only meaningful"
10839 " when protocol is TCP.\n");
10842 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10843 printf("invalid TCP flags.\n");
10847 if (res->tcp_flags_value != 0) {
10848 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10849 filter.tcp_flags = res->tcp_flags_value;
10852 if (res->dst_ip_value.family == AF_INET)
10853 /* no need to convert, already big endian. */
10854 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10856 if (filter.dst_ip_mask == 0) {
10857 printf("can not support ipv6 involved compare.\n");
10863 if (res->src_ip_value.family == AF_INET)
10864 /* no need to convert, already big endian. */
10865 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10867 if (filter.src_ip_mask == 0) {
10868 printf("can not support ipv6 involved compare.\n");
10873 /* need convert to big endian. */
10874 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10875 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10876 filter.queue = res->queue_id;
10878 if (!strcmp(res->ops, "add"))
10879 ret = rte_eth_dev_filter_ctrl(res->port_id,
10880 RTE_ETH_FILTER_NTUPLE,
10881 RTE_ETH_FILTER_ADD,
10884 ret = rte_eth_dev_filter_ctrl(res->port_id,
10885 RTE_ETH_FILTER_NTUPLE,
10886 RTE_ETH_FILTER_DELETE,
10889 printf("5tuple filter programming error: (%s)\n",
10893 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10894 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10895 filter, "5tuple_filter");
10896 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10897 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10899 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10900 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10902 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10903 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10905 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10906 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10908 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10909 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10911 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10912 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10914 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10915 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10916 dst_port, "dst_port");
10917 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10918 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10919 dst_port_value, UINT16);
10920 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10921 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10922 src_port, "src_port");
10923 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10924 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10925 src_port_value, UINT16);
10926 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10927 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10928 protocol, "protocol");
10929 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10930 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10931 protocol_value, UINT8);
10932 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10933 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10935 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10936 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10938 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10939 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10940 tcp_flags, "tcp_flags");
10941 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10942 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10943 tcp_flags_value, UINT8);
10944 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10945 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10946 priority, "priority");
10947 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10948 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10949 priority_value, UINT8);
10950 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10951 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10953 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10954 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10957 cmdline_parse_inst_t cmd_5tuple_filter = {
10958 .f = cmd_5tuple_filter_parsed,
10960 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10961 "src_ip <value> dst_port <value> src_port <value> "
10962 "protocol <value> mask <value> tcp_flags <value> "
10963 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10965 (void *)&cmd_5tuple_filter_filter,
10966 (void *)&cmd_5tuple_filter_port_id,
10967 (void *)&cmd_5tuple_filter_ops,
10968 (void *)&cmd_5tuple_filter_dst_ip,
10969 (void *)&cmd_5tuple_filter_dst_ip_value,
10970 (void *)&cmd_5tuple_filter_src_ip,
10971 (void *)&cmd_5tuple_filter_src_ip_value,
10972 (void *)&cmd_5tuple_filter_dst_port,
10973 (void *)&cmd_5tuple_filter_dst_port_value,
10974 (void *)&cmd_5tuple_filter_src_port,
10975 (void *)&cmd_5tuple_filter_src_port_value,
10976 (void *)&cmd_5tuple_filter_protocol,
10977 (void *)&cmd_5tuple_filter_protocol_value,
10978 (void *)&cmd_5tuple_filter_mask,
10979 (void *)&cmd_5tuple_filter_mask_value,
10980 (void *)&cmd_5tuple_filter_tcp_flags,
10981 (void *)&cmd_5tuple_filter_tcp_flags_value,
10982 (void *)&cmd_5tuple_filter_priority,
10983 (void *)&cmd_5tuple_filter_priority_value,
10984 (void *)&cmd_5tuple_filter_queue,
10985 (void *)&cmd_5tuple_filter_queue_id,
10990 /* *** ADD/REMOVE A flex FILTER *** */
10991 struct cmd_flex_filter_result {
10992 cmdline_fixed_string_t filter;
10993 cmdline_fixed_string_t ops;
10995 cmdline_fixed_string_t len;
10997 cmdline_fixed_string_t bytes;
10998 cmdline_fixed_string_t bytes_value;
10999 cmdline_fixed_string_t mask;
11000 cmdline_fixed_string_t mask_value;
11001 cmdline_fixed_string_t priority;
11002 uint8_t priority_value;
11003 cmdline_fixed_string_t queue;
11007 static int xdigit2val(unsigned char c)
11012 else if (isupper(c))
11013 val = c - 'A' + 10;
11015 val = c - 'a' + 10;
11020 cmd_flex_filter_parsed(void *parsed_result,
11021 __rte_unused struct cmdline *cl,
11022 __rte_unused void *data)
11025 struct rte_eth_flex_filter filter;
11026 struct cmd_flex_filter_result *res = parsed_result;
11027 char *bytes_ptr, *mask_ptr;
11028 uint16_t len, i, j = 0;
11033 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
11034 printf("the len exceed the max length 128\n");
11037 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
11038 filter.len = res->len_value;
11039 filter.priority = res->priority_value;
11040 filter.queue = res->queue_id;
11041 bytes_ptr = res->bytes_value;
11042 mask_ptr = res->mask_value;
11044 /* translate bytes string to array. */
11045 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
11046 (bytes_ptr[1] == 'X')))
11048 len = strnlen(bytes_ptr, res->len_value * 2);
11049 if (len == 0 || (len % 8 != 0)) {
11050 printf("please check len and bytes input\n");
11053 for (i = 0; i < len; i++) {
11055 if (isxdigit(c) == 0) {
11056 /* invalid characters. */
11057 printf("invalid input\n");
11060 val = xdigit2val(c);
11063 filter.bytes[j] = byte;
11064 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
11071 /* translate mask string to uint8_t array. */
11072 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
11073 (mask_ptr[1] == 'X')))
11075 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
11077 printf("invalid input\n");
11082 for (i = 0; i < len; i++) {
11084 if (isxdigit(c) == 0) {
11085 /* invalid characters. */
11086 printf("invalid input\n");
11089 val = xdigit2val(c);
11092 filter.mask[j] = byte;
11093 printf("mask[%d]:%02x ", j, filter.mask[j]);
11101 if (!strcmp(res->ops, "add"))
11102 ret = rte_eth_dev_filter_ctrl(res->port_id,
11103 RTE_ETH_FILTER_FLEXIBLE,
11104 RTE_ETH_FILTER_ADD,
11107 ret = rte_eth_dev_filter_ctrl(res->port_id,
11108 RTE_ETH_FILTER_FLEXIBLE,
11109 RTE_ETH_FILTER_DELETE,
11113 printf("flex filter setting error: (%s)\n", strerror(-ret));
11116 cmdline_parse_token_string_t cmd_flex_filter_filter =
11117 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11118 filter, "flex_filter");
11119 cmdline_parse_token_num_t cmd_flex_filter_port_id =
11120 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11122 cmdline_parse_token_string_t cmd_flex_filter_ops =
11123 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11125 cmdline_parse_token_string_t cmd_flex_filter_len =
11126 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11128 cmdline_parse_token_num_t cmd_flex_filter_len_value =
11129 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11131 cmdline_parse_token_string_t cmd_flex_filter_bytes =
11132 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11134 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
11135 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11136 bytes_value, NULL);
11137 cmdline_parse_token_string_t cmd_flex_filter_mask =
11138 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11140 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
11141 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11143 cmdline_parse_token_string_t cmd_flex_filter_priority =
11144 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11145 priority, "priority");
11146 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
11147 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11148 priority_value, UINT8);
11149 cmdline_parse_token_string_t cmd_flex_filter_queue =
11150 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11152 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
11153 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11155 cmdline_parse_inst_t cmd_flex_filter = {
11156 .f = cmd_flex_filter_parsed,
11158 .help_str = "flex_filter <port_id> add|del len <value> bytes "
11159 "<value> mask <value> priority <value> queue <queue_id>: "
11160 "Add/Del a flex filter",
11162 (void *)&cmd_flex_filter_filter,
11163 (void *)&cmd_flex_filter_port_id,
11164 (void *)&cmd_flex_filter_ops,
11165 (void *)&cmd_flex_filter_len,
11166 (void *)&cmd_flex_filter_len_value,
11167 (void *)&cmd_flex_filter_bytes,
11168 (void *)&cmd_flex_filter_bytes_value,
11169 (void *)&cmd_flex_filter_mask,
11170 (void *)&cmd_flex_filter_mask_value,
11171 (void *)&cmd_flex_filter_priority,
11172 (void *)&cmd_flex_filter_priority_value,
11173 (void *)&cmd_flex_filter_queue,
11174 (void *)&cmd_flex_filter_queue_id,
11179 /* *** Filters Control *** */
11181 /* *** deal with ethertype filter *** */
11182 struct cmd_ethertype_filter_result {
11183 cmdline_fixed_string_t filter;
11185 cmdline_fixed_string_t ops;
11186 cmdline_fixed_string_t mac;
11187 struct rte_ether_addr mac_addr;
11188 cmdline_fixed_string_t ethertype;
11189 uint16_t ethertype_value;
11190 cmdline_fixed_string_t drop;
11191 cmdline_fixed_string_t queue;
11195 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
11196 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11197 filter, "ethertype_filter");
11198 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
11199 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
11201 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
11202 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11204 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
11205 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11206 mac, "mac_addr#mac_ignr");
11207 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
11208 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
11210 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
11211 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11212 ethertype, "ethertype");
11213 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
11214 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
11215 ethertype_value, UINT16);
11216 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
11217 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11219 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
11220 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11222 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
11223 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
11227 cmd_ethertype_filter_parsed(void *parsed_result,
11228 __rte_unused struct cmdline *cl,
11229 __rte_unused void *data)
11231 struct cmd_ethertype_filter_result *res = parsed_result;
11232 struct rte_eth_ethertype_filter filter;
11235 ret = rte_eth_dev_filter_supported(res->port_id,
11236 RTE_ETH_FILTER_ETHERTYPE);
11238 printf("ethertype filter is not supported on port %u.\n",
11243 memset(&filter, 0, sizeof(filter));
11244 if (!strcmp(res->mac, "mac_addr")) {
11245 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
11246 rte_memcpy(&filter.mac_addr, &res->mac_addr,
11247 sizeof(struct rte_ether_addr));
11249 if (!strcmp(res->drop, "drop"))
11250 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
11251 filter.ether_type = res->ethertype_value;
11252 filter.queue = res->queue_id;
11254 if (!strcmp(res->ops, "add"))
11255 ret = rte_eth_dev_filter_ctrl(res->port_id,
11256 RTE_ETH_FILTER_ETHERTYPE,
11257 RTE_ETH_FILTER_ADD,
11260 ret = rte_eth_dev_filter_ctrl(res->port_id,
11261 RTE_ETH_FILTER_ETHERTYPE,
11262 RTE_ETH_FILTER_DELETE,
11265 printf("ethertype filter programming error: (%s)\n",
11269 cmdline_parse_inst_t cmd_ethertype_filter = {
11270 .f = cmd_ethertype_filter_parsed,
11272 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
11273 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
11274 "Add or delete an ethertype filter entry",
11276 (void *)&cmd_ethertype_filter_filter,
11277 (void *)&cmd_ethertype_filter_port_id,
11278 (void *)&cmd_ethertype_filter_ops,
11279 (void *)&cmd_ethertype_filter_mac,
11280 (void *)&cmd_ethertype_filter_mac_addr,
11281 (void *)&cmd_ethertype_filter_ethertype,
11282 (void *)&cmd_ethertype_filter_ethertype_value,
11283 (void *)&cmd_ethertype_filter_drop,
11284 (void *)&cmd_ethertype_filter_queue,
11285 (void *)&cmd_ethertype_filter_queue_id,
11290 /* *** deal with flow director filter *** */
11291 struct cmd_flow_director_result {
11292 cmdline_fixed_string_t flow_director_filter;
11294 cmdline_fixed_string_t mode;
11295 cmdline_fixed_string_t mode_value;
11296 cmdline_fixed_string_t ops;
11297 cmdline_fixed_string_t flow;
11298 cmdline_fixed_string_t flow_type;
11299 cmdline_fixed_string_t ether;
11300 uint16_t ether_type;
11301 cmdline_fixed_string_t src;
11302 cmdline_ipaddr_t ip_src;
11304 cmdline_fixed_string_t dst;
11305 cmdline_ipaddr_t ip_dst;
11307 cmdline_fixed_string_t verify_tag;
11308 uint32_t verify_tag_value;
11309 cmdline_fixed_string_t tos;
11311 cmdline_fixed_string_t proto;
11312 uint8_t proto_value;
11313 cmdline_fixed_string_t ttl;
11315 cmdline_fixed_string_t vlan;
11316 uint16_t vlan_value;
11317 cmdline_fixed_string_t flexbytes;
11318 cmdline_fixed_string_t flexbytes_value;
11319 cmdline_fixed_string_t pf_vf;
11320 cmdline_fixed_string_t drop;
11321 cmdline_fixed_string_t queue;
11323 cmdline_fixed_string_t fd_id;
11324 uint32_t fd_id_value;
11325 cmdline_fixed_string_t mac;
11326 struct rte_ether_addr mac_addr;
11327 cmdline_fixed_string_t tunnel;
11328 cmdline_fixed_string_t tunnel_type;
11329 cmdline_fixed_string_t tunnel_id;
11330 uint32_t tunnel_id_value;
11331 cmdline_fixed_string_t packet;
11336 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
11339 const char *p, *p0 = q_arg;
11341 unsigned long int_fld;
11342 char *str_fld[max_num];
11347 p = strchr(p0, '(');
11351 p0 = strchr(p, ')');
11356 if (size >= sizeof(s))
11359 snprintf(s, sizeof(s), "%.*s", size, p);
11360 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11361 if (ret < 0 || ret > max_num)
11363 for (i = 0; i < ret; i++) {
11365 int_fld = strtoul(str_fld[i], &end, 0);
11366 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
11368 flexbytes[i] = (uint8_t)int_fld;
11374 str2flowtype(char *string)
11377 static const struct {
11380 } flowtype_str[] = {
11381 {"raw", RTE_ETH_FLOW_RAW},
11382 {"ipv4", RTE_ETH_FLOW_IPV4},
11383 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11384 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11385 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11386 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11387 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11388 {"ipv6", RTE_ETH_FLOW_IPV6},
11389 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11390 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11391 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11392 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11393 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11394 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11397 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
11398 if (!strcmp(flowtype_str[i].str, string))
11399 return flowtype_str[i].type;
11402 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
11403 return (uint16_t)atoi(string);
11405 return RTE_ETH_FLOW_UNKNOWN;
11408 static enum rte_eth_fdir_tunnel_type
11409 str2fdir_tunneltype(char *string)
11413 static const struct {
11415 enum rte_eth_fdir_tunnel_type type;
11416 } tunneltype_str[] = {
11417 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
11418 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
11421 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
11422 if (!strcmp(tunneltype_str[i].str, string))
11423 return tunneltype_str[i].type;
11425 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
11428 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
11430 if ((ip_addr).family == AF_INET) \
11431 (ip) = (ip_addr).addr.ipv4.s_addr; \
11433 printf("invalid parameter.\n"); \
11438 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
11440 if ((ip_addr).family == AF_INET6) \
11441 rte_memcpy(&(ip), \
11442 &((ip_addr).addr.ipv6), \
11443 sizeof(struct in6_addr)); \
11445 printf("invalid parameter.\n"); \
11451 cmd_flow_director_filter_parsed(void *parsed_result,
11452 __rte_unused struct cmdline *cl,
11453 __rte_unused void *data)
11455 struct cmd_flow_director_result *res = parsed_result;
11456 struct rte_eth_fdir_filter entry;
11457 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11459 unsigned long vf_id;
11462 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11464 printf("flow director is not supported on port %u.\n",
11468 memset(flexbytes, 0, sizeof(flexbytes));
11469 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11471 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11472 if (strcmp(res->mode_value, "MAC-VLAN")) {
11473 printf("Please set mode to MAC-VLAN.\n");
11476 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11477 if (strcmp(res->mode_value, "Tunnel")) {
11478 printf("Please set mode to Tunnel.\n");
11482 if (!strcmp(res->mode_value, "raw")) {
11483 #ifdef RTE_NET_I40E
11484 struct rte_pmd_i40e_flow_type_mapping
11485 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11486 struct rte_pmd_i40e_pkt_template_conf conf;
11487 uint16_t flow_type = str2flowtype(res->flow_type);
11488 uint16_t i, port = res->port_id;
11491 memset(&conf, 0, sizeof(conf));
11493 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11494 printf("Invalid flow type specified.\n");
11497 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11501 if (mapping[flow_type].pctype == 0ULL) {
11502 printf("Invalid flow type specified.\n");
11505 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11506 if (mapping[flow_type].pctype & (1ULL << i)) {
11507 conf.input.pctype = i;
11512 conf.input.packet = open_file(res->filepath,
11513 &conf.input.length);
11514 if (!conf.input.packet)
11516 if (!strcmp(res->drop, "drop"))
11517 conf.action.behavior =
11518 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11520 conf.action.behavior =
11521 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11522 conf.action.report_status =
11523 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11524 conf.action.rx_queue = res->queue_id;
11525 conf.soft_id = res->fd_id_value;
11526 add = strcmp(res->ops, "del") ? 1 : 0;
11527 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11531 printf("flow director config error: (%s)\n",
11533 close_file(conf.input.packet);
11536 } else if (strcmp(res->mode_value, "IP")) {
11537 printf("Please set mode to IP or raw.\n");
11540 entry.input.flow_type = str2flowtype(res->flow_type);
11543 ret = parse_flexbytes(res->flexbytes_value,
11545 RTE_ETH_FDIR_MAX_FLEXLEN);
11547 printf("error: Cannot parse flexbytes input.\n");
11551 switch (entry.input.flow_type) {
11552 case RTE_ETH_FLOW_FRAG_IPV4:
11553 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11554 entry.input.flow.ip4_flow.proto = res->proto_value;
11556 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11557 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11558 IPV4_ADDR_TO_UINT(res->ip_dst,
11559 entry.input.flow.ip4_flow.dst_ip);
11560 IPV4_ADDR_TO_UINT(res->ip_src,
11561 entry.input.flow.ip4_flow.src_ip);
11562 entry.input.flow.ip4_flow.tos = res->tos_value;
11563 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11564 /* need convert to big endian. */
11565 entry.input.flow.udp4_flow.dst_port =
11566 rte_cpu_to_be_16(res->port_dst);
11567 entry.input.flow.udp4_flow.src_port =
11568 rte_cpu_to_be_16(res->port_src);
11570 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11571 IPV4_ADDR_TO_UINT(res->ip_dst,
11572 entry.input.flow.sctp4_flow.ip.dst_ip);
11573 IPV4_ADDR_TO_UINT(res->ip_src,
11574 entry.input.flow.sctp4_flow.ip.src_ip);
11575 entry.input.flow.ip4_flow.tos = res->tos_value;
11576 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11577 /* need convert to big endian. */
11578 entry.input.flow.sctp4_flow.dst_port =
11579 rte_cpu_to_be_16(res->port_dst);
11580 entry.input.flow.sctp4_flow.src_port =
11581 rte_cpu_to_be_16(res->port_src);
11582 entry.input.flow.sctp4_flow.verify_tag =
11583 rte_cpu_to_be_32(res->verify_tag_value);
11585 case RTE_ETH_FLOW_FRAG_IPV6:
11586 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11587 entry.input.flow.ipv6_flow.proto = res->proto_value;
11589 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11590 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11591 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11592 entry.input.flow.ipv6_flow.dst_ip);
11593 IPV6_ADDR_TO_ARRAY(res->ip_src,
11594 entry.input.flow.ipv6_flow.src_ip);
11595 entry.input.flow.ipv6_flow.tc = res->tos_value;
11596 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11597 /* need convert to big endian. */
11598 entry.input.flow.udp6_flow.dst_port =
11599 rte_cpu_to_be_16(res->port_dst);
11600 entry.input.flow.udp6_flow.src_port =
11601 rte_cpu_to_be_16(res->port_src);
11603 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11604 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11605 entry.input.flow.sctp6_flow.ip.dst_ip);
11606 IPV6_ADDR_TO_ARRAY(res->ip_src,
11607 entry.input.flow.sctp6_flow.ip.src_ip);
11608 entry.input.flow.ipv6_flow.tc = res->tos_value;
11609 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11610 /* need convert to big endian. */
11611 entry.input.flow.sctp6_flow.dst_port =
11612 rte_cpu_to_be_16(res->port_dst);
11613 entry.input.flow.sctp6_flow.src_port =
11614 rte_cpu_to_be_16(res->port_src);
11615 entry.input.flow.sctp6_flow.verify_tag =
11616 rte_cpu_to_be_32(res->verify_tag_value);
11618 case RTE_ETH_FLOW_L2_PAYLOAD:
11619 entry.input.flow.l2_flow.ether_type =
11620 rte_cpu_to_be_16(res->ether_type);
11626 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11627 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11629 sizeof(struct rte_ether_addr));
11631 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11632 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11634 sizeof(struct rte_ether_addr));
11635 entry.input.flow.tunnel_flow.tunnel_type =
11636 str2fdir_tunneltype(res->tunnel_type);
11637 entry.input.flow.tunnel_flow.tunnel_id =
11638 rte_cpu_to_be_32(res->tunnel_id_value);
11641 rte_memcpy(entry.input.flow_ext.flexbytes,
11643 RTE_ETH_FDIR_MAX_FLEXLEN);
11645 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11647 entry.action.flex_off = 0; /*use 0 by default */
11648 if (!strcmp(res->drop, "drop"))
11649 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11651 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11653 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11654 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11655 if (!strcmp(res->pf_vf, "pf"))
11656 entry.input.flow_ext.is_vf = 0;
11657 else if (!strncmp(res->pf_vf, "vf", 2)) {
11658 struct rte_eth_dev_info dev_info;
11660 ret = eth_dev_info_get_print_err(res->port_id,
11666 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11667 if (errno != 0 || *end != '\0' ||
11668 vf_id >= dev_info.max_vfs) {
11669 printf("invalid parameter %s.\n", res->pf_vf);
11672 entry.input.flow_ext.is_vf = 1;
11673 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11675 printf("invalid parameter %s.\n", res->pf_vf);
11680 /* set to report FD ID by default */
11681 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11682 entry.action.rx_queue = res->queue_id;
11683 entry.soft_id = res->fd_id_value;
11684 if (!strcmp(res->ops, "add"))
11685 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11686 RTE_ETH_FILTER_ADD, &entry);
11687 else if (!strcmp(res->ops, "del"))
11688 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11689 RTE_ETH_FILTER_DELETE, &entry);
11691 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11692 RTE_ETH_FILTER_UPDATE, &entry);
11694 printf("flow director programming error: (%s)\n",
11698 cmdline_parse_token_string_t cmd_flow_director_filter =
11699 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11700 flow_director_filter, "flow_director_filter");
11701 cmdline_parse_token_num_t cmd_flow_director_port_id =
11702 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11704 cmdline_parse_token_string_t cmd_flow_director_ops =
11705 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11706 ops, "add#del#update");
11707 cmdline_parse_token_string_t cmd_flow_director_flow =
11708 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11710 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11711 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11713 cmdline_parse_token_string_t cmd_flow_director_ether =
11714 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11716 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11717 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11718 ether_type, UINT16);
11719 cmdline_parse_token_string_t cmd_flow_director_src =
11720 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11722 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11723 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11725 cmdline_parse_token_num_t cmd_flow_director_port_src =
11726 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11728 cmdline_parse_token_string_t cmd_flow_director_dst =
11729 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11731 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11732 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11734 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11735 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11737 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11738 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11739 verify_tag, "verify_tag");
11740 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11741 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11742 verify_tag_value, UINT32);
11743 cmdline_parse_token_string_t cmd_flow_director_tos =
11744 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11746 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11747 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11749 cmdline_parse_token_string_t cmd_flow_director_proto =
11750 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11752 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11753 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11754 proto_value, UINT8);
11755 cmdline_parse_token_string_t cmd_flow_director_ttl =
11756 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11758 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11759 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11761 cmdline_parse_token_string_t cmd_flow_director_vlan =
11762 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11764 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11765 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11766 vlan_value, UINT16);
11767 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11768 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11769 flexbytes, "flexbytes");
11770 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11771 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11772 flexbytes_value, NULL);
11773 cmdline_parse_token_string_t cmd_flow_director_drop =
11774 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11776 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11777 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11779 cmdline_parse_token_string_t cmd_flow_director_queue =
11780 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11782 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11783 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11785 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11786 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11788 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11789 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11790 fd_id_value, UINT32);
11792 cmdline_parse_token_string_t cmd_flow_director_mode =
11793 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11795 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11796 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11798 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11799 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11800 mode_value, "MAC-VLAN");
11801 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11802 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11803 mode_value, "Tunnel");
11804 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11805 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11806 mode_value, "raw");
11807 cmdline_parse_token_string_t cmd_flow_director_mac =
11808 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11810 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11811 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11813 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11814 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11816 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11817 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11818 tunnel_type, "NVGRE#VxLAN");
11819 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11820 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11821 tunnel_id, "tunnel-id");
11822 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11823 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11824 tunnel_id_value, UINT32);
11825 cmdline_parse_token_string_t cmd_flow_director_packet =
11826 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11828 cmdline_parse_token_string_t cmd_flow_director_filepath =
11829 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11832 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11833 .f = cmd_flow_director_filter_parsed,
11835 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11836 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11837 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11838 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11839 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11840 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11841 "fd_id <fd_id_value>: "
11842 "Add or delete an ip flow director entry on NIC",
11844 (void *)&cmd_flow_director_filter,
11845 (void *)&cmd_flow_director_port_id,
11846 (void *)&cmd_flow_director_mode,
11847 (void *)&cmd_flow_director_mode_ip,
11848 (void *)&cmd_flow_director_ops,
11849 (void *)&cmd_flow_director_flow,
11850 (void *)&cmd_flow_director_flow_type,
11851 (void *)&cmd_flow_director_src,
11852 (void *)&cmd_flow_director_ip_src,
11853 (void *)&cmd_flow_director_dst,
11854 (void *)&cmd_flow_director_ip_dst,
11855 (void *)&cmd_flow_director_tos,
11856 (void *)&cmd_flow_director_tos_value,
11857 (void *)&cmd_flow_director_proto,
11858 (void *)&cmd_flow_director_proto_value,
11859 (void *)&cmd_flow_director_ttl,
11860 (void *)&cmd_flow_director_ttl_value,
11861 (void *)&cmd_flow_director_vlan,
11862 (void *)&cmd_flow_director_vlan_value,
11863 (void *)&cmd_flow_director_flexbytes,
11864 (void *)&cmd_flow_director_flexbytes_value,
11865 (void *)&cmd_flow_director_drop,
11866 (void *)&cmd_flow_director_pf_vf,
11867 (void *)&cmd_flow_director_queue,
11868 (void *)&cmd_flow_director_queue_id,
11869 (void *)&cmd_flow_director_fd_id,
11870 (void *)&cmd_flow_director_fd_id_value,
11875 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11876 .f = cmd_flow_director_filter_parsed,
11878 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11879 "director entry on NIC",
11881 (void *)&cmd_flow_director_filter,
11882 (void *)&cmd_flow_director_port_id,
11883 (void *)&cmd_flow_director_mode,
11884 (void *)&cmd_flow_director_mode_ip,
11885 (void *)&cmd_flow_director_ops,
11886 (void *)&cmd_flow_director_flow,
11887 (void *)&cmd_flow_director_flow_type,
11888 (void *)&cmd_flow_director_src,
11889 (void *)&cmd_flow_director_ip_src,
11890 (void *)&cmd_flow_director_port_src,
11891 (void *)&cmd_flow_director_dst,
11892 (void *)&cmd_flow_director_ip_dst,
11893 (void *)&cmd_flow_director_port_dst,
11894 (void *)&cmd_flow_director_tos,
11895 (void *)&cmd_flow_director_tos_value,
11896 (void *)&cmd_flow_director_ttl,
11897 (void *)&cmd_flow_director_ttl_value,
11898 (void *)&cmd_flow_director_vlan,
11899 (void *)&cmd_flow_director_vlan_value,
11900 (void *)&cmd_flow_director_flexbytes,
11901 (void *)&cmd_flow_director_flexbytes_value,
11902 (void *)&cmd_flow_director_drop,
11903 (void *)&cmd_flow_director_pf_vf,
11904 (void *)&cmd_flow_director_queue,
11905 (void *)&cmd_flow_director_queue_id,
11906 (void *)&cmd_flow_director_fd_id,
11907 (void *)&cmd_flow_director_fd_id_value,
11912 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11913 .f = cmd_flow_director_filter_parsed,
11915 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11916 "director entry on NIC",
11918 (void *)&cmd_flow_director_filter,
11919 (void *)&cmd_flow_director_port_id,
11920 (void *)&cmd_flow_director_mode,
11921 (void *)&cmd_flow_director_mode_ip,
11922 (void *)&cmd_flow_director_ops,
11923 (void *)&cmd_flow_director_flow,
11924 (void *)&cmd_flow_director_flow_type,
11925 (void *)&cmd_flow_director_src,
11926 (void *)&cmd_flow_director_ip_src,
11927 (void *)&cmd_flow_director_port_src,
11928 (void *)&cmd_flow_director_dst,
11929 (void *)&cmd_flow_director_ip_dst,
11930 (void *)&cmd_flow_director_port_dst,
11931 (void *)&cmd_flow_director_verify_tag,
11932 (void *)&cmd_flow_director_verify_tag_value,
11933 (void *)&cmd_flow_director_tos,
11934 (void *)&cmd_flow_director_tos_value,
11935 (void *)&cmd_flow_director_ttl,
11936 (void *)&cmd_flow_director_ttl_value,
11937 (void *)&cmd_flow_director_vlan,
11938 (void *)&cmd_flow_director_vlan_value,
11939 (void *)&cmd_flow_director_flexbytes,
11940 (void *)&cmd_flow_director_flexbytes_value,
11941 (void *)&cmd_flow_director_drop,
11942 (void *)&cmd_flow_director_pf_vf,
11943 (void *)&cmd_flow_director_queue,
11944 (void *)&cmd_flow_director_queue_id,
11945 (void *)&cmd_flow_director_fd_id,
11946 (void *)&cmd_flow_director_fd_id_value,
11951 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11952 .f = cmd_flow_director_filter_parsed,
11954 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11955 "director entry on NIC",
11957 (void *)&cmd_flow_director_filter,
11958 (void *)&cmd_flow_director_port_id,
11959 (void *)&cmd_flow_director_mode,
11960 (void *)&cmd_flow_director_mode_ip,
11961 (void *)&cmd_flow_director_ops,
11962 (void *)&cmd_flow_director_flow,
11963 (void *)&cmd_flow_director_flow_type,
11964 (void *)&cmd_flow_director_ether,
11965 (void *)&cmd_flow_director_ether_type,
11966 (void *)&cmd_flow_director_flexbytes,
11967 (void *)&cmd_flow_director_flexbytes_value,
11968 (void *)&cmd_flow_director_drop,
11969 (void *)&cmd_flow_director_pf_vf,
11970 (void *)&cmd_flow_director_queue,
11971 (void *)&cmd_flow_director_queue_id,
11972 (void *)&cmd_flow_director_fd_id,
11973 (void *)&cmd_flow_director_fd_id_value,
11978 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11979 .f = cmd_flow_director_filter_parsed,
11981 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11982 "director entry on NIC",
11984 (void *)&cmd_flow_director_filter,
11985 (void *)&cmd_flow_director_port_id,
11986 (void *)&cmd_flow_director_mode,
11987 (void *)&cmd_flow_director_mode_mac_vlan,
11988 (void *)&cmd_flow_director_ops,
11989 (void *)&cmd_flow_director_mac,
11990 (void *)&cmd_flow_director_mac_addr,
11991 (void *)&cmd_flow_director_vlan,
11992 (void *)&cmd_flow_director_vlan_value,
11993 (void *)&cmd_flow_director_flexbytes,
11994 (void *)&cmd_flow_director_flexbytes_value,
11995 (void *)&cmd_flow_director_drop,
11996 (void *)&cmd_flow_director_queue,
11997 (void *)&cmd_flow_director_queue_id,
11998 (void *)&cmd_flow_director_fd_id,
11999 (void *)&cmd_flow_director_fd_id_value,
12004 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
12005 .f = cmd_flow_director_filter_parsed,
12007 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
12008 "director entry on NIC",
12010 (void *)&cmd_flow_director_filter,
12011 (void *)&cmd_flow_director_port_id,
12012 (void *)&cmd_flow_director_mode,
12013 (void *)&cmd_flow_director_mode_tunnel,
12014 (void *)&cmd_flow_director_ops,
12015 (void *)&cmd_flow_director_mac,
12016 (void *)&cmd_flow_director_mac_addr,
12017 (void *)&cmd_flow_director_vlan,
12018 (void *)&cmd_flow_director_vlan_value,
12019 (void *)&cmd_flow_director_tunnel,
12020 (void *)&cmd_flow_director_tunnel_type,
12021 (void *)&cmd_flow_director_tunnel_id,
12022 (void *)&cmd_flow_director_tunnel_id_value,
12023 (void *)&cmd_flow_director_flexbytes,
12024 (void *)&cmd_flow_director_flexbytes_value,
12025 (void *)&cmd_flow_director_drop,
12026 (void *)&cmd_flow_director_queue,
12027 (void *)&cmd_flow_director_queue_id,
12028 (void *)&cmd_flow_director_fd_id,
12029 (void *)&cmd_flow_director_fd_id_value,
12034 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
12035 .f = cmd_flow_director_filter_parsed,
12037 .help_str = "flow_director_filter ... : Add or delete a raw flow "
12038 "director entry on NIC",
12040 (void *)&cmd_flow_director_filter,
12041 (void *)&cmd_flow_director_port_id,
12042 (void *)&cmd_flow_director_mode,
12043 (void *)&cmd_flow_director_mode_raw,
12044 (void *)&cmd_flow_director_ops,
12045 (void *)&cmd_flow_director_flow,
12046 (void *)&cmd_flow_director_flow_type,
12047 (void *)&cmd_flow_director_drop,
12048 (void *)&cmd_flow_director_queue,
12049 (void *)&cmd_flow_director_queue_id,
12050 (void *)&cmd_flow_director_fd_id,
12051 (void *)&cmd_flow_director_fd_id_value,
12052 (void *)&cmd_flow_director_packet,
12053 (void *)&cmd_flow_director_filepath,
12058 struct cmd_flush_flow_director_result {
12059 cmdline_fixed_string_t flush_flow_director;
12063 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
12064 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
12065 flush_flow_director, "flush_flow_director");
12066 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
12067 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
12071 cmd_flush_flow_director_parsed(void *parsed_result,
12072 __rte_unused struct cmdline *cl,
12073 __rte_unused void *data)
12075 struct cmd_flow_director_result *res = parsed_result;
12078 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
12080 printf("flow director is not supported on port %u.\n",
12085 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12086 RTE_ETH_FILTER_FLUSH, NULL);
12088 printf("flow director table flushing error: (%s)\n",
12092 cmdline_parse_inst_t cmd_flush_flow_director = {
12093 .f = cmd_flush_flow_director_parsed,
12095 .help_str = "flush_flow_director <port_id>: "
12096 "Flush all flow director entries of a device on NIC",
12098 (void *)&cmd_flush_flow_director_flush,
12099 (void *)&cmd_flush_flow_director_port_id,
12104 /* *** deal with flow director mask *** */
12105 struct cmd_flow_director_mask_result {
12106 cmdline_fixed_string_t flow_director_mask;
12108 cmdline_fixed_string_t mode;
12109 cmdline_fixed_string_t mode_value;
12110 cmdline_fixed_string_t vlan;
12111 uint16_t vlan_mask;
12112 cmdline_fixed_string_t src_mask;
12113 cmdline_ipaddr_t ipv4_src;
12114 cmdline_ipaddr_t ipv6_src;
12116 cmdline_fixed_string_t dst_mask;
12117 cmdline_ipaddr_t ipv4_dst;
12118 cmdline_ipaddr_t ipv6_dst;
12120 cmdline_fixed_string_t mac;
12121 uint8_t mac_addr_byte_mask;
12122 cmdline_fixed_string_t tunnel_id;
12123 uint32_t tunnel_id_mask;
12124 cmdline_fixed_string_t tunnel_type;
12125 uint8_t tunnel_type_mask;
12129 cmd_flow_director_mask_parsed(void *parsed_result,
12130 __rte_unused struct cmdline *cl,
12131 __rte_unused void *data)
12133 struct cmd_flow_director_mask_result *res = parsed_result;
12134 struct rte_eth_fdir_masks *mask;
12135 struct rte_port *port;
12137 port = &ports[res->port_id];
12138 /** Check if the port is not started **/
12139 if (port->port_status != RTE_PORT_STOPPED) {
12140 printf("Please stop port %d first\n", res->port_id);
12144 mask = &port->dev_conf.fdir_conf.mask;
12146 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
12147 if (strcmp(res->mode_value, "MAC-VLAN")) {
12148 printf("Please set mode to MAC-VLAN.\n");
12152 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
12153 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
12154 if (strcmp(res->mode_value, "Tunnel")) {
12155 printf("Please set mode to Tunnel.\n");
12159 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
12160 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
12161 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
12162 mask->tunnel_type_mask = res->tunnel_type_mask;
12164 if (strcmp(res->mode_value, "IP")) {
12165 printf("Please set mode to IP.\n");
12169 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
12170 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
12171 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
12172 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
12173 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
12174 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
12175 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
12178 cmd_reconfig_device_queue(res->port_id, 1, 1);
12181 cmdline_parse_token_string_t cmd_flow_director_mask =
12182 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12183 flow_director_mask, "flow_director_mask");
12184 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
12185 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12187 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
12188 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12190 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
12191 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12192 vlan_mask, UINT16);
12193 cmdline_parse_token_string_t cmd_flow_director_mask_src =
12194 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12195 src_mask, "src_mask");
12196 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
12197 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12199 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
12200 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12202 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
12203 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12205 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
12206 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12207 dst_mask, "dst_mask");
12208 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
12209 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12211 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
12212 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12214 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
12215 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12218 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
12219 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12221 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
12222 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12224 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
12225 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12226 mode_value, "MAC-VLAN");
12227 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
12228 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12229 mode_value, "Tunnel");
12230 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
12231 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12233 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
12234 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12235 mac_addr_byte_mask, UINT8);
12236 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
12237 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12238 tunnel_type, "tunnel-type");
12239 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
12240 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12241 tunnel_type_mask, UINT8);
12242 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
12243 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12244 tunnel_id, "tunnel-id");
12245 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
12246 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12247 tunnel_id_mask, UINT32);
12249 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
12250 .f = cmd_flow_director_mask_parsed,
12252 .help_str = "flow_director_mask ... : "
12253 "Set IP mode flow director's mask on NIC",
12255 (void *)&cmd_flow_director_mask,
12256 (void *)&cmd_flow_director_mask_port_id,
12257 (void *)&cmd_flow_director_mask_mode,
12258 (void *)&cmd_flow_director_mask_mode_ip,
12259 (void *)&cmd_flow_director_mask_vlan,
12260 (void *)&cmd_flow_director_mask_vlan_value,
12261 (void *)&cmd_flow_director_mask_src,
12262 (void *)&cmd_flow_director_mask_ipv4_src,
12263 (void *)&cmd_flow_director_mask_ipv6_src,
12264 (void *)&cmd_flow_director_mask_port_src,
12265 (void *)&cmd_flow_director_mask_dst,
12266 (void *)&cmd_flow_director_mask_ipv4_dst,
12267 (void *)&cmd_flow_director_mask_ipv6_dst,
12268 (void *)&cmd_flow_director_mask_port_dst,
12273 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
12274 .f = cmd_flow_director_mask_parsed,
12276 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
12277 "flow director's mask on NIC",
12279 (void *)&cmd_flow_director_mask,
12280 (void *)&cmd_flow_director_mask_port_id,
12281 (void *)&cmd_flow_director_mask_mode,
12282 (void *)&cmd_flow_director_mask_mode_mac_vlan,
12283 (void *)&cmd_flow_director_mask_vlan,
12284 (void *)&cmd_flow_director_mask_vlan_value,
12289 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
12290 .f = cmd_flow_director_mask_parsed,
12292 .help_str = "flow_director_mask ... : Set tunnel mode "
12293 "flow director's mask on NIC",
12295 (void *)&cmd_flow_director_mask,
12296 (void *)&cmd_flow_director_mask_port_id,
12297 (void *)&cmd_flow_director_mask_mode,
12298 (void *)&cmd_flow_director_mask_mode_tunnel,
12299 (void *)&cmd_flow_director_mask_vlan,
12300 (void *)&cmd_flow_director_mask_vlan_value,
12301 (void *)&cmd_flow_director_mask_mac,
12302 (void *)&cmd_flow_director_mask_mac_value,
12303 (void *)&cmd_flow_director_mask_tunnel_type,
12304 (void *)&cmd_flow_director_mask_tunnel_type_value,
12305 (void *)&cmd_flow_director_mask_tunnel_id,
12306 (void *)&cmd_flow_director_mask_tunnel_id_value,
12311 /* *** deal with flow director mask on flexible payload *** */
12312 struct cmd_flow_director_flex_mask_result {
12313 cmdline_fixed_string_t flow_director_flexmask;
12315 cmdline_fixed_string_t flow;
12316 cmdline_fixed_string_t flow_type;
12317 cmdline_fixed_string_t mask;
12321 cmd_flow_director_flex_mask_parsed(void *parsed_result,
12322 __rte_unused struct cmdline *cl,
12323 __rte_unused void *data)
12325 struct cmd_flow_director_flex_mask_result *res = parsed_result;
12326 struct rte_eth_fdir_info fdir_info;
12327 struct rte_eth_fdir_flex_mask flex_mask;
12328 struct rte_port *port;
12329 uint64_t flow_type_mask;
12333 port = &ports[res->port_id];
12334 /** Check if the port is not started **/
12335 if (port->port_status != RTE_PORT_STOPPED) {
12336 printf("Please stop port %d first\n", res->port_id);
12340 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
12341 ret = parse_flexbytes(res->mask,
12343 RTE_ETH_FDIR_MAX_FLEXLEN);
12345 printf("error: Cannot parse mask input.\n");
12349 memset(&fdir_info, 0, sizeof(fdir_info));
12350 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12351 RTE_ETH_FILTER_INFO, &fdir_info);
12353 printf("Cannot get FDir filter info\n");
12357 if (!strcmp(res->flow_type, "none")) {
12358 /* means don't specify the flow type */
12359 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
12360 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
12361 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
12362 0, sizeof(struct rte_eth_fdir_flex_mask));
12363 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
12364 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
12366 sizeof(struct rte_eth_fdir_flex_mask));
12367 cmd_reconfig_device_queue(res->port_id, 1, 1);
12370 flow_type_mask = fdir_info.flow_types_mask[0];
12371 if (!strcmp(res->flow_type, "all")) {
12372 if (!flow_type_mask) {
12373 printf("No flow type supported\n");
12376 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
12377 if (flow_type_mask & (1ULL << i)) {
12378 flex_mask.flow_type = i;
12379 fdir_set_flex_mask(res->port_id, &flex_mask);
12382 cmd_reconfig_device_queue(res->port_id, 1, 1);
12385 flex_mask.flow_type = str2flowtype(res->flow_type);
12386 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
12387 printf("Flow type %s not supported on port %d\n",
12388 res->flow_type, res->port_id);
12391 fdir_set_flex_mask(res->port_id, &flex_mask);
12392 cmd_reconfig_device_queue(res->port_id, 1, 1);
12395 cmdline_parse_token_string_t cmd_flow_director_flexmask =
12396 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12397 flow_director_flexmask,
12398 "flow_director_flex_mask");
12399 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
12400 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12402 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
12403 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12405 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
12406 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12407 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
12408 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
12409 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
12410 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12413 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
12414 .f = cmd_flow_director_flex_mask_parsed,
12416 .help_str = "flow_director_flex_mask ... : "
12417 "Set flow director's flex mask on NIC",
12419 (void *)&cmd_flow_director_flexmask,
12420 (void *)&cmd_flow_director_flexmask_port_id,
12421 (void *)&cmd_flow_director_flexmask_flow,
12422 (void *)&cmd_flow_director_flexmask_flow_type,
12423 (void *)&cmd_flow_director_flexmask_mask,
12428 /* *** deal with flow director flexible payload configuration *** */
12429 struct cmd_flow_director_flexpayload_result {
12430 cmdline_fixed_string_t flow_director_flexpayload;
12432 cmdline_fixed_string_t payload_layer;
12433 cmdline_fixed_string_t payload_cfg;
12437 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
12440 const char *p, *p0 = q_arg;
12442 unsigned long int_fld;
12443 char *str_fld[max_num];
12448 p = strchr(p0, '(');
12452 p0 = strchr(p, ')');
12457 if (size >= sizeof(s))
12460 snprintf(s, sizeof(s), "%.*s", size, p);
12461 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12462 if (ret < 0 || ret > max_num)
12464 for (i = 0; i < ret; i++) {
12466 int_fld = strtoul(str_fld[i], &end, 0);
12467 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12469 offsets[i] = (uint16_t)int_fld;
12475 cmd_flow_director_flxpld_parsed(void *parsed_result,
12476 __rte_unused struct cmdline *cl,
12477 __rte_unused void *data)
12479 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12480 struct rte_eth_flex_payload_cfg flex_cfg;
12481 struct rte_port *port;
12484 port = &ports[res->port_id];
12485 /** Check if the port is not started **/
12486 if (port->port_status != RTE_PORT_STOPPED) {
12487 printf("Please stop port %d first\n", res->port_id);
12491 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12493 if (!strcmp(res->payload_layer, "raw"))
12494 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12495 else if (!strcmp(res->payload_layer, "l2"))
12496 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12497 else if (!strcmp(res->payload_layer, "l3"))
12498 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12499 else if (!strcmp(res->payload_layer, "l4"))
12500 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12502 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12503 RTE_ETH_FDIR_MAX_FLEXLEN);
12505 printf("error: Cannot parse flex payload input.\n");
12509 fdir_set_flex_payload(res->port_id, &flex_cfg);
12510 cmd_reconfig_device_queue(res->port_id, 1, 1);
12513 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12514 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12515 flow_director_flexpayload,
12516 "flow_director_flex_payload");
12517 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12518 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12520 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12521 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12522 payload_layer, "raw#l2#l3#l4");
12523 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12524 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12525 payload_cfg, NULL);
12527 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12528 .f = cmd_flow_director_flxpld_parsed,
12530 .help_str = "flow_director_flexpayload ... : "
12531 "Set flow director's flex payload on NIC",
12533 (void *)&cmd_flow_director_flexpayload,
12534 (void *)&cmd_flow_director_flexpayload_port_id,
12535 (void *)&cmd_flow_director_flexpayload_payload_layer,
12536 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12541 /* Generic flow interface command. */
12542 extern cmdline_parse_inst_t cmd_flow;
12544 /* *** Classification Filters Control *** */
12545 /* *** Get symmetric hash enable per port *** */
12546 struct cmd_get_sym_hash_ena_per_port_result {
12547 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12552 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12553 __rte_unused struct cmdline *cl,
12554 __rte_unused void *data)
12556 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12557 struct rte_eth_hash_filter_info info;
12560 if (rte_eth_dev_filter_supported(res->port_id,
12561 RTE_ETH_FILTER_HASH) < 0) {
12562 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12567 memset(&info, 0, sizeof(info));
12568 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12569 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12570 RTE_ETH_FILTER_GET, &info);
12573 printf("Cannot get symmetric hash enable per port "
12574 "on port %u\n", res->port_id);
12578 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12579 "enabled" : "disabled", res->port_id);
12582 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12583 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12584 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12585 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12586 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12589 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12590 .f = cmd_get_sym_hash_per_port_parsed,
12592 .help_str = "get_sym_hash_ena_per_port <port_id>",
12594 (void *)&cmd_get_sym_hash_ena_per_port_all,
12595 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12600 /* *** Set symmetric hash enable per port *** */
12601 struct cmd_set_sym_hash_ena_per_port_result {
12602 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12603 cmdline_fixed_string_t enable;
12608 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12609 __rte_unused struct cmdline *cl,
12610 __rte_unused void *data)
12612 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12613 struct rte_eth_hash_filter_info info;
12616 if (rte_eth_dev_filter_supported(res->port_id,
12617 RTE_ETH_FILTER_HASH) < 0) {
12618 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12623 memset(&info, 0, sizeof(info));
12624 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12625 if (!strcmp(res->enable, "enable"))
12626 info.info.enable = 1;
12627 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12628 RTE_ETH_FILTER_SET, &info);
12630 printf("Cannot set symmetric hash enable per port on "
12631 "port %u\n", res->port_id);
12634 printf("Symmetric hash has been set to %s on port %u\n",
12635 res->enable, res->port_id);
12638 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12639 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12640 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12641 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12642 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12644 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12645 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12646 enable, "enable#disable");
12648 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12649 .f = cmd_set_sym_hash_per_port_parsed,
12651 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12653 (void *)&cmd_set_sym_hash_ena_per_port_all,
12654 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12655 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12660 /* Get global config of hash function */
12661 struct cmd_get_hash_global_config_result {
12662 cmdline_fixed_string_t get_hash_global_config;
12667 flowtype_to_str(uint16_t ftype)
12673 } ftype_table[] = {
12674 {"ipv4", RTE_ETH_FLOW_IPV4},
12675 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12676 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12677 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12678 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12679 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12680 {"ipv6", RTE_ETH_FLOW_IPV6},
12681 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12682 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12683 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12684 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12685 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12686 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12687 {"port", RTE_ETH_FLOW_PORT},
12688 {"vxlan", RTE_ETH_FLOW_VXLAN},
12689 {"geneve", RTE_ETH_FLOW_GENEVE},
12690 {"nvgre", RTE_ETH_FLOW_NVGRE},
12691 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12694 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12695 if (ftype_table[i].ftype == ftype)
12696 return ftype_table[i].str;
12703 cmd_get_hash_global_config_parsed(void *parsed_result,
12704 __rte_unused struct cmdline *cl,
12705 __rte_unused void *data)
12707 struct cmd_get_hash_global_config_result *res = parsed_result;
12708 struct rte_eth_hash_filter_info info;
12709 uint32_t idx, offset;
12714 if (rte_eth_dev_filter_supported(res->port_id,
12715 RTE_ETH_FILTER_HASH) < 0) {
12716 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12721 memset(&info, 0, sizeof(info));
12722 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12723 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12724 RTE_ETH_FILTER_GET, &info);
12726 printf("Cannot get hash global configurations by port %d\n",
12731 switch (info.info.global_conf.hash_func) {
12732 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12733 printf("Hash function is Toeplitz\n");
12735 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12736 printf("Hash function is Simple XOR\n");
12738 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12739 printf("Hash function is Symmetric Toeplitz\n");
12742 printf("Unknown hash function\n");
12746 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12747 idx = i / UINT64_BIT;
12748 offset = i % UINT64_BIT;
12749 if (!(info.info.global_conf.valid_bit_mask[idx] &
12752 str = flowtype_to_str(i);
12755 printf("Symmetric hash is %s globally for flow type %s "
12757 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12758 (1ULL << offset)) ? "enabled" : "disabled"), str,
12763 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12764 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12765 get_hash_global_config, "get_hash_global_config");
12766 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12767 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12770 cmdline_parse_inst_t cmd_get_hash_global_config = {
12771 .f = cmd_get_hash_global_config_parsed,
12773 .help_str = "get_hash_global_config <port_id>",
12775 (void *)&cmd_get_hash_global_config_all,
12776 (void *)&cmd_get_hash_global_config_port_id,
12781 /* Set global config of hash function */
12782 struct cmd_set_hash_global_config_result {
12783 cmdline_fixed_string_t set_hash_global_config;
12785 cmdline_fixed_string_t hash_func;
12786 cmdline_fixed_string_t flow_type;
12787 cmdline_fixed_string_t enable;
12791 cmd_set_hash_global_config_parsed(void *parsed_result,
12792 __rte_unused struct cmdline *cl,
12793 __rte_unused void *data)
12795 struct cmd_set_hash_global_config_result *res = parsed_result;
12796 struct rte_eth_hash_filter_info info;
12797 uint32_t ftype, idx, offset;
12800 if (rte_eth_dev_filter_supported(res->port_id,
12801 RTE_ETH_FILTER_HASH) < 0) {
12802 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12806 memset(&info, 0, sizeof(info));
12807 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12808 if (!strcmp(res->hash_func, "toeplitz"))
12809 info.info.global_conf.hash_func =
12810 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12811 else if (!strcmp(res->hash_func, "simple_xor"))
12812 info.info.global_conf.hash_func =
12813 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12814 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12815 info.info.global_conf.hash_func =
12816 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12817 else if (!strcmp(res->hash_func, "default"))
12818 info.info.global_conf.hash_func =
12819 RTE_ETH_HASH_FUNCTION_DEFAULT;
12821 ftype = str2flowtype(res->flow_type);
12822 idx = ftype / UINT64_BIT;
12823 offset = ftype % UINT64_BIT;
12824 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12825 if (!strcmp(res->enable, "enable"))
12826 info.info.global_conf.sym_hash_enable_mask[idx] |=
12828 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12829 RTE_ETH_FILTER_SET, &info);
12831 printf("Cannot set global hash configurations by port %d\n",
12834 printf("Global hash configurations have been set "
12835 "successfully by port %d\n", res->port_id);
12838 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12839 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12840 set_hash_global_config, "set_hash_global_config");
12841 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12842 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12844 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12845 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12846 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12847 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12848 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12850 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12851 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12852 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12853 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12854 enable, "enable#disable");
12856 cmdline_parse_inst_t cmd_set_hash_global_config = {
12857 .f = cmd_set_hash_global_config_parsed,
12859 .help_str = "set_hash_global_config <port_id> "
12860 "toeplitz|simple_xor|symmetric_toeplitz|default "
12861 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12862 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12863 "l2_payload enable|disable",
12865 (void *)&cmd_set_hash_global_config_all,
12866 (void *)&cmd_set_hash_global_config_port_id,
12867 (void *)&cmd_set_hash_global_config_hash_func,
12868 (void *)&cmd_set_hash_global_config_flow_type,
12869 (void *)&cmd_set_hash_global_config_enable,
12874 /* Set hash input set */
12875 struct cmd_set_hash_input_set_result {
12876 cmdline_fixed_string_t set_hash_input_set;
12878 cmdline_fixed_string_t flow_type;
12879 cmdline_fixed_string_t inset_field;
12880 cmdline_fixed_string_t select;
12883 static enum rte_eth_input_set_field
12884 str2inset(char *string)
12888 static const struct {
12890 enum rte_eth_input_set_field inset;
12891 } inset_table[] = {
12892 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12893 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12894 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12895 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12896 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12897 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12898 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12899 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12900 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12901 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12902 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12903 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12904 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12905 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12906 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12907 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12908 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12909 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12910 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12911 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12912 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12913 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12914 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12915 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12916 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12917 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12918 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12919 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12920 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12921 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12922 {"none", RTE_ETH_INPUT_SET_NONE},
12925 for (i = 0; i < RTE_DIM(inset_table); i++) {
12926 if (!strcmp(string, inset_table[i].str))
12927 return inset_table[i].inset;
12930 return RTE_ETH_INPUT_SET_UNKNOWN;
12934 cmd_set_hash_input_set_parsed(void *parsed_result,
12935 __rte_unused struct cmdline *cl,
12936 __rte_unused void *data)
12938 struct cmd_set_hash_input_set_result *res = parsed_result;
12939 struct rte_eth_hash_filter_info info;
12941 memset(&info, 0, sizeof(info));
12942 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12943 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12944 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12945 info.info.input_set_conf.inset_size = 1;
12946 if (!strcmp(res->select, "select"))
12947 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12948 else if (!strcmp(res->select, "add"))
12949 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12950 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12951 RTE_ETH_FILTER_SET, &info);
12954 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12955 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12956 set_hash_input_set, "set_hash_input_set");
12957 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12958 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12960 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12961 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12963 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12964 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12966 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12967 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12968 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12969 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12970 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12972 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12973 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12974 select, "select#add");
12976 cmdline_parse_inst_t cmd_set_hash_input_set = {
12977 .f = cmd_set_hash_input_set_parsed,
12979 .help_str = "set_hash_input_set <port_id> "
12980 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12981 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12982 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12983 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12984 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12985 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12986 "fld-7th|fld-8th|none select|add",
12988 (void *)&cmd_set_hash_input_set_cmd,
12989 (void *)&cmd_set_hash_input_set_port_id,
12990 (void *)&cmd_set_hash_input_set_flow_type,
12991 (void *)&cmd_set_hash_input_set_field,
12992 (void *)&cmd_set_hash_input_set_select,
12997 /* Set flow director input set */
12998 struct cmd_set_fdir_input_set_result {
12999 cmdline_fixed_string_t set_fdir_input_set;
13001 cmdline_fixed_string_t flow_type;
13002 cmdline_fixed_string_t inset_field;
13003 cmdline_fixed_string_t select;
13007 cmd_set_fdir_input_set_parsed(void *parsed_result,
13008 __rte_unused struct cmdline *cl,
13009 __rte_unused void *data)
13011 struct cmd_set_fdir_input_set_result *res = parsed_result;
13012 struct rte_eth_fdir_filter_info info;
13014 memset(&info, 0, sizeof(info));
13015 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
13016 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
13017 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
13018 info.info.input_set_conf.inset_size = 1;
13019 if (!strcmp(res->select, "select"))
13020 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
13021 else if (!strcmp(res->select, "add"))
13022 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
13023 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
13024 RTE_ETH_FILTER_SET, &info);
13027 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
13028 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
13029 set_fdir_input_set, "set_fdir_input_set");
13030 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
13031 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
13033 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
13034 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
13036 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
13037 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
13038 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
13039 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
13041 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
13042 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
13043 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
13044 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
13045 "sctp-veri-tag#none");
13046 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
13047 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
13048 select, "select#add");
13050 cmdline_parse_inst_t cmd_set_fdir_input_set = {
13051 .f = cmd_set_fdir_input_set_parsed,
13053 .help_str = "set_fdir_input_set <port_id> "
13054 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
13055 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
13056 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
13057 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
13058 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
13059 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
13060 "sctp-veri-tag|none select|add",
13062 (void *)&cmd_set_fdir_input_set_cmd,
13063 (void *)&cmd_set_fdir_input_set_port_id,
13064 (void *)&cmd_set_fdir_input_set_flow_type,
13065 (void *)&cmd_set_fdir_input_set_field,
13066 (void *)&cmd_set_fdir_input_set_select,
13071 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
13072 struct cmd_mcast_addr_result {
13073 cmdline_fixed_string_t mcast_addr_cmd;
13074 cmdline_fixed_string_t what;
13076 struct rte_ether_addr mc_addr;
13079 static void cmd_mcast_addr_parsed(void *parsed_result,
13080 __rte_unused struct cmdline *cl,
13081 __rte_unused void *data)
13083 struct cmd_mcast_addr_result *res = parsed_result;
13085 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
13086 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
13087 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
13088 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
13089 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
13092 if (strcmp(res->what, "add") == 0)
13093 mcast_addr_add(res->port_num, &res->mc_addr);
13095 mcast_addr_remove(res->port_num, &res->mc_addr);
13098 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
13099 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
13100 mcast_addr_cmd, "mcast_addr");
13101 cmdline_parse_token_string_t cmd_mcast_addr_what =
13102 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
13104 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
13105 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
13106 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
13107 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
13109 cmdline_parse_inst_t cmd_mcast_addr = {
13110 .f = cmd_mcast_addr_parsed,
13112 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
13113 "Add/Remove multicast MAC address on port_id",
13115 (void *)&cmd_mcast_addr_cmd,
13116 (void *)&cmd_mcast_addr_what,
13117 (void *)&cmd_mcast_addr_portnum,
13118 (void *)&cmd_mcast_addr_addr,
13123 /* l2 tunnel config
13124 * only support E-tag now.
13127 /* Ether type config */
13128 struct cmd_config_l2_tunnel_eth_type_result {
13129 cmdline_fixed_string_t port;
13130 cmdline_fixed_string_t config;
13131 cmdline_fixed_string_t all;
13133 cmdline_fixed_string_t l2_tunnel;
13134 cmdline_fixed_string_t l2_tunnel_type;
13135 cmdline_fixed_string_t eth_type;
13136 uint16_t eth_type_val;
13139 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
13140 TOKEN_STRING_INITIALIZER
13141 (struct cmd_config_l2_tunnel_eth_type_result,
13143 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
13144 TOKEN_STRING_INITIALIZER
13145 (struct cmd_config_l2_tunnel_eth_type_result,
13147 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
13148 TOKEN_STRING_INITIALIZER
13149 (struct cmd_config_l2_tunnel_eth_type_result,
13151 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
13152 TOKEN_NUM_INITIALIZER
13153 (struct cmd_config_l2_tunnel_eth_type_result,
13155 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
13156 TOKEN_STRING_INITIALIZER
13157 (struct cmd_config_l2_tunnel_eth_type_result,
13158 l2_tunnel, "l2-tunnel");
13159 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
13160 TOKEN_STRING_INITIALIZER
13161 (struct cmd_config_l2_tunnel_eth_type_result,
13162 l2_tunnel_type, "E-tag");
13163 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
13164 TOKEN_STRING_INITIALIZER
13165 (struct cmd_config_l2_tunnel_eth_type_result,
13166 eth_type, "ether-type");
13167 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
13168 TOKEN_NUM_INITIALIZER
13169 (struct cmd_config_l2_tunnel_eth_type_result,
13170 eth_type_val, UINT16);
13172 static enum rte_eth_tunnel_type
13173 str2fdir_l2_tunnel_type(char *string)
13177 static const struct {
13179 enum rte_eth_tunnel_type type;
13180 } l2_tunnel_type_str[] = {
13181 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
13184 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
13185 if (!strcmp(l2_tunnel_type_str[i].str, string))
13186 return l2_tunnel_type_str[i].type;
13188 return RTE_TUNNEL_TYPE_NONE;
13191 /* ether type config for all ports */
13193 cmd_config_l2_tunnel_eth_type_all_parsed
13194 (void *parsed_result,
13195 __rte_unused struct cmdline *cl,
13196 __rte_unused void *data)
13198 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
13199 struct rte_eth_l2_tunnel_conf entry;
13202 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13203 entry.ether_type = res->eth_type_val;
13205 RTE_ETH_FOREACH_DEV(pid) {
13206 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
13210 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
13211 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
13213 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
13215 (void *)&cmd_config_l2_tunnel_eth_type_port,
13216 (void *)&cmd_config_l2_tunnel_eth_type_config,
13217 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
13218 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
13219 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
13220 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
13221 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
13226 /* ether type config for a specific port */
13228 cmd_config_l2_tunnel_eth_type_specific_parsed(
13229 void *parsed_result,
13230 __rte_unused struct cmdline *cl,
13231 __rte_unused void *data)
13233 struct cmd_config_l2_tunnel_eth_type_result *res =
13235 struct rte_eth_l2_tunnel_conf entry;
13237 if (port_id_is_invalid(res->id, ENABLED_WARN))
13240 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13241 entry.ether_type = res->eth_type_val;
13243 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
13246 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
13247 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
13249 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
13251 (void *)&cmd_config_l2_tunnel_eth_type_port,
13252 (void *)&cmd_config_l2_tunnel_eth_type_config,
13253 (void *)&cmd_config_l2_tunnel_eth_type_id,
13254 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
13255 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
13256 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
13257 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
13262 /* Enable/disable l2 tunnel */
13263 struct cmd_config_l2_tunnel_en_dis_result {
13264 cmdline_fixed_string_t port;
13265 cmdline_fixed_string_t config;
13266 cmdline_fixed_string_t all;
13268 cmdline_fixed_string_t l2_tunnel;
13269 cmdline_fixed_string_t l2_tunnel_type;
13270 cmdline_fixed_string_t en_dis;
13273 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
13274 TOKEN_STRING_INITIALIZER
13275 (struct cmd_config_l2_tunnel_en_dis_result,
13277 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
13278 TOKEN_STRING_INITIALIZER
13279 (struct cmd_config_l2_tunnel_en_dis_result,
13281 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
13282 TOKEN_STRING_INITIALIZER
13283 (struct cmd_config_l2_tunnel_en_dis_result,
13285 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
13286 TOKEN_NUM_INITIALIZER
13287 (struct cmd_config_l2_tunnel_en_dis_result,
13289 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
13290 TOKEN_STRING_INITIALIZER
13291 (struct cmd_config_l2_tunnel_en_dis_result,
13292 l2_tunnel, "l2-tunnel");
13293 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
13294 TOKEN_STRING_INITIALIZER
13295 (struct cmd_config_l2_tunnel_en_dis_result,
13296 l2_tunnel_type, "E-tag");
13297 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
13298 TOKEN_STRING_INITIALIZER
13299 (struct cmd_config_l2_tunnel_en_dis_result,
13300 en_dis, "enable#disable");
13302 /* enable/disable l2 tunnel for all ports */
13304 cmd_config_l2_tunnel_en_dis_all_parsed(
13305 void *parsed_result,
13306 __rte_unused struct cmdline *cl,
13307 __rte_unused void *data)
13309 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
13310 struct rte_eth_l2_tunnel_conf entry;
13314 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13316 if (!strcmp("enable", res->en_dis))
13321 RTE_ETH_FOREACH_DEV(pid) {
13322 rte_eth_dev_l2_tunnel_offload_set(pid,
13324 ETH_L2_TUNNEL_ENABLE_MASK,
13329 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
13330 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
13332 .help_str = "port config all l2-tunnel E-tag enable|disable",
13334 (void *)&cmd_config_l2_tunnel_en_dis_port,
13335 (void *)&cmd_config_l2_tunnel_en_dis_config,
13336 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
13337 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13338 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13339 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13344 /* enable/disable l2 tunnel for a port */
13346 cmd_config_l2_tunnel_en_dis_specific_parsed(
13347 void *parsed_result,
13348 __rte_unused struct cmdline *cl,
13349 __rte_unused void *data)
13351 struct cmd_config_l2_tunnel_en_dis_result *res =
13353 struct rte_eth_l2_tunnel_conf entry;
13355 if (port_id_is_invalid(res->id, ENABLED_WARN))
13358 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13360 if (!strcmp("enable", res->en_dis))
13361 rte_eth_dev_l2_tunnel_offload_set(res->id,
13363 ETH_L2_TUNNEL_ENABLE_MASK,
13366 rte_eth_dev_l2_tunnel_offload_set(res->id,
13368 ETH_L2_TUNNEL_ENABLE_MASK,
13372 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
13373 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
13375 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
13377 (void *)&cmd_config_l2_tunnel_en_dis_port,
13378 (void *)&cmd_config_l2_tunnel_en_dis_config,
13379 (void *)&cmd_config_l2_tunnel_en_dis_id,
13380 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13381 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13382 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13387 /* E-tag configuration */
13389 /* Common result structure for all E-tag configuration */
13390 struct cmd_config_e_tag_result {
13391 cmdline_fixed_string_t e_tag;
13392 cmdline_fixed_string_t set;
13393 cmdline_fixed_string_t insertion;
13394 cmdline_fixed_string_t stripping;
13395 cmdline_fixed_string_t forwarding;
13396 cmdline_fixed_string_t filter;
13397 cmdline_fixed_string_t add;
13398 cmdline_fixed_string_t del;
13399 cmdline_fixed_string_t on;
13400 cmdline_fixed_string_t off;
13401 cmdline_fixed_string_t on_off;
13402 cmdline_fixed_string_t port_tag_id;
13403 uint32_t port_tag_id_val;
13404 cmdline_fixed_string_t e_tag_id;
13405 uint16_t e_tag_id_val;
13406 cmdline_fixed_string_t dst_pool;
13407 uint8_t dst_pool_val;
13408 cmdline_fixed_string_t port;
13410 cmdline_fixed_string_t vf;
13414 /* Common CLI fields for all E-tag configuration */
13415 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
13416 TOKEN_STRING_INITIALIZER
13417 (struct cmd_config_e_tag_result,
13419 cmdline_parse_token_string_t cmd_config_e_tag_set =
13420 TOKEN_STRING_INITIALIZER
13421 (struct cmd_config_e_tag_result,
13423 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
13424 TOKEN_STRING_INITIALIZER
13425 (struct cmd_config_e_tag_result,
13426 insertion, "insertion");
13427 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
13428 TOKEN_STRING_INITIALIZER
13429 (struct cmd_config_e_tag_result,
13430 stripping, "stripping");
13431 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
13432 TOKEN_STRING_INITIALIZER
13433 (struct cmd_config_e_tag_result,
13434 forwarding, "forwarding");
13435 cmdline_parse_token_string_t cmd_config_e_tag_filter =
13436 TOKEN_STRING_INITIALIZER
13437 (struct cmd_config_e_tag_result,
13439 cmdline_parse_token_string_t cmd_config_e_tag_add =
13440 TOKEN_STRING_INITIALIZER
13441 (struct cmd_config_e_tag_result,
13443 cmdline_parse_token_string_t cmd_config_e_tag_del =
13444 TOKEN_STRING_INITIALIZER
13445 (struct cmd_config_e_tag_result,
13447 cmdline_parse_token_string_t cmd_config_e_tag_on =
13448 TOKEN_STRING_INITIALIZER
13449 (struct cmd_config_e_tag_result,
13451 cmdline_parse_token_string_t cmd_config_e_tag_off =
13452 TOKEN_STRING_INITIALIZER
13453 (struct cmd_config_e_tag_result,
13455 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13456 TOKEN_STRING_INITIALIZER
13457 (struct cmd_config_e_tag_result,
13459 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13460 TOKEN_STRING_INITIALIZER
13461 (struct cmd_config_e_tag_result,
13462 port_tag_id, "port-tag-id");
13463 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13464 TOKEN_NUM_INITIALIZER
13465 (struct cmd_config_e_tag_result,
13466 port_tag_id_val, UINT32);
13467 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13468 TOKEN_STRING_INITIALIZER
13469 (struct cmd_config_e_tag_result,
13470 e_tag_id, "e-tag-id");
13471 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13472 TOKEN_NUM_INITIALIZER
13473 (struct cmd_config_e_tag_result,
13474 e_tag_id_val, UINT16);
13475 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13476 TOKEN_STRING_INITIALIZER
13477 (struct cmd_config_e_tag_result,
13478 dst_pool, "dst-pool");
13479 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13480 TOKEN_NUM_INITIALIZER
13481 (struct cmd_config_e_tag_result,
13482 dst_pool_val, UINT8);
13483 cmdline_parse_token_string_t cmd_config_e_tag_port =
13484 TOKEN_STRING_INITIALIZER
13485 (struct cmd_config_e_tag_result,
13487 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13488 TOKEN_NUM_INITIALIZER
13489 (struct cmd_config_e_tag_result,
13491 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13492 TOKEN_STRING_INITIALIZER
13493 (struct cmd_config_e_tag_result,
13495 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13496 TOKEN_NUM_INITIALIZER
13497 (struct cmd_config_e_tag_result,
13500 /* E-tag insertion configuration */
13502 cmd_config_e_tag_insertion_en_parsed(
13503 void *parsed_result,
13504 __rte_unused struct cmdline *cl,
13505 __rte_unused void *data)
13507 struct cmd_config_e_tag_result *res =
13509 struct rte_eth_l2_tunnel_conf entry;
13511 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13514 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13515 entry.tunnel_id = res->port_tag_id_val;
13516 entry.vf_id = res->vf_id;
13517 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13519 ETH_L2_TUNNEL_INSERTION_MASK,
13524 cmd_config_e_tag_insertion_dis_parsed(
13525 void *parsed_result,
13526 __rte_unused struct cmdline *cl,
13527 __rte_unused void *data)
13529 struct cmd_config_e_tag_result *res =
13531 struct rte_eth_l2_tunnel_conf entry;
13533 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13536 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13537 entry.vf_id = res->vf_id;
13539 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13541 ETH_L2_TUNNEL_INSERTION_MASK,
13545 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13546 .f = cmd_config_e_tag_insertion_en_parsed,
13548 .help_str = "E-tag ... : E-tag insertion enable",
13550 (void *)&cmd_config_e_tag_e_tag,
13551 (void *)&cmd_config_e_tag_set,
13552 (void *)&cmd_config_e_tag_insertion,
13553 (void *)&cmd_config_e_tag_on,
13554 (void *)&cmd_config_e_tag_port_tag_id,
13555 (void *)&cmd_config_e_tag_port_tag_id_val,
13556 (void *)&cmd_config_e_tag_port,
13557 (void *)&cmd_config_e_tag_port_id,
13558 (void *)&cmd_config_e_tag_vf,
13559 (void *)&cmd_config_e_tag_vf_id,
13564 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13565 .f = cmd_config_e_tag_insertion_dis_parsed,
13567 .help_str = "E-tag ... : E-tag insertion disable",
13569 (void *)&cmd_config_e_tag_e_tag,
13570 (void *)&cmd_config_e_tag_set,
13571 (void *)&cmd_config_e_tag_insertion,
13572 (void *)&cmd_config_e_tag_off,
13573 (void *)&cmd_config_e_tag_port,
13574 (void *)&cmd_config_e_tag_port_id,
13575 (void *)&cmd_config_e_tag_vf,
13576 (void *)&cmd_config_e_tag_vf_id,
13581 /* E-tag stripping configuration */
13583 cmd_config_e_tag_stripping_parsed(
13584 void *parsed_result,
13585 __rte_unused struct cmdline *cl,
13586 __rte_unused void *data)
13588 struct cmd_config_e_tag_result *res =
13590 struct rte_eth_l2_tunnel_conf entry;
13592 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13595 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13597 if (!strcmp(res->on_off, "on"))
13598 rte_eth_dev_l2_tunnel_offload_set
13601 ETH_L2_TUNNEL_STRIPPING_MASK,
13604 rte_eth_dev_l2_tunnel_offload_set
13607 ETH_L2_TUNNEL_STRIPPING_MASK,
13611 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13612 .f = cmd_config_e_tag_stripping_parsed,
13614 .help_str = "E-tag ... : E-tag stripping enable/disable",
13616 (void *)&cmd_config_e_tag_e_tag,
13617 (void *)&cmd_config_e_tag_set,
13618 (void *)&cmd_config_e_tag_stripping,
13619 (void *)&cmd_config_e_tag_on_off,
13620 (void *)&cmd_config_e_tag_port,
13621 (void *)&cmd_config_e_tag_port_id,
13626 /* E-tag forwarding configuration */
13628 cmd_config_e_tag_forwarding_parsed(
13629 void *parsed_result,
13630 __rte_unused struct cmdline *cl,
13631 __rte_unused void *data)
13633 struct cmd_config_e_tag_result *res = parsed_result;
13634 struct rte_eth_l2_tunnel_conf entry;
13636 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13639 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13641 if (!strcmp(res->on_off, "on"))
13642 rte_eth_dev_l2_tunnel_offload_set
13645 ETH_L2_TUNNEL_FORWARDING_MASK,
13648 rte_eth_dev_l2_tunnel_offload_set
13651 ETH_L2_TUNNEL_FORWARDING_MASK,
13655 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13656 .f = cmd_config_e_tag_forwarding_parsed,
13658 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13660 (void *)&cmd_config_e_tag_e_tag,
13661 (void *)&cmd_config_e_tag_set,
13662 (void *)&cmd_config_e_tag_forwarding,
13663 (void *)&cmd_config_e_tag_on_off,
13664 (void *)&cmd_config_e_tag_port,
13665 (void *)&cmd_config_e_tag_port_id,
13670 /* E-tag filter configuration */
13672 cmd_config_e_tag_filter_add_parsed(
13673 void *parsed_result,
13674 __rte_unused struct cmdline *cl,
13675 __rte_unused void *data)
13677 struct cmd_config_e_tag_result *res = parsed_result;
13678 struct rte_eth_l2_tunnel_conf entry;
13681 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13684 if (res->e_tag_id_val > 0x3fff) {
13685 printf("e-tag-id must be equal or less than 0x3fff.\n");
13689 ret = rte_eth_dev_filter_supported(res->port_id,
13690 RTE_ETH_FILTER_L2_TUNNEL);
13692 printf("E-tag filter is not supported on port %u.\n",
13697 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13698 entry.tunnel_id = res->e_tag_id_val;
13699 entry.pool = res->dst_pool_val;
13701 ret = rte_eth_dev_filter_ctrl(res->port_id,
13702 RTE_ETH_FILTER_L2_TUNNEL,
13703 RTE_ETH_FILTER_ADD,
13706 printf("E-tag filter programming error: (%s)\n",
13710 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13711 .f = cmd_config_e_tag_filter_add_parsed,
13713 .help_str = "E-tag ... : E-tag filter add",
13715 (void *)&cmd_config_e_tag_e_tag,
13716 (void *)&cmd_config_e_tag_set,
13717 (void *)&cmd_config_e_tag_filter,
13718 (void *)&cmd_config_e_tag_add,
13719 (void *)&cmd_config_e_tag_e_tag_id,
13720 (void *)&cmd_config_e_tag_e_tag_id_val,
13721 (void *)&cmd_config_e_tag_dst_pool,
13722 (void *)&cmd_config_e_tag_dst_pool_val,
13723 (void *)&cmd_config_e_tag_port,
13724 (void *)&cmd_config_e_tag_port_id,
13730 cmd_config_e_tag_filter_del_parsed(
13731 void *parsed_result,
13732 __rte_unused struct cmdline *cl,
13733 __rte_unused void *data)
13735 struct cmd_config_e_tag_result *res = parsed_result;
13736 struct rte_eth_l2_tunnel_conf entry;
13739 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13742 if (res->e_tag_id_val > 0x3fff) {
13743 printf("e-tag-id must be less than 0x3fff.\n");
13747 ret = rte_eth_dev_filter_supported(res->port_id,
13748 RTE_ETH_FILTER_L2_TUNNEL);
13750 printf("E-tag filter is not supported on port %u.\n",
13755 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13756 entry.tunnel_id = res->e_tag_id_val;
13758 ret = rte_eth_dev_filter_ctrl(res->port_id,
13759 RTE_ETH_FILTER_L2_TUNNEL,
13760 RTE_ETH_FILTER_DELETE,
13763 printf("E-tag filter programming error: (%s)\n",
13767 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13768 .f = cmd_config_e_tag_filter_del_parsed,
13770 .help_str = "E-tag ... : E-tag filter delete",
13772 (void *)&cmd_config_e_tag_e_tag,
13773 (void *)&cmd_config_e_tag_set,
13774 (void *)&cmd_config_e_tag_filter,
13775 (void *)&cmd_config_e_tag_del,
13776 (void *)&cmd_config_e_tag_e_tag_id,
13777 (void *)&cmd_config_e_tag_e_tag_id_val,
13778 (void *)&cmd_config_e_tag_port,
13779 (void *)&cmd_config_e_tag_port_id,
13784 /* vf vlan anti spoof configuration */
13786 /* Common result structure for vf vlan anti spoof */
13787 struct cmd_vf_vlan_anti_spoof_result {
13788 cmdline_fixed_string_t set;
13789 cmdline_fixed_string_t vf;
13790 cmdline_fixed_string_t vlan;
13791 cmdline_fixed_string_t antispoof;
13794 cmdline_fixed_string_t on_off;
13797 /* Common CLI fields for vf vlan anti spoof enable disable */
13798 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13799 TOKEN_STRING_INITIALIZER
13800 (struct cmd_vf_vlan_anti_spoof_result,
13802 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13803 TOKEN_STRING_INITIALIZER
13804 (struct cmd_vf_vlan_anti_spoof_result,
13806 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13807 TOKEN_STRING_INITIALIZER
13808 (struct cmd_vf_vlan_anti_spoof_result,
13810 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13811 TOKEN_STRING_INITIALIZER
13812 (struct cmd_vf_vlan_anti_spoof_result,
13813 antispoof, "antispoof");
13814 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13815 TOKEN_NUM_INITIALIZER
13816 (struct cmd_vf_vlan_anti_spoof_result,
13818 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13819 TOKEN_NUM_INITIALIZER
13820 (struct cmd_vf_vlan_anti_spoof_result,
13822 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13823 TOKEN_STRING_INITIALIZER
13824 (struct cmd_vf_vlan_anti_spoof_result,
13828 cmd_set_vf_vlan_anti_spoof_parsed(
13829 void *parsed_result,
13830 __rte_unused struct cmdline *cl,
13831 __rte_unused void *data)
13833 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13834 int ret = -ENOTSUP;
13836 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13838 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13841 #ifdef RTE_NET_IXGBE
13842 if (ret == -ENOTSUP)
13843 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13844 res->vf_id, is_on);
13846 #ifdef RTE_NET_I40E
13847 if (ret == -ENOTSUP)
13848 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13849 res->vf_id, is_on);
13851 #ifdef RTE_NET_BNXT
13852 if (ret == -ENOTSUP)
13853 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13854 res->vf_id, is_on);
13861 printf("invalid vf_id %d\n", res->vf_id);
13864 printf("invalid port_id %d\n", res->port_id);
13867 printf("function not implemented\n");
13870 printf("programming error: (%s)\n", strerror(-ret));
13874 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13875 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13877 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13879 (void *)&cmd_vf_vlan_anti_spoof_set,
13880 (void *)&cmd_vf_vlan_anti_spoof_vf,
13881 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13882 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13883 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13884 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13885 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13890 /* vf mac anti spoof configuration */
13892 /* Common result structure for vf mac anti spoof */
13893 struct cmd_vf_mac_anti_spoof_result {
13894 cmdline_fixed_string_t set;
13895 cmdline_fixed_string_t vf;
13896 cmdline_fixed_string_t mac;
13897 cmdline_fixed_string_t antispoof;
13900 cmdline_fixed_string_t on_off;
13903 /* Common CLI fields for vf mac anti spoof enable disable */
13904 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13905 TOKEN_STRING_INITIALIZER
13906 (struct cmd_vf_mac_anti_spoof_result,
13908 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13909 TOKEN_STRING_INITIALIZER
13910 (struct cmd_vf_mac_anti_spoof_result,
13912 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13913 TOKEN_STRING_INITIALIZER
13914 (struct cmd_vf_mac_anti_spoof_result,
13916 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13917 TOKEN_STRING_INITIALIZER
13918 (struct cmd_vf_mac_anti_spoof_result,
13919 antispoof, "antispoof");
13920 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13921 TOKEN_NUM_INITIALIZER
13922 (struct cmd_vf_mac_anti_spoof_result,
13924 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13925 TOKEN_NUM_INITIALIZER
13926 (struct cmd_vf_mac_anti_spoof_result,
13928 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13929 TOKEN_STRING_INITIALIZER
13930 (struct cmd_vf_mac_anti_spoof_result,
13934 cmd_set_vf_mac_anti_spoof_parsed(
13935 void *parsed_result,
13936 __rte_unused struct cmdline *cl,
13937 __rte_unused void *data)
13939 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13940 int ret = -ENOTSUP;
13942 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13944 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13947 #ifdef RTE_NET_IXGBE
13948 if (ret == -ENOTSUP)
13949 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13950 res->vf_id, is_on);
13952 #ifdef RTE_NET_I40E
13953 if (ret == -ENOTSUP)
13954 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13955 res->vf_id, is_on);
13957 #ifdef RTE_NET_BNXT
13958 if (ret == -ENOTSUP)
13959 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13960 res->vf_id, is_on);
13967 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13970 printf("invalid port_id %d\n", res->port_id);
13973 printf("function not implemented\n");
13976 printf("programming error: (%s)\n", strerror(-ret));
13980 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13981 .f = cmd_set_vf_mac_anti_spoof_parsed,
13983 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13985 (void *)&cmd_vf_mac_anti_spoof_set,
13986 (void *)&cmd_vf_mac_anti_spoof_vf,
13987 (void *)&cmd_vf_mac_anti_spoof_mac,
13988 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13989 (void *)&cmd_vf_mac_anti_spoof_port_id,
13990 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13991 (void *)&cmd_vf_mac_anti_spoof_on_off,
13996 /* vf vlan strip queue configuration */
13998 /* Common result structure for vf mac anti spoof */
13999 struct cmd_vf_vlan_stripq_result {
14000 cmdline_fixed_string_t set;
14001 cmdline_fixed_string_t vf;
14002 cmdline_fixed_string_t vlan;
14003 cmdline_fixed_string_t stripq;
14006 cmdline_fixed_string_t on_off;
14009 /* Common CLI fields for vf vlan strip enable disable */
14010 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
14011 TOKEN_STRING_INITIALIZER
14012 (struct cmd_vf_vlan_stripq_result,
14014 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
14015 TOKEN_STRING_INITIALIZER
14016 (struct cmd_vf_vlan_stripq_result,
14018 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
14019 TOKEN_STRING_INITIALIZER
14020 (struct cmd_vf_vlan_stripq_result,
14022 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
14023 TOKEN_STRING_INITIALIZER
14024 (struct cmd_vf_vlan_stripq_result,
14026 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
14027 TOKEN_NUM_INITIALIZER
14028 (struct cmd_vf_vlan_stripq_result,
14030 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
14031 TOKEN_NUM_INITIALIZER
14032 (struct cmd_vf_vlan_stripq_result,
14034 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
14035 TOKEN_STRING_INITIALIZER
14036 (struct cmd_vf_vlan_stripq_result,
14040 cmd_set_vf_vlan_stripq_parsed(
14041 void *parsed_result,
14042 __rte_unused struct cmdline *cl,
14043 __rte_unused void *data)
14045 struct cmd_vf_vlan_stripq_result *res = parsed_result;
14046 int ret = -ENOTSUP;
14048 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14050 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14053 #ifdef RTE_NET_IXGBE
14054 if (ret == -ENOTSUP)
14055 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
14056 res->vf_id, is_on);
14058 #ifdef RTE_NET_I40E
14059 if (ret == -ENOTSUP)
14060 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
14061 res->vf_id, is_on);
14063 #ifdef RTE_NET_BNXT
14064 if (ret == -ENOTSUP)
14065 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
14066 res->vf_id, is_on);
14073 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14076 printf("invalid port_id %d\n", res->port_id);
14079 printf("function not implemented\n");
14082 printf("programming error: (%s)\n", strerror(-ret));
14086 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
14087 .f = cmd_set_vf_vlan_stripq_parsed,
14089 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
14091 (void *)&cmd_vf_vlan_stripq_set,
14092 (void *)&cmd_vf_vlan_stripq_vf,
14093 (void *)&cmd_vf_vlan_stripq_vlan,
14094 (void *)&cmd_vf_vlan_stripq_stripq,
14095 (void *)&cmd_vf_vlan_stripq_port_id,
14096 (void *)&cmd_vf_vlan_stripq_vf_id,
14097 (void *)&cmd_vf_vlan_stripq_on_off,
14102 /* vf vlan insert configuration */
14104 /* Common result structure for vf vlan insert */
14105 struct cmd_vf_vlan_insert_result {
14106 cmdline_fixed_string_t set;
14107 cmdline_fixed_string_t vf;
14108 cmdline_fixed_string_t vlan;
14109 cmdline_fixed_string_t insert;
14115 /* Common CLI fields for vf vlan insert enable disable */
14116 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
14117 TOKEN_STRING_INITIALIZER
14118 (struct cmd_vf_vlan_insert_result,
14120 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
14121 TOKEN_STRING_INITIALIZER
14122 (struct cmd_vf_vlan_insert_result,
14124 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
14125 TOKEN_STRING_INITIALIZER
14126 (struct cmd_vf_vlan_insert_result,
14128 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
14129 TOKEN_STRING_INITIALIZER
14130 (struct cmd_vf_vlan_insert_result,
14132 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
14133 TOKEN_NUM_INITIALIZER
14134 (struct cmd_vf_vlan_insert_result,
14136 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
14137 TOKEN_NUM_INITIALIZER
14138 (struct cmd_vf_vlan_insert_result,
14140 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
14141 TOKEN_NUM_INITIALIZER
14142 (struct cmd_vf_vlan_insert_result,
14146 cmd_set_vf_vlan_insert_parsed(
14147 void *parsed_result,
14148 __rte_unused struct cmdline *cl,
14149 __rte_unused void *data)
14151 struct cmd_vf_vlan_insert_result *res = parsed_result;
14152 int ret = -ENOTSUP;
14154 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14157 #ifdef RTE_NET_IXGBE
14158 if (ret == -ENOTSUP)
14159 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
14162 #ifdef RTE_NET_I40E
14163 if (ret == -ENOTSUP)
14164 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
14167 #ifdef RTE_NET_BNXT
14168 if (ret == -ENOTSUP)
14169 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
14177 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
14180 printf("invalid port_id %d\n", res->port_id);
14183 printf("function not implemented\n");
14186 printf("programming error: (%s)\n", strerror(-ret));
14190 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
14191 .f = cmd_set_vf_vlan_insert_parsed,
14193 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
14195 (void *)&cmd_vf_vlan_insert_set,
14196 (void *)&cmd_vf_vlan_insert_vf,
14197 (void *)&cmd_vf_vlan_insert_vlan,
14198 (void *)&cmd_vf_vlan_insert_insert,
14199 (void *)&cmd_vf_vlan_insert_port_id,
14200 (void *)&cmd_vf_vlan_insert_vf_id,
14201 (void *)&cmd_vf_vlan_insert_vlan_id,
14206 /* tx loopback configuration */
14208 /* Common result structure for tx loopback */
14209 struct cmd_tx_loopback_result {
14210 cmdline_fixed_string_t set;
14211 cmdline_fixed_string_t tx;
14212 cmdline_fixed_string_t loopback;
14214 cmdline_fixed_string_t on_off;
14217 /* Common CLI fields for tx loopback enable disable */
14218 cmdline_parse_token_string_t cmd_tx_loopback_set =
14219 TOKEN_STRING_INITIALIZER
14220 (struct cmd_tx_loopback_result,
14222 cmdline_parse_token_string_t cmd_tx_loopback_tx =
14223 TOKEN_STRING_INITIALIZER
14224 (struct cmd_tx_loopback_result,
14226 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
14227 TOKEN_STRING_INITIALIZER
14228 (struct cmd_tx_loopback_result,
14229 loopback, "loopback");
14230 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
14231 TOKEN_NUM_INITIALIZER
14232 (struct cmd_tx_loopback_result,
14234 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
14235 TOKEN_STRING_INITIALIZER
14236 (struct cmd_tx_loopback_result,
14240 cmd_set_tx_loopback_parsed(
14241 void *parsed_result,
14242 __rte_unused struct cmdline *cl,
14243 __rte_unused void *data)
14245 struct cmd_tx_loopback_result *res = parsed_result;
14246 int ret = -ENOTSUP;
14248 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14250 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14253 #ifdef RTE_NET_IXGBE
14254 if (ret == -ENOTSUP)
14255 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
14257 #ifdef RTE_NET_I40E
14258 if (ret == -ENOTSUP)
14259 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
14261 #ifdef RTE_NET_BNXT
14262 if (ret == -ENOTSUP)
14263 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
14265 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
14266 if (ret == -ENOTSUP)
14267 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
14274 printf("invalid is_on %d\n", is_on);
14277 printf("invalid port_id %d\n", res->port_id);
14280 printf("function not implemented\n");
14283 printf("programming error: (%s)\n", strerror(-ret));
14287 cmdline_parse_inst_t cmd_set_tx_loopback = {
14288 .f = cmd_set_tx_loopback_parsed,
14290 .help_str = "set tx loopback <port_id> on|off",
14292 (void *)&cmd_tx_loopback_set,
14293 (void *)&cmd_tx_loopback_tx,
14294 (void *)&cmd_tx_loopback_loopback,
14295 (void *)&cmd_tx_loopback_port_id,
14296 (void *)&cmd_tx_loopback_on_off,
14301 /* all queues drop enable configuration */
14303 /* Common result structure for all queues drop enable */
14304 struct cmd_all_queues_drop_en_result {
14305 cmdline_fixed_string_t set;
14306 cmdline_fixed_string_t all;
14307 cmdline_fixed_string_t queues;
14308 cmdline_fixed_string_t drop;
14310 cmdline_fixed_string_t on_off;
14313 /* Common CLI fields for tx loopback enable disable */
14314 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
14315 TOKEN_STRING_INITIALIZER
14316 (struct cmd_all_queues_drop_en_result,
14318 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
14319 TOKEN_STRING_INITIALIZER
14320 (struct cmd_all_queues_drop_en_result,
14322 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
14323 TOKEN_STRING_INITIALIZER
14324 (struct cmd_all_queues_drop_en_result,
14326 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
14327 TOKEN_STRING_INITIALIZER
14328 (struct cmd_all_queues_drop_en_result,
14330 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
14331 TOKEN_NUM_INITIALIZER
14332 (struct cmd_all_queues_drop_en_result,
14334 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
14335 TOKEN_STRING_INITIALIZER
14336 (struct cmd_all_queues_drop_en_result,
14340 cmd_set_all_queues_drop_en_parsed(
14341 void *parsed_result,
14342 __rte_unused struct cmdline *cl,
14343 __rte_unused void *data)
14345 struct cmd_all_queues_drop_en_result *res = parsed_result;
14346 int ret = -ENOTSUP;
14347 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14349 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14352 #ifdef RTE_NET_IXGBE
14353 if (ret == -ENOTSUP)
14354 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
14356 #ifdef RTE_NET_BNXT
14357 if (ret == -ENOTSUP)
14358 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
14364 printf("invalid is_on %d\n", is_on);
14367 printf("invalid port_id %d\n", res->port_id);
14370 printf("function not implemented\n");
14373 printf("programming error: (%s)\n", strerror(-ret));
14377 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
14378 .f = cmd_set_all_queues_drop_en_parsed,
14380 .help_str = "set all queues drop <port_id> on|off",
14382 (void *)&cmd_all_queues_drop_en_set,
14383 (void *)&cmd_all_queues_drop_en_all,
14384 (void *)&cmd_all_queues_drop_en_queues,
14385 (void *)&cmd_all_queues_drop_en_drop,
14386 (void *)&cmd_all_queues_drop_en_port_id,
14387 (void *)&cmd_all_queues_drop_en_on_off,
14392 /* vf split drop enable configuration */
14394 /* Common result structure for vf split drop enable */
14395 struct cmd_vf_split_drop_en_result {
14396 cmdline_fixed_string_t set;
14397 cmdline_fixed_string_t vf;
14398 cmdline_fixed_string_t split;
14399 cmdline_fixed_string_t drop;
14402 cmdline_fixed_string_t on_off;
14405 /* Common CLI fields for vf split drop enable disable */
14406 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
14407 TOKEN_STRING_INITIALIZER
14408 (struct cmd_vf_split_drop_en_result,
14410 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
14411 TOKEN_STRING_INITIALIZER
14412 (struct cmd_vf_split_drop_en_result,
14414 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
14415 TOKEN_STRING_INITIALIZER
14416 (struct cmd_vf_split_drop_en_result,
14418 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
14419 TOKEN_STRING_INITIALIZER
14420 (struct cmd_vf_split_drop_en_result,
14422 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
14423 TOKEN_NUM_INITIALIZER
14424 (struct cmd_vf_split_drop_en_result,
14426 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
14427 TOKEN_NUM_INITIALIZER
14428 (struct cmd_vf_split_drop_en_result,
14430 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
14431 TOKEN_STRING_INITIALIZER
14432 (struct cmd_vf_split_drop_en_result,
14436 cmd_set_vf_split_drop_en_parsed(
14437 void *parsed_result,
14438 __rte_unused struct cmdline *cl,
14439 __rte_unused void *data)
14441 struct cmd_vf_split_drop_en_result *res = parsed_result;
14442 int ret = -ENOTSUP;
14443 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14445 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14448 #ifdef RTE_NET_IXGBE
14449 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14456 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14459 printf("invalid port_id %d\n", res->port_id);
14462 printf("not supported on port %d\n", res->port_id);
14465 printf("programming error: (%s)\n", strerror(-ret));
14469 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14470 .f = cmd_set_vf_split_drop_en_parsed,
14472 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14474 (void *)&cmd_vf_split_drop_en_set,
14475 (void *)&cmd_vf_split_drop_en_vf,
14476 (void *)&cmd_vf_split_drop_en_split,
14477 (void *)&cmd_vf_split_drop_en_drop,
14478 (void *)&cmd_vf_split_drop_en_port_id,
14479 (void *)&cmd_vf_split_drop_en_vf_id,
14480 (void *)&cmd_vf_split_drop_en_on_off,
14485 /* vf mac address configuration */
14487 /* Common result structure for vf mac address */
14488 struct cmd_set_vf_mac_addr_result {
14489 cmdline_fixed_string_t set;
14490 cmdline_fixed_string_t vf;
14491 cmdline_fixed_string_t mac;
14492 cmdline_fixed_string_t addr;
14495 struct rte_ether_addr mac_addr;
14499 /* Common CLI fields for vf split drop enable disable */
14500 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14501 TOKEN_STRING_INITIALIZER
14502 (struct cmd_set_vf_mac_addr_result,
14504 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14505 TOKEN_STRING_INITIALIZER
14506 (struct cmd_set_vf_mac_addr_result,
14508 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14509 TOKEN_STRING_INITIALIZER
14510 (struct cmd_set_vf_mac_addr_result,
14512 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14513 TOKEN_STRING_INITIALIZER
14514 (struct cmd_set_vf_mac_addr_result,
14516 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14517 TOKEN_NUM_INITIALIZER
14518 (struct cmd_set_vf_mac_addr_result,
14520 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14521 TOKEN_NUM_INITIALIZER
14522 (struct cmd_set_vf_mac_addr_result,
14524 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14525 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14529 cmd_set_vf_mac_addr_parsed(
14530 void *parsed_result,
14531 __rte_unused struct cmdline *cl,
14532 __rte_unused void *data)
14534 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14535 int ret = -ENOTSUP;
14537 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14540 #ifdef RTE_NET_IXGBE
14541 if (ret == -ENOTSUP)
14542 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14545 #ifdef RTE_NET_I40E
14546 if (ret == -ENOTSUP)
14547 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14550 #ifdef RTE_NET_BNXT
14551 if (ret == -ENOTSUP)
14552 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14560 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14563 printf("invalid port_id %d\n", res->port_id);
14566 printf("function not implemented\n");
14569 printf("programming error: (%s)\n", strerror(-ret));
14573 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14574 .f = cmd_set_vf_mac_addr_parsed,
14576 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14578 (void *)&cmd_set_vf_mac_addr_set,
14579 (void *)&cmd_set_vf_mac_addr_vf,
14580 (void *)&cmd_set_vf_mac_addr_mac,
14581 (void *)&cmd_set_vf_mac_addr_addr,
14582 (void *)&cmd_set_vf_mac_addr_port_id,
14583 (void *)&cmd_set_vf_mac_addr_vf_id,
14584 (void *)&cmd_set_vf_mac_addr_mac_addr,
14589 /* MACsec configuration */
14591 /* Common result structure for MACsec offload enable */
14592 struct cmd_macsec_offload_on_result {
14593 cmdline_fixed_string_t set;
14594 cmdline_fixed_string_t macsec;
14595 cmdline_fixed_string_t offload;
14597 cmdline_fixed_string_t on;
14598 cmdline_fixed_string_t encrypt;
14599 cmdline_fixed_string_t en_on_off;
14600 cmdline_fixed_string_t replay_protect;
14601 cmdline_fixed_string_t rp_on_off;
14604 /* Common CLI fields for MACsec offload disable */
14605 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14606 TOKEN_STRING_INITIALIZER
14607 (struct cmd_macsec_offload_on_result,
14609 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14610 TOKEN_STRING_INITIALIZER
14611 (struct cmd_macsec_offload_on_result,
14613 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14614 TOKEN_STRING_INITIALIZER
14615 (struct cmd_macsec_offload_on_result,
14616 offload, "offload");
14617 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14618 TOKEN_NUM_INITIALIZER
14619 (struct cmd_macsec_offload_on_result,
14621 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14622 TOKEN_STRING_INITIALIZER
14623 (struct cmd_macsec_offload_on_result,
14625 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14626 TOKEN_STRING_INITIALIZER
14627 (struct cmd_macsec_offload_on_result,
14628 encrypt, "encrypt");
14629 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14630 TOKEN_STRING_INITIALIZER
14631 (struct cmd_macsec_offload_on_result,
14632 en_on_off, "on#off");
14633 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14634 TOKEN_STRING_INITIALIZER
14635 (struct cmd_macsec_offload_on_result,
14636 replay_protect, "replay-protect");
14637 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14638 TOKEN_STRING_INITIALIZER
14639 (struct cmd_macsec_offload_on_result,
14640 rp_on_off, "on#off");
14643 cmd_set_macsec_offload_on_parsed(
14644 void *parsed_result,
14645 __rte_unused struct cmdline *cl,
14646 __rte_unused void *data)
14648 struct cmd_macsec_offload_on_result *res = parsed_result;
14649 int ret = -ENOTSUP;
14650 portid_t port_id = res->port_id;
14651 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14652 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14653 struct rte_eth_dev_info dev_info;
14655 if (port_id_is_invalid(port_id, ENABLED_WARN))
14657 if (!port_is_stopped(port_id)) {
14658 printf("Please stop port %d first\n", port_id);
14662 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14666 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14667 #ifdef RTE_NET_IXGBE
14668 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14676 ports[port_id].dev_conf.txmode.offloads |=
14677 DEV_TX_OFFLOAD_MACSEC_INSERT;
14678 cmd_reconfig_device_queue(port_id, 1, 1);
14681 printf("invalid port_id %d\n", port_id);
14684 printf("not supported on port %d\n", port_id);
14687 printf("programming error: (%s)\n", strerror(-ret));
14691 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14692 .f = cmd_set_macsec_offload_on_parsed,
14694 .help_str = "set macsec offload <port_id> on "
14695 "encrypt on|off replay-protect on|off",
14697 (void *)&cmd_macsec_offload_on_set,
14698 (void *)&cmd_macsec_offload_on_macsec,
14699 (void *)&cmd_macsec_offload_on_offload,
14700 (void *)&cmd_macsec_offload_on_port_id,
14701 (void *)&cmd_macsec_offload_on_on,
14702 (void *)&cmd_macsec_offload_on_encrypt,
14703 (void *)&cmd_macsec_offload_on_en_on_off,
14704 (void *)&cmd_macsec_offload_on_replay_protect,
14705 (void *)&cmd_macsec_offload_on_rp_on_off,
14710 /* Common result structure for MACsec offload disable */
14711 struct cmd_macsec_offload_off_result {
14712 cmdline_fixed_string_t set;
14713 cmdline_fixed_string_t macsec;
14714 cmdline_fixed_string_t offload;
14716 cmdline_fixed_string_t off;
14719 /* Common CLI fields for MACsec offload disable */
14720 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14721 TOKEN_STRING_INITIALIZER
14722 (struct cmd_macsec_offload_off_result,
14724 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14725 TOKEN_STRING_INITIALIZER
14726 (struct cmd_macsec_offload_off_result,
14728 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14729 TOKEN_STRING_INITIALIZER
14730 (struct cmd_macsec_offload_off_result,
14731 offload, "offload");
14732 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14733 TOKEN_NUM_INITIALIZER
14734 (struct cmd_macsec_offload_off_result,
14736 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14737 TOKEN_STRING_INITIALIZER
14738 (struct cmd_macsec_offload_off_result,
14742 cmd_set_macsec_offload_off_parsed(
14743 void *parsed_result,
14744 __rte_unused struct cmdline *cl,
14745 __rte_unused void *data)
14747 struct cmd_macsec_offload_off_result *res = parsed_result;
14748 int ret = -ENOTSUP;
14749 struct rte_eth_dev_info dev_info;
14750 portid_t port_id = res->port_id;
14752 if (port_id_is_invalid(port_id, ENABLED_WARN))
14754 if (!port_is_stopped(port_id)) {
14755 printf("Please stop port %d first\n", port_id);
14759 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14763 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14764 #ifdef RTE_NET_IXGBE
14765 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14770 ports[port_id].dev_conf.txmode.offloads &=
14771 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14772 cmd_reconfig_device_queue(port_id, 1, 1);
14775 printf("invalid port_id %d\n", port_id);
14778 printf("not supported on port %d\n", port_id);
14781 printf("programming error: (%s)\n", strerror(-ret));
14785 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14786 .f = cmd_set_macsec_offload_off_parsed,
14788 .help_str = "set macsec offload <port_id> off",
14790 (void *)&cmd_macsec_offload_off_set,
14791 (void *)&cmd_macsec_offload_off_macsec,
14792 (void *)&cmd_macsec_offload_off_offload,
14793 (void *)&cmd_macsec_offload_off_port_id,
14794 (void *)&cmd_macsec_offload_off_off,
14799 /* Common result structure for MACsec secure connection configure */
14800 struct cmd_macsec_sc_result {
14801 cmdline_fixed_string_t set;
14802 cmdline_fixed_string_t macsec;
14803 cmdline_fixed_string_t sc;
14804 cmdline_fixed_string_t tx_rx;
14806 struct rte_ether_addr mac;
14810 /* Common CLI fields for MACsec secure connection configure */
14811 cmdline_parse_token_string_t cmd_macsec_sc_set =
14812 TOKEN_STRING_INITIALIZER
14813 (struct cmd_macsec_sc_result,
14815 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14816 TOKEN_STRING_INITIALIZER
14817 (struct cmd_macsec_sc_result,
14819 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14820 TOKEN_STRING_INITIALIZER
14821 (struct cmd_macsec_sc_result,
14823 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14824 TOKEN_STRING_INITIALIZER
14825 (struct cmd_macsec_sc_result,
14827 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14828 TOKEN_NUM_INITIALIZER
14829 (struct cmd_macsec_sc_result,
14831 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14832 TOKEN_ETHERADDR_INITIALIZER
14833 (struct cmd_macsec_sc_result,
14835 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14836 TOKEN_NUM_INITIALIZER
14837 (struct cmd_macsec_sc_result,
14841 cmd_set_macsec_sc_parsed(
14842 void *parsed_result,
14843 __rte_unused struct cmdline *cl,
14844 __rte_unused void *data)
14846 struct cmd_macsec_sc_result *res = parsed_result;
14847 int ret = -ENOTSUP;
14848 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14850 #ifdef RTE_NET_IXGBE
14852 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14853 res->mac.addr_bytes) :
14854 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14855 res->mac.addr_bytes, res->pi);
14857 RTE_SET_USED(is_tx);
14863 printf("invalid port_id %d\n", res->port_id);
14866 printf("not supported on port %d\n", res->port_id);
14869 printf("programming error: (%s)\n", strerror(-ret));
14873 cmdline_parse_inst_t cmd_set_macsec_sc = {
14874 .f = cmd_set_macsec_sc_parsed,
14876 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14878 (void *)&cmd_macsec_sc_set,
14879 (void *)&cmd_macsec_sc_macsec,
14880 (void *)&cmd_macsec_sc_sc,
14881 (void *)&cmd_macsec_sc_tx_rx,
14882 (void *)&cmd_macsec_sc_port_id,
14883 (void *)&cmd_macsec_sc_mac,
14884 (void *)&cmd_macsec_sc_pi,
14889 /* Common result structure for MACsec secure connection configure */
14890 struct cmd_macsec_sa_result {
14891 cmdline_fixed_string_t set;
14892 cmdline_fixed_string_t macsec;
14893 cmdline_fixed_string_t sa;
14894 cmdline_fixed_string_t tx_rx;
14899 cmdline_fixed_string_t key;
14902 /* Common CLI fields for MACsec secure connection configure */
14903 cmdline_parse_token_string_t cmd_macsec_sa_set =
14904 TOKEN_STRING_INITIALIZER
14905 (struct cmd_macsec_sa_result,
14907 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14908 TOKEN_STRING_INITIALIZER
14909 (struct cmd_macsec_sa_result,
14911 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14912 TOKEN_STRING_INITIALIZER
14913 (struct cmd_macsec_sa_result,
14915 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14916 TOKEN_STRING_INITIALIZER
14917 (struct cmd_macsec_sa_result,
14919 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14920 TOKEN_NUM_INITIALIZER
14921 (struct cmd_macsec_sa_result,
14923 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14924 TOKEN_NUM_INITIALIZER
14925 (struct cmd_macsec_sa_result,
14927 cmdline_parse_token_num_t cmd_macsec_sa_an =
14928 TOKEN_NUM_INITIALIZER
14929 (struct cmd_macsec_sa_result,
14931 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14932 TOKEN_NUM_INITIALIZER
14933 (struct cmd_macsec_sa_result,
14935 cmdline_parse_token_string_t cmd_macsec_sa_key =
14936 TOKEN_STRING_INITIALIZER
14937 (struct cmd_macsec_sa_result,
14941 cmd_set_macsec_sa_parsed(
14942 void *parsed_result,
14943 __rte_unused struct cmdline *cl,
14944 __rte_unused void *data)
14946 struct cmd_macsec_sa_result *res = parsed_result;
14947 int ret = -ENOTSUP;
14948 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14949 uint8_t key[16] = { 0 };
14955 key_len = strlen(res->key) / 2;
14959 for (i = 0; i < key_len; i++) {
14960 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14963 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14966 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14969 #ifdef RTE_NET_IXGBE
14971 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14972 res->idx, res->an, res->pn, key) :
14973 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14974 res->idx, res->an, res->pn, key);
14976 RTE_SET_USED(is_tx);
14983 printf("invalid idx %d or an %d\n", res->idx, res->an);
14986 printf("invalid port_id %d\n", res->port_id);
14989 printf("not supported on port %d\n", res->port_id);
14992 printf("programming error: (%s)\n", strerror(-ret));
14996 cmdline_parse_inst_t cmd_set_macsec_sa = {
14997 .f = cmd_set_macsec_sa_parsed,
14999 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
15001 (void *)&cmd_macsec_sa_set,
15002 (void *)&cmd_macsec_sa_macsec,
15003 (void *)&cmd_macsec_sa_sa,
15004 (void *)&cmd_macsec_sa_tx_rx,
15005 (void *)&cmd_macsec_sa_port_id,
15006 (void *)&cmd_macsec_sa_idx,
15007 (void *)&cmd_macsec_sa_an,
15008 (void *)&cmd_macsec_sa_pn,
15009 (void *)&cmd_macsec_sa_key,
15014 /* VF unicast promiscuous mode configuration */
15016 /* Common result structure for VF unicast promiscuous mode */
15017 struct cmd_vf_promisc_result {
15018 cmdline_fixed_string_t set;
15019 cmdline_fixed_string_t vf;
15020 cmdline_fixed_string_t promisc;
15023 cmdline_fixed_string_t on_off;
15026 /* Common CLI fields for VF unicast promiscuous mode enable disable */
15027 cmdline_parse_token_string_t cmd_vf_promisc_set =
15028 TOKEN_STRING_INITIALIZER
15029 (struct cmd_vf_promisc_result,
15031 cmdline_parse_token_string_t cmd_vf_promisc_vf =
15032 TOKEN_STRING_INITIALIZER
15033 (struct cmd_vf_promisc_result,
15035 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
15036 TOKEN_STRING_INITIALIZER
15037 (struct cmd_vf_promisc_result,
15038 promisc, "promisc");
15039 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
15040 TOKEN_NUM_INITIALIZER
15041 (struct cmd_vf_promisc_result,
15043 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
15044 TOKEN_NUM_INITIALIZER
15045 (struct cmd_vf_promisc_result,
15047 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
15048 TOKEN_STRING_INITIALIZER
15049 (struct cmd_vf_promisc_result,
15053 cmd_set_vf_promisc_parsed(
15054 void *parsed_result,
15055 __rte_unused struct cmdline *cl,
15056 __rte_unused void *data)
15058 struct cmd_vf_promisc_result *res = parsed_result;
15059 int ret = -ENOTSUP;
15061 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15063 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15066 #ifdef RTE_NET_I40E
15067 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
15068 res->vf_id, is_on);
15075 printf("invalid vf_id %d\n", res->vf_id);
15078 printf("invalid port_id %d\n", res->port_id);
15081 printf("function not implemented\n");
15084 printf("programming error: (%s)\n", strerror(-ret));
15088 cmdline_parse_inst_t cmd_set_vf_promisc = {
15089 .f = cmd_set_vf_promisc_parsed,
15091 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
15092 "Set unicast promiscuous mode for a VF from the PF",
15094 (void *)&cmd_vf_promisc_set,
15095 (void *)&cmd_vf_promisc_vf,
15096 (void *)&cmd_vf_promisc_promisc,
15097 (void *)&cmd_vf_promisc_port_id,
15098 (void *)&cmd_vf_promisc_vf_id,
15099 (void *)&cmd_vf_promisc_on_off,
15104 /* VF multicast promiscuous mode configuration */
15106 /* Common result structure for VF multicast promiscuous mode */
15107 struct cmd_vf_allmulti_result {
15108 cmdline_fixed_string_t set;
15109 cmdline_fixed_string_t vf;
15110 cmdline_fixed_string_t allmulti;
15113 cmdline_fixed_string_t on_off;
15116 /* Common CLI fields for VF multicast promiscuous mode enable disable */
15117 cmdline_parse_token_string_t cmd_vf_allmulti_set =
15118 TOKEN_STRING_INITIALIZER
15119 (struct cmd_vf_allmulti_result,
15121 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
15122 TOKEN_STRING_INITIALIZER
15123 (struct cmd_vf_allmulti_result,
15125 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
15126 TOKEN_STRING_INITIALIZER
15127 (struct cmd_vf_allmulti_result,
15128 allmulti, "allmulti");
15129 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
15130 TOKEN_NUM_INITIALIZER
15131 (struct cmd_vf_allmulti_result,
15133 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
15134 TOKEN_NUM_INITIALIZER
15135 (struct cmd_vf_allmulti_result,
15137 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
15138 TOKEN_STRING_INITIALIZER
15139 (struct cmd_vf_allmulti_result,
15143 cmd_set_vf_allmulti_parsed(
15144 void *parsed_result,
15145 __rte_unused struct cmdline *cl,
15146 __rte_unused void *data)
15148 struct cmd_vf_allmulti_result *res = parsed_result;
15149 int ret = -ENOTSUP;
15151 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15153 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15156 #ifdef RTE_NET_I40E
15157 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
15158 res->vf_id, is_on);
15165 printf("invalid vf_id %d\n", res->vf_id);
15168 printf("invalid port_id %d\n", res->port_id);
15171 printf("function not implemented\n");
15174 printf("programming error: (%s)\n", strerror(-ret));
15178 cmdline_parse_inst_t cmd_set_vf_allmulti = {
15179 .f = cmd_set_vf_allmulti_parsed,
15181 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
15182 "Set multicast promiscuous mode for a VF from the PF",
15184 (void *)&cmd_vf_allmulti_set,
15185 (void *)&cmd_vf_allmulti_vf,
15186 (void *)&cmd_vf_allmulti_allmulti,
15187 (void *)&cmd_vf_allmulti_port_id,
15188 (void *)&cmd_vf_allmulti_vf_id,
15189 (void *)&cmd_vf_allmulti_on_off,
15194 /* vf broadcast mode configuration */
15196 /* Common result structure for vf broadcast */
15197 struct cmd_set_vf_broadcast_result {
15198 cmdline_fixed_string_t set;
15199 cmdline_fixed_string_t vf;
15200 cmdline_fixed_string_t broadcast;
15203 cmdline_fixed_string_t on_off;
15206 /* Common CLI fields for vf broadcast enable disable */
15207 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
15208 TOKEN_STRING_INITIALIZER
15209 (struct cmd_set_vf_broadcast_result,
15211 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
15212 TOKEN_STRING_INITIALIZER
15213 (struct cmd_set_vf_broadcast_result,
15215 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
15216 TOKEN_STRING_INITIALIZER
15217 (struct cmd_set_vf_broadcast_result,
15218 broadcast, "broadcast");
15219 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
15220 TOKEN_NUM_INITIALIZER
15221 (struct cmd_set_vf_broadcast_result,
15223 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
15224 TOKEN_NUM_INITIALIZER
15225 (struct cmd_set_vf_broadcast_result,
15227 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
15228 TOKEN_STRING_INITIALIZER
15229 (struct cmd_set_vf_broadcast_result,
15233 cmd_set_vf_broadcast_parsed(
15234 void *parsed_result,
15235 __rte_unused struct cmdline *cl,
15236 __rte_unused void *data)
15238 struct cmd_set_vf_broadcast_result *res = parsed_result;
15239 int ret = -ENOTSUP;
15241 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15243 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15246 #ifdef RTE_NET_I40E
15247 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
15248 res->vf_id, is_on);
15255 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15258 printf("invalid port_id %d\n", res->port_id);
15261 printf("function not implemented\n");
15264 printf("programming error: (%s)\n", strerror(-ret));
15268 cmdline_parse_inst_t cmd_set_vf_broadcast = {
15269 .f = cmd_set_vf_broadcast_parsed,
15271 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
15273 (void *)&cmd_set_vf_broadcast_set,
15274 (void *)&cmd_set_vf_broadcast_vf,
15275 (void *)&cmd_set_vf_broadcast_broadcast,
15276 (void *)&cmd_set_vf_broadcast_port_id,
15277 (void *)&cmd_set_vf_broadcast_vf_id,
15278 (void *)&cmd_set_vf_broadcast_on_off,
15283 /* vf vlan tag configuration */
15285 /* Common result structure for vf vlan tag */
15286 struct cmd_set_vf_vlan_tag_result {
15287 cmdline_fixed_string_t set;
15288 cmdline_fixed_string_t vf;
15289 cmdline_fixed_string_t vlan;
15290 cmdline_fixed_string_t tag;
15293 cmdline_fixed_string_t on_off;
15296 /* Common CLI fields for vf vlan tag enable disable */
15297 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
15298 TOKEN_STRING_INITIALIZER
15299 (struct cmd_set_vf_vlan_tag_result,
15301 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
15302 TOKEN_STRING_INITIALIZER
15303 (struct cmd_set_vf_vlan_tag_result,
15305 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
15306 TOKEN_STRING_INITIALIZER
15307 (struct cmd_set_vf_vlan_tag_result,
15309 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
15310 TOKEN_STRING_INITIALIZER
15311 (struct cmd_set_vf_vlan_tag_result,
15313 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
15314 TOKEN_NUM_INITIALIZER
15315 (struct cmd_set_vf_vlan_tag_result,
15317 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
15318 TOKEN_NUM_INITIALIZER
15319 (struct cmd_set_vf_vlan_tag_result,
15321 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
15322 TOKEN_STRING_INITIALIZER
15323 (struct cmd_set_vf_vlan_tag_result,
15327 cmd_set_vf_vlan_tag_parsed(
15328 void *parsed_result,
15329 __rte_unused struct cmdline *cl,
15330 __rte_unused void *data)
15332 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
15333 int ret = -ENOTSUP;
15335 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15337 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15340 #ifdef RTE_NET_I40E
15341 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
15342 res->vf_id, is_on);
15349 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15352 printf("invalid port_id %d\n", res->port_id);
15355 printf("function not implemented\n");
15358 printf("programming error: (%s)\n", strerror(-ret));
15362 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
15363 .f = cmd_set_vf_vlan_tag_parsed,
15365 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
15367 (void *)&cmd_set_vf_vlan_tag_set,
15368 (void *)&cmd_set_vf_vlan_tag_vf,
15369 (void *)&cmd_set_vf_vlan_tag_vlan,
15370 (void *)&cmd_set_vf_vlan_tag_tag,
15371 (void *)&cmd_set_vf_vlan_tag_port_id,
15372 (void *)&cmd_set_vf_vlan_tag_vf_id,
15373 (void *)&cmd_set_vf_vlan_tag_on_off,
15378 /* Common definition of VF and TC TX bandwidth configuration */
15379 struct cmd_vf_tc_bw_result {
15380 cmdline_fixed_string_t set;
15381 cmdline_fixed_string_t vf;
15382 cmdline_fixed_string_t tc;
15383 cmdline_fixed_string_t tx;
15384 cmdline_fixed_string_t min_bw;
15385 cmdline_fixed_string_t max_bw;
15386 cmdline_fixed_string_t strict_link_prio;
15391 cmdline_fixed_string_t bw_list;
15395 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
15396 TOKEN_STRING_INITIALIZER
15397 (struct cmd_vf_tc_bw_result,
15399 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
15400 TOKEN_STRING_INITIALIZER
15401 (struct cmd_vf_tc_bw_result,
15403 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
15404 TOKEN_STRING_INITIALIZER
15405 (struct cmd_vf_tc_bw_result,
15407 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
15408 TOKEN_STRING_INITIALIZER
15409 (struct cmd_vf_tc_bw_result,
15411 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
15412 TOKEN_STRING_INITIALIZER
15413 (struct cmd_vf_tc_bw_result,
15414 strict_link_prio, "strict-link-priority");
15415 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
15416 TOKEN_STRING_INITIALIZER
15417 (struct cmd_vf_tc_bw_result,
15418 min_bw, "min-bandwidth");
15419 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
15420 TOKEN_STRING_INITIALIZER
15421 (struct cmd_vf_tc_bw_result,
15422 max_bw, "max-bandwidth");
15423 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
15424 TOKEN_NUM_INITIALIZER
15425 (struct cmd_vf_tc_bw_result,
15427 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
15428 TOKEN_NUM_INITIALIZER
15429 (struct cmd_vf_tc_bw_result,
15431 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
15432 TOKEN_NUM_INITIALIZER
15433 (struct cmd_vf_tc_bw_result,
15435 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
15436 TOKEN_NUM_INITIALIZER
15437 (struct cmd_vf_tc_bw_result,
15439 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
15440 TOKEN_STRING_INITIALIZER
15441 (struct cmd_vf_tc_bw_result,
15443 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
15444 TOKEN_NUM_INITIALIZER
15445 (struct cmd_vf_tc_bw_result,
15448 /* VF max bandwidth setting */
15450 cmd_vf_max_bw_parsed(
15451 void *parsed_result,
15452 __rte_unused struct cmdline *cl,
15453 __rte_unused void *data)
15455 struct cmd_vf_tc_bw_result *res = parsed_result;
15456 int ret = -ENOTSUP;
15458 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15461 #ifdef RTE_NET_I40E
15462 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15463 res->vf_id, res->bw);
15470 printf("invalid vf_id %d or bandwidth %d\n",
15471 res->vf_id, res->bw);
15474 printf("invalid port_id %d\n", res->port_id);
15477 printf("function not implemented\n");
15480 printf("programming error: (%s)\n", strerror(-ret));
15484 cmdline_parse_inst_t cmd_vf_max_bw = {
15485 .f = cmd_vf_max_bw_parsed,
15487 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15489 (void *)&cmd_vf_tc_bw_set,
15490 (void *)&cmd_vf_tc_bw_vf,
15491 (void *)&cmd_vf_tc_bw_tx,
15492 (void *)&cmd_vf_tc_bw_max_bw,
15493 (void *)&cmd_vf_tc_bw_port_id,
15494 (void *)&cmd_vf_tc_bw_vf_id,
15495 (void *)&cmd_vf_tc_bw_bw,
15501 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15506 const char *p, *p0 = str;
15513 p = strchr(p0, '(');
15515 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15519 p0 = strchr(p, ')');
15521 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15525 if (size >= sizeof(s)) {
15526 printf("The string size exceeds the internal buffer size\n");
15529 snprintf(s, sizeof(s), "%.*s", size, p);
15530 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15532 printf("Failed to get the bandwidth list. ");
15536 for (i = 0; i < ret; i++)
15537 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15542 /* TC min bandwidth setting */
15544 cmd_vf_tc_min_bw_parsed(
15545 void *parsed_result,
15546 __rte_unused struct cmdline *cl,
15547 __rte_unused void *data)
15549 struct cmd_vf_tc_bw_result *res = parsed_result;
15552 int ret = -ENOTSUP;
15554 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15557 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15561 #ifdef RTE_NET_I40E
15562 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15570 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15573 printf("invalid port_id %d\n", res->port_id);
15576 printf("function not implemented\n");
15579 printf("programming error: (%s)\n", strerror(-ret));
15583 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15584 .f = cmd_vf_tc_min_bw_parsed,
15586 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15587 " <bw1, bw2, ...>",
15589 (void *)&cmd_vf_tc_bw_set,
15590 (void *)&cmd_vf_tc_bw_vf,
15591 (void *)&cmd_vf_tc_bw_tc,
15592 (void *)&cmd_vf_tc_bw_tx,
15593 (void *)&cmd_vf_tc_bw_min_bw,
15594 (void *)&cmd_vf_tc_bw_port_id,
15595 (void *)&cmd_vf_tc_bw_vf_id,
15596 (void *)&cmd_vf_tc_bw_bw_list,
15602 cmd_tc_min_bw_parsed(
15603 void *parsed_result,
15604 __rte_unused struct cmdline *cl,
15605 __rte_unused void *data)
15607 struct cmd_vf_tc_bw_result *res = parsed_result;
15608 struct rte_port *port;
15611 int ret = -ENOTSUP;
15613 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15616 port = &ports[res->port_id];
15617 /** Check if the port is not started **/
15618 if (port->port_status != RTE_PORT_STOPPED) {
15619 printf("Please stop port %d first\n", res->port_id);
15623 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15627 #ifdef RTE_NET_IXGBE
15628 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15635 printf("invalid bandwidth\n");
15638 printf("invalid port_id %d\n", res->port_id);
15641 printf("function not implemented\n");
15644 printf("programming error: (%s)\n", strerror(-ret));
15648 cmdline_parse_inst_t cmd_tc_min_bw = {
15649 .f = cmd_tc_min_bw_parsed,
15651 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15653 (void *)&cmd_vf_tc_bw_set,
15654 (void *)&cmd_vf_tc_bw_tc,
15655 (void *)&cmd_vf_tc_bw_tx,
15656 (void *)&cmd_vf_tc_bw_min_bw,
15657 (void *)&cmd_vf_tc_bw_port_id,
15658 (void *)&cmd_vf_tc_bw_bw_list,
15663 /* TC max bandwidth setting */
15665 cmd_vf_tc_max_bw_parsed(
15666 void *parsed_result,
15667 __rte_unused struct cmdline *cl,
15668 __rte_unused void *data)
15670 struct cmd_vf_tc_bw_result *res = parsed_result;
15671 int ret = -ENOTSUP;
15673 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15676 #ifdef RTE_NET_I40E
15677 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15678 res->tc_no, res->bw);
15685 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15686 res->vf_id, res->tc_no, res->bw);
15689 printf("invalid port_id %d\n", res->port_id);
15692 printf("function not implemented\n");
15695 printf("programming error: (%s)\n", strerror(-ret));
15699 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15700 .f = cmd_vf_tc_max_bw_parsed,
15702 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15705 (void *)&cmd_vf_tc_bw_set,
15706 (void *)&cmd_vf_tc_bw_vf,
15707 (void *)&cmd_vf_tc_bw_tc,
15708 (void *)&cmd_vf_tc_bw_tx,
15709 (void *)&cmd_vf_tc_bw_max_bw,
15710 (void *)&cmd_vf_tc_bw_port_id,
15711 (void *)&cmd_vf_tc_bw_vf_id,
15712 (void *)&cmd_vf_tc_bw_tc_no,
15713 (void *)&cmd_vf_tc_bw_bw,
15718 /** Set VXLAN encapsulation details */
15719 struct cmd_set_vxlan_result {
15720 cmdline_fixed_string_t set;
15721 cmdline_fixed_string_t vxlan;
15722 cmdline_fixed_string_t pos_token;
15723 cmdline_fixed_string_t ip_version;
15724 uint32_t vlan_present:1;
15728 cmdline_ipaddr_t ip_src;
15729 cmdline_ipaddr_t ip_dst;
15733 struct rte_ether_addr eth_src;
15734 struct rte_ether_addr eth_dst;
15737 cmdline_parse_token_string_t cmd_set_vxlan_set =
15738 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15739 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15740 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15741 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15742 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15744 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15745 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15746 "vxlan-with-vlan");
15747 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15748 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15750 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15751 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15753 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15754 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15756 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15757 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15758 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15759 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15761 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15762 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15763 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15764 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15766 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15767 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15768 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15769 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15771 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15772 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15773 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15774 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15776 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15777 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15778 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15779 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15781 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15782 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15783 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15784 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15786 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15787 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15788 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15789 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15791 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15792 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15793 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15794 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15796 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15797 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15798 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15799 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15801 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15802 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15804 static void cmd_set_vxlan_parsed(void *parsed_result,
15805 __rte_unused struct cmdline *cl,
15806 __rte_unused void *data)
15808 struct cmd_set_vxlan_result *res = parsed_result;
15813 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15816 vxlan_encap_conf.select_tos_ttl = 0;
15817 if (strcmp(res->vxlan, "vxlan") == 0)
15818 vxlan_encap_conf.select_vlan = 0;
15819 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15820 vxlan_encap_conf.select_vlan = 1;
15821 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15822 vxlan_encap_conf.select_vlan = 0;
15823 vxlan_encap_conf.select_tos_ttl = 1;
15825 if (strcmp(res->ip_version, "ipv4") == 0)
15826 vxlan_encap_conf.select_ipv4 = 1;
15827 else if (strcmp(res->ip_version, "ipv6") == 0)
15828 vxlan_encap_conf.select_ipv4 = 0;
15831 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15832 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15833 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15834 vxlan_encap_conf.ip_tos = res->tos;
15835 vxlan_encap_conf.ip_ttl = res->ttl;
15836 if (vxlan_encap_conf.select_ipv4) {
15837 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15838 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15840 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15841 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15843 if (vxlan_encap_conf.select_vlan)
15844 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15845 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15846 RTE_ETHER_ADDR_LEN);
15847 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15848 RTE_ETHER_ADDR_LEN);
15851 cmdline_parse_inst_t cmd_set_vxlan = {
15852 .f = cmd_set_vxlan_parsed,
15854 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15855 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15856 " eth-src <eth-src> eth-dst <eth-dst>",
15858 (void *)&cmd_set_vxlan_set,
15859 (void *)&cmd_set_vxlan_vxlan,
15860 (void *)&cmd_set_vxlan_ip_version,
15861 (void *)&cmd_set_vxlan_ip_version_value,
15862 (void *)&cmd_set_vxlan_vni,
15863 (void *)&cmd_set_vxlan_vni_value,
15864 (void *)&cmd_set_vxlan_udp_src,
15865 (void *)&cmd_set_vxlan_udp_src_value,
15866 (void *)&cmd_set_vxlan_udp_dst,
15867 (void *)&cmd_set_vxlan_udp_dst_value,
15868 (void *)&cmd_set_vxlan_ip_src,
15869 (void *)&cmd_set_vxlan_ip_src_value,
15870 (void *)&cmd_set_vxlan_ip_dst,
15871 (void *)&cmd_set_vxlan_ip_dst_value,
15872 (void *)&cmd_set_vxlan_eth_src,
15873 (void *)&cmd_set_vxlan_eth_src_value,
15874 (void *)&cmd_set_vxlan_eth_dst,
15875 (void *)&cmd_set_vxlan_eth_dst_value,
15880 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15881 .f = cmd_set_vxlan_parsed,
15883 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15884 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15885 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15886 " eth-dst <eth-dst>",
15888 (void *)&cmd_set_vxlan_set,
15889 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15890 (void *)&cmd_set_vxlan_ip_version,
15891 (void *)&cmd_set_vxlan_ip_version_value,
15892 (void *)&cmd_set_vxlan_vni,
15893 (void *)&cmd_set_vxlan_vni_value,
15894 (void *)&cmd_set_vxlan_udp_src,
15895 (void *)&cmd_set_vxlan_udp_src_value,
15896 (void *)&cmd_set_vxlan_udp_dst,
15897 (void *)&cmd_set_vxlan_udp_dst_value,
15898 (void *)&cmd_set_vxlan_ip_tos,
15899 (void *)&cmd_set_vxlan_ip_tos_value,
15900 (void *)&cmd_set_vxlan_ip_ttl,
15901 (void *)&cmd_set_vxlan_ip_ttl_value,
15902 (void *)&cmd_set_vxlan_ip_src,
15903 (void *)&cmd_set_vxlan_ip_src_value,
15904 (void *)&cmd_set_vxlan_ip_dst,
15905 (void *)&cmd_set_vxlan_ip_dst_value,
15906 (void *)&cmd_set_vxlan_eth_src,
15907 (void *)&cmd_set_vxlan_eth_src_value,
15908 (void *)&cmd_set_vxlan_eth_dst,
15909 (void *)&cmd_set_vxlan_eth_dst_value,
15914 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15915 .f = cmd_set_vxlan_parsed,
15917 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15918 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15919 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15922 (void *)&cmd_set_vxlan_set,
15923 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15924 (void *)&cmd_set_vxlan_ip_version,
15925 (void *)&cmd_set_vxlan_ip_version_value,
15926 (void *)&cmd_set_vxlan_vni,
15927 (void *)&cmd_set_vxlan_vni_value,
15928 (void *)&cmd_set_vxlan_udp_src,
15929 (void *)&cmd_set_vxlan_udp_src_value,
15930 (void *)&cmd_set_vxlan_udp_dst,
15931 (void *)&cmd_set_vxlan_udp_dst_value,
15932 (void *)&cmd_set_vxlan_ip_src,
15933 (void *)&cmd_set_vxlan_ip_src_value,
15934 (void *)&cmd_set_vxlan_ip_dst,
15935 (void *)&cmd_set_vxlan_ip_dst_value,
15936 (void *)&cmd_set_vxlan_vlan,
15937 (void *)&cmd_set_vxlan_vlan_value,
15938 (void *)&cmd_set_vxlan_eth_src,
15939 (void *)&cmd_set_vxlan_eth_src_value,
15940 (void *)&cmd_set_vxlan_eth_dst,
15941 (void *)&cmd_set_vxlan_eth_dst_value,
15946 /** Set NVGRE encapsulation details */
15947 struct cmd_set_nvgre_result {
15948 cmdline_fixed_string_t set;
15949 cmdline_fixed_string_t nvgre;
15950 cmdline_fixed_string_t pos_token;
15951 cmdline_fixed_string_t ip_version;
15953 cmdline_ipaddr_t ip_src;
15954 cmdline_ipaddr_t ip_dst;
15956 struct rte_ether_addr eth_src;
15957 struct rte_ether_addr eth_dst;
15960 cmdline_parse_token_string_t cmd_set_nvgre_set =
15961 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15962 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15963 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15964 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15965 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15966 "nvgre-with-vlan");
15967 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15968 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15970 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15971 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15973 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15974 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15976 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15977 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15978 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15979 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15981 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15982 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15983 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15984 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15986 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15987 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15988 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15989 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15991 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15992 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15993 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15994 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15996 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15997 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15998 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15999 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
16001 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
16002 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
16004 static void cmd_set_nvgre_parsed(void *parsed_result,
16005 __rte_unused struct cmdline *cl,
16006 __rte_unused void *data)
16008 struct cmd_set_nvgre_result *res = parsed_result;
16010 uint32_t nvgre_tni;
16013 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
16016 if (strcmp(res->nvgre, "nvgre") == 0)
16017 nvgre_encap_conf.select_vlan = 0;
16018 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
16019 nvgre_encap_conf.select_vlan = 1;
16020 if (strcmp(res->ip_version, "ipv4") == 0)
16021 nvgre_encap_conf.select_ipv4 = 1;
16022 else if (strcmp(res->ip_version, "ipv6") == 0)
16023 nvgre_encap_conf.select_ipv4 = 0;
16026 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
16027 if (nvgre_encap_conf.select_ipv4) {
16028 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
16029 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
16031 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
16032 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
16034 if (nvgre_encap_conf.select_vlan)
16035 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16036 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
16037 RTE_ETHER_ADDR_LEN);
16038 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16039 RTE_ETHER_ADDR_LEN);
16042 cmdline_parse_inst_t cmd_set_nvgre = {
16043 .f = cmd_set_nvgre_parsed,
16045 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
16046 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
16047 " eth-dst <eth-dst>",
16049 (void *)&cmd_set_nvgre_set,
16050 (void *)&cmd_set_nvgre_nvgre,
16051 (void *)&cmd_set_nvgre_ip_version,
16052 (void *)&cmd_set_nvgre_ip_version_value,
16053 (void *)&cmd_set_nvgre_tni,
16054 (void *)&cmd_set_nvgre_tni_value,
16055 (void *)&cmd_set_nvgre_ip_src,
16056 (void *)&cmd_set_nvgre_ip_src_value,
16057 (void *)&cmd_set_nvgre_ip_dst,
16058 (void *)&cmd_set_nvgre_ip_dst_value,
16059 (void *)&cmd_set_nvgre_eth_src,
16060 (void *)&cmd_set_nvgre_eth_src_value,
16061 (void *)&cmd_set_nvgre_eth_dst,
16062 (void *)&cmd_set_nvgre_eth_dst_value,
16067 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
16068 .f = cmd_set_nvgre_parsed,
16070 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
16071 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16072 " eth-src <eth-src> eth-dst <eth-dst>",
16074 (void *)&cmd_set_nvgre_set,
16075 (void *)&cmd_set_nvgre_nvgre_with_vlan,
16076 (void *)&cmd_set_nvgre_ip_version,
16077 (void *)&cmd_set_nvgre_ip_version_value,
16078 (void *)&cmd_set_nvgre_tni,
16079 (void *)&cmd_set_nvgre_tni_value,
16080 (void *)&cmd_set_nvgre_ip_src,
16081 (void *)&cmd_set_nvgre_ip_src_value,
16082 (void *)&cmd_set_nvgre_ip_dst,
16083 (void *)&cmd_set_nvgre_ip_dst_value,
16084 (void *)&cmd_set_nvgre_vlan,
16085 (void *)&cmd_set_nvgre_vlan_value,
16086 (void *)&cmd_set_nvgre_eth_src,
16087 (void *)&cmd_set_nvgre_eth_src_value,
16088 (void *)&cmd_set_nvgre_eth_dst,
16089 (void *)&cmd_set_nvgre_eth_dst_value,
16094 /** Set L2 encapsulation details */
16095 struct cmd_set_l2_encap_result {
16096 cmdline_fixed_string_t set;
16097 cmdline_fixed_string_t l2_encap;
16098 cmdline_fixed_string_t pos_token;
16099 cmdline_fixed_string_t ip_version;
16100 uint32_t vlan_present:1;
16102 struct rte_ether_addr eth_src;
16103 struct rte_ether_addr eth_dst;
16106 cmdline_parse_token_string_t cmd_set_l2_encap_set =
16107 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
16108 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
16109 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
16110 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
16111 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
16112 "l2_encap-with-vlan");
16113 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
16114 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
16116 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
16117 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
16119 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
16120 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
16122 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
16123 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
16124 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
16125 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
16127 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
16128 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
16129 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
16130 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
16132 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
16133 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
16135 static void cmd_set_l2_encap_parsed(void *parsed_result,
16136 __rte_unused struct cmdline *cl,
16137 __rte_unused void *data)
16139 struct cmd_set_l2_encap_result *res = parsed_result;
16141 if (strcmp(res->l2_encap, "l2_encap") == 0)
16142 l2_encap_conf.select_vlan = 0;
16143 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
16144 l2_encap_conf.select_vlan = 1;
16145 if (strcmp(res->ip_version, "ipv4") == 0)
16146 l2_encap_conf.select_ipv4 = 1;
16147 else if (strcmp(res->ip_version, "ipv6") == 0)
16148 l2_encap_conf.select_ipv4 = 0;
16151 if (l2_encap_conf.select_vlan)
16152 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16153 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
16154 RTE_ETHER_ADDR_LEN);
16155 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16156 RTE_ETHER_ADDR_LEN);
16159 cmdline_parse_inst_t cmd_set_l2_encap = {
16160 .f = cmd_set_l2_encap_parsed,
16162 .help_str = "set l2_encap ip-version ipv4|ipv6"
16163 " eth-src <eth-src> eth-dst <eth-dst>",
16165 (void *)&cmd_set_l2_encap_set,
16166 (void *)&cmd_set_l2_encap_l2_encap,
16167 (void *)&cmd_set_l2_encap_ip_version,
16168 (void *)&cmd_set_l2_encap_ip_version_value,
16169 (void *)&cmd_set_l2_encap_eth_src,
16170 (void *)&cmd_set_l2_encap_eth_src_value,
16171 (void *)&cmd_set_l2_encap_eth_dst,
16172 (void *)&cmd_set_l2_encap_eth_dst_value,
16177 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
16178 .f = cmd_set_l2_encap_parsed,
16180 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
16181 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16183 (void *)&cmd_set_l2_encap_set,
16184 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
16185 (void *)&cmd_set_l2_encap_ip_version,
16186 (void *)&cmd_set_l2_encap_ip_version_value,
16187 (void *)&cmd_set_l2_encap_vlan,
16188 (void *)&cmd_set_l2_encap_vlan_value,
16189 (void *)&cmd_set_l2_encap_eth_src,
16190 (void *)&cmd_set_l2_encap_eth_src_value,
16191 (void *)&cmd_set_l2_encap_eth_dst,
16192 (void *)&cmd_set_l2_encap_eth_dst_value,
16197 /** Set L2 decapsulation details */
16198 struct cmd_set_l2_decap_result {
16199 cmdline_fixed_string_t set;
16200 cmdline_fixed_string_t l2_decap;
16201 cmdline_fixed_string_t pos_token;
16202 uint32_t vlan_present:1;
16205 cmdline_parse_token_string_t cmd_set_l2_decap_set =
16206 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
16207 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
16208 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
16210 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
16211 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
16212 "l2_decap-with-vlan");
16214 static void cmd_set_l2_decap_parsed(void *parsed_result,
16215 __rte_unused struct cmdline *cl,
16216 __rte_unused void *data)
16218 struct cmd_set_l2_decap_result *res = parsed_result;
16220 if (strcmp(res->l2_decap, "l2_decap") == 0)
16221 l2_decap_conf.select_vlan = 0;
16222 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
16223 l2_decap_conf.select_vlan = 1;
16226 cmdline_parse_inst_t cmd_set_l2_decap = {
16227 .f = cmd_set_l2_decap_parsed,
16229 .help_str = "set l2_decap",
16231 (void *)&cmd_set_l2_decap_set,
16232 (void *)&cmd_set_l2_decap_l2_decap,
16237 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
16238 .f = cmd_set_l2_decap_parsed,
16240 .help_str = "set l2_decap-with-vlan",
16242 (void *)&cmd_set_l2_decap_set,
16243 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
16248 /** Set MPLSoGRE encapsulation details */
16249 struct cmd_set_mplsogre_encap_result {
16250 cmdline_fixed_string_t set;
16251 cmdline_fixed_string_t mplsogre;
16252 cmdline_fixed_string_t pos_token;
16253 cmdline_fixed_string_t ip_version;
16254 uint32_t vlan_present:1;
16256 cmdline_ipaddr_t ip_src;
16257 cmdline_ipaddr_t ip_dst;
16259 struct rte_ether_addr eth_src;
16260 struct rte_ether_addr eth_dst;
16263 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
16264 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
16266 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
16267 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
16269 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
16270 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16271 mplsogre, "mplsogre_encap-with-vlan");
16272 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
16273 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16274 pos_token, "ip-version");
16275 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
16276 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16277 ip_version, "ipv4#ipv6");
16278 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
16279 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16280 pos_token, "label");
16281 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
16282 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
16284 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
16285 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16286 pos_token, "ip-src");
16287 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
16288 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
16289 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
16290 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16291 pos_token, "ip-dst");
16292 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
16293 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
16294 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
16295 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16296 pos_token, "vlan-tci");
16297 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
16298 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
16300 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
16301 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16302 pos_token, "eth-src");
16303 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
16304 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16306 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
16307 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16308 pos_token, "eth-dst");
16309 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
16310 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16313 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
16314 __rte_unused struct cmdline *cl,
16315 __rte_unused void *data)
16317 struct cmd_set_mplsogre_encap_result *res = parsed_result;
16319 uint32_t mplsogre_label;
16322 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
16325 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
16326 mplsogre_encap_conf.select_vlan = 0;
16327 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
16328 mplsogre_encap_conf.select_vlan = 1;
16329 if (strcmp(res->ip_version, "ipv4") == 0)
16330 mplsogre_encap_conf.select_ipv4 = 1;
16331 else if (strcmp(res->ip_version, "ipv6") == 0)
16332 mplsogre_encap_conf.select_ipv4 = 0;
16335 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
16336 if (mplsogre_encap_conf.select_ipv4) {
16337 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
16338 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
16340 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
16341 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
16343 if (mplsogre_encap_conf.select_vlan)
16344 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16345 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
16346 RTE_ETHER_ADDR_LEN);
16347 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16348 RTE_ETHER_ADDR_LEN);
16351 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
16352 .f = cmd_set_mplsogre_encap_parsed,
16354 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
16355 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
16356 " eth-dst <eth-dst>",
16358 (void *)&cmd_set_mplsogre_encap_set,
16359 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
16360 (void *)&cmd_set_mplsogre_encap_ip_version,
16361 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16362 (void *)&cmd_set_mplsogre_encap_label,
16363 (void *)&cmd_set_mplsogre_encap_label_value,
16364 (void *)&cmd_set_mplsogre_encap_ip_src,
16365 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16366 (void *)&cmd_set_mplsogre_encap_ip_dst,
16367 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16368 (void *)&cmd_set_mplsogre_encap_eth_src,
16369 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16370 (void *)&cmd_set_mplsogre_encap_eth_dst,
16371 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16376 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16377 .f = cmd_set_mplsogre_encap_parsed,
16379 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16380 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16381 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16383 (void *)&cmd_set_mplsogre_encap_set,
16384 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16385 (void *)&cmd_set_mplsogre_encap_ip_version,
16386 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16387 (void *)&cmd_set_mplsogre_encap_label,
16388 (void *)&cmd_set_mplsogre_encap_label_value,
16389 (void *)&cmd_set_mplsogre_encap_ip_src,
16390 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16391 (void *)&cmd_set_mplsogre_encap_ip_dst,
16392 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16393 (void *)&cmd_set_mplsogre_encap_vlan,
16394 (void *)&cmd_set_mplsogre_encap_vlan_value,
16395 (void *)&cmd_set_mplsogre_encap_eth_src,
16396 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16397 (void *)&cmd_set_mplsogre_encap_eth_dst,
16398 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16403 /** Set MPLSoGRE decapsulation details */
16404 struct cmd_set_mplsogre_decap_result {
16405 cmdline_fixed_string_t set;
16406 cmdline_fixed_string_t mplsogre;
16407 cmdline_fixed_string_t pos_token;
16408 cmdline_fixed_string_t ip_version;
16409 uint32_t vlan_present:1;
16412 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16413 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16415 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16416 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16418 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16419 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16420 mplsogre, "mplsogre_decap-with-vlan");
16421 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16422 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16423 pos_token, "ip-version");
16424 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16425 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16426 ip_version, "ipv4#ipv6");
16428 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16429 __rte_unused struct cmdline *cl,
16430 __rte_unused void *data)
16432 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16434 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16435 mplsogre_decap_conf.select_vlan = 0;
16436 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16437 mplsogre_decap_conf.select_vlan = 1;
16438 if (strcmp(res->ip_version, "ipv4") == 0)
16439 mplsogre_decap_conf.select_ipv4 = 1;
16440 else if (strcmp(res->ip_version, "ipv6") == 0)
16441 mplsogre_decap_conf.select_ipv4 = 0;
16444 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16445 .f = cmd_set_mplsogre_decap_parsed,
16447 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16449 (void *)&cmd_set_mplsogre_decap_set,
16450 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16451 (void *)&cmd_set_mplsogre_decap_ip_version,
16452 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16457 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16458 .f = cmd_set_mplsogre_decap_parsed,
16460 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16462 (void *)&cmd_set_mplsogre_decap_set,
16463 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16464 (void *)&cmd_set_mplsogre_decap_ip_version,
16465 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16470 /** Set MPLSoUDP encapsulation details */
16471 struct cmd_set_mplsoudp_encap_result {
16472 cmdline_fixed_string_t set;
16473 cmdline_fixed_string_t mplsoudp;
16474 cmdline_fixed_string_t pos_token;
16475 cmdline_fixed_string_t ip_version;
16476 uint32_t vlan_present:1;
16480 cmdline_ipaddr_t ip_src;
16481 cmdline_ipaddr_t ip_dst;
16483 struct rte_ether_addr eth_src;
16484 struct rte_ether_addr eth_dst;
16487 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16488 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16490 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16491 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16493 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16494 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16495 mplsoudp, "mplsoudp_encap-with-vlan");
16496 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16497 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16498 pos_token, "ip-version");
16499 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16500 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16501 ip_version, "ipv4#ipv6");
16502 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16503 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16504 pos_token, "label");
16505 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16506 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16508 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16509 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16510 pos_token, "udp-src");
16511 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16512 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16514 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16515 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16516 pos_token, "udp-dst");
16517 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16518 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16520 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16521 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16522 pos_token, "ip-src");
16523 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16524 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16525 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16526 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16527 pos_token, "ip-dst");
16528 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16529 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16530 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16531 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16532 pos_token, "vlan-tci");
16533 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16534 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16536 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16537 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16538 pos_token, "eth-src");
16539 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16540 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16542 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16543 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16544 pos_token, "eth-dst");
16545 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16546 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16549 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16550 __rte_unused struct cmdline *cl,
16551 __rte_unused void *data)
16553 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16555 uint32_t mplsoudp_label;
16558 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16561 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16562 mplsoudp_encap_conf.select_vlan = 0;
16563 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16564 mplsoudp_encap_conf.select_vlan = 1;
16565 if (strcmp(res->ip_version, "ipv4") == 0)
16566 mplsoudp_encap_conf.select_ipv4 = 1;
16567 else if (strcmp(res->ip_version, "ipv6") == 0)
16568 mplsoudp_encap_conf.select_ipv4 = 0;
16571 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16572 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16573 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16574 if (mplsoudp_encap_conf.select_ipv4) {
16575 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16576 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16578 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16579 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16581 if (mplsoudp_encap_conf.select_vlan)
16582 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16583 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16584 RTE_ETHER_ADDR_LEN);
16585 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16586 RTE_ETHER_ADDR_LEN);
16589 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16590 .f = cmd_set_mplsoudp_encap_parsed,
16592 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16593 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16594 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16596 (void *)&cmd_set_mplsoudp_encap_set,
16597 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16598 (void *)&cmd_set_mplsoudp_encap_ip_version,
16599 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16600 (void *)&cmd_set_mplsoudp_encap_label,
16601 (void *)&cmd_set_mplsoudp_encap_label_value,
16602 (void *)&cmd_set_mplsoudp_encap_udp_src,
16603 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16604 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16605 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16606 (void *)&cmd_set_mplsoudp_encap_ip_src,
16607 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16608 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16609 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16610 (void *)&cmd_set_mplsoudp_encap_eth_src,
16611 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16612 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16613 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16618 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16619 .f = cmd_set_mplsoudp_encap_parsed,
16621 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16622 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16623 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16624 " eth-src <eth-src> eth-dst <eth-dst>",
16626 (void *)&cmd_set_mplsoudp_encap_set,
16627 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16628 (void *)&cmd_set_mplsoudp_encap_ip_version,
16629 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16630 (void *)&cmd_set_mplsoudp_encap_label,
16631 (void *)&cmd_set_mplsoudp_encap_label_value,
16632 (void *)&cmd_set_mplsoudp_encap_udp_src,
16633 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16634 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16635 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16636 (void *)&cmd_set_mplsoudp_encap_ip_src,
16637 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16638 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16639 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16640 (void *)&cmd_set_mplsoudp_encap_vlan,
16641 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16642 (void *)&cmd_set_mplsoudp_encap_eth_src,
16643 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16644 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16645 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16650 /** Set MPLSoUDP decapsulation details */
16651 struct cmd_set_mplsoudp_decap_result {
16652 cmdline_fixed_string_t set;
16653 cmdline_fixed_string_t mplsoudp;
16654 cmdline_fixed_string_t pos_token;
16655 cmdline_fixed_string_t ip_version;
16656 uint32_t vlan_present:1;
16659 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16660 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16662 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16663 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16665 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16666 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16667 mplsoudp, "mplsoudp_decap-with-vlan");
16668 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16669 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16670 pos_token, "ip-version");
16671 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16672 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16673 ip_version, "ipv4#ipv6");
16675 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16676 __rte_unused struct cmdline *cl,
16677 __rte_unused void *data)
16679 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16681 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16682 mplsoudp_decap_conf.select_vlan = 0;
16683 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16684 mplsoudp_decap_conf.select_vlan = 1;
16685 if (strcmp(res->ip_version, "ipv4") == 0)
16686 mplsoudp_decap_conf.select_ipv4 = 1;
16687 else if (strcmp(res->ip_version, "ipv6") == 0)
16688 mplsoudp_decap_conf.select_ipv4 = 0;
16691 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16692 .f = cmd_set_mplsoudp_decap_parsed,
16694 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16696 (void *)&cmd_set_mplsoudp_decap_set,
16697 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16698 (void *)&cmd_set_mplsoudp_decap_ip_version,
16699 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16704 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16705 .f = cmd_set_mplsoudp_decap_parsed,
16707 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16709 (void *)&cmd_set_mplsoudp_decap_set,
16710 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16711 (void *)&cmd_set_mplsoudp_decap_ip_version,
16712 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16717 /* Strict link priority scheduling mode setting */
16719 cmd_strict_link_prio_parsed(
16720 void *parsed_result,
16721 __rte_unused struct cmdline *cl,
16722 __rte_unused void *data)
16724 struct cmd_vf_tc_bw_result *res = parsed_result;
16725 int ret = -ENOTSUP;
16727 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16730 #ifdef RTE_NET_I40E
16731 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16738 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16741 printf("invalid port_id %d\n", res->port_id);
16744 printf("function not implemented\n");
16747 printf("programming error: (%s)\n", strerror(-ret));
16751 cmdline_parse_inst_t cmd_strict_link_prio = {
16752 .f = cmd_strict_link_prio_parsed,
16754 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16756 (void *)&cmd_vf_tc_bw_set,
16757 (void *)&cmd_vf_tc_bw_tx,
16758 (void *)&cmd_vf_tc_bw_strict_link_prio,
16759 (void *)&cmd_vf_tc_bw_port_id,
16760 (void *)&cmd_vf_tc_bw_tc_map,
16765 /* Load dynamic device personalization*/
16766 struct cmd_ddp_add_result {
16767 cmdline_fixed_string_t ddp;
16768 cmdline_fixed_string_t add;
16773 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16774 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16775 cmdline_parse_token_string_t cmd_ddp_add_add =
16776 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16777 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16778 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16779 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16780 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16783 cmd_ddp_add_parsed(
16784 void *parsed_result,
16785 __rte_unused struct cmdline *cl,
16786 __rte_unused void *data)
16788 struct cmd_ddp_add_result *res = parsed_result;
16794 int ret = -ENOTSUP;
16796 if (!all_ports_stopped()) {
16797 printf("Please stop all ports first\n");
16801 filepath = strdup(res->filepath);
16802 if (filepath == NULL) {
16803 printf("Failed to allocate memory\n");
16806 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16808 buff = open_file(file_fld[0], &size);
16810 free((void *)filepath);
16814 #ifdef RTE_NET_I40E
16815 if (ret == -ENOTSUP)
16816 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16818 RTE_PMD_I40E_PKG_OP_WR_ADD);
16821 if (ret == -EEXIST)
16822 printf("Profile has already existed.\n");
16824 printf("Failed to load profile.\n");
16825 else if (file_num == 2)
16826 save_file(file_fld[1], buff, size);
16829 free((void *)filepath);
16832 cmdline_parse_inst_t cmd_ddp_add = {
16833 .f = cmd_ddp_add_parsed,
16835 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16837 (void *)&cmd_ddp_add_ddp,
16838 (void *)&cmd_ddp_add_add,
16839 (void *)&cmd_ddp_add_port_id,
16840 (void *)&cmd_ddp_add_filepath,
16845 /* Delete dynamic device personalization*/
16846 struct cmd_ddp_del_result {
16847 cmdline_fixed_string_t ddp;
16848 cmdline_fixed_string_t del;
16853 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16854 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16855 cmdline_parse_token_string_t cmd_ddp_del_del =
16856 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16857 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16858 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16859 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16860 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16863 cmd_ddp_del_parsed(
16864 void *parsed_result,
16865 __rte_unused struct cmdline *cl,
16866 __rte_unused void *data)
16868 struct cmd_ddp_del_result *res = parsed_result;
16871 int ret = -ENOTSUP;
16873 if (!all_ports_stopped()) {
16874 printf("Please stop all ports first\n");
16878 buff = open_file(res->filepath, &size);
16882 #ifdef RTE_NET_I40E
16883 if (ret == -ENOTSUP)
16884 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16886 RTE_PMD_I40E_PKG_OP_WR_DEL);
16889 if (ret == -EACCES)
16890 printf("Profile does not exist.\n");
16892 printf("Failed to delete profile.\n");
16897 cmdline_parse_inst_t cmd_ddp_del = {
16898 .f = cmd_ddp_del_parsed,
16900 .help_str = "ddp del <port_id> <backup_profile_path>",
16902 (void *)&cmd_ddp_del_ddp,
16903 (void *)&cmd_ddp_del_del,
16904 (void *)&cmd_ddp_del_port_id,
16905 (void *)&cmd_ddp_del_filepath,
16910 /* Get dynamic device personalization profile info */
16911 struct cmd_ddp_info_result {
16912 cmdline_fixed_string_t ddp;
16913 cmdline_fixed_string_t get;
16914 cmdline_fixed_string_t info;
16918 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16919 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16920 cmdline_parse_token_string_t cmd_ddp_info_get =
16921 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16922 cmdline_parse_token_string_t cmd_ddp_info_info =
16923 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16924 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16925 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16928 cmd_ddp_info_parsed(
16929 void *parsed_result,
16930 __rte_unused struct cmdline *cl,
16931 __rte_unused void *data)
16933 struct cmd_ddp_info_result *res = parsed_result;
16936 int ret = -ENOTSUP;
16937 #ifdef RTE_NET_I40E
16940 uint32_t buff_size = 0;
16941 struct rte_pmd_i40e_profile_info info;
16942 uint32_t dev_num = 0;
16943 struct rte_pmd_i40e_ddp_device_id *devs;
16944 uint32_t proto_num = 0;
16945 struct rte_pmd_i40e_proto_info *proto = NULL;
16946 uint32_t pctype_num = 0;
16947 struct rte_pmd_i40e_ptype_info *pctype;
16948 uint32_t ptype_num = 0;
16949 struct rte_pmd_i40e_ptype_info *ptype;
16954 pkg = open_file(res->filepath, &pkg_size);
16958 #ifdef RTE_NET_I40E
16959 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16960 (uint8_t *)&info, sizeof(info),
16961 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16963 printf("Global Track id: 0x%x\n", info.track_id);
16964 printf("Global Version: %d.%d.%d.%d\n",
16965 info.version.major,
16966 info.version.minor,
16967 info.version.update,
16968 info.version.draft);
16969 printf("Global Package name: %s\n\n", info.name);
16972 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16973 (uint8_t *)&info, sizeof(info),
16974 RTE_PMD_I40E_PKG_INFO_HEADER);
16976 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16977 printf("i40e Profile Version: %d.%d.%d.%d\n",
16978 info.version.major,
16979 info.version.minor,
16980 info.version.update,
16981 info.version.draft);
16982 printf("i40e Profile name: %s\n\n", info.name);
16985 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16986 (uint8_t *)&buff_size, sizeof(buff_size),
16987 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16988 if (!ret && buff_size) {
16989 buff = (uint8_t *)malloc(buff_size);
16991 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16993 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16995 printf("Package Notes:\n%s\n\n", buff);
17000 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
17001 (uint8_t *)&dev_num, sizeof(dev_num),
17002 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
17003 if (!ret && dev_num) {
17004 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
17005 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
17007 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
17008 (uint8_t *)devs, buff_size,
17009 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
17011 printf("List of supported devices:\n");
17012 for (i = 0; i < dev_num; i++) {
17013 printf(" %04X:%04X %04X:%04X\n",
17014 devs[i].vendor_dev_id >> 16,
17015 devs[i].vendor_dev_id & 0xFFFF,
17016 devs[i].sub_vendor_dev_id >> 16,
17017 devs[i].sub_vendor_dev_id & 0xFFFF);
17025 /* get information about protocols and packet types */
17026 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
17027 (uint8_t *)&proto_num, sizeof(proto_num),
17028 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
17029 if (ret || !proto_num)
17030 goto no_print_return;
17032 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
17033 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
17035 goto no_print_return;
17037 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
17039 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
17041 printf("List of used protocols:\n");
17042 for (i = 0; i < proto_num; i++)
17043 printf(" %2u: %s\n", proto[i].proto_id,
17047 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
17048 (uint8_t *)&pctype_num, sizeof(pctype_num),
17049 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
17050 if (ret || !pctype_num)
17051 goto no_print_pctypes;
17053 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
17054 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
17056 goto no_print_pctypes;
17058 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
17060 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
17063 goto no_print_pctypes;
17066 printf("List of defined packet classification types:\n");
17067 for (i = 0; i < pctype_num; i++) {
17068 printf(" %2u:", pctype[i].ptype_id);
17069 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
17070 proto_id = pctype[i].protocols[j];
17071 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
17072 for (n = 0; n < proto_num; n++) {
17073 if (proto[n].proto_id == proto_id) {
17074 printf(" %s", proto[n].name);
17087 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
17089 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
17090 if (ret || !ptype_num)
17091 goto no_print_return;
17093 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
17094 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
17096 goto no_print_return;
17098 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
17100 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
17103 goto no_print_return;
17105 printf("List of defined packet types:\n");
17106 for (i = 0; i < ptype_num; i++) {
17107 printf(" %2u:", ptype[i].ptype_id);
17108 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
17109 proto_id = ptype[i].protocols[j];
17110 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
17111 for (n = 0; n < proto_num; n++) {
17112 if (proto[n].proto_id == proto_id) {
17113 printf(" %s", proto[n].name);
17129 if (ret == -ENOTSUP)
17130 printf("Function not supported in PMD driver\n");
17134 cmdline_parse_inst_t cmd_ddp_get_info = {
17135 .f = cmd_ddp_info_parsed,
17137 .help_str = "ddp get info <profile_path>",
17139 (void *)&cmd_ddp_info_ddp,
17140 (void *)&cmd_ddp_info_get,
17141 (void *)&cmd_ddp_info_info,
17142 (void *)&cmd_ddp_info_filepath,
17147 /* Get dynamic device personalization profile info list*/
17148 #define PROFILE_INFO_SIZE 48
17149 #define MAX_PROFILE_NUM 16
17151 struct cmd_ddp_get_list_result {
17152 cmdline_fixed_string_t ddp;
17153 cmdline_fixed_string_t get;
17154 cmdline_fixed_string_t list;
17158 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
17159 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
17160 cmdline_parse_token_string_t cmd_ddp_get_list_get =
17161 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
17162 cmdline_parse_token_string_t cmd_ddp_get_list_list =
17163 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
17164 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
17165 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
17168 cmd_ddp_get_list_parsed(
17169 __rte_unused void *parsed_result,
17170 __rte_unused struct cmdline *cl,
17171 __rte_unused void *data)
17173 #ifdef RTE_NET_I40E
17174 struct cmd_ddp_get_list_result *res = parsed_result;
17175 struct rte_pmd_i40e_profile_list *p_list;
17176 struct rte_pmd_i40e_profile_info *p_info;
17181 int ret = -ENOTSUP;
17183 #ifdef RTE_NET_I40E
17184 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
17185 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
17187 printf("%s: Failed to malloc buffer\n", __func__);
17191 if (ret == -ENOTSUP)
17192 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
17193 (uint8_t *)p_list, size);
17196 p_num = p_list->p_count;
17197 printf("Profile number is: %d\n\n", p_num);
17199 for (i = 0; i < p_num; i++) {
17200 p_info = &p_list->p_info[i];
17201 printf("Profile %d:\n", i);
17202 printf("Track id: 0x%x\n", p_info->track_id);
17203 printf("Version: %d.%d.%d.%d\n",
17204 p_info->version.major,
17205 p_info->version.minor,
17206 p_info->version.update,
17207 p_info->version.draft);
17208 printf("Profile name: %s\n\n", p_info->name);
17216 printf("Failed to get ddp list\n");
17219 cmdline_parse_inst_t cmd_ddp_get_list = {
17220 .f = cmd_ddp_get_list_parsed,
17222 .help_str = "ddp get list <port_id>",
17224 (void *)&cmd_ddp_get_list_ddp,
17225 (void *)&cmd_ddp_get_list_get,
17226 (void *)&cmd_ddp_get_list_list,
17227 (void *)&cmd_ddp_get_list_port_id,
17232 /* Configure input set */
17233 struct cmd_cfg_input_set_result {
17234 cmdline_fixed_string_t port;
17235 cmdline_fixed_string_t cfg;
17237 cmdline_fixed_string_t pctype;
17239 cmdline_fixed_string_t inset_type;
17240 cmdline_fixed_string_t opt;
17241 cmdline_fixed_string_t field;
17246 cmd_cfg_input_set_parsed(
17247 __rte_unused void *parsed_result,
17248 __rte_unused struct cmdline *cl,
17249 __rte_unused void *data)
17251 #ifdef RTE_NET_I40E
17252 struct cmd_cfg_input_set_result *res = parsed_result;
17253 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17254 struct rte_pmd_i40e_inset inset;
17256 int ret = -ENOTSUP;
17258 if (!all_ports_stopped()) {
17259 printf("Please stop all ports first\n");
17263 #ifdef RTE_NET_I40E
17264 if (!strcmp(res->inset_type, "hash_inset"))
17265 inset_type = INSET_HASH;
17266 else if (!strcmp(res->inset_type, "fdir_inset"))
17267 inset_type = INSET_FDIR;
17268 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17269 inset_type = INSET_FDIR_FLX;
17270 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
17271 &inset, inset_type);
17273 printf("Failed to get input set.\n");
17277 if (!strcmp(res->opt, "get")) {
17278 ret = rte_pmd_i40e_inset_field_get(inset.inset,
17281 printf("Field index %d is enabled.\n", res->field_idx);
17283 printf("Field index %d is disabled.\n", res->field_idx);
17285 } else if (!strcmp(res->opt, "set"))
17286 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
17288 else if (!strcmp(res->opt, "clear"))
17289 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
17292 printf("Failed to configure input set field.\n");
17296 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17297 &inset, inset_type);
17299 printf("Failed to set input set.\n");
17304 if (ret == -ENOTSUP)
17305 printf("Function not supported\n");
17308 cmdline_parse_token_string_t cmd_cfg_input_set_port =
17309 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17311 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
17312 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17314 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
17315 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17317 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
17318 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17320 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
17321 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17323 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
17324 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17326 "hash_inset#fdir_inset#fdir_flx_inset");
17327 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
17328 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17329 opt, "get#set#clear");
17330 cmdline_parse_token_string_t cmd_cfg_input_set_field =
17331 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17333 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
17334 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17337 cmdline_parse_inst_t cmd_cfg_input_set = {
17338 .f = cmd_cfg_input_set_parsed,
17340 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17341 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
17343 (void *)&cmd_cfg_input_set_port,
17344 (void *)&cmd_cfg_input_set_cfg,
17345 (void *)&cmd_cfg_input_set_port_id,
17346 (void *)&cmd_cfg_input_set_pctype,
17347 (void *)&cmd_cfg_input_set_pctype_id,
17348 (void *)&cmd_cfg_input_set_inset_type,
17349 (void *)&cmd_cfg_input_set_opt,
17350 (void *)&cmd_cfg_input_set_field,
17351 (void *)&cmd_cfg_input_set_field_idx,
17356 /* Clear input set */
17357 struct cmd_clear_input_set_result {
17358 cmdline_fixed_string_t port;
17359 cmdline_fixed_string_t cfg;
17361 cmdline_fixed_string_t pctype;
17363 cmdline_fixed_string_t inset_type;
17364 cmdline_fixed_string_t clear;
17365 cmdline_fixed_string_t all;
17369 cmd_clear_input_set_parsed(
17370 __rte_unused void *parsed_result,
17371 __rte_unused struct cmdline *cl,
17372 __rte_unused void *data)
17374 #ifdef RTE_NET_I40E
17375 struct cmd_clear_input_set_result *res = parsed_result;
17376 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17377 struct rte_pmd_i40e_inset inset;
17379 int ret = -ENOTSUP;
17381 if (!all_ports_stopped()) {
17382 printf("Please stop all ports first\n");
17386 #ifdef RTE_NET_I40E
17387 if (!strcmp(res->inset_type, "hash_inset"))
17388 inset_type = INSET_HASH;
17389 else if (!strcmp(res->inset_type, "fdir_inset"))
17390 inset_type = INSET_FDIR;
17391 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17392 inset_type = INSET_FDIR_FLX;
17394 memset(&inset, 0, sizeof(inset));
17396 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17397 &inset, inset_type);
17399 printf("Failed to clear input set.\n");
17405 if (ret == -ENOTSUP)
17406 printf("Function not supported\n");
17409 cmdline_parse_token_string_t cmd_clear_input_set_port =
17410 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17412 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17413 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17415 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17416 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17418 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17419 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17421 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17422 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17424 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17425 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17427 "hash_inset#fdir_inset#fdir_flx_inset");
17428 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17429 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17431 cmdline_parse_token_string_t cmd_clear_input_set_all =
17432 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17435 cmdline_parse_inst_t cmd_clear_input_set = {
17436 .f = cmd_clear_input_set_parsed,
17438 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17439 "fdir_inset|fdir_flx_inset clear all",
17441 (void *)&cmd_clear_input_set_port,
17442 (void *)&cmd_clear_input_set_cfg,
17443 (void *)&cmd_clear_input_set_port_id,
17444 (void *)&cmd_clear_input_set_pctype,
17445 (void *)&cmd_clear_input_set_pctype_id,
17446 (void *)&cmd_clear_input_set_inset_type,
17447 (void *)&cmd_clear_input_set_clear,
17448 (void *)&cmd_clear_input_set_all,
17453 /* show vf stats */
17455 /* Common result structure for show vf stats */
17456 struct cmd_show_vf_stats_result {
17457 cmdline_fixed_string_t show;
17458 cmdline_fixed_string_t vf;
17459 cmdline_fixed_string_t stats;
17464 /* Common CLI fields show vf stats*/
17465 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17466 TOKEN_STRING_INITIALIZER
17467 (struct cmd_show_vf_stats_result,
17469 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17470 TOKEN_STRING_INITIALIZER
17471 (struct cmd_show_vf_stats_result,
17473 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17474 TOKEN_STRING_INITIALIZER
17475 (struct cmd_show_vf_stats_result,
17477 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17478 TOKEN_NUM_INITIALIZER
17479 (struct cmd_show_vf_stats_result,
17481 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17482 TOKEN_NUM_INITIALIZER
17483 (struct cmd_show_vf_stats_result,
17487 cmd_show_vf_stats_parsed(
17488 void *parsed_result,
17489 __rte_unused struct cmdline *cl,
17490 __rte_unused void *data)
17492 struct cmd_show_vf_stats_result *res = parsed_result;
17493 struct rte_eth_stats stats;
17494 int ret = -ENOTSUP;
17495 static const char *nic_stats_border = "########################";
17497 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17500 memset(&stats, 0, sizeof(stats));
17502 #ifdef RTE_NET_I40E
17503 if (ret == -ENOTSUP)
17504 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17508 #ifdef RTE_NET_BNXT
17509 if (ret == -ENOTSUP)
17510 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17519 printf("invalid vf_id %d\n", res->vf_id);
17522 printf("invalid port_id %d\n", res->port_id);
17525 printf("function not implemented\n");
17528 printf("programming error: (%s)\n", strerror(-ret));
17531 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17532 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17534 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17536 stats.ipackets, stats.imissed, stats.ibytes);
17537 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17538 printf(" RX-nombuf: %-10"PRIu64"\n",
17540 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17542 stats.opackets, stats.oerrors, stats.obytes);
17544 printf(" %s############################%s\n",
17545 nic_stats_border, nic_stats_border);
17548 cmdline_parse_inst_t cmd_show_vf_stats = {
17549 .f = cmd_show_vf_stats_parsed,
17551 .help_str = "show vf stats <port_id> <vf_id>",
17553 (void *)&cmd_show_vf_stats_show,
17554 (void *)&cmd_show_vf_stats_vf,
17555 (void *)&cmd_show_vf_stats_stats,
17556 (void *)&cmd_show_vf_stats_port_id,
17557 (void *)&cmd_show_vf_stats_vf_id,
17562 /* clear vf stats */
17564 /* Common result structure for clear vf stats */
17565 struct cmd_clear_vf_stats_result {
17566 cmdline_fixed_string_t clear;
17567 cmdline_fixed_string_t vf;
17568 cmdline_fixed_string_t stats;
17573 /* Common CLI fields clear vf stats*/
17574 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17575 TOKEN_STRING_INITIALIZER
17576 (struct cmd_clear_vf_stats_result,
17578 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17579 TOKEN_STRING_INITIALIZER
17580 (struct cmd_clear_vf_stats_result,
17582 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17583 TOKEN_STRING_INITIALIZER
17584 (struct cmd_clear_vf_stats_result,
17586 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17587 TOKEN_NUM_INITIALIZER
17588 (struct cmd_clear_vf_stats_result,
17590 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17591 TOKEN_NUM_INITIALIZER
17592 (struct cmd_clear_vf_stats_result,
17596 cmd_clear_vf_stats_parsed(
17597 void *parsed_result,
17598 __rte_unused struct cmdline *cl,
17599 __rte_unused void *data)
17601 struct cmd_clear_vf_stats_result *res = parsed_result;
17602 int ret = -ENOTSUP;
17604 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17607 #ifdef RTE_NET_I40E
17608 if (ret == -ENOTSUP)
17609 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17612 #ifdef RTE_NET_BNXT
17613 if (ret == -ENOTSUP)
17614 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17622 printf("invalid vf_id %d\n", res->vf_id);
17625 printf("invalid port_id %d\n", res->port_id);
17628 printf("function not implemented\n");
17631 printf("programming error: (%s)\n", strerror(-ret));
17635 cmdline_parse_inst_t cmd_clear_vf_stats = {
17636 .f = cmd_clear_vf_stats_parsed,
17638 .help_str = "clear vf stats <port_id> <vf_id>",
17640 (void *)&cmd_clear_vf_stats_clear,
17641 (void *)&cmd_clear_vf_stats_vf,
17642 (void *)&cmd_clear_vf_stats_stats,
17643 (void *)&cmd_clear_vf_stats_port_id,
17644 (void *)&cmd_clear_vf_stats_vf_id,
17649 /* port config pctype mapping reset */
17651 /* Common result structure for port config pctype mapping reset */
17652 struct cmd_pctype_mapping_reset_result {
17653 cmdline_fixed_string_t port;
17654 cmdline_fixed_string_t config;
17656 cmdline_fixed_string_t pctype;
17657 cmdline_fixed_string_t mapping;
17658 cmdline_fixed_string_t reset;
17661 /* Common CLI fields for port config pctype mapping reset*/
17662 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17663 TOKEN_STRING_INITIALIZER
17664 (struct cmd_pctype_mapping_reset_result,
17666 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17667 TOKEN_STRING_INITIALIZER
17668 (struct cmd_pctype_mapping_reset_result,
17670 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17671 TOKEN_NUM_INITIALIZER
17672 (struct cmd_pctype_mapping_reset_result,
17674 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17675 TOKEN_STRING_INITIALIZER
17676 (struct cmd_pctype_mapping_reset_result,
17678 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17679 TOKEN_STRING_INITIALIZER
17680 (struct cmd_pctype_mapping_reset_result,
17681 mapping, "mapping");
17682 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17683 TOKEN_STRING_INITIALIZER
17684 (struct cmd_pctype_mapping_reset_result,
17688 cmd_pctype_mapping_reset_parsed(
17689 void *parsed_result,
17690 __rte_unused struct cmdline *cl,
17691 __rte_unused void *data)
17693 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17694 int ret = -ENOTSUP;
17696 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17699 #ifdef RTE_NET_I40E
17700 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17707 printf("invalid port_id %d\n", res->port_id);
17710 printf("function not implemented\n");
17713 printf("programming error: (%s)\n", strerror(-ret));
17717 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17718 .f = cmd_pctype_mapping_reset_parsed,
17720 .help_str = "port config <port_id> pctype mapping reset",
17722 (void *)&cmd_pctype_mapping_reset_port,
17723 (void *)&cmd_pctype_mapping_reset_config,
17724 (void *)&cmd_pctype_mapping_reset_port_id,
17725 (void *)&cmd_pctype_mapping_reset_pctype,
17726 (void *)&cmd_pctype_mapping_reset_mapping,
17727 (void *)&cmd_pctype_mapping_reset_reset,
17732 /* show port pctype mapping */
17734 /* Common result structure for show port pctype mapping */
17735 struct cmd_pctype_mapping_get_result {
17736 cmdline_fixed_string_t show;
17737 cmdline_fixed_string_t port;
17739 cmdline_fixed_string_t pctype;
17740 cmdline_fixed_string_t mapping;
17743 /* Common CLI fields for pctype mapping get */
17744 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17745 TOKEN_STRING_INITIALIZER
17746 (struct cmd_pctype_mapping_get_result,
17748 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17749 TOKEN_STRING_INITIALIZER
17750 (struct cmd_pctype_mapping_get_result,
17752 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17753 TOKEN_NUM_INITIALIZER
17754 (struct cmd_pctype_mapping_get_result,
17756 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17757 TOKEN_STRING_INITIALIZER
17758 (struct cmd_pctype_mapping_get_result,
17760 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17761 TOKEN_STRING_INITIALIZER
17762 (struct cmd_pctype_mapping_get_result,
17763 mapping, "mapping");
17766 cmd_pctype_mapping_get_parsed(
17767 void *parsed_result,
17768 __rte_unused struct cmdline *cl,
17769 __rte_unused void *data)
17771 struct cmd_pctype_mapping_get_result *res = parsed_result;
17772 int ret = -ENOTSUP;
17773 #ifdef RTE_NET_I40E
17774 struct rte_pmd_i40e_flow_type_mapping
17775 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17776 int i, j, first_pctype;
17779 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17782 #ifdef RTE_NET_I40E
17783 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17790 printf("invalid port_id %d\n", res->port_id);
17793 printf("function not implemented\n");
17796 printf("programming error: (%s)\n", strerror(-ret));
17800 #ifdef RTE_NET_I40E
17801 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17802 if (mapping[i].pctype != 0ULL) {
17805 printf("pctype: ");
17806 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17807 if (mapping[i].pctype & (1ULL << j)) {
17808 printf(first_pctype ?
17809 "%02d" : ",%02d", j);
17813 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17819 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17820 .f = cmd_pctype_mapping_get_parsed,
17822 .help_str = "show port <port_id> pctype mapping",
17824 (void *)&cmd_pctype_mapping_get_show,
17825 (void *)&cmd_pctype_mapping_get_port,
17826 (void *)&cmd_pctype_mapping_get_port_id,
17827 (void *)&cmd_pctype_mapping_get_pctype,
17828 (void *)&cmd_pctype_mapping_get_mapping,
17833 /* port config pctype mapping update */
17835 /* Common result structure for port config pctype mapping update */
17836 struct cmd_pctype_mapping_update_result {
17837 cmdline_fixed_string_t port;
17838 cmdline_fixed_string_t config;
17840 cmdline_fixed_string_t pctype;
17841 cmdline_fixed_string_t mapping;
17842 cmdline_fixed_string_t update;
17843 cmdline_fixed_string_t pctype_list;
17844 uint16_t flow_type;
17847 /* Common CLI fields for pctype mapping update*/
17848 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17849 TOKEN_STRING_INITIALIZER
17850 (struct cmd_pctype_mapping_update_result,
17852 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17853 TOKEN_STRING_INITIALIZER
17854 (struct cmd_pctype_mapping_update_result,
17856 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17857 TOKEN_NUM_INITIALIZER
17858 (struct cmd_pctype_mapping_update_result,
17860 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17861 TOKEN_STRING_INITIALIZER
17862 (struct cmd_pctype_mapping_update_result,
17864 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17865 TOKEN_STRING_INITIALIZER
17866 (struct cmd_pctype_mapping_update_result,
17867 mapping, "mapping");
17868 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17869 TOKEN_STRING_INITIALIZER
17870 (struct cmd_pctype_mapping_update_result,
17872 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17873 TOKEN_STRING_INITIALIZER
17874 (struct cmd_pctype_mapping_update_result,
17875 pctype_list, NULL);
17876 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17877 TOKEN_NUM_INITIALIZER
17878 (struct cmd_pctype_mapping_update_result,
17879 flow_type, UINT16);
17882 cmd_pctype_mapping_update_parsed(
17883 void *parsed_result,
17884 __rte_unused struct cmdline *cl,
17885 __rte_unused void *data)
17887 struct cmd_pctype_mapping_update_result *res = parsed_result;
17888 int ret = -ENOTSUP;
17889 #ifdef RTE_NET_I40E
17890 struct rte_pmd_i40e_flow_type_mapping mapping;
17892 unsigned int nb_item;
17893 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17896 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17899 #ifdef RTE_NET_I40E
17900 nb_item = parse_item_list(res->pctype_list, "pctypes",
17901 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17902 mapping.flow_type = res->flow_type;
17903 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17904 mapping.pctype |= (1ULL << pctype_list[i]);
17905 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17915 printf("invalid pctype or flow type\n");
17918 printf("invalid port_id %d\n", res->port_id);
17921 printf("function not implemented\n");
17924 printf("programming error: (%s)\n", strerror(-ret));
17928 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17929 .f = cmd_pctype_mapping_update_parsed,
17931 .help_str = "port config <port_id> pctype mapping update"
17932 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17934 (void *)&cmd_pctype_mapping_update_port,
17935 (void *)&cmd_pctype_mapping_update_config,
17936 (void *)&cmd_pctype_mapping_update_port_id,
17937 (void *)&cmd_pctype_mapping_update_pctype,
17938 (void *)&cmd_pctype_mapping_update_mapping,
17939 (void *)&cmd_pctype_mapping_update_update,
17940 (void *)&cmd_pctype_mapping_update_pc_type,
17941 (void *)&cmd_pctype_mapping_update_flow_type,
17946 /* ptype mapping get */
17948 /* Common result structure for ptype mapping get */
17949 struct cmd_ptype_mapping_get_result {
17950 cmdline_fixed_string_t ptype;
17951 cmdline_fixed_string_t mapping;
17952 cmdline_fixed_string_t get;
17954 uint8_t valid_only;
17957 /* Common CLI fields for ptype mapping get */
17958 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17959 TOKEN_STRING_INITIALIZER
17960 (struct cmd_ptype_mapping_get_result,
17962 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17963 TOKEN_STRING_INITIALIZER
17964 (struct cmd_ptype_mapping_get_result,
17965 mapping, "mapping");
17966 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17967 TOKEN_STRING_INITIALIZER
17968 (struct cmd_ptype_mapping_get_result,
17970 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17971 TOKEN_NUM_INITIALIZER
17972 (struct cmd_ptype_mapping_get_result,
17974 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17975 TOKEN_NUM_INITIALIZER
17976 (struct cmd_ptype_mapping_get_result,
17977 valid_only, UINT8);
17980 cmd_ptype_mapping_get_parsed(
17981 void *parsed_result,
17982 __rte_unused struct cmdline *cl,
17983 __rte_unused void *data)
17985 struct cmd_ptype_mapping_get_result *res = parsed_result;
17986 int ret = -ENOTSUP;
17987 #ifdef RTE_NET_I40E
17988 int max_ptype_num = 256;
17989 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17994 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17997 #ifdef RTE_NET_I40E
17998 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
18009 printf("invalid port_id %d\n", res->port_id);
18012 printf("function not implemented\n");
18015 printf("programming error: (%s)\n", strerror(-ret));
18018 #ifdef RTE_NET_I40E
18020 for (i = 0; i < count; i++)
18021 printf("%3d\t0x%08x\n",
18022 mapping[i].hw_ptype, mapping[i].sw_ptype);
18027 cmdline_parse_inst_t cmd_ptype_mapping_get = {
18028 .f = cmd_ptype_mapping_get_parsed,
18030 .help_str = "ptype mapping get <port_id> <valid_only>",
18032 (void *)&cmd_ptype_mapping_get_ptype,
18033 (void *)&cmd_ptype_mapping_get_mapping,
18034 (void *)&cmd_ptype_mapping_get_get,
18035 (void *)&cmd_ptype_mapping_get_port_id,
18036 (void *)&cmd_ptype_mapping_get_valid_only,
18041 /* ptype mapping replace */
18043 /* Common result structure for ptype mapping replace */
18044 struct cmd_ptype_mapping_replace_result {
18045 cmdline_fixed_string_t ptype;
18046 cmdline_fixed_string_t mapping;
18047 cmdline_fixed_string_t replace;
18054 /* Common CLI fields for ptype mapping replace */
18055 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
18056 TOKEN_STRING_INITIALIZER
18057 (struct cmd_ptype_mapping_replace_result,
18059 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
18060 TOKEN_STRING_INITIALIZER
18061 (struct cmd_ptype_mapping_replace_result,
18062 mapping, "mapping");
18063 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
18064 TOKEN_STRING_INITIALIZER
18065 (struct cmd_ptype_mapping_replace_result,
18066 replace, "replace");
18067 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
18068 TOKEN_NUM_INITIALIZER
18069 (struct cmd_ptype_mapping_replace_result,
18071 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
18072 TOKEN_NUM_INITIALIZER
18073 (struct cmd_ptype_mapping_replace_result,
18075 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
18076 TOKEN_NUM_INITIALIZER
18077 (struct cmd_ptype_mapping_replace_result,
18079 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
18080 TOKEN_NUM_INITIALIZER
18081 (struct cmd_ptype_mapping_replace_result,
18085 cmd_ptype_mapping_replace_parsed(
18086 void *parsed_result,
18087 __rte_unused struct cmdline *cl,
18088 __rte_unused void *data)
18090 struct cmd_ptype_mapping_replace_result *res = parsed_result;
18091 int ret = -ENOTSUP;
18093 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18096 #ifdef RTE_NET_I40E
18097 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
18107 printf("invalid ptype 0x%8x or 0x%8x\n",
18108 res->target, res->pkt_type);
18111 printf("invalid port_id %d\n", res->port_id);
18114 printf("function not implemented\n");
18117 printf("programming error: (%s)\n", strerror(-ret));
18121 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
18122 .f = cmd_ptype_mapping_replace_parsed,
18125 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
18127 (void *)&cmd_ptype_mapping_replace_ptype,
18128 (void *)&cmd_ptype_mapping_replace_mapping,
18129 (void *)&cmd_ptype_mapping_replace_replace,
18130 (void *)&cmd_ptype_mapping_replace_port_id,
18131 (void *)&cmd_ptype_mapping_replace_target,
18132 (void *)&cmd_ptype_mapping_replace_mask,
18133 (void *)&cmd_ptype_mapping_replace_pkt_type,
18138 /* ptype mapping reset */
18140 /* Common result structure for ptype mapping reset */
18141 struct cmd_ptype_mapping_reset_result {
18142 cmdline_fixed_string_t ptype;
18143 cmdline_fixed_string_t mapping;
18144 cmdline_fixed_string_t reset;
18148 /* Common CLI fields for ptype mapping reset*/
18149 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
18150 TOKEN_STRING_INITIALIZER
18151 (struct cmd_ptype_mapping_reset_result,
18153 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
18154 TOKEN_STRING_INITIALIZER
18155 (struct cmd_ptype_mapping_reset_result,
18156 mapping, "mapping");
18157 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
18158 TOKEN_STRING_INITIALIZER
18159 (struct cmd_ptype_mapping_reset_result,
18161 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
18162 TOKEN_NUM_INITIALIZER
18163 (struct cmd_ptype_mapping_reset_result,
18167 cmd_ptype_mapping_reset_parsed(
18168 void *parsed_result,
18169 __rte_unused struct cmdline *cl,
18170 __rte_unused void *data)
18172 struct cmd_ptype_mapping_reset_result *res = parsed_result;
18173 int ret = -ENOTSUP;
18175 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18178 #ifdef RTE_NET_I40E
18179 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
18186 printf("invalid port_id %d\n", res->port_id);
18189 printf("function not implemented\n");
18192 printf("programming error: (%s)\n", strerror(-ret));
18196 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
18197 .f = cmd_ptype_mapping_reset_parsed,
18199 .help_str = "ptype mapping reset <port_id>",
18201 (void *)&cmd_ptype_mapping_reset_ptype,
18202 (void *)&cmd_ptype_mapping_reset_mapping,
18203 (void *)&cmd_ptype_mapping_reset_reset,
18204 (void *)&cmd_ptype_mapping_reset_port_id,
18209 /* ptype mapping update */
18211 /* Common result structure for ptype mapping update */
18212 struct cmd_ptype_mapping_update_result {
18213 cmdline_fixed_string_t ptype;
18214 cmdline_fixed_string_t mapping;
18215 cmdline_fixed_string_t reset;
18221 /* Common CLI fields for ptype mapping update*/
18222 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
18223 TOKEN_STRING_INITIALIZER
18224 (struct cmd_ptype_mapping_update_result,
18226 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
18227 TOKEN_STRING_INITIALIZER
18228 (struct cmd_ptype_mapping_update_result,
18229 mapping, "mapping");
18230 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
18231 TOKEN_STRING_INITIALIZER
18232 (struct cmd_ptype_mapping_update_result,
18234 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
18235 TOKEN_NUM_INITIALIZER
18236 (struct cmd_ptype_mapping_update_result,
18238 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
18239 TOKEN_NUM_INITIALIZER
18240 (struct cmd_ptype_mapping_update_result,
18242 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
18243 TOKEN_NUM_INITIALIZER
18244 (struct cmd_ptype_mapping_update_result,
18248 cmd_ptype_mapping_update_parsed(
18249 void *parsed_result,
18250 __rte_unused struct cmdline *cl,
18251 __rte_unused void *data)
18253 struct cmd_ptype_mapping_update_result *res = parsed_result;
18254 int ret = -ENOTSUP;
18255 #ifdef RTE_NET_I40E
18256 struct rte_pmd_i40e_ptype_mapping mapping;
18258 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18261 #ifdef RTE_NET_I40E
18262 mapping.hw_ptype = res->hw_ptype;
18263 mapping.sw_ptype = res->sw_ptype;
18264 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
18274 printf("invalid ptype 0x%8x\n", res->sw_ptype);
18277 printf("invalid port_id %d\n", res->port_id);
18280 printf("function not implemented\n");
18283 printf("programming error: (%s)\n", strerror(-ret));
18287 cmdline_parse_inst_t cmd_ptype_mapping_update = {
18288 .f = cmd_ptype_mapping_update_parsed,
18290 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
18292 (void *)&cmd_ptype_mapping_update_ptype,
18293 (void *)&cmd_ptype_mapping_update_mapping,
18294 (void *)&cmd_ptype_mapping_update_update,
18295 (void *)&cmd_ptype_mapping_update_port_id,
18296 (void *)&cmd_ptype_mapping_update_hw_ptype,
18297 (void *)&cmd_ptype_mapping_update_sw_ptype,
18302 /* Common result structure for file commands */
18303 struct cmd_cmdfile_result {
18304 cmdline_fixed_string_t load;
18305 cmdline_fixed_string_t filename;
18308 /* Common CLI fields for file commands */
18309 cmdline_parse_token_string_t cmd_load_cmdfile =
18310 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
18311 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
18312 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
18315 cmd_load_from_file_parsed(
18316 void *parsed_result,
18317 __rte_unused struct cmdline *cl,
18318 __rte_unused void *data)
18320 struct cmd_cmdfile_result *res = parsed_result;
18322 cmdline_read_from_file(res->filename);
18325 cmdline_parse_inst_t cmd_load_from_file = {
18326 .f = cmd_load_from_file_parsed,
18328 .help_str = "load <filename>",
18330 (void *)&cmd_load_cmdfile,
18331 (void *)&cmd_load_cmdfile_filename,
18336 /* Get Rx offloads capabilities */
18337 struct cmd_rx_offload_get_capa_result {
18338 cmdline_fixed_string_t show;
18339 cmdline_fixed_string_t port;
18341 cmdline_fixed_string_t rx_offload;
18342 cmdline_fixed_string_t capabilities;
18345 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
18346 TOKEN_STRING_INITIALIZER
18347 (struct cmd_rx_offload_get_capa_result,
18349 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
18350 TOKEN_STRING_INITIALIZER
18351 (struct cmd_rx_offload_get_capa_result,
18353 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
18354 TOKEN_NUM_INITIALIZER
18355 (struct cmd_rx_offload_get_capa_result,
18357 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
18358 TOKEN_STRING_INITIALIZER
18359 (struct cmd_rx_offload_get_capa_result,
18360 rx_offload, "rx_offload");
18361 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
18362 TOKEN_STRING_INITIALIZER
18363 (struct cmd_rx_offload_get_capa_result,
18364 capabilities, "capabilities");
18367 print_rx_offloads(uint64_t offloads)
18369 uint64_t single_offload;
18377 begin = __builtin_ctzll(offloads);
18378 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18380 single_offload = 1ULL << begin;
18381 for (bit = begin; bit < end; bit++) {
18382 if (offloads & single_offload)
18384 rte_eth_dev_rx_offload_name(single_offload));
18385 single_offload <<= 1;
18390 cmd_rx_offload_get_capa_parsed(
18391 void *parsed_result,
18392 __rte_unused struct cmdline *cl,
18393 __rte_unused void *data)
18395 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18396 struct rte_eth_dev_info dev_info;
18397 portid_t port_id = res->port_id;
18398 uint64_t queue_offloads;
18399 uint64_t port_offloads;
18402 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18406 queue_offloads = dev_info.rx_queue_offload_capa;
18407 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18409 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18410 printf(" Per Queue :");
18411 print_rx_offloads(queue_offloads);
18414 printf(" Per Port :");
18415 print_rx_offloads(port_offloads);
18419 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18420 .f = cmd_rx_offload_get_capa_parsed,
18422 .help_str = "show port <port_id> rx_offload capabilities",
18424 (void *)&cmd_rx_offload_get_capa_show,
18425 (void *)&cmd_rx_offload_get_capa_port,
18426 (void *)&cmd_rx_offload_get_capa_port_id,
18427 (void *)&cmd_rx_offload_get_capa_rx_offload,
18428 (void *)&cmd_rx_offload_get_capa_capabilities,
18433 /* Get Rx offloads configuration */
18434 struct cmd_rx_offload_get_configuration_result {
18435 cmdline_fixed_string_t show;
18436 cmdline_fixed_string_t port;
18438 cmdline_fixed_string_t rx_offload;
18439 cmdline_fixed_string_t configuration;
18442 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18443 TOKEN_STRING_INITIALIZER
18444 (struct cmd_rx_offload_get_configuration_result,
18446 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18447 TOKEN_STRING_INITIALIZER
18448 (struct cmd_rx_offload_get_configuration_result,
18450 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18451 TOKEN_NUM_INITIALIZER
18452 (struct cmd_rx_offload_get_configuration_result,
18454 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18455 TOKEN_STRING_INITIALIZER
18456 (struct cmd_rx_offload_get_configuration_result,
18457 rx_offload, "rx_offload");
18458 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18459 TOKEN_STRING_INITIALIZER
18460 (struct cmd_rx_offload_get_configuration_result,
18461 configuration, "configuration");
18464 cmd_rx_offload_get_configuration_parsed(
18465 void *parsed_result,
18466 __rte_unused struct cmdline *cl,
18467 __rte_unused void *data)
18469 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18470 struct rte_eth_dev_info dev_info;
18471 portid_t port_id = res->port_id;
18472 struct rte_port *port = &ports[port_id];
18473 uint64_t port_offloads;
18474 uint64_t queue_offloads;
18475 uint16_t nb_rx_queues;
18479 printf("Rx Offloading Configuration of port %d :\n", port_id);
18481 port_offloads = port->dev_conf.rxmode.offloads;
18483 print_rx_offloads(port_offloads);
18486 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18490 nb_rx_queues = dev_info.nb_rx_queues;
18491 for (q = 0; q < nb_rx_queues; q++) {
18492 queue_offloads = port->rx_conf[q].offloads;
18493 printf(" Queue[%2d] :", q);
18494 print_rx_offloads(queue_offloads);
18500 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18501 .f = cmd_rx_offload_get_configuration_parsed,
18503 .help_str = "show port <port_id> rx_offload configuration",
18505 (void *)&cmd_rx_offload_get_configuration_show,
18506 (void *)&cmd_rx_offload_get_configuration_port,
18507 (void *)&cmd_rx_offload_get_configuration_port_id,
18508 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18509 (void *)&cmd_rx_offload_get_configuration_configuration,
18514 /* Enable/Disable a per port offloading */
18515 struct cmd_config_per_port_rx_offload_result {
18516 cmdline_fixed_string_t port;
18517 cmdline_fixed_string_t config;
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_port_rx_offload_result_port =
18525 TOKEN_STRING_INITIALIZER
18526 (struct cmd_config_per_port_rx_offload_result,
18528 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18529 TOKEN_STRING_INITIALIZER
18530 (struct cmd_config_per_port_rx_offload_result,
18532 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18533 TOKEN_NUM_INITIALIZER
18534 (struct cmd_config_per_port_rx_offload_result,
18536 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18537 TOKEN_STRING_INITIALIZER
18538 (struct cmd_config_per_port_rx_offload_result,
18539 rx_offload, "rx_offload");
18540 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18541 TOKEN_STRING_INITIALIZER
18542 (struct cmd_config_per_port_rx_offload_result,
18543 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18544 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18545 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18546 "scatter#buffer_split#timestamp#security#"
18547 "keep_crc#rss_hash");
18548 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18549 TOKEN_STRING_INITIALIZER
18550 (struct cmd_config_per_port_rx_offload_result,
18554 search_rx_offload(const char *name)
18556 uint64_t single_offload;
18557 const char *single_name;
18561 single_offload = 1;
18562 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18563 single_name = rte_eth_dev_rx_offload_name(single_offload);
18564 if (!strcasecmp(single_name, name)) {
18568 single_offload <<= 1;
18572 return single_offload;
18578 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18579 __rte_unused struct cmdline *cl,
18580 __rte_unused void *data)
18582 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18583 portid_t port_id = res->port_id;
18584 struct rte_eth_dev_info dev_info;
18585 struct rte_port *port = &ports[port_id];
18586 uint64_t single_offload;
18587 uint16_t nb_rx_queues;
18591 if (port->port_status != RTE_PORT_STOPPED) {
18592 printf("Error: Can't config offload when Port %d "
18593 "is not stopped\n", port_id);
18597 single_offload = search_rx_offload(res->offload);
18598 if (single_offload == 0) {
18599 printf("Unknown offload name: %s\n", res->offload);
18603 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18607 nb_rx_queues = dev_info.nb_rx_queues;
18608 if (!strcmp(res->on_off, "on")) {
18609 port->dev_conf.rxmode.offloads |= single_offload;
18610 for (q = 0; q < nb_rx_queues; q++)
18611 port->rx_conf[q].offloads |= single_offload;
18613 port->dev_conf.rxmode.offloads &= ~single_offload;
18614 for (q = 0; q < nb_rx_queues; q++)
18615 port->rx_conf[q].offloads &= ~single_offload;
18618 cmd_reconfig_device_queue(port_id, 1, 1);
18621 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18622 .f = cmd_config_per_port_rx_offload_parsed,
18624 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18625 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18626 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18627 "jumbo_frame|scatter|buffer_split|timestamp|security|"
18628 "keep_crc|rss_hash on|off",
18630 (void *)&cmd_config_per_port_rx_offload_result_port,
18631 (void *)&cmd_config_per_port_rx_offload_result_config,
18632 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18633 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18634 (void *)&cmd_config_per_port_rx_offload_result_offload,
18635 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18640 /* Enable/Disable a per queue offloading */
18641 struct cmd_config_per_queue_rx_offload_result {
18642 cmdline_fixed_string_t port;
18644 cmdline_fixed_string_t rxq;
18646 cmdline_fixed_string_t rx_offload;
18647 cmdline_fixed_string_t offload;
18648 cmdline_fixed_string_t on_off;
18651 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18652 TOKEN_STRING_INITIALIZER
18653 (struct cmd_config_per_queue_rx_offload_result,
18655 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18656 TOKEN_NUM_INITIALIZER
18657 (struct cmd_config_per_queue_rx_offload_result,
18659 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18660 TOKEN_STRING_INITIALIZER
18661 (struct cmd_config_per_queue_rx_offload_result,
18663 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18664 TOKEN_NUM_INITIALIZER
18665 (struct cmd_config_per_queue_rx_offload_result,
18667 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18668 TOKEN_STRING_INITIALIZER
18669 (struct cmd_config_per_queue_rx_offload_result,
18670 rx_offload, "rx_offload");
18671 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18672 TOKEN_STRING_INITIALIZER
18673 (struct cmd_config_per_queue_rx_offload_result,
18674 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18675 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18676 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18677 "scatter#buffer_split#timestamp#security#keep_crc");
18678 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18679 TOKEN_STRING_INITIALIZER
18680 (struct cmd_config_per_queue_rx_offload_result,
18684 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18685 __rte_unused struct cmdline *cl,
18686 __rte_unused void *data)
18688 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18689 struct rte_eth_dev_info dev_info;
18690 portid_t port_id = res->port_id;
18691 uint16_t queue_id = res->queue_id;
18692 struct rte_port *port = &ports[port_id];
18693 uint64_t single_offload;
18696 if (port->port_status != RTE_PORT_STOPPED) {
18697 printf("Error: Can't config offload when Port %d "
18698 "is not stopped\n", port_id);
18702 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18706 if (queue_id >= dev_info.nb_rx_queues) {
18707 printf("Error: input queue_id should be 0 ... "
18708 "%d\n", dev_info.nb_rx_queues - 1);
18712 single_offload = search_rx_offload(res->offload);
18713 if (single_offload == 0) {
18714 printf("Unknown offload name: %s\n", res->offload);
18718 if (!strcmp(res->on_off, "on"))
18719 port->rx_conf[queue_id].offloads |= single_offload;
18721 port->rx_conf[queue_id].offloads &= ~single_offload;
18723 cmd_reconfig_device_queue(port_id, 1, 1);
18726 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18727 .f = cmd_config_per_queue_rx_offload_parsed,
18729 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18730 "vlan_strip|ipv4_cksum|"
18731 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18732 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18733 "jumbo_frame|scatter|buffer_split|timestamp|security|"
18736 (void *)&cmd_config_per_queue_rx_offload_result_port,
18737 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18738 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18739 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18740 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18741 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18742 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18747 /* Get Tx offloads capabilities */
18748 struct cmd_tx_offload_get_capa_result {
18749 cmdline_fixed_string_t show;
18750 cmdline_fixed_string_t port;
18752 cmdline_fixed_string_t tx_offload;
18753 cmdline_fixed_string_t capabilities;
18756 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18757 TOKEN_STRING_INITIALIZER
18758 (struct cmd_tx_offload_get_capa_result,
18760 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18761 TOKEN_STRING_INITIALIZER
18762 (struct cmd_tx_offload_get_capa_result,
18764 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18765 TOKEN_NUM_INITIALIZER
18766 (struct cmd_tx_offload_get_capa_result,
18768 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18769 TOKEN_STRING_INITIALIZER
18770 (struct cmd_tx_offload_get_capa_result,
18771 tx_offload, "tx_offload");
18772 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18773 TOKEN_STRING_INITIALIZER
18774 (struct cmd_tx_offload_get_capa_result,
18775 capabilities, "capabilities");
18778 print_tx_offloads(uint64_t offloads)
18780 uint64_t single_offload;
18788 begin = __builtin_ctzll(offloads);
18789 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18791 single_offload = 1ULL << begin;
18792 for (bit = begin; bit < end; bit++) {
18793 if (offloads & single_offload)
18795 rte_eth_dev_tx_offload_name(single_offload));
18796 single_offload <<= 1;
18801 cmd_tx_offload_get_capa_parsed(
18802 void *parsed_result,
18803 __rte_unused struct cmdline *cl,
18804 __rte_unused void *data)
18806 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18807 struct rte_eth_dev_info dev_info;
18808 portid_t port_id = res->port_id;
18809 uint64_t queue_offloads;
18810 uint64_t port_offloads;
18813 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18817 queue_offloads = dev_info.tx_queue_offload_capa;
18818 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18820 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18821 printf(" Per Queue :");
18822 print_tx_offloads(queue_offloads);
18825 printf(" Per Port :");
18826 print_tx_offloads(port_offloads);
18830 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18831 .f = cmd_tx_offload_get_capa_parsed,
18833 .help_str = "show port <port_id> tx_offload capabilities",
18835 (void *)&cmd_tx_offload_get_capa_show,
18836 (void *)&cmd_tx_offload_get_capa_port,
18837 (void *)&cmd_tx_offload_get_capa_port_id,
18838 (void *)&cmd_tx_offload_get_capa_tx_offload,
18839 (void *)&cmd_tx_offload_get_capa_capabilities,
18844 /* Get Tx offloads configuration */
18845 struct cmd_tx_offload_get_configuration_result {
18846 cmdline_fixed_string_t show;
18847 cmdline_fixed_string_t port;
18849 cmdline_fixed_string_t tx_offload;
18850 cmdline_fixed_string_t configuration;
18853 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18854 TOKEN_STRING_INITIALIZER
18855 (struct cmd_tx_offload_get_configuration_result,
18857 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18858 TOKEN_STRING_INITIALIZER
18859 (struct cmd_tx_offload_get_configuration_result,
18861 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18862 TOKEN_NUM_INITIALIZER
18863 (struct cmd_tx_offload_get_configuration_result,
18865 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18866 TOKEN_STRING_INITIALIZER
18867 (struct cmd_tx_offload_get_configuration_result,
18868 tx_offload, "tx_offload");
18869 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18870 TOKEN_STRING_INITIALIZER
18871 (struct cmd_tx_offload_get_configuration_result,
18872 configuration, "configuration");
18875 cmd_tx_offload_get_configuration_parsed(
18876 void *parsed_result,
18877 __rte_unused struct cmdline *cl,
18878 __rte_unused void *data)
18880 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18881 struct rte_eth_dev_info dev_info;
18882 portid_t port_id = res->port_id;
18883 struct rte_port *port = &ports[port_id];
18884 uint64_t port_offloads;
18885 uint64_t queue_offloads;
18886 uint16_t nb_tx_queues;
18890 printf("Tx Offloading Configuration of port %d :\n", port_id);
18892 port_offloads = port->dev_conf.txmode.offloads;
18894 print_tx_offloads(port_offloads);
18897 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18901 nb_tx_queues = dev_info.nb_tx_queues;
18902 for (q = 0; q < nb_tx_queues; q++) {
18903 queue_offloads = port->tx_conf[q].offloads;
18904 printf(" Queue[%2d] :", q);
18905 print_tx_offloads(queue_offloads);
18911 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18912 .f = cmd_tx_offload_get_configuration_parsed,
18914 .help_str = "show port <port_id> tx_offload configuration",
18916 (void *)&cmd_tx_offload_get_configuration_show,
18917 (void *)&cmd_tx_offload_get_configuration_port,
18918 (void *)&cmd_tx_offload_get_configuration_port_id,
18919 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18920 (void *)&cmd_tx_offload_get_configuration_configuration,
18925 /* Enable/Disable a per port offloading */
18926 struct cmd_config_per_port_tx_offload_result {
18927 cmdline_fixed_string_t port;
18928 cmdline_fixed_string_t config;
18930 cmdline_fixed_string_t tx_offload;
18931 cmdline_fixed_string_t offload;
18932 cmdline_fixed_string_t on_off;
18935 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18936 TOKEN_STRING_INITIALIZER
18937 (struct cmd_config_per_port_tx_offload_result,
18939 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18940 TOKEN_STRING_INITIALIZER
18941 (struct cmd_config_per_port_tx_offload_result,
18943 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18944 TOKEN_NUM_INITIALIZER
18945 (struct cmd_config_per_port_tx_offload_result,
18947 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18948 TOKEN_STRING_INITIALIZER
18949 (struct cmd_config_per_port_tx_offload_result,
18950 tx_offload, "tx_offload");
18951 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18952 TOKEN_STRING_INITIALIZER
18953 (struct cmd_config_per_port_tx_offload_result,
18954 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18955 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18956 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18957 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18958 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18959 "send_on_timestamp");
18960 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18961 TOKEN_STRING_INITIALIZER
18962 (struct cmd_config_per_port_tx_offload_result,
18966 search_tx_offload(const char *name)
18968 uint64_t single_offload;
18969 const char *single_name;
18973 single_offload = 1;
18974 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18975 single_name = rte_eth_dev_tx_offload_name(single_offload);
18976 if (single_name == NULL)
18978 if (!strcasecmp(single_name, name)) {
18981 } else if (!strcasecmp(single_name, "UNKNOWN"))
18983 single_offload <<= 1;
18987 return single_offload;
18993 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18994 __rte_unused struct cmdline *cl,
18995 __rte_unused void *data)
18997 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18998 portid_t port_id = res->port_id;
18999 struct rte_eth_dev_info dev_info;
19000 struct rte_port *port = &ports[port_id];
19001 uint64_t single_offload;
19002 uint16_t nb_tx_queues;
19006 if (port->port_status != RTE_PORT_STOPPED) {
19007 printf("Error: Can't config offload when Port %d "
19008 "is not stopped\n", port_id);
19012 single_offload = search_tx_offload(res->offload);
19013 if (single_offload == 0) {
19014 printf("Unknown offload name: %s\n", res->offload);
19018 ret = eth_dev_info_get_print_err(port_id, &dev_info);
19022 nb_tx_queues = dev_info.nb_tx_queues;
19023 if (!strcmp(res->on_off, "on")) {
19024 port->dev_conf.txmode.offloads |= single_offload;
19025 for (q = 0; q < nb_tx_queues; q++)
19026 port->tx_conf[q].offloads |= single_offload;
19028 port->dev_conf.txmode.offloads &= ~single_offload;
19029 for (q = 0; q < nb_tx_queues; q++)
19030 port->tx_conf[q].offloads &= ~single_offload;
19033 cmd_reconfig_device_queue(port_id, 1, 1);
19036 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
19037 .f = cmd_config_per_port_tx_offload_parsed,
19039 .help_str = "port config <port_id> tx_offload "
19040 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
19041 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
19042 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
19043 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
19044 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
19045 "send_on_timestamp on|off",
19047 (void *)&cmd_config_per_port_tx_offload_result_port,
19048 (void *)&cmd_config_per_port_tx_offload_result_config,
19049 (void *)&cmd_config_per_port_tx_offload_result_port_id,
19050 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
19051 (void *)&cmd_config_per_port_tx_offload_result_offload,
19052 (void *)&cmd_config_per_port_tx_offload_result_on_off,
19057 /* Enable/Disable a per queue offloading */
19058 struct cmd_config_per_queue_tx_offload_result {
19059 cmdline_fixed_string_t port;
19061 cmdline_fixed_string_t txq;
19063 cmdline_fixed_string_t tx_offload;
19064 cmdline_fixed_string_t offload;
19065 cmdline_fixed_string_t on_off;
19068 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
19069 TOKEN_STRING_INITIALIZER
19070 (struct cmd_config_per_queue_tx_offload_result,
19072 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
19073 TOKEN_NUM_INITIALIZER
19074 (struct cmd_config_per_queue_tx_offload_result,
19076 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
19077 TOKEN_STRING_INITIALIZER
19078 (struct cmd_config_per_queue_tx_offload_result,
19080 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
19081 TOKEN_NUM_INITIALIZER
19082 (struct cmd_config_per_queue_tx_offload_result,
19084 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
19085 TOKEN_STRING_INITIALIZER
19086 (struct cmd_config_per_queue_tx_offload_result,
19087 tx_offload, "tx_offload");
19088 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
19089 TOKEN_STRING_INITIALIZER
19090 (struct cmd_config_per_queue_tx_offload_result,
19091 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
19092 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
19093 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
19094 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
19095 "mt_lockfree#multi_segs#mbuf_fast_free#security");
19096 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
19097 TOKEN_STRING_INITIALIZER
19098 (struct cmd_config_per_queue_tx_offload_result,
19102 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
19103 __rte_unused struct cmdline *cl,
19104 __rte_unused void *data)
19106 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
19107 struct rte_eth_dev_info dev_info;
19108 portid_t port_id = res->port_id;
19109 uint16_t queue_id = res->queue_id;
19110 struct rte_port *port = &ports[port_id];
19111 uint64_t single_offload;
19114 if (port->port_status != RTE_PORT_STOPPED) {
19115 printf("Error: Can't config offload when Port %d "
19116 "is not stopped\n", port_id);
19120 ret = eth_dev_info_get_print_err(port_id, &dev_info);
19124 if (queue_id >= dev_info.nb_tx_queues) {
19125 printf("Error: input queue_id should be 0 ... "
19126 "%d\n", dev_info.nb_tx_queues - 1);
19130 single_offload = search_tx_offload(res->offload);
19131 if (single_offload == 0) {
19132 printf("Unknown offload name: %s\n", res->offload);
19136 if (!strcmp(res->on_off, "on"))
19137 port->tx_conf[queue_id].offloads |= single_offload;
19139 port->tx_conf[queue_id].offloads &= ~single_offload;
19141 cmd_reconfig_device_queue(port_id, 1, 1);
19144 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
19145 .f = cmd_config_per_queue_tx_offload_parsed,
19147 .help_str = "port <port_id> txq <queue_id> tx_offload "
19148 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
19149 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
19150 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
19151 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
19152 "mt_lockfree|multi_segs|mbuf_fast_free|security "
19155 (void *)&cmd_config_per_queue_tx_offload_result_port,
19156 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
19157 (void *)&cmd_config_per_queue_tx_offload_result_txq,
19158 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
19159 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
19160 (void *)&cmd_config_per_queue_tx_offload_result_offload,
19161 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
19166 /* *** configure tx_metadata for specific port *** */
19167 struct cmd_config_tx_metadata_specific_result {
19168 cmdline_fixed_string_t port;
19169 cmdline_fixed_string_t keyword;
19171 cmdline_fixed_string_t item;
19176 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
19177 __rte_unused struct cmdline *cl,
19178 __rte_unused void *data)
19180 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
19182 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
19184 ports[res->port_id].tx_metadata = res->value;
19185 /* Add/remove callback to insert valid metadata in every Tx packet. */
19186 if (ports[res->port_id].tx_metadata)
19187 add_tx_md_callback(res->port_id);
19189 remove_tx_md_callback(res->port_id);
19190 rte_flow_dynf_metadata_register();
19193 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
19194 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19196 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
19197 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19198 keyword, "config");
19199 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
19200 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19202 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
19203 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19204 item, "tx_metadata");
19205 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
19206 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19209 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
19210 .f = cmd_config_tx_metadata_specific_parsed,
19212 .help_str = "port config <port_id> tx_metadata <value>",
19214 (void *)&cmd_config_tx_metadata_specific_port,
19215 (void *)&cmd_config_tx_metadata_specific_keyword,
19216 (void *)&cmd_config_tx_metadata_specific_id,
19217 (void *)&cmd_config_tx_metadata_specific_item,
19218 (void *)&cmd_config_tx_metadata_specific_value,
19223 /* *** set dynf *** */
19224 struct cmd_config_tx_dynf_specific_result {
19225 cmdline_fixed_string_t port;
19226 cmdline_fixed_string_t keyword;
19228 cmdline_fixed_string_t item;
19229 cmdline_fixed_string_t name;
19230 cmdline_fixed_string_t value;
19234 cmd_config_dynf_specific_parsed(void *parsed_result,
19235 __rte_unused struct cmdline *cl,
19236 __rte_unused void *data)
19238 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
19239 struct rte_mbuf_dynflag desc_flag;
19241 uint64_t old_port_flags;
19243 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
19245 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
19247 if (strlcpy(desc_flag.name, res->name,
19248 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
19249 printf("Flag name too long\n");
19252 desc_flag.flags = 0;
19253 flag = rte_mbuf_dynflag_register(&desc_flag);
19255 printf("Can't register flag\n");
19258 strcpy(dynf_names[flag], desc_flag.name);
19260 old_port_flags = ports[res->port_id].mbuf_dynf;
19261 if (!strcmp(res->value, "set")) {
19262 ports[res->port_id].mbuf_dynf |= 1UL << flag;
19263 if (old_port_flags == 0)
19264 add_tx_dynf_callback(res->port_id);
19266 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
19267 if (ports[res->port_id].mbuf_dynf == 0)
19268 remove_tx_dynf_callback(res->port_id);
19272 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
19273 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19275 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
19276 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19277 keyword, "config");
19278 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
19279 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19281 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
19282 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19284 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
19285 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19287 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
19288 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19289 value, "set#clear");
19291 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
19292 .f = cmd_config_dynf_specific_parsed,
19294 .help_str = "port config <port id> dynf <name> set|clear",
19296 (void *)&cmd_config_tx_dynf_specific_port,
19297 (void *)&cmd_config_tx_dynf_specific_keyword,
19298 (void *)&cmd_config_tx_dynf_specific_port_id,
19299 (void *)&cmd_config_tx_dynf_specific_item,
19300 (void *)&cmd_config_tx_dynf_specific_name,
19301 (void *)&cmd_config_tx_dynf_specific_value,
19306 /* *** display tx_metadata per port configuration *** */
19307 struct cmd_show_tx_metadata_result {
19308 cmdline_fixed_string_t cmd_show;
19309 cmdline_fixed_string_t cmd_port;
19310 cmdline_fixed_string_t cmd_keyword;
19315 cmd_show_tx_metadata_parsed(void *parsed_result,
19316 __rte_unused struct cmdline *cl,
19317 __rte_unused void *data)
19319 struct cmd_show_tx_metadata_result *res = parsed_result;
19321 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19322 printf("invalid port id %u\n", res->cmd_pid);
19325 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
19326 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
19327 ports[res->cmd_pid].tx_metadata);
19331 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
19332 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19334 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
19335 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19337 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
19338 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
19340 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
19341 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19342 cmd_keyword, "tx_metadata");
19344 cmdline_parse_inst_t cmd_show_tx_metadata = {
19345 .f = cmd_show_tx_metadata_parsed,
19347 .help_str = "show port <port_id> tx_metadata",
19349 (void *)&cmd_show_tx_metadata_show,
19350 (void *)&cmd_show_tx_metadata_port,
19351 (void *)&cmd_show_tx_metadata_pid,
19352 (void *)&cmd_show_tx_metadata_keyword,
19357 /* *** show fec capability per port configuration *** */
19358 struct cmd_show_fec_capability_result {
19359 cmdline_fixed_string_t cmd_show;
19360 cmdline_fixed_string_t cmd_port;
19361 cmdline_fixed_string_t cmd_fec;
19362 cmdline_fixed_string_t cmd_keyword;
19367 cmd_show_fec_capability_parsed(void *parsed_result,
19368 __rte_unused struct cmdline *cl,
19369 __rte_unused void *data)
19371 #define FEC_CAP_NUM 2
19372 struct cmd_show_fec_capability_result *res = parsed_result;
19373 struct rte_eth_fec_capa speed_fec_capa[FEC_CAP_NUM];
19374 unsigned int num = FEC_CAP_NUM;
19375 unsigned int ret_num;
19378 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19379 printf("Invalid port id %u\n", res->cmd_pid);
19383 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
19384 if (ret == -ENOTSUP) {
19385 printf("Function not implemented\n");
19387 } else if (ret < 0) {
19388 printf("Get FEC capability failed\n");
19392 ret_num = (unsigned int)ret;
19393 show_fec_capability(ret_num, speed_fec_capa);
19396 cmdline_parse_token_string_t cmd_show_fec_capability_show =
19397 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19399 cmdline_parse_token_string_t cmd_show_fec_capability_port =
19400 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19402 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
19403 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
19405 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
19406 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19408 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
19409 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19410 cmd_keyword, "capabilities");
19412 cmdline_parse_inst_t cmd_show_capability = {
19413 .f = cmd_show_fec_capability_parsed,
19415 .help_str = "show port <port_id> fec capabilities",
19417 (void *)&cmd_show_fec_capability_show,
19418 (void *)&cmd_show_fec_capability_port,
19419 (void *)&cmd_show_fec_capability_pid,
19420 (void *)&cmd_show_fec_capability_fec,
19421 (void *)&cmd_show_fec_capability_keyword,
19426 /* *** show fec mode per port configuration *** */
19427 struct cmd_show_fec_metadata_result {
19428 cmdline_fixed_string_t cmd_show;
19429 cmdline_fixed_string_t cmd_port;
19430 cmdline_fixed_string_t cmd_keyword;
19435 cmd_show_fec_mode_parsed(void *parsed_result,
19436 __rte_unused struct cmdline *cl,
19437 __rte_unused void *data)
19439 #define FEC_NAME_SIZE 16
19440 struct cmd_show_fec_metadata_result *res = parsed_result;
19442 char buf[FEC_NAME_SIZE];
19445 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19446 printf("Invalid port id %u\n", res->cmd_pid);
19449 ret = rte_eth_fec_get(res->cmd_pid, &mode);
19450 if (ret == -ENOTSUP) {
19451 printf("Function not implemented\n");
19453 } else if (ret < 0) {
19454 printf("Get FEC mode failed\n");
19459 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
19460 strlcpy(buf, "off", sizeof(buf));
19462 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
19463 strlcpy(buf, "auto", sizeof(buf));
19465 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
19466 strlcpy(buf, "baser", sizeof(buf));
19468 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
19469 strlcpy(buf, "rs", sizeof(buf));
19475 printf("%s\n", buf);
19478 cmdline_parse_token_string_t cmd_show_fec_mode_show =
19479 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
19481 cmdline_parse_token_string_t cmd_show_fec_mode_port =
19482 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
19484 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
19485 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
19487 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
19488 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
19489 cmd_keyword, "fec_mode");
19491 cmdline_parse_inst_t cmd_show_fec_mode = {
19492 .f = cmd_show_fec_mode_parsed,
19494 .help_str = "show port <port_id> fec_mode",
19496 (void *)&cmd_show_fec_mode_show,
19497 (void *)&cmd_show_fec_mode_port,
19498 (void *)&cmd_show_fec_mode_pid,
19499 (void *)&cmd_show_fec_mode_keyword,
19504 /* *** set fec mode per port configuration *** */
19505 struct cmd_set_port_fec_mode {
19506 cmdline_fixed_string_t set;
19507 cmdline_fixed_string_t port;
19509 cmdline_fixed_string_t fec_mode;
19510 cmdline_fixed_string_t fec_value;
19513 /* Common CLI fields for set fec mode */
19514 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
19515 TOKEN_STRING_INITIALIZER
19516 (struct cmd_set_port_fec_mode,
19518 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
19519 TOKEN_STRING_INITIALIZER
19520 (struct cmd_set_port_fec_mode,
19522 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
19523 TOKEN_NUM_INITIALIZER
19524 (struct cmd_set_port_fec_mode,
19526 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
19527 TOKEN_STRING_INITIALIZER
19528 (struct cmd_set_port_fec_mode,
19529 fec_mode, "fec_mode");
19530 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
19531 TOKEN_STRING_INITIALIZER
19532 (struct cmd_set_port_fec_mode,
19536 cmd_set_port_fec_mode_parsed(
19537 void *parsed_result,
19538 __rte_unused struct cmdline *cl,
19539 __rte_unused void *data)
19541 struct cmd_set_port_fec_mode *res = parsed_result;
19542 uint16_t port_id = res->port_id;
19546 ret = parse_fec_mode(res->fec_value, &mode);
19548 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
19553 ret = rte_eth_fec_set(port_id, mode);
19554 if (ret == -ENOTSUP) {
19555 printf("Function not implemented\n");
19557 } else if (ret < 0) {
19558 printf("Set FEC mode failed\n");
19563 cmdline_parse_inst_t cmd_set_fec_mode = {
19564 .f = cmd_set_port_fec_mode_parsed,
19566 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
19568 (void *)&cmd_set_port_fec_mode_set,
19569 (void *)&cmd_set_port_fec_mode_port,
19570 (void *)&cmd_set_port_fec_mode_port_id,
19571 (void *)&cmd_set_port_fec_mode_str,
19572 (void *)&cmd_set_port_fec_mode_value,
19577 /* show port supported ptypes */
19579 /* Common result structure for show port ptypes */
19580 struct cmd_show_port_supported_ptypes_result {
19581 cmdline_fixed_string_t show;
19582 cmdline_fixed_string_t port;
19584 cmdline_fixed_string_t ptypes;
19587 /* Common CLI fields for show port ptypes */
19588 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
19589 TOKEN_STRING_INITIALIZER
19590 (struct cmd_show_port_supported_ptypes_result,
19592 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
19593 TOKEN_STRING_INITIALIZER
19594 (struct cmd_show_port_supported_ptypes_result,
19596 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19597 TOKEN_NUM_INITIALIZER
19598 (struct cmd_show_port_supported_ptypes_result,
19600 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19601 TOKEN_STRING_INITIALIZER
19602 (struct cmd_show_port_supported_ptypes_result,
19606 cmd_show_port_supported_ptypes_parsed(
19607 void *parsed_result,
19608 __rte_unused struct cmdline *cl,
19609 __rte_unused void *data)
19611 #define RSVD_PTYPE_MASK 0xf0000000
19612 #define MAX_PTYPES_PER_LAYER 16
19613 #define LTYPE_NAMESIZE 32
19614 #define PTYPE_NAMESIZE 256
19615 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19616 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19617 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19618 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19619 uint16_t port_id = res->port_id;
19622 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19626 while (ptype_mask != RSVD_PTYPE_MASK) {
19628 switch (ptype_mask) {
19629 case RTE_PTYPE_L2_MASK:
19630 strlcpy(ltype, "L2", sizeof(ltype));
19632 case RTE_PTYPE_L3_MASK:
19633 strlcpy(ltype, "L3", sizeof(ltype));
19635 case RTE_PTYPE_L4_MASK:
19636 strlcpy(ltype, "L4", sizeof(ltype));
19638 case RTE_PTYPE_TUNNEL_MASK:
19639 strlcpy(ltype, "Tunnel", sizeof(ltype));
19641 case RTE_PTYPE_INNER_L2_MASK:
19642 strlcpy(ltype, "Inner L2", sizeof(ltype));
19644 case RTE_PTYPE_INNER_L3_MASK:
19645 strlcpy(ltype, "Inner L3", sizeof(ltype));
19647 case RTE_PTYPE_INNER_L4_MASK:
19648 strlcpy(ltype, "Inner L4", sizeof(ltype));
19654 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19655 ptype_mask, ptypes,
19656 MAX_PTYPES_PER_LAYER);
19659 printf("Supported %s ptypes:\n", ltype);
19661 printf("%s ptypes unsupported\n", ltype);
19663 for (i = 0; i < ret; ++i) {
19664 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19665 printf("%s\n", buf);
19672 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19673 .f = cmd_show_port_supported_ptypes_parsed,
19675 .help_str = "show port <port_id> ptypes",
19677 (void *)&cmd_show_port_supported_ptypes_show,
19678 (void *)&cmd_show_port_supported_ptypes_port,
19679 (void *)&cmd_show_port_supported_ptypes_port_id,
19680 (void *)&cmd_show_port_supported_ptypes_ptypes,
19685 /* *** display rx/tx descriptor status *** */
19686 struct cmd_show_rx_tx_desc_status_result {
19687 cmdline_fixed_string_t cmd_show;
19688 cmdline_fixed_string_t cmd_port;
19689 cmdline_fixed_string_t cmd_keyword;
19690 cmdline_fixed_string_t cmd_desc;
19691 cmdline_fixed_string_t cmd_status;
19698 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19699 __rte_unused struct cmdline *cl,
19700 __rte_unused void *data)
19702 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19705 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19706 printf("invalid port id %u\n", res->cmd_pid);
19710 if (!strcmp(res->cmd_keyword, "rxq")) {
19711 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19714 printf("Invalid queueid = %d\n", res->cmd_qid);
19717 if (rc == RTE_ETH_RX_DESC_AVAIL)
19718 printf("Desc status = AVAILABLE\n");
19719 else if (rc == RTE_ETH_RX_DESC_DONE)
19720 printf("Desc status = DONE\n");
19722 printf("Desc status = UNAVAILABLE\n");
19723 } else if (!strcmp(res->cmd_keyword, "txq")) {
19724 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19727 printf("Invalid queueid = %d\n", res->cmd_qid);
19730 if (rc == RTE_ETH_TX_DESC_FULL)
19731 printf("Desc status = FULL\n");
19732 else if (rc == RTE_ETH_TX_DESC_DONE)
19733 printf("Desc status = DONE\n");
19735 printf("Desc status = UNAVAILABLE\n");
19739 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19740 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19742 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19743 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19745 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19746 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19748 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19749 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19750 cmd_keyword, "rxq#txq");
19751 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19752 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19754 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19755 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19757 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19758 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19760 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19761 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19762 cmd_status, "status");
19763 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19764 .f = cmd_show_rx_tx_desc_status_parsed,
19766 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19769 (void *)&cmd_show_rx_tx_desc_status_show,
19770 (void *)&cmd_show_rx_tx_desc_status_port,
19771 (void *)&cmd_show_rx_tx_desc_status_pid,
19772 (void *)&cmd_show_rx_tx_desc_status_keyword,
19773 (void *)&cmd_show_rx_tx_desc_status_qid,
19774 (void *)&cmd_show_rx_tx_desc_status_desc,
19775 (void *)&cmd_show_rx_tx_desc_status_did,
19776 (void *)&cmd_show_rx_tx_desc_status_status,
19781 /* Common result structure for set port ptypes */
19782 struct cmd_set_port_ptypes_result {
19783 cmdline_fixed_string_t set;
19784 cmdline_fixed_string_t port;
19786 cmdline_fixed_string_t ptype_mask;
19790 /* Common CLI fields for set port ptypes */
19791 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19792 TOKEN_STRING_INITIALIZER
19793 (struct cmd_set_port_ptypes_result,
19795 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19796 TOKEN_STRING_INITIALIZER
19797 (struct cmd_set_port_ptypes_result,
19799 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19800 TOKEN_NUM_INITIALIZER
19801 (struct cmd_set_port_ptypes_result,
19803 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19804 TOKEN_STRING_INITIALIZER
19805 (struct cmd_set_port_ptypes_result,
19806 ptype_mask, "ptype_mask");
19807 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19808 TOKEN_NUM_INITIALIZER
19809 (struct cmd_set_port_ptypes_result,
19813 cmd_set_port_ptypes_parsed(
19814 void *parsed_result,
19815 __rte_unused struct cmdline *cl,
19816 __rte_unused void *data)
19818 struct cmd_set_port_ptypes_result *res = parsed_result;
19819 #define PTYPE_NAMESIZE 256
19820 char ptype_name[PTYPE_NAMESIZE];
19821 uint16_t port_id = res->port_id;
19822 uint32_t ptype_mask = res->mask;
19825 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19828 printf("Port %d doesn't support any ptypes.\n", port_id);
19832 uint32_t ptypes[ret];
19834 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19836 printf("Unable to set requested ptypes for Port %d\n", port_id);
19840 printf("Successfully set following ptypes for Port %d\n", port_id);
19841 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19842 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19843 printf("%s\n", ptype_name);
19846 clear_ptypes = false;
19849 cmdline_parse_inst_t cmd_set_port_ptypes = {
19850 .f = cmd_set_port_ptypes_parsed,
19852 .help_str = "set port <port_id> ptype_mask <mask>",
19854 (void *)&cmd_set_port_ptypes_set,
19855 (void *)&cmd_set_port_ptypes_port,
19856 (void *)&cmd_set_port_ptypes_port_id,
19857 (void *)&cmd_set_port_ptypes_mask_str,
19858 (void *)&cmd_set_port_ptypes_mask_u32,
19863 /* *** display mac addresses added to a port *** */
19864 struct cmd_showport_macs_result {
19865 cmdline_fixed_string_t cmd_show;
19866 cmdline_fixed_string_t cmd_port;
19867 cmdline_fixed_string_t cmd_keyword;
19872 cmd_showport_macs_parsed(void *parsed_result,
19873 __rte_unused struct cmdline *cl,
19874 __rte_unused void *data)
19876 struct cmd_showport_macs_result *res = parsed_result;
19878 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19881 if (!strcmp(res->cmd_keyword, "macs"))
19882 show_macs(res->cmd_pid);
19883 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19884 show_mcast_macs(res->cmd_pid);
19887 cmdline_parse_token_string_t cmd_showport_macs_show =
19888 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19890 cmdline_parse_token_string_t cmd_showport_macs_port =
19891 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19893 cmdline_parse_token_num_t cmd_showport_macs_pid =
19894 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19896 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19897 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19898 cmd_keyword, "macs#mcast_macs");
19900 cmdline_parse_inst_t cmd_showport_macs = {
19901 .f = cmd_showport_macs_parsed,
19903 .help_str = "show port <port_id> macs|mcast_macs",
19905 (void *)&cmd_showport_macs_show,
19906 (void *)&cmd_showport_macs_port,
19907 (void *)&cmd_showport_macs_pid,
19908 (void *)&cmd_showport_macs_keyword,
19913 /* ******************************************************************************** */
19915 /* list of instructions */
19916 cmdline_parse_ctx_t main_ctx[] = {
19917 (cmdline_parse_inst_t *)&cmd_help_brief,
19918 (cmdline_parse_inst_t *)&cmd_help_long,
19919 (cmdline_parse_inst_t *)&cmd_quit,
19920 (cmdline_parse_inst_t *)&cmd_load_from_file,
19921 (cmdline_parse_inst_t *)&cmd_showport,
19922 (cmdline_parse_inst_t *)&cmd_showqueue,
19923 (cmdline_parse_inst_t *)&cmd_showeeprom,
19924 (cmdline_parse_inst_t *)&cmd_showportall,
19925 (cmdline_parse_inst_t *)&cmd_showdevice,
19926 (cmdline_parse_inst_t *)&cmd_showcfg,
19927 (cmdline_parse_inst_t *)&cmd_showfwdall,
19928 (cmdline_parse_inst_t *)&cmd_start,
19929 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19930 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19931 (cmdline_parse_inst_t *)&cmd_set_link_up,
19932 (cmdline_parse_inst_t *)&cmd_set_link_down,
19933 (cmdline_parse_inst_t *)&cmd_reset,
19934 (cmdline_parse_inst_t *)&cmd_set_numbers,
19935 (cmdline_parse_inst_t *)&cmd_set_log,
19936 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
19937 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
19938 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19939 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19940 (cmdline_parse_inst_t *)&cmd_set_txtimes,
19941 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19942 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19943 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19944 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19945 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19946 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19947 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19948 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19949 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19950 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19951 (cmdline_parse_inst_t *)&cmd_set_link_check,
19952 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19953 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19954 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19955 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19956 #ifdef RTE_NET_BOND
19957 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19958 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19959 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19960 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19961 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19962 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19963 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19964 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19965 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19966 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19967 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19969 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19970 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19971 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19972 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19973 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19974 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19975 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19976 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19977 (cmdline_parse_inst_t *)&cmd_csum_set,
19978 (cmdline_parse_inst_t *)&cmd_csum_show,
19979 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19980 (cmdline_parse_inst_t *)&cmd_tso_set,
19981 (cmdline_parse_inst_t *)&cmd_tso_show,
19982 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19983 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19984 (cmdline_parse_inst_t *)&cmd_gro_enable,
19985 (cmdline_parse_inst_t *)&cmd_gro_flush,
19986 (cmdline_parse_inst_t *)&cmd_gro_show,
19987 (cmdline_parse_inst_t *)&cmd_gso_enable,
19988 (cmdline_parse_inst_t *)&cmd_gso_size,
19989 (cmdline_parse_inst_t *)&cmd_gso_show,
19990 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19991 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19992 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19993 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19994 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19995 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19996 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19997 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19998 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19999 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
20000 (cmdline_parse_inst_t *)&cmd_config_dcb,
20001 (cmdline_parse_inst_t *)&cmd_read_reg,
20002 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
20003 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
20004 (cmdline_parse_inst_t *)&cmd_write_reg,
20005 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
20006 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
20007 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
20008 (cmdline_parse_inst_t *)&cmd_stop,
20009 (cmdline_parse_inst_t *)&cmd_mac_addr,
20010 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
20011 (cmdline_parse_inst_t *)&cmd_set_qmap,
20012 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
20013 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
20014 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
20015 (cmdline_parse_inst_t *)&cmd_operate_port,
20016 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
20017 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
20018 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
20019 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
20020 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
20021 (cmdline_parse_inst_t *)&cmd_config_speed_all,
20022 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
20023 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
20024 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
20025 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
20026 (cmdline_parse_inst_t *)&cmd_config_mtu,
20027 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
20028 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
20029 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
20030 (cmdline_parse_inst_t *)&cmd_config_rss,
20031 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
20032 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
20033 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
20034 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
20035 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
20036 (cmdline_parse_inst_t *)&cmd_showport_reta,
20037 (cmdline_parse_inst_t *)&cmd_showport_macs,
20038 (cmdline_parse_inst_t *)&cmd_config_burst,
20039 (cmdline_parse_inst_t *)&cmd_config_thresh,
20040 (cmdline_parse_inst_t *)&cmd_config_threshold,
20041 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
20042 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
20043 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
20044 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
20045 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
20046 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
20047 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
20048 (cmdline_parse_inst_t *)&cmd_global_config,
20049 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
20050 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
20051 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
20052 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
20053 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
20054 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
20055 (cmdline_parse_inst_t *)&cmd_dump,
20056 (cmdline_parse_inst_t *)&cmd_dump_one,
20057 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
20058 (cmdline_parse_inst_t *)&cmd_syn_filter,
20059 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
20060 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
20061 (cmdline_parse_inst_t *)&cmd_flex_filter,
20062 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
20063 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
20064 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
20065 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
20066 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
20067 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
20068 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
20069 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
20070 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
20071 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
20072 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
20073 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
20074 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
20075 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
20076 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
20077 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
20078 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
20079 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
20080 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
20081 (cmdline_parse_inst_t *)&cmd_flow,
20082 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
20083 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
20084 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
20085 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
20086 (cmdline_parse_inst_t *)&cmd_create_port_meter,
20087 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
20088 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
20089 (cmdline_parse_inst_t *)&cmd_del_port_meter,
20090 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
20091 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
20092 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
20093 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
20094 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
20095 (cmdline_parse_inst_t *)&cmd_mcast_addr,
20096 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
20097 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
20098 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
20099 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
20100 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
20101 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
20102 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
20103 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
20104 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
20105 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
20106 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
20107 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
20108 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
20109 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
20110 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
20111 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
20112 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
20113 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
20114 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
20115 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
20116 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
20117 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
20118 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
20119 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
20120 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
20121 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
20122 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
20123 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
20124 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
20125 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
20126 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
20127 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
20128 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
20129 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
20130 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
20131 (cmdline_parse_inst_t *)&cmd_set_vxlan,
20132 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
20133 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
20134 (cmdline_parse_inst_t *)&cmd_set_nvgre,
20135 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
20136 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
20137 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
20138 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
20139 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
20140 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
20141 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
20142 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
20143 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
20144 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
20145 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
20146 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
20147 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
20148 (cmdline_parse_inst_t *)&cmd_ddp_add,
20149 (cmdline_parse_inst_t *)&cmd_ddp_del,
20150 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
20151 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
20152 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
20153 (cmdline_parse_inst_t *)&cmd_clear_input_set,
20154 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
20155 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
20156 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
20157 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
20158 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
20159 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
20160 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
20161 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
20163 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
20164 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
20165 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
20166 (cmdline_parse_inst_t *)&cmd_queue_region,
20167 (cmdline_parse_inst_t *)&cmd_region_flowtype,
20168 (cmdline_parse_inst_t *)&cmd_user_priority_region,
20169 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
20170 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
20171 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
20172 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
20173 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
20174 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
20175 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
20176 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
20177 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
20178 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
20179 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
20180 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
20181 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
20182 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
20183 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
20184 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
20185 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
20186 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
20187 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
20188 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
20189 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
20190 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
20191 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
20192 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
20193 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
20194 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
20195 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
20196 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
20197 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
20198 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
20199 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
20200 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
20201 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
20202 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
20204 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
20205 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
20207 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
20208 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
20209 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
20210 (cmdline_parse_inst_t *)&cmd_set_raw,
20211 (cmdline_parse_inst_t *)&cmd_show_set_raw,
20212 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
20213 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
20214 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
20215 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
20216 (cmdline_parse_inst_t *)&cmd_show_capability,
20220 /* read cmdline commands from file */
20222 cmdline_read_from_file(const char *filename)
20224 struct cmdline *cl;
20226 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
20228 printf("Failed to create file based cmdline context: %s\n",
20233 cmdline_interact(cl);
20238 printf("Read CLI commands from %s\n", filename);
20241 /* prompt function, called from main on MAIN lcore */
20245 /* initialize non-constant commands */
20246 cmd_set_fwd_mode_init();
20247 cmd_set_fwd_retry_mode_init();
20249 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
20250 if (testpmd_cl == NULL)
20252 cmdline_interact(testpmd_cl);
20253 cmdline_stdin_exit(testpmd_cl);
20259 if (testpmd_cl != NULL)
20260 cmdline_quit(testpmd_cl);
20264 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
20266 if (id == (portid_t)RTE_PORT_ALL) {
20269 RTE_ETH_FOREACH_DEV(pid) {
20270 /* check if need_reconfig has been set to 1 */
20271 if (ports[pid].need_reconfig == 0)
20272 ports[pid].need_reconfig = dev;
20273 /* check if need_reconfig_queues has been set to 1 */
20274 if (ports[pid].need_reconfig_queues == 0)
20275 ports[pid].need_reconfig_queues = queue;
20277 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
20278 /* check if need_reconfig has been set to 1 */
20279 if (ports[id].need_reconfig == 0)
20280 ports[id].need_reconfig = dev;
20281 /* check if need_reconfig_queues has been set to 1 */
20282 if (ports[id].need_reconfig_queues == 0)
20283 ports[id].need_reconfig_queues = queue;