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 "rx_vxlan_port add (udp_port) (port_id)\n"
412 " Add an UDP port for VXLAN packet filter on a port\n\n"
414 "rx_vxlan_port rm (udp_port) (port_id)\n"
415 " Remove an UDP port for VXLAN packet filter on a port\n\n"
417 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
418 " Set hardware insertion of VLAN IDs (single or double VLAN "
419 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
421 "tx_vlan set pvid port_id vlan_id (on|off)\n"
422 " Set port based TX VLAN insertion.\n\n"
424 "tx_vlan reset (port_id)\n"
425 " Disable hardware insertion of a VLAN header in"
426 " packets sent on a port.\n\n"
428 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
429 " Select hardware or software calculation of the"
430 " checksum when transmitting a packet using the"
431 " csum forward engine.\n"
432 " ip|udp|tcp|sctp always concern the inner layer.\n"
433 " outer-ip concerns the outer IP layer in"
434 " outer-udp concerns the outer UDP layer in"
435 " case the packet is recognized as a tunnel packet by"
436 " the forward engine (vxlan, gre and ipip are supported)\n"
437 " Please check the NIC datasheet for HW limits.\n\n"
439 "csum parse-tunnel (on|off) (tx_port_id)\n"
440 " If disabled, treat tunnel packets as non-tunneled"
441 " packets (treat inner headers as payload). The port\n"
442 " argument is the port used for TX in csum forward"
445 "csum show (port_id)\n"
446 " Display tx checksum offload configuration\n\n"
448 "tso set (segsize) (portid)\n"
449 " Enable TCP Segmentation Offload in csum forward"
451 " Please check the NIC datasheet for HW limits.\n\n"
454 " Display the status of TCP Segmentation Offload.\n\n"
456 "set port (port_id) gro on|off\n"
457 " Enable or disable Generic Receive Offload in"
458 " csum forwarding engine.\n\n"
460 "show port (port_id) gro\n"
461 " Display GRO configuration.\n\n"
463 "set gro flush (cycles)\n"
464 " Set the cycle to flush GROed packets from"
465 " reassembly tables.\n\n"
467 "set port (port_id) gso (on|off)"
468 " Enable or disable Generic Segmentation Offload in"
469 " csum forwarding engine.\n\n"
471 "set gso segsz (length)\n"
472 " Set max packet length for output GSO segments,"
473 " including packet header and payload.\n\n"
475 "show port (port_id) gso\n"
476 " Show GSO configuration.\n\n"
479 " Set packet forwarding mode.\n\n"
481 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
482 " Add a MAC address on port_id.\n\n"
484 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
485 " Remove a MAC address from port_id.\n\n"
487 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
488 " Set the default MAC address for port_id.\n\n"
490 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
491 " Add a MAC address for a VF on the port.\n\n"
493 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
494 " Set the MAC address for a VF from the PF.\n\n"
496 "set eth-peer (port_id) (peer_addr)\n"
497 " set the peer address for certain port.\n\n"
499 "set port (port_id) uta (mac_address|all) (on|off)\n"
500 " Add/Remove a or all unicast hash filter(s)"
503 "set promisc (port_id|all) (on|off)\n"
504 " Set the promiscuous mode on port_id, or all.\n\n"
506 "set allmulti (port_id|all) (on|off)\n"
507 " Set the allmulti mode on port_id, or all.\n\n"
509 "set vf promisc (port_id) (vf_id) (on|off)\n"
510 " Set unicast promiscuous mode for a VF from the PF.\n\n"
512 "set vf allmulti (port_id) (vf_id) (on|off)\n"
513 " Set multicast promiscuous mode for a VF from the PF.\n\n"
515 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
516 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
517 " (on|off) autoneg (on|off) (port_id)\n"
518 "set flow_ctrl rx (on|off) (portid)\n"
519 "set flow_ctrl tx (on|off) (portid)\n"
520 "set flow_ctrl high_water (high_water) (portid)\n"
521 "set flow_ctrl low_water (low_water) (portid)\n"
522 "set flow_ctrl pause_time (pause_time) (portid)\n"
523 "set flow_ctrl send_xon (send_xon) (portid)\n"
524 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
525 "set flow_ctrl autoneg (on|off) (port_id)\n"
526 " Set the link flow control parameter on a port.\n\n"
528 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
529 " (low_water) (pause_time) (priority) (port_id)\n"
530 " Set the priority flow control parameter on a"
533 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
534 " Set statistics mapping (qmapping 0..15) for RX/TX"
536 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
537 " on port 0 to mapping 5.\n\n"
539 "set xstats-hide-zero on|off\n"
540 " Set the option to hide the zero values"
541 " for xstats display.\n"
543 "set record-core-cycles on|off\n"
544 " Set the option to enable measurement of CPU cycles.\n"
546 "set record-burst-stats on|off\n"
547 " Set the option to enable display of RX and TX bursts.\n"
549 "set port (port_id) vf (vf_id) rx|tx on|off\n"
550 " Enable/Disable a VF receive/tranmit from a port\n\n"
552 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
554 " AUPE:accepts untagged VLAN;"
555 "ROPE:accept unicast hash\n\n"
556 " BAM:accepts broadcast packets;"
557 "MPE:accepts all multicast packets\n\n"
558 " Enable/Disable a VF receive mode of a port\n\n"
560 "set port (port_id) queue (queue_id) rate (rate_num)\n"
561 " Set rate limit for a queue of a port\n\n"
563 "set port (port_id) vf (vf_id) rate (rate_num) "
564 "queue_mask (queue_mask_value)\n"
565 " Set rate limit for queues in VF of a port\n\n"
567 "set port (port_id) mirror-rule (rule_id)"
568 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
569 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
570 " Set pool or vlan type mirror rule on a port.\n"
571 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
572 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
575 "set port (port_id) mirror-rule (rule_id)"
576 " (uplink-mirror|downlink-mirror) dst-pool"
577 " (pool_id) (on|off)\n"
578 " Set uplink or downlink type mirror rule on a port.\n"
579 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
580 " 0 on' enable mirror income traffic to pool 0.\n\n"
582 "reset port (port_id) mirror-rule (rule_id)\n"
583 " Reset a mirror rule.\n\n"
585 "set flush_rx (on|off)\n"
586 " Flush (default) or don't flush RX streams before"
587 " forwarding. Mainly used with PCAP drivers.\n\n"
589 "set bypass mode (normal|bypass|isolate) (port_id)\n"
590 " Set the bypass mode for the lowest port on bypass enabled"
593 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
594 "mode (normal|bypass|isolate) (port_id)\n"
595 " Set the event required to initiate specified bypass mode for"
596 " the lowest port on a bypass enabled NIC where:\n"
597 " timeout = enable bypass after watchdog timeout.\n"
598 " os_on = enable bypass when OS/board is powered on.\n"
599 " os_off = enable bypass when OS/board is powered off.\n"
600 " power_on = enable bypass when power supply is turned on.\n"
601 " power_off = enable bypass when power supply is turned off."
604 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
605 " Set the bypass watchdog timeout to 'n' seconds"
606 " where 0 = instant.\n\n"
608 "show bypass config (port_id)\n"
609 " Show the bypass configuration for a bypass enabled NIC"
610 " using the lowest port on the NIC.\n\n"
613 "create bonded device (mode) (socket)\n"
614 " Create a new bonded device with specific bonding mode and socket.\n\n"
616 "add bonding slave (slave_id) (port_id)\n"
617 " Add a slave device to a bonded device.\n\n"
619 "remove bonding slave (slave_id) (port_id)\n"
620 " Remove a slave device from a bonded device.\n\n"
622 "set bonding mode (value) (port_id)\n"
623 " Set the bonding mode on a bonded device.\n\n"
625 "set bonding primary (slave_id) (port_id)\n"
626 " Set the primary slave for a bonded device.\n\n"
628 "show bonding config (port_id)\n"
629 " Show the bonding config for port_id.\n\n"
631 "set bonding mac_addr (port_id) (address)\n"
632 " Set the MAC address of a bonded device.\n\n"
634 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
635 " Set Aggregation mode for IEEE802.3AD (mode 4)"
637 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
638 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
640 "set bonding mon_period (port_id) (value)\n"
641 " Set the bonding link status monitoring polling period in ms.\n\n"
643 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
644 " Enable/disable dedicated queues for LACP control traffic.\n\n"
647 "set link-up port (port_id)\n"
648 " Set link up for a port.\n\n"
650 "set link-down port (port_id)\n"
651 " Set link down for a port.\n\n"
653 "E-tag set insertion on port-tag-id (value)"
654 " port (port_id) vf (vf_id)\n"
655 " Enable E-tag insertion for a VF on a port\n\n"
657 "E-tag set insertion off port (port_id) vf (vf_id)\n"
658 " Disable E-tag insertion for a VF on a port\n\n"
660 "E-tag set stripping (on|off) port (port_id)\n"
661 " Enable/disable E-tag stripping on a port\n\n"
663 "E-tag set forwarding (on|off) port (port_id)\n"
664 " Enable/disable E-tag based forwarding"
667 "E-tag set filter add e-tag-id (value) dst-pool"
668 " (pool_id) port (port_id)\n"
669 " Add an E-tag forwarding filter on a port\n\n"
671 "E-tag set filter del e-tag-id (value) port (port_id)\n"
672 " Delete an E-tag forwarding filter on a port\n\n"
674 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
675 " Load a profile package on a port\n\n"
677 "ddp del (port_id) (backup_profile_path)\n"
678 " Delete a profile package from a port\n\n"
680 "ptype mapping get (port_id) (valid_only)\n"
681 " Get ptype mapping on a port\n\n"
683 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
684 " Replace target with the pkt_type in ptype mapping\n\n"
686 "ptype mapping reset (port_id)\n"
687 " Reset ptype mapping on a port\n\n"
689 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
690 " Update a ptype mapping item on a port\n\n"
692 "set port (port_id) ptype_mask (ptype_mask)\n"
693 " set packet types classification for a specific port\n\n"
695 "set port (port_id) queue-region region_id (value) "
696 "queue_start_index (value) queue_num (value)\n"
697 " Set a queue region on a port\n\n"
699 "set port (port_id) queue-region region_id (value) "
701 " Set a flowtype region index on a port\n\n"
703 "set port (port_id) queue-region UP (value) region_id (value)\n"
704 " Set the mapping of User Priority to "
705 "queue region on a port\n\n"
707 "set port (port_id) queue-region flush (on|off)\n"
708 " flush all queue region related configuration\n\n"
710 "show port meter cap (port_id)\n"
711 " Show port meter capability information\n\n"
713 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
714 " meter profile add - srtcm rfc 2697\n\n"
716 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
717 " meter profile add - trtcm rfc 2698\n\n"
719 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
720 " meter profile add - trtcm rfc 4115\n\n"
722 "del port meter profile (port_id) (profile_id)\n"
723 " meter profile delete\n\n"
725 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
726 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
727 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
728 "(dscp_tbl_entry63)]\n"
731 "enable port meter (port_id) (mtr_id)\n"
734 "disable port meter (port_id) (mtr_id)\n"
737 "del port meter (port_id) (mtr_id)\n"
740 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
741 " meter update meter profile\n\n"
743 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
744 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
745 " update meter dscp table entries\n\n"
747 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
748 "(action0) [(action1) (action2)]\n"
749 " meter update policer action\n\n"
751 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
752 " meter update stats\n\n"
754 "show port (port_id) queue-region\n"
755 " show all queue region related configuration info\n\n"
757 "set port (port_id) fec_mode auto|off|rs|baser\n"
758 " set fec mode for a specific port\n\n"
760 , list_pkt_forwarding_modes()
764 if (show_all || !strcmp(res->section, "ports")) {
770 "----------------\n\n"
772 "port start (port_id|all)\n"
773 " Start all ports or port_id.\n\n"
775 "port stop (port_id|all)\n"
776 " Stop all ports or port_id.\n\n"
778 "port close (port_id|all)\n"
779 " Close all ports or port_id.\n\n"
781 "port reset (port_id|all)\n"
782 " Reset all ports or port_id.\n\n"
784 "port attach (ident)\n"
785 " Attach physical or virtual dev by pci address or virtual device name\n\n"
787 "port detach (port_id)\n"
788 " Detach physical or virtual dev by port_id\n\n"
790 "port config (port_id|all)"
791 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
792 " duplex (half|full|auto)\n"
793 " Set speed and duplex for all ports or port_id\n\n"
795 "port config (port_id|all) loopback (mode)\n"
796 " Set loopback mode for all ports or port_id\n\n"
798 "port config all (rxq|txq|rxd|txd) (value)\n"
799 " Set number for rxq/txq/rxd/txd.\n\n"
801 "port config all max-pkt-len (value)\n"
802 " Set the max packet length.\n\n"
804 "port config all max-lro-pkt-size (value)\n"
805 " Set the max LRO aggregated packet size.\n\n"
807 "port config all drop-en (on|off)\n"
808 " Enable or disable packet drop on all RX queues of all ports when no "
809 "receive buffers available.\n\n"
811 "port config all rss (all|default|ip|tcp|udp|sctp|"
812 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|level-default|"
813 "level-outer|level-inner|<flowtype_id>)\n"
814 " Set the RSS mode.\n\n"
816 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
817 " Set the RSS redirection table.\n\n"
819 "port config (port_id) dcb vt (on|off) (traffic_class)"
821 " Set the DCB mode.\n\n"
823 "port config all burst (value)\n"
824 " Set the number of packets per burst.\n\n"
826 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
828 " Set the ring prefetch/host/writeback threshold"
829 " for tx/rx queue.\n\n"
831 "port config all (txfreet|txrst|rxfreet) (value)\n"
832 " Set free threshold for rx/tx, or set"
833 " tx rs bit threshold.\n\n"
834 "port config mtu X value\n"
835 " Set the MTU of port X to a given value\n\n"
837 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
838 " Set a rx/tx queue's ring size configuration, the new"
839 " value will take effect after command that (re-)start the port"
840 " or command that setup the specific queue\n\n"
842 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
843 " Start/stop a rx/tx queue of port X. Only take effect"
844 " when port X is started\n\n"
846 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
847 " Switch on/off a deferred start of port X rx/tx queue. Only"
848 " take effect when port X is stopped.\n\n"
850 "port (port_id) (rxq|txq) (queue_id) setup\n"
851 " Setup a rx/tx queue of port X.\n\n"
853 "port config (port_id|all) l2-tunnel E-tag ether-type"
855 " Set the value of E-tag ether-type.\n\n"
857 "port config (port_id|all) l2-tunnel E-tag"
858 " (enable|disable)\n"
859 " Enable/disable the E-tag support.\n\n"
861 "port config (port_id) pctype mapping reset\n"
862 " Reset flow type to pctype mapping on a port\n\n"
864 "port config (port_id) pctype mapping update"
865 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
866 " Update a flow type to pctype mapping item on a port\n\n"
868 "port config (port_id) pctype (pctype_id) hash_inset|"
869 "fdir_inset|fdir_flx_inset get|set|clear field\n"
871 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
873 "port config (port_id) pctype (pctype_id) hash_inset|"
874 "fdir_inset|fdir_flx_inset clear all"
875 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
877 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
878 " Add/remove UDP tunnel port for tunneling offload\n\n"
880 "port config <port_id> rx_offload vlan_strip|"
881 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
882 "outer_ipv4_cksum|macsec_strip|header_split|"
883 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
884 "buffer_split|timestamp|security|keep_crc on|off\n"
885 " Enable or disable a per port Rx offloading"
886 " on all Rx queues of a port\n\n"
888 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
889 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
890 "outer_ipv4_cksum|macsec_strip|header_split|"
891 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
892 "buffer_split|timestamp|security|keep_crc on|off\n"
893 " Enable or disable a per queue Rx offloading"
894 " only on a specific Rx queue\n\n"
896 "port config (port_id) tx_offload vlan_insert|"
897 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
898 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
899 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
900 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
902 " Enable or disable a per port Tx offloading"
903 " on all Tx queues of a port\n\n"
905 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
906 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
907 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
908 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
909 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
911 " Enable or disable a per queue Tx offloading"
912 " only on a specific Tx queue\n\n"
914 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
915 " Load an eBPF program as a callback"
916 " for particular RX/TX queue\n\n"
918 "bpf-unload rx|tx (port) (queue)\n"
919 " Unload previously loaded eBPF program"
920 " for particular RX/TX queue\n\n"
922 "port config (port_id) tx_metadata (value)\n"
923 " Set Tx metadata value per port. Testpmd will add this value"
924 " to any Tx packet sent from this port\n\n"
926 "port config (port_id) dynf (name) set|clear\n"
927 " Register a dynf and Set/clear this flag on Tx. "
928 "Testpmd will set this value to any Tx packet "
929 "sent from this port\n\n"
933 if (show_all || !strcmp(res->section, "registers")) {
941 "read reg (port_id) (address)\n"
942 " Display value of a port register.\n\n"
944 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
945 " Display a port register bit field.\n\n"
947 "read regbit (port_id) (address) (bit_x)\n"
948 " Display a single port register bit.\n\n"
950 "write reg (port_id) (address) (value)\n"
951 " Set value of a port register.\n\n"
953 "write regfield (port_id) (address) (bit_x) (bit_y)"
955 " Set bit field of a port register.\n\n"
957 "write regbit (port_id) (address) (bit_x) (value)\n"
958 " Set single bit value of a port register.\n\n"
961 if (show_all || !strcmp(res->section, "filters")) {
969 "flow_director_filter (port_id) mode IP (add|del|update)"
970 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
971 " src (src_ip_address) dst (dst_ip_address)"
972 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
973 " vlan (vlan_value) flexbytes (flexbytes_value)"
974 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
975 " fd_id (fd_id_value)\n"
976 " Add/Del an IP type flow director filter.\n\n"
978 "flow_director_filter (port_id) mode IP (add|del|update)"
979 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
980 " src (src_ip_address) (src_port)"
981 " dst (dst_ip_address) (dst_port)"
982 " tos (tos_value) ttl (ttl_value)"
983 " vlan (vlan_value) flexbytes (flexbytes_value)"
984 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
985 " fd_id (fd_id_value)\n"
986 " Add/Del an UDP/TCP type flow director filter.\n\n"
988 "flow_director_filter (port_id) mode IP (add|del|update)"
989 " flow (ipv4-sctp|ipv6-sctp)"
990 " src (src_ip_address) (src_port)"
991 " dst (dst_ip_address) (dst_port)"
992 " tag (verification_tag) "
993 " tos (tos_value) ttl (ttl_value)"
995 " flexbytes (flexbytes_value) (drop|fwd)"
996 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
997 " Add/Del a SCTP type flow director filter.\n\n"
999 "flow_director_filter (port_id) mode IP (add|del|update)"
1000 " flow l2_payload ether (ethertype)"
1001 " flexbytes (flexbytes_value) (drop|fwd)"
1002 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1003 " Add/Del a l2 payload type flow director filter.\n\n"
1005 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1006 " mac (mac_address) vlan (vlan_value)"
1007 " flexbytes (flexbytes_value) (drop|fwd)"
1008 " queue (queue_id) fd_id (fd_id_value)\n"
1009 " Add/Del a MAC-VLAN flow director filter.\n\n"
1011 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1012 " mac (mac_address) vlan (vlan_value)"
1013 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1014 " flexbytes (flexbytes_value) (drop|fwd)"
1015 " queue (queue_id) fd_id (fd_id_value)\n"
1016 " Add/Del a Tunnel flow director filter.\n\n"
1018 "flow_director_filter (port_id) mode raw (add|del|update)"
1019 " flow (flow_id) (drop|fwd) queue (queue_id)"
1020 " fd_id (fd_id_value) packet (packet file name)\n"
1021 " Add/Del a raw type flow director filter.\n\n"
1023 "flush_flow_director (port_id)\n"
1024 " Flush all flow director entries of a device.\n\n"
1026 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1027 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1028 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1029 " Set flow director IP mask.\n\n"
1031 "flow_director_mask (port_id) mode MAC-VLAN"
1032 " vlan (vlan_value)\n"
1033 " Set flow director MAC-VLAN mask.\n\n"
1035 "flow_director_mask (port_id) mode Tunnel"
1036 " vlan (vlan_value) mac (mac_value)"
1037 " tunnel-type (tunnel_type_value)"
1038 " tunnel-id (tunnel_id_value)\n"
1039 " Set flow director Tunnel mask.\n\n"
1041 "flow_director_flex_mask (port_id)"
1042 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1043 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1045 " Configure mask of flex payload.\n\n"
1047 "flow_director_flex_payload (port_id)"
1048 " (raw|l2|l3|l4) (config)\n"
1049 " Configure flex payload selection.\n\n"
1051 "set_fdir_input_set (port_id) "
1052 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1053 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1054 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1055 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1056 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1057 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1058 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1060 " Set the input set for FDir.\n\n"
1062 "flow validate {port_id}"
1063 " [group {group_id}] [priority {level}]"
1064 " [ingress] [egress]"
1065 " pattern {item} [/ {item} [...]] / end"
1066 " actions {action} [/ {action} [...]] / end\n"
1067 " Check whether a flow rule can be created.\n\n"
1069 "flow create {port_id}"
1070 " [group {group_id}] [priority {level}]"
1071 " [ingress] [egress]"
1072 " pattern {item} [/ {item} [...]] / end"
1073 " actions {action} [/ {action} [...]] / end\n"
1074 " Create a flow rule.\n\n"
1076 "flow destroy {port_id} rule {rule_id} [...]\n"
1077 " Destroy specific flow rules.\n\n"
1079 "flow flush {port_id}\n"
1080 " Destroy all flow rules.\n\n"
1082 "flow query {port_id} {rule_id} {action}\n"
1083 " Query an existing flow rule.\n\n"
1085 "flow list {port_id} [group {group_id}] [...]\n"
1086 " List existing flow rules sorted by priority,"
1087 " filtered by group identifiers.\n\n"
1089 "flow isolate {port_id} {boolean}\n"
1090 " Restrict ingress traffic to the defined"
1093 "flow aged {port_id} [destroy]\n"
1094 " List and destroy aged flows"
1097 "flow shared_action {port_id} create"
1098 " [action_id {shared_action_id}]"
1099 " [ingress] [egress]"
1100 " action {action} / end\n"
1101 " Create shared action.\n\n"
1103 "flow shared_action {port_id} update"
1104 " {shared_action_id} action {action} / end\n"
1105 " Update shared action.\n\n"
1107 "flow shared_action {port_id} destroy"
1108 " action_id {shared_action_id} [...]\n"
1109 " Destroy specific shared actions.\n\n"
1111 "flow shared_action {port_id} query"
1112 " {shared_action_id}\n"
1113 " Query an existing shared action.\n\n"
1115 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1116 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1117 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1118 " Configure the VXLAN encapsulation for flows.\n\n"
1120 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1121 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1122 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1123 " eth-dst (eth-dst)\n"
1124 " Configure the VXLAN encapsulation for flows.\n\n"
1126 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1127 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1128 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1129 " eth-dst (eth-dst)\n"
1130 " Configure the VXLAN encapsulation for flows.\n\n"
1132 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1133 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1135 " Configure the NVGRE encapsulation for flows.\n\n"
1137 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1138 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1139 " eth-src (eth-src) eth-dst (eth-dst)\n"
1140 " Configure the NVGRE encapsulation for flows.\n\n"
1142 "set raw_encap {flow items}\n"
1143 " Configure the encapsulation with raw data.\n\n"
1145 "set raw_decap {flow items}\n"
1146 " Configure the decapsulation with raw data.\n\n"
1151 if (show_all || !strcmp(res->section, "traffic_management")) {
1155 "Traffic Management:\n"
1157 "show port tm cap (port_id)\n"
1158 " Display the port TM capability.\n\n"
1160 "show port tm level cap (port_id) (level_id)\n"
1161 " Display the port TM hierarchical level capability.\n\n"
1163 "show port tm node cap (port_id) (node_id)\n"
1164 " Display the port TM node capability.\n\n"
1166 "show port tm node type (port_id) (node_id)\n"
1167 " Display the port TM node type.\n\n"
1169 "show port tm node stats (port_id) (node_id) (clear)\n"
1170 " Display the port TM node stats.\n\n"
1172 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1173 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1174 " (packet_length_adjust) (packet_mode)\n"
1175 " Add port tm node private shaper profile.\n\n"
1177 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1178 " Delete port tm node private shaper profile.\n\n"
1180 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1181 " (shaper_profile_id)\n"
1182 " Add/update port tm node shared shaper.\n\n"
1184 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1185 " Delete port tm node shared shaper.\n\n"
1187 "set port tm node shaper profile (port_id) (node_id)"
1188 " (shaper_profile_id)\n"
1189 " Set port tm node shaper profile.\n\n"
1191 "add port tm node wred profile (port_id) (wred_profile_id)"
1192 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1193 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1194 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1195 " Add port tm node wred profile.\n\n"
1197 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1198 " Delete port tm node wred profile.\n\n"
1200 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1201 " (priority) (weight) (level_id) (shaper_profile_id)"
1202 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1203 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1204 " Add port tm nonleaf node.\n\n"
1206 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1207 " (priority) (weight) (level_id) (shaper_profile_id)"
1208 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1209 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1210 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1212 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1213 " (priority) (weight) (level_id) (shaper_profile_id)"
1214 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1215 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1216 " Add port tm leaf node.\n\n"
1218 "del port tm node (port_id) (node_id)\n"
1219 " Delete port tm node.\n\n"
1221 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1222 " (priority) (weight)\n"
1223 " Set port tm node parent.\n\n"
1225 "suspend port tm node (port_id) (node_id)"
1226 " Suspend tm node.\n\n"
1228 "resume port tm node (port_id) (node_id)"
1229 " Resume tm node.\n\n"
1231 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1232 " Commit tm hierarchy.\n\n"
1234 "set port tm mark ip_ecn (port) (green) (yellow)"
1236 " Enables/Disables the traffic management marking"
1237 " for IP ECN (Explicit Congestion Notification)"
1238 " packets on a given port\n\n"
1240 "set port tm mark ip_dscp (port) (green) (yellow)"
1242 " Enables/Disables the traffic management marking"
1243 " on the port for IP dscp packets\n\n"
1245 "set port tm mark vlan_dei (port) (green) (yellow)"
1247 " Enables/Disables the traffic management marking"
1248 " on the port for VLAN packets with DEI enabled\n\n"
1252 if (show_all || !strcmp(res->section, "devices")) {
1256 "Device Operations:\n"
1258 "device detach (identifier)\n"
1259 " Detach device by identifier.\n\n"
1265 cmdline_parse_token_string_t cmd_help_long_help =
1266 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1268 cmdline_parse_token_string_t cmd_help_long_section =
1269 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1270 "all#control#display#config#"
1271 "ports#registers#filters#traffic_management#devices");
1273 cmdline_parse_inst_t cmd_help_long = {
1274 .f = cmd_help_long_parsed,
1276 .help_str = "help all|control|display|config|ports|register|"
1277 "filters|traffic_management|devices: "
1280 (void *)&cmd_help_long_help,
1281 (void *)&cmd_help_long_section,
1287 /* *** start/stop/close all ports *** */
1288 struct cmd_operate_port_result {
1289 cmdline_fixed_string_t keyword;
1290 cmdline_fixed_string_t name;
1291 cmdline_fixed_string_t value;
1294 static void cmd_operate_port_parsed(void *parsed_result,
1295 __rte_unused struct cmdline *cl,
1296 __rte_unused void *data)
1298 struct cmd_operate_port_result *res = parsed_result;
1300 if (!strcmp(res->name, "start"))
1301 start_port(RTE_PORT_ALL);
1302 else if (!strcmp(res->name, "stop"))
1303 stop_port(RTE_PORT_ALL);
1304 else if (!strcmp(res->name, "close"))
1305 close_port(RTE_PORT_ALL);
1306 else if (!strcmp(res->name, "reset"))
1307 reset_port(RTE_PORT_ALL);
1309 printf("Unknown parameter\n");
1312 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1313 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1315 cmdline_parse_token_string_t cmd_operate_port_all_port =
1316 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1317 "start#stop#close#reset");
1318 cmdline_parse_token_string_t cmd_operate_port_all_all =
1319 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1321 cmdline_parse_inst_t cmd_operate_port = {
1322 .f = cmd_operate_port_parsed,
1324 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1326 (void *)&cmd_operate_port_all_cmd,
1327 (void *)&cmd_operate_port_all_port,
1328 (void *)&cmd_operate_port_all_all,
1333 /* *** start/stop/close specific port *** */
1334 struct cmd_operate_specific_port_result {
1335 cmdline_fixed_string_t keyword;
1336 cmdline_fixed_string_t name;
1340 static void cmd_operate_specific_port_parsed(void *parsed_result,
1341 __rte_unused struct cmdline *cl,
1342 __rte_unused void *data)
1344 struct cmd_operate_specific_port_result *res = parsed_result;
1346 if (!strcmp(res->name, "start"))
1347 start_port(res->value);
1348 else if (!strcmp(res->name, "stop"))
1349 stop_port(res->value);
1350 else if (!strcmp(res->name, "close"))
1351 close_port(res->value);
1352 else if (!strcmp(res->name, "reset"))
1353 reset_port(res->value);
1355 printf("Unknown parameter\n");
1358 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1359 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1361 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1362 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1363 name, "start#stop#close#reset");
1364 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1365 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1368 cmdline_parse_inst_t cmd_operate_specific_port = {
1369 .f = cmd_operate_specific_port_parsed,
1371 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1373 (void *)&cmd_operate_specific_port_cmd,
1374 (void *)&cmd_operate_specific_port_port,
1375 (void *)&cmd_operate_specific_port_id,
1380 /* *** enable port setup (after attach) via iterator or event *** */
1381 struct cmd_set_port_setup_on_result {
1382 cmdline_fixed_string_t set;
1383 cmdline_fixed_string_t port;
1384 cmdline_fixed_string_t setup;
1385 cmdline_fixed_string_t on;
1386 cmdline_fixed_string_t mode;
1389 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1390 __rte_unused struct cmdline *cl,
1391 __rte_unused void *data)
1393 struct cmd_set_port_setup_on_result *res = parsed_result;
1395 if (strcmp(res->mode, "event") == 0)
1396 setup_on_probe_event = true;
1397 else if (strcmp(res->mode, "iterator") == 0)
1398 setup_on_probe_event = false;
1400 printf("Unknown mode\n");
1403 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1404 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1406 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1407 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1409 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1410 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1412 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1413 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1415 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1416 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1417 mode, "iterator#event");
1419 cmdline_parse_inst_t cmd_set_port_setup_on = {
1420 .f = cmd_set_port_setup_on_parsed,
1422 .help_str = "set port setup on iterator|event",
1424 (void *)&cmd_set_port_setup_on_set,
1425 (void *)&cmd_set_port_setup_on_port,
1426 (void *)&cmd_set_port_setup_on_setup,
1427 (void *)&cmd_set_port_setup_on_on,
1428 (void *)&cmd_set_port_setup_on_mode,
1433 /* *** attach a specified port *** */
1434 struct cmd_operate_attach_port_result {
1435 cmdline_fixed_string_t port;
1436 cmdline_fixed_string_t keyword;
1437 cmdline_multi_string_t identifier;
1440 static void cmd_operate_attach_port_parsed(void *parsed_result,
1441 __rte_unused struct cmdline *cl,
1442 __rte_unused void *data)
1444 struct cmd_operate_attach_port_result *res = parsed_result;
1446 if (!strcmp(res->keyword, "attach"))
1447 attach_port(res->identifier);
1449 printf("Unknown parameter\n");
1452 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1453 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1455 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1456 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1458 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1459 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1460 identifier, TOKEN_STRING_MULTI);
1462 cmdline_parse_inst_t cmd_operate_attach_port = {
1463 .f = cmd_operate_attach_port_parsed,
1465 .help_str = "port attach <identifier>: "
1466 "(identifier: pci address or virtual dev name)",
1468 (void *)&cmd_operate_attach_port_port,
1469 (void *)&cmd_operate_attach_port_keyword,
1470 (void *)&cmd_operate_attach_port_identifier,
1475 /* *** detach a specified port *** */
1476 struct cmd_operate_detach_port_result {
1477 cmdline_fixed_string_t port;
1478 cmdline_fixed_string_t keyword;
1482 static void cmd_operate_detach_port_parsed(void *parsed_result,
1483 __rte_unused struct cmdline *cl,
1484 __rte_unused void *data)
1486 struct cmd_operate_detach_port_result *res = parsed_result;
1488 if (!strcmp(res->keyword, "detach")) {
1489 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1490 detach_port_device(res->port_id);
1492 printf("Unknown parameter\n");
1496 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1497 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1499 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1500 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1502 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1503 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1506 cmdline_parse_inst_t cmd_operate_detach_port = {
1507 .f = cmd_operate_detach_port_parsed,
1509 .help_str = "port detach <port_id>",
1511 (void *)&cmd_operate_detach_port_port,
1512 (void *)&cmd_operate_detach_port_keyword,
1513 (void *)&cmd_operate_detach_port_port_id,
1518 /* *** detach device by identifier *** */
1519 struct cmd_operate_detach_device_result {
1520 cmdline_fixed_string_t device;
1521 cmdline_fixed_string_t keyword;
1522 cmdline_fixed_string_t identifier;
1525 static void cmd_operate_detach_device_parsed(void *parsed_result,
1526 __rte_unused struct cmdline *cl,
1527 __rte_unused void *data)
1529 struct cmd_operate_detach_device_result *res = parsed_result;
1531 if (!strcmp(res->keyword, "detach"))
1532 detach_devargs(res->identifier);
1534 printf("Unknown parameter\n");
1537 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1538 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1540 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1541 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1543 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1544 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1547 cmdline_parse_inst_t cmd_operate_detach_device = {
1548 .f = cmd_operate_detach_device_parsed,
1550 .help_str = "device detach <identifier>:"
1551 "(identifier: pci address or virtual dev name)",
1553 (void *)&cmd_operate_detach_device_device,
1554 (void *)&cmd_operate_detach_device_keyword,
1555 (void *)&cmd_operate_detach_device_identifier,
1559 /* *** configure speed for all ports *** */
1560 struct cmd_config_speed_all {
1561 cmdline_fixed_string_t port;
1562 cmdline_fixed_string_t keyword;
1563 cmdline_fixed_string_t all;
1564 cmdline_fixed_string_t item1;
1565 cmdline_fixed_string_t item2;
1566 cmdline_fixed_string_t value1;
1567 cmdline_fixed_string_t value2;
1571 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1576 if (!strcmp(duplexstr, "half")) {
1577 duplex = ETH_LINK_HALF_DUPLEX;
1578 } else if (!strcmp(duplexstr, "full")) {
1579 duplex = ETH_LINK_FULL_DUPLEX;
1580 } else if (!strcmp(duplexstr, "auto")) {
1581 duplex = ETH_LINK_FULL_DUPLEX;
1583 printf("Unknown duplex parameter\n");
1587 if (!strcmp(speedstr, "10")) {
1588 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1589 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1590 } else if (!strcmp(speedstr, "100")) {
1591 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1592 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1594 if (duplex != ETH_LINK_FULL_DUPLEX) {
1595 printf("Invalid speed/duplex parameters\n");
1598 if (!strcmp(speedstr, "1000")) {
1599 *speed = ETH_LINK_SPEED_1G;
1600 } else if (!strcmp(speedstr, "10000")) {
1601 *speed = ETH_LINK_SPEED_10G;
1602 } else if (!strcmp(speedstr, "25000")) {
1603 *speed = ETH_LINK_SPEED_25G;
1604 } else if (!strcmp(speedstr, "40000")) {
1605 *speed = ETH_LINK_SPEED_40G;
1606 } else if (!strcmp(speedstr, "50000")) {
1607 *speed = ETH_LINK_SPEED_50G;
1608 } else if (!strcmp(speedstr, "100000")) {
1609 *speed = ETH_LINK_SPEED_100G;
1610 } else if (!strcmp(speedstr, "200000")) {
1611 *speed = ETH_LINK_SPEED_200G;
1612 } else if (!strcmp(speedstr, "auto")) {
1613 *speed = ETH_LINK_SPEED_AUTONEG;
1615 printf("Unknown speed parameter\n");
1624 cmd_config_speed_all_parsed(void *parsed_result,
1625 __rte_unused struct cmdline *cl,
1626 __rte_unused void *data)
1628 struct cmd_config_speed_all *res = parsed_result;
1629 uint32_t link_speed;
1632 if (!all_ports_stopped()) {
1633 printf("Please stop all ports first\n");
1637 if (parse_and_check_speed_duplex(res->value1, res->value2,
1641 RTE_ETH_FOREACH_DEV(pid) {
1642 ports[pid].dev_conf.link_speeds = link_speed;
1645 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1648 cmdline_parse_token_string_t cmd_config_speed_all_port =
1649 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1650 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1651 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1653 cmdline_parse_token_string_t cmd_config_speed_all_all =
1654 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1655 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1656 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1657 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1658 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1659 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1660 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1661 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1662 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1663 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1666 cmdline_parse_inst_t cmd_config_speed_all = {
1667 .f = cmd_config_speed_all_parsed,
1669 .help_str = "port config all speed "
1670 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1673 (void *)&cmd_config_speed_all_port,
1674 (void *)&cmd_config_speed_all_keyword,
1675 (void *)&cmd_config_speed_all_all,
1676 (void *)&cmd_config_speed_all_item1,
1677 (void *)&cmd_config_speed_all_value1,
1678 (void *)&cmd_config_speed_all_item2,
1679 (void *)&cmd_config_speed_all_value2,
1684 /* *** configure speed for specific port *** */
1685 struct cmd_config_speed_specific {
1686 cmdline_fixed_string_t port;
1687 cmdline_fixed_string_t keyword;
1689 cmdline_fixed_string_t item1;
1690 cmdline_fixed_string_t item2;
1691 cmdline_fixed_string_t value1;
1692 cmdline_fixed_string_t value2;
1696 cmd_config_speed_specific_parsed(void *parsed_result,
1697 __rte_unused struct cmdline *cl,
1698 __rte_unused void *data)
1700 struct cmd_config_speed_specific *res = parsed_result;
1701 uint32_t link_speed;
1703 if (!all_ports_stopped()) {
1704 printf("Please stop all ports first\n");
1708 if (port_id_is_invalid(res->id, ENABLED_WARN))
1711 if (parse_and_check_speed_duplex(res->value1, res->value2,
1715 ports[res->id].dev_conf.link_speeds = link_speed;
1717 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1721 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1722 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1724 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1725 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1727 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1728 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1729 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1730 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1732 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1733 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1734 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1735 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1736 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1738 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1739 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1742 cmdline_parse_inst_t cmd_config_speed_specific = {
1743 .f = cmd_config_speed_specific_parsed,
1745 .help_str = "port config <port_id> speed "
1746 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1749 (void *)&cmd_config_speed_specific_port,
1750 (void *)&cmd_config_speed_specific_keyword,
1751 (void *)&cmd_config_speed_specific_id,
1752 (void *)&cmd_config_speed_specific_item1,
1753 (void *)&cmd_config_speed_specific_value1,
1754 (void *)&cmd_config_speed_specific_item2,
1755 (void *)&cmd_config_speed_specific_value2,
1760 /* *** configure loopback for all ports *** */
1761 struct cmd_config_loopback_all {
1762 cmdline_fixed_string_t port;
1763 cmdline_fixed_string_t keyword;
1764 cmdline_fixed_string_t all;
1765 cmdline_fixed_string_t item;
1770 cmd_config_loopback_all_parsed(void *parsed_result,
1771 __rte_unused struct cmdline *cl,
1772 __rte_unused void *data)
1774 struct cmd_config_loopback_all *res = parsed_result;
1777 if (!all_ports_stopped()) {
1778 printf("Please stop all ports first\n");
1782 RTE_ETH_FOREACH_DEV(pid) {
1783 ports[pid].dev_conf.lpbk_mode = res->mode;
1786 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1789 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1790 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1791 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1792 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1794 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1795 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1796 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1797 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1799 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1800 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1802 cmdline_parse_inst_t cmd_config_loopback_all = {
1803 .f = cmd_config_loopback_all_parsed,
1805 .help_str = "port config all loopback <mode>",
1807 (void *)&cmd_config_loopback_all_port,
1808 (void *)&cmd_config_loopback_all_keyword,
1809 (void *)&cmd_config_loopback_all_all,
1810 (void *)&cmd_config_loopback_all_item,
1811 (void *)&cmd_config_loopback_all_mode,
1816 /* *** configure loopback for specific port *** */
1817 struct cmd_config_loopback_specific {
1818 cmdline_fixed_string_t port;
1819 cmdline_fixed_string_t keyword;
1821 cmdline_fixed_string_t item;
1826 cmd_config_loopback_specific_parsed(void *parsed_result,
1827 __rte_unused struct cmdline *cl,
1828 __rte_unused void *data)
1830 struct cmd_config_loopback_specific *res = parsed_result;
1832 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1835 if (!port_is_stopped(res->port_id)) {
1836 printf("Please stop port %u first\n", res->port_id);
1840 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1842 cmd_reconfig_device_queue(res->port_id, 1, 1);
1846 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1847 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1849 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1850 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1852 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1853 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1855 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1856 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1858 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1859 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1862 cmdline_parse_inst_t cmd_config_loopback_specific = {
1863 .f = cmd_config_loopback_specific_parsed,
1865 .help_str = "port config <port_id> loopback <mode>",
1867 (void *)&cmd_config_loopback_specific_port,
1868 (void *)&cmd_config_loopback_specific_keyword,
1869 (void *)&cmd_config_loopback_specific_id,
1870 (void *)&cmd_config_loopback_specific_item,
1871 (void *)&cmd_config_loopback_specific_mode,
1876 /* *** configure txq/rxq, txd/rxd *** */
1877 struct cmd_config_rx_tx {
1878 cmdline_fixed_string_t port;
1879 cmdline_fixed_string_t keyword;
1880 cmdline_fixed_string_t all;
1881 cmdline_fixed_string_t name;
1886 cmd_config_rx_tx_parsed(void *parsed_result,
1887 __rte_unused struct cmdline *cl,
1888 __rte_unused void *data)
1890 struct cmd_config_rx_tx *res = parsed_result;
1892 if (!all_ports_stopped()) {
1893 printf("Please stop all ports first\n");
1896 if (!strcmp(res->name, "rxq")) {
1897 if (!res->value && !nb_txq) {
1898 printf("Warning: Either rx or tx queues should be non zero\n");
1901 if (check_nb_rxq(res->value) != 0)
1903 nb_rxq = res->value;
1905 else if (!strcmp(res->name, "txq")) {
1906 if (!res->value && !nb_rxq) {
1907 printf("Warning: Either rx or tx queues should be non zero\n");
1910 if (check_nb_txq(res->value) != 0)
1912 nb_txq = res->value;
1914 else if (!strcmp(res->name, "rxd")) {
1915 if (check_nb_rxd(res->value) != 0)
1917 nb_rxd = res->value;
1918 } else if (!strcmp(res->name, "txd")) {
1919 if (check_nb_txd(res->value) != 0)
1922 nb_txd = res->value;
1924 printf("Unknown parameter\n");
1932 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1935 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1936 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1937 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1938 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1939 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1940 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1941 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1942 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1944 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1945 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1947 cmdline_parse_inst_t cmd_config_rx_tx = {
1948 .f = cmd_config_rx_tx_parsed,
1950 .help_str = "port config all rxq|txq|rxd|txd <value>",
1952 (void *)&cmd_config_rx_tx_port,
1953 (void *)&cmd_config_rx_tx_keyword,
1954 (void *)&cmd_config_rx_tx_all,
1955 (void *)&cmd_config_rx_tx_name,
1956 (void *)&cmd_config_rx_tx_value,
1961 /* *** config max packet length *** */
1962 struct cmd_config_max_pkt_len_result {
1963 cmdline_fixed_string_t port;
1964 cmdline_fixed_string_t keyword;
1965 cmdline_fixed_string_t all;
1966 cmdline_fixed_string_t name;
1971 cmd_config_max_pkt_len_parsed(void *parsed_result,
1972 __rte_unused struct cmdline *cl,
1973 __rte_unused void *data)
1975 struct cmd_config_max_pkt_len_result *res = parsed_result;
1978 if (!all_ports_stopped()) {
1979 printf("Please stop all ports first\n");
1983 RTE_ETH_FOREACH_DEV(pid) {
1984 struct rte_port *port = &ports[pid];
1985 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1987 if (!strcmp(res->name, "max-pkt-len")) {
1988 if (res->value < RTE_ETHER_MIN_LEN) {
1989 printf("max-pkt-len can not be less than %d\n",
1993 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1996 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1997 if (res->value > RTE_ETHER_MAX_LEN)
1998 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2000 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2001 port->dev_conf.rxmode.offloads = rx_offloads;
2003 printf("Unknown parameter\n");
2010 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2013 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2014 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2016 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2017 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2019 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2020 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2022 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2023 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2025 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2026 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2029 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2030 .f = cmd_config_max_pkt_len_parsed,
2032 .help_str = "port config all max-pkt-len <value>",
2034 (void *)&cmd_config_max_pkt_len_port,
2035 (void *)&cmd_config_max_pkt_len_keyword,
2036 (void *)&cmd_config_max_pkt_len_all,
2037 (void *)&cmd_config_max_pkt_len_name,
2038 (void *)&cmd_config_max_pkt_len_value,
2043 /* *** config max LRO aggregated packet size *** */
2044 struct cmd_config_max_lro_pkt_size_result {
2045 cmdline_fixed_string_t port;
2046 cmdline_fixed_string_t keyword;
2047 cmdline_fixed_string_t all;
2048 cmdline_fixed_string_t name;
2053 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2054 __rte_unused struct cmdline *cl,
2055 __rte_unused void *data)
2057 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2060 if (!all_ports_stopped()) {
2061 printf("Please stop all ports first\n");
2065 RTE_ETH_FOREACH_DEV(pid) {
2066 struct rte_port *port = &ports[pid];
2068 if (!strcmp(res->name, "max-lro-pkt-size")) {
2070 port->dev_conf.rxmode.max_lro_pkt_size)
2073 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2075 printf("Unknown parameter\n");
2082 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2085 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2086 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2088 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2089 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2091 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2092 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2094 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2095 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2096 name, "max-lro-pkt-size");
2097 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2098 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2101 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2102 .f = cmd_config_max_lro_pkt_size_parsed,
2104 .help_str = "port config all max-lro-pkt-size <value>",
2106 (void *)&cmd_config_max_lro_pkt_size_port,
2107 (void *)&cmd_config_max_lro_pkt_size_keyword,
2108 (void *)&cmd_config_max_lro_pkt_size_all,
2109 (void *)&cmd_config_max_lro_pkt_size_name,
2110 (void *)&cmd_config_max_lro_pkt_size_value,
2115 /* *** configure port MTU *** */
2116 struct cmd_config_mtu_result {
2117 cmdline_fixed_string_t port;
2118 cmdline_fixed_string_t keyword;
2119 cmdline_fixed_string_t mtu;
2125 cmd_config_mtu_parsed(void *parsed_result,
2126 __rte_unused struct cmdline *cl,
2127 __rte_unused void *data)
2129 struct cmd_config_mtu_result *res = parsed_result;
2131 if (res->value < RTE_ETHER_MIN_LEN) {
2132 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2135 port_mtu_set(res->port_id, res->value);
2138 cmdline_parse_token_string_t cmd_config_mtu_port =
2139 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2141 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2142 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2144 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2145 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2147 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2148 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2149 cmdline_parse_token_num_t cmd_config_mtu_value =
2150 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2152 cmdline_parse_inst_t cmd_config_mtu = {
2153 .f = cmd_config_mtu_parsed,
2155 .help_str = "port config mtu <port_id> <value>",
2157 (void *)&cmd_config_mtu_port,
2158 (void *)&cmd_config_mtu_keyword,
2159 (void *)&cmd_config_mtu_mtu,
2160 (void *)&cmd_config_mtu_port_id,
2161 (void *)&cmd_config_mtu_value,
2166 /* *** configure rx mode *** */
2167 struct cmd_config_rx_mode_flag {
2168 cmdline_fixed_string_t port;
2169 cmdline_fixed_string_t keyword;
2170 cmdline_fixed_string_t all;
2171 cmdline_fixed_string_t name;
2172 cmdline_fixed_string_t value;
2176 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2177 __rte_unused struct cmdline *cl,
2178 __rte_unused void *data)
2180 struct cmd_config_rx_mode_flag *res = parsed_result;
2182 if (!all_ports_stopped()) {
2183 printf("Please stop all ports first\n");
2187 if (!strcmp(res->name, "drop-en")) {
2188 if (!strcmp(res->value, "on"))
2190 else if (!strcmp(res->value, "off"))
2193 printf("Unknown parameter\n");
2197 printf("Unknown parameter\n");
2203 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2206 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2207 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2208 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2209 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2211 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2212 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2213 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2214 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2216 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2217 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2220 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2221 .f = cmd_config_rx_mode_flag_parsed,
2223 .help_str = "port config all drop-en on|off",
2225 (void *)&cmd_config_rx_mode_flag_port,
2226 (void *)&cmd_config_rx_mode_flag_keyword,
2227 (void *)&cmd_config_rx_mode_flag_all,
2228 (void *)&cmd_config_rx_mode_flag_name,
2229 (void *)&cmd_config_rx_mode_flag_value,
2234 /* *** configure rss *** */
2235 struct cmd_config_rss {
2236 cmdline_fixed_string_t port;
2237 cmdline_fixed_string_t keyword;
2238 cmdline_fixed_string_t all;
2239 cmdline_fixed_string_t name;
2240 cmdline_fixed_string_t value;
2244 cmd_config_rss_parsed(void *parsed_result,
2245 __rte_unused struct cmdline *cl,
2246 __rte_unused void *data)
2248 struct cmd_config_rss *res = parsed_result;
2249 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2250 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2251 int use_default = 0;
2252 int all_updated = 1;
2257 if (!strcmp(res->value, "all"))
2258 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2259 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2260 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2261 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU;
2262 else if (!strcmp(res->value, "eth"))
2263 rss_conf.rss_hf = ETH_RSS_ETH;
2264 else if (!strcmp(res->value, "vlan"))
2265 rss_conf.rss_hf = ETH_RSS_VLAN;
2266 else if (!strcmp(res->value, "ip"))
2267 rss_conf.rss_hf = ETH_RSS_IP;
2268 else if (!strcmp(res->value, "udp"))
2269 rss_conf.rss_hf = ETH_RSS_UDP;
2270 else if (!strcmp(res->value, "tcp"))
2271 rss_conf.rss_hf = ETH_RSS_TCP;
2272 else if (!strcmp(res->value, "sctp"))
2273 rss_conf.rss_hf = ETH_RSS_SCTP;
2274 else if (!strcmp(res->value, "ether"))
2275 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2276 else if (!strcmp(res->value, "port"))
2277 rss_conf.rss_hf = ETH_RSS_PORT;
2278 else if (!strcmp(res->value, "vxlan"))
2279 rss_conf.rss_hf = ETH_RSS_VXLAN;
2280 else if (!strcmp(res->value, "geneve"))
2281 rss_conf.rss_hf = ETH_RSS_GENEVE;
2282 else if (!strcmp(res->value, "nvgre"))
2283 rss_conf.rss_hf = ETH_RSS_NVGRE;
2284 else if (!strcmp(res->value, "l3-pre32"))
2285 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2286 else if (!strcmp(res->value, "l3-pre40"))
2287 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2288 else if (!strcmp(res->value, "l3-pre48"))
2289 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2290 else if (!strcmp(res->value, "l3-pre56"))
2291 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2292 else if (!strcmp(res->value, "l3-pre64"))
2293 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2294 else if (!strcmp(res->value, "l3-pre96"))
2295 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2296 else if (!strcmp(res->value, "l3-src-only"))
2297 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2298 else if (!strcmp(res->value, "l3-dst-only"))
2299 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2300 else if (!strcmp(res->value, "l4-src-only"))
2301 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2302 else if (!strcmp(res->value, "l4-dst-only"))
2303 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2304 else if (!strcmp(res->value, "l2-src-only"))
2305 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2306 else if (!strcmp(res->value, "l2-dst-only"))
2307 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2308 else if (!strcmp(res->value, "l2tpv3"))
2309 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2310 else if (!strcmp(res->value, "esp"))
2311 rss_conf.rss_hf = ETH_RSS_ESP;
2312 else if (!strcmp(res->value, "ah"))
2313 rss_conf.rss_hf = ETH_RSS_AH;
2314 else if (!strcmp(res->value, "pfcp"))
2315 rss_conf.rss_hf = ETH_RSS_PFCP;
2316 else if (!strcmp(res->value, "pppoe"))
2317 rss_conf.rss_hf = ETH_RSS_PPPOE;
2318 else if (!strcmp(res->value, "gtpu"))
2319 rss_conf.rss_hf = ETH_RSS_GTPU;
2320 else if (!strcmp(res->value, "none"))
2321 rss_conf.rss_hf = 0;
2322 else if (!strcmp(res->value, "level-default")) {
2323 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2324 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2325 } else if (!strcmp(res->value, "level-outer")) {
2326 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2327 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2328 } else if (!strcmp(res->value, "level-inner")) {
2329 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2330 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2331 } else if (!strcmp(res->value, "default"))
2333 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2334 atoi(res->value) < 64)
2335 rss_conf.rss_hf = 1ULL << atoi(res->value);
2337 printf("Unknown parameter\n");
2340 rss_conf.rss_key = NULL;
2341 /* Update global configuration for RSS types. */
2342 RTE_ETH_FOREACH_DEV(i) {
2343 struct rte_eth_rss_conf local_rss_conf;
2345 ret = eth_dev_info_get_print_err(i, &dev_info);
2350 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2352 local_rss_conf = rss_conf;
2353 local_rss_conf.rss_hf = rss_conf.rss_hf &
2354 dev_info.flow_type_rss_offloads;
2355 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2356 printf("Port %u modified RSS hash function based on hardware support,"
2357 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2358 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2360 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2363 printf("Configuration of RSS hash at ethernet port %d "
2364 "failed with error (%d): %s.\n",
2365 i, -diag, strerror(-diag));
2368 if (all_updated && !use_default) {
2369 rss_hf = rss_conf.rss_hf;
2370 printf("rss_hf %#"PRIx64"\n", rss_hf);
2374 cmdline_parse_token_string_t cmd_config_rss_port =
2375 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2376 cmdline_parse_token_string_t cmd_config_rss_keyword =
2377 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2378 cmdline_parse_token_string_t cmd_config_rss_all =
2379 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2380 cmdline_parse_token_string_t cmd_config_rss_name =
2381 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2382 cmdline_parse_token_string_t cmd_config_rss_value =
2383 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2385 cmdline_parse_inst_t cmd_config_rss = {
2386 .f = cmd_config_rss_parsed,
2388 .help_str = "port config all rss "
2389 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2390 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|level-default|"
2391 "level-outer|level-inner|<flowtype_id>",
2393 (void *)&cmd_config_rss_port,
2394 (void *)&cmd_config_rss_keyword,
2395 (void *)&cmd_config_rss_all,
2396 (void *)&cmd_config_rss_name,
2397 (void *)&cmd_config_rss_value,
2402 /* *** configure rss hash key *** */
2403 struct cmd_config_rss_hash_key {
2404 cmdline_fixed_string_t port;
2405 cmdline_fixed_string_t config;
2407 cmdline_fixed_string_t rss_hash_key;
2408 cmdline_fixed_string_t rss_type;
2409 cmdline_fixed_string_t key;
2413 hexa_digit_to_value(char hexa_digit)
2415 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2416 return (uint8_t) (hexa_digit - '0');
2417 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2418 return (uint8_t) ((hexa_digit - 'a') + 10);
2419 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2420 return (uint8_t) ((hexa_digit - 'A') + 10);
2421 /* Invalid hexa digit */
2426 parse_and_check_key_hexa_digit(char *key, int idx)
2430 hexa_v = hexa_digit_to_value(key[idx]);
2432 printf("invalid key: character %c at position %d is not a "
2433 "valid hexa digit\n", key[idx], idx);
2438 cmd_config_rss_hash_key_parsed(void *parsed_result,
2439 __rte_unused struct cmdline *cl,
2440 __rte_unused void *data)
2442 struct cmd_config_rss_hash_key *res = parsed_result;
2443 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2447 struct rte_eth_dev_info dev_info;
2448 uint8_t hash_key_size;
2452 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2456 if (dev_info.hash_key_size > 0 &&
2457 dev_info.hash_key_size <= sizeof(hash_key))
2458 hash_key_size = dev_info.hash_key_size;
2460 printf("dev_info did not provide a valid hash key size\n");
2463 /* Check the length of the RSS hash key */
2464 key_len = strlen(res->key);
2465 if (key_len != (hash_key_size * 2)) {
2466 printf("key length: %d invalid - key must be a string of %d"
2467 " hexa-decimal numbers\n",
2468 (int) key_len, hash_key_size * 2);
2471 /* Translate RSS hash key into binary representation */
2472 for (i = 0; i < hash_key_size; i++) {
2473 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2476 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2479 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2481 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2485 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2486 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2487 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2488 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2490 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2491 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2492 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2493 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2494 rss_hash_key, "rss-hash-key");
2495 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2496 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2497 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2498 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2499 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2500 "ipv6-tcp-ex#ipv6-udp-ex#"
2501 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2502 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2503 "l2tpv3#esp#ah#pfcp#pppoe#gtpu");
2504 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2505 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2507 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2508 .f = cmd_config_rss_hash_key_parsed,
2510 .help_str = "port config <port_id> rss-hash-key "
2511 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2512 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2513 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2514 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2515 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2516 "l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2517 "<string of hex digits (variable length, NIC dependent)>",
2519 (void *)&cmd_config_rss_hash_key_port,
2520 (void *)&cmd_config_rss_hash_key_config,
2521 (void *)&cmd_config_rss_hash_key_port_id,
2522 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2523 (void *)&cmd_config_rss_hash_key_rss_type,
2524 (void *)&cmd_config_rss_hash_key_value,
2529 /* *** configure port rxq/txq ring size *** */
2530 struct cmd_config_rxtx_ring_size {
2531 cmdline_fixed_string_t port;
2532 cmdline_fixed_string_t config;
2534 cmdline_fixed_string_t rxtxq;
2536 cmdline_fixed_string_t rsize;
2541 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2542 __rte_unused struct cmdline *cl,
2543 __rte_unused void *data)
2545 struct cmd_config_rxtx_ring_size *res = parsed_result;
2546 struct rte_port *port;
2549 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2552 if (res->portid == (portid_t)RTE_PORT_ALL) {
2553 printf("Invalid port id\n");
2557 port = &ports[res->portid];
2559 if (!strcmp(res->rxtxq, "rxq"))
2561 else if (!strcmp(res->rxtxq, "txq"))
2564 printf("Unknown parameter\n");
2568 if (isrx && rx_queue_id_is_invalid(res->qid))
2570 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2573 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2574 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2580 port->nb_rx_desc[res->qid] = res->size;
2582 port->nb_tx_desc[res->qid] = res->size;
2584 cmd_reconfig_device_queue(res->portid, 0, 1);
2587 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2588 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2590 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2591 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2593 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2594 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2596 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2597 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2599 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2600 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2602 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2603 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2604 rsize, "ring_size");
2605 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2606 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2609 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2610 .f = cmd_config_rxtx_ring_size_parsed,
2612 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2614 (void *)&cmd_config_rxtx_ring_size_port,
2615 (void *)&cmd_config_rxtx_ring_size_config,
2616 (void *)&cmd_config_rxtx_ring_size_portid,
2617 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2618 (void *)&cmd_config_rxtx_ring_size_qid,
2619 (void *)&cmd_config_rxtx_ring_size_rsize,
2620 (void *)&cmd_config_rxtx_ring_size_size,
2625 /* *** configure port rxq/txq start/stop *** */
2626 struct cmd_config_rxtx_queue {
2627 cmdline_fixed_string_t port;
2629 cmdline_fixed_string_t rxtxq;
2631 cmdline_fixed_string_t opname;
2635 cmd_config_rxtx_queue_parsed(void *parsed_result,
2636 __rte_unused struct cmdline *cl,
2637 __rte_unused void *data)
2639 struct cmd_config_rxtx_queue *res = parsed_result;
2644 if (test_done == 0) {
2645 printf("Please stop forwarding first\n");
2649 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2652 if (port_is_started(res->portid) != 1) {
2653 printf("Please start port %u first\n", res->portid);
2657 if (!strcmp(res->rxtxq, "rxq"))
2659 else if (!strcmp(res->rxtxq, "txq"))
2662 printf("Unknown parameter\n");
2666 if (isrx && rx_queue_id_is_invalid(res->qid))
2668 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2671 if (!strcmp(res->opname, "start"))
2673 else if (!strcmp(res->opname, "stop"))
2676 printf("Unknown parameter\n");
2680 if (isstart && isrx)
2681 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2682 else if (!isstart && isrx)
2683 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2684 else if (isstart && !isrx)
2685 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2687 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2689 if (ret == -ENOTSUP)
2690 printf("Function not supported in PMD driver\n");
2693 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2694 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2695 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2696 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2697 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2698 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2699 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2700 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2701 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2702 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2705 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2706 .f = cmd_config_rxtx_queue_parsed,
2708 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2710 (void *)&cmd_config_rxtx_queue_port,
2711 (void *)&cmd_config_rxtx_queue_portid,
2712 (void *)&cmd_config_rxtx_queue_rxtxq,
2713 (void *)&cmd_config_rxtx_queue_qid,
2714 (void *)&cmd_config_rxtx_queue_opname,
2719 /* *** configure port rxq/txq deferred start on/off *** */
2720 struct cmd_config_deferred_start_rxtx_queue {
2721 cmdline_fixed_string_t port;
2723 cmdline_fixed_string_t rxtxq;
2725 cmdline_fixed_string_t opname;
2726 cmdline_fixed_string_t state;
2730 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2731 __rte_unused struct cmdline *cl,
2732 __rte_unused void *data)
2734 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2735 struct rte_port *port;
2738 uint8_t needreconfig = 0;
2740 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2743 if (port_is_started(res->port_id) != 0) {
2744 printf("Please stop port %u first\n", res->port_id);
2748 port = &ports[res->port_id];
2750 isrx = !strcmp(res->rxtxq, "rxq");
2752 if (isrx && rx_queue_id_is_invalid(res->qid))
2754 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2757 ison = !strcmp(res->state, "on");
2759 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2760 port->rx_conf[res->qid].rx_deferred_start = ison;
2762 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2763 port->tx_conf[res->qid].tx_deferred_start = ison;
2768 cmd_reconfig_device_queue(res->port_id, 0, 1);
2771 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2772 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2774 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2775 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2777 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2778 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2780 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2781 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2783 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2784 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2785 opname, "deferred_start");
2786 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2787 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2790 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2791 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2793 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2795 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2796 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2797 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2798 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2799 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2800 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2805 /* *** configure port rxq/txq setup *** */
2806 struct cmd_setup_rxtx_queue {
2807 cmdline_fixed_string_t port;
2809 cmdline_fixed_string_t rxtxq;
2811 cmdline_fixed_string_t setup;
2814 /* Common CLI fields for queue setup */
2815 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2816 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2817 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2818 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2819 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2820 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2821 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2822 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2823 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2824 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2827 cmd_setup_rxtx_queue_parsed(
2828 void *parsed_result,
2829 __rte_unused struct cmdline *cl,
2830 __rte_unused void *data)
2832 struct cmd_setup_rxtx_queue *res = parsed_result;
2833 struct rte_port *port;
2834 struct rte_mempool *mp;
2835 unsigned int socket_id;
2839 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2842 if (res->portid == (portid_t)RTE_PORT_ALL) {
2843 printf("Invalid port id\n");
2847 if (!strcmp(res->rxtxq, "rxq"))
2849 else if (!strcmp(res->rxtxq, "txq"))
2852 printf("Unknown parameter\n");
2856 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2857 printf("Invalid rx queue\n");
2859 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2860 printf("Invalid tx queue\n");
2864 port = &ports[res->portid];
2866 socket_id = rxring_numa[res->portid];
2867 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2868 socket_id = port->socket_id;
2870 mp = mbuf_pool_find(socket_id, 0);
2872 printf("Failed to setup RX queue: "
2873 "No mempool allocation"
2874 " on the socket %d\n",
2875 rxring_numa[res->portid]);
2878 ret = rx_queue_setup(res->portid,
2880 port->nb_rx_desc[res->qid],
2882 &port->rx_conf[res->qid],
2885 printf("Failed to setup RX queue\n");
2887 socket_id = txring_numa[res->portid];
2888 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2889 socket_id = port->socket_id;
2891 ret = rte_eth_tx_queue_setup(res->portid,
2893 port->nb_tx_desc[res->qid],
2895 &port->tx_conf[res->qid]);
2897 printf("Failed to setup TX queue\n");
2901 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2902 .f = cmd_setup_rxtx_queue_parsed,
2904 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2906 (void *)&cmd_setup_rxtx_queue_port,
2907 (void *)&cmd_setup_rxtx_queue_portid,
2908 (void *)&cmd_setup_rxtx_queue_rxtxq,
2909 (void *)&cmd_setup_rxtx_queue_qid,
2910 (void *)&cmd_setup_rxtx_queue_setup,
2916 /* *** Configure RSS RETA *** */
2917 struct cmd_config_rss_reta {
2918 cmdline_fixed_string_t port;
2919 cmdline_fixed_string_t keyword;
2921 cmdline_fixed_string_t name;
2922 cmdline_fixed_string_t list_name;
2923 cmdline_fixed_string_t list_of_items;
2927 parse_reta_config(const char *str,
2928 struct rte_eth_rss_reta_entry64 *reta_conf,
2929 uint16_t nb_entries)
2933 uint16_t hash_index, idx, shift;
2936 const char *p, *p0 = str;
2943 unsigned long int_fld[_NUM_FLD];
2944 char *str_fld[_NUM_FLD];
2946 while ((p = strchr(p0,'(')) != NULL) {
2948 if((p0 = strchr(p,')')) == NULL)
2952 if(size >= sizeof(s))
2955 snprintf(s, sizeof(s), "%.*s", size, p);
2956 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2958 for (i = 0; i < _NUM_FLD; i++) {
2960 int_fld[i] = strtoul(str_fld[i], &end, 0);
2961 if (errno != 0 || end == str_fld[i] ||
2966 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2967 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2969 if (hash_index >= nb_entries) {
2970 printf("Invalid RETA hash index=%d\n", hash_index);
2974 idx = hash_index / RTE_RETA_GROUP_SIZE;
2975 shift = hash_index % RTE_RETA_GROUP_SIZE;
2976 reta_conf[idx].mask |= (1ULL << shift);
2977 reta_conf[idx].reta[shift] = nb_queue;
2984 cmd_set_rss_reta_parsed(void *parsed_result,
2985 __rte_unused struct cmdline *cl,
2986 __rte_unused void *data)
2989 struct rte_eth_dev_info dev_info;
2990 struct rte_eth_rss_reta_entry64 reta_conf[8];
2991 struct cmd_config_rss_reta *res = parsed_result;
2993 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2997 if (dev_info.reta_size == 0) {
2998 printf("Redirection table size is 0 which is "
2999 "invalid for RSS\n");
3002 printf("The reta size of port %d is %u\n",
3003 res->port_id, dev_info.reta_size);
3004 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3005 printf("Currently do not support more than %u entries of "
3006 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3010 memset(reta_conf, 0, sizeof(reta_conf));
3011 if (!strcmp(res->list_name, "reta")) {
3012 if (parse_reta_config(res->list_of_items, reta_conf,
3013 dev_info.reta_size)) {
3014 printf("Invalid RSS Redirection Table "
3015 "config entered\n");
3018 ret = rte_eth_dev_rss_reta_update(res->port_id,
3019 reta_conf, dev_info.reta_size);
3021 printf("Bad redirection table parameter, "
3022 "return code = %d \n", ret);
3026 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3027 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3028 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3029 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3030 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3031 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3032 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3033 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3034 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3035 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3036 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3037 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3039 cmdline_parse_inst_t cmd_config_rss_reta = {
3040 .f = cmd_set_rss_reta_parsed,
3042 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3044 (void *)&cmd_config_rss_reta_port,
3045 (void *)&cmd_config_rss_reta_keyword,
3046 (void *)&cmd_config_rss_reta_port_id,
3047 (void *)&cmd_config_rss_reta_name,
3048 (void *)&cmd_config_rss_reta_list_name,
3049 (void *)&cmd_config_rss_reta_list_of_items,
3054 /* *** SHOW PORT RETA INFO *** */
3055 struct cmd_showport_reta {
3056 cmdline_fixed_string_t show;
3057 cmdline_fixed_string_t port;
3059 cmdline_fixed_string_t rss;
3060 cmdline_fixed_string_t reta;
3062 cmdline_fixed_string_t list_of_items;
3066 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3067 uint16_t nb_entries,
3071 const char *p, *p0 = str;
3076 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3077 RTE_RETA_GROUP_SIZE;
3080 p = strchr(p0, '(');
3084 p0 = strchr(p, ')');
3088 if (size >= sizeof(s)) {
3089 printf("The string size exceeds the internal buffer size\n");
3092 snprintf(s, sizeof(s), "%.*s", size, p);
3093 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3094 if (ret <= 0 || ret != num) {
3095 printf("The bits of masks do not match the number of "
3096 "reta entries: %u\n", num);
3099 for (i = 0; i < ret; i++)
3100 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3106 cmd_showport_reta_parsed(void *parsed_result,
3107 __rte_unused struct cmdline *cl,
3108 __rte_unused void *data)
3110 struct cmd_showport_reta *res = parsed_result;
3111 struct rte_eth_rss_reta_entry64 reta_conf[8];
3112 struct rte_eth_dev_info dev_info;
3113 uint16_t max_reta_size;
3116 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3120 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3121 if (res->size == 0 || res->size > max_reta_size) {
3122 printf("Invalid redirection table size: %u (1-%u)\n",
3123 res->size, max_reta_size);
3127 memset(reta_conf, 0, sizeof(reta_conf));
3128 if (showport_parse_reta_config(reta_conf, res->size,
3129 res->list_of_items) < 0) {
3130 printf("Invalid string: %s for reta masks\n",
3131 res->list_of_items);
3134 port_rss_reta_info(res->port_id, reta_conf, res->size);
3137 cmdline_parse_token_string_t cmd_showport_reta_show =
3138 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3139 cmdline_parse_token_string_t cmd_showport_reta_port =
3140 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3141 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3142 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3143 cmdline_parse_token_string_t cmd_showport_reta_rss =
3144 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3145 cmdline_parse_token_string_t cmd_showport_reta_reta =
3146 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3147 cmdline_parse_token_num_t cmd_showport_reta_size =
3148 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3149 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3150 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3151 list_of_items, NULL);
3153 cmdline_parse_inst_t cmd_showport_reta = {
3154 .f = cmd_showport_reta_parsed,
3156 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3158 (void *)&cmd_showport_reta_show,
3159 (void *)&cmd_showport_reta_port,
3160 (void *)&cmd_showport_reta_port_id,
3161 (void *)&cmd_showport_reta_rss,
3162 (void *)&cmd_showport_reta_reta,
3163 (void *)&cmd_showport_reta_size,
3164 (void *)&cmd_showport_reta_list_of_items,
3169 /* *** Show RSS hash configuration *** */
3170 struct cmd_showport_rss_hash {
3171 cmdline_fixed_string_t show;
3172 cmdline_fixed_string_t port;
3174 cmdline_fixed_string_t rss_hash;
3175 cmdline_fixed_string_t rss_type;
3176 cmdline_fixed_string_t key; /* optional argument */
3179 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3180 __rte_unused struct cmdline *cl,
3183 struct cmd_showport_rss_hash *res = parsed_result;
3185 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3188 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3189 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3190 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3191 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3192 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3193 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3194 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3195 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3197 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3198 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3200 cmdline_parse_inst_t cmd_showport_rss_hash = {
3201 .f = cmd_showport_rss_hash_parsed,
3203 .help_str = "show port <port_id> rss-hash",
3205 (void *)&cmd_showport_rss_hash_show,
3206 (void *)&cmd_showport_rss_hash_port,
3207 (void *)&cmd_showport_rss_hash_port_id,
3208 (void *)&cmd_showport_rss_hash_rss_hash,
3213 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3214 .f = cmd_showport_rss_hash_parsed,
3216 .help_str = "show port <port_id> rss-hash key",
3218 (void *)&cmd_showport_rss_hash_show,
3219 (void *)&cmd_showport_rss_hash_port,
3220 (void *)&cmd_showport_rss_hash_port_id,
3221 (void *)&cmd_showport_rss_hash_rss_hash,
3222 (void *)&cmd_showport_rss_hash_rss_key,
3227 /* *** Configure DCB *** */
3228 struct cmd_config_dcb {
3229 cmdline_fixed_string_t port;
3230 cmdline_fixed_string_t config;
3232 cmdline_fixed_string_t dcb;
3233 cmdline_fixed_string_t vt;
3234 cmdline_fixed_string_t vt_en;
3236 cmdline_fixed_string_t pfc;
3237 cmdline_fixed_string_t pfc_en;
3241 cmd_config_dcb_parsed(void *parsed_result,
3242 __rte_unused struct cmdline *cl,
3243 __rte_unused void *data)
3245 struct cmd_config_dcb *res = parsed_result;
3246 portid_t port_id = res->port_id;
3247 struct rte_port *port;
3251 port = &ports[port_id];
3252 /** Check if the port is not started **/
3253 if (port->port_status != RTE_PORT_STOPPED) {
3254 printf("Please stop port %d first\n", port_id);
3258 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3259 printf("The invalid number of traffic class,"
3260 " only 4 or 8 allowed.\n");
3264 if (nb_fwd_lcores < res->num_tcs) {
3265 printf("nb_cores shouldn't be less than number of TCs.\n");
3268 if (!strncmp(res->pfc_en, "on", 2))
3273 /* DCB in VT mode */
3274 if (!strncmp(res->vt_en, "on", 2))
3275 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3276 (enum rte_eth_nb_tcs)res->num_tcs,
3279 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3280 (enum rte_eth_nb_tcs)res->num_tcs,
3285 printf("Cannot initialize network ports.\n");
3289 cmd_reconfig_device_queue(port_id, 1, 1);
3292 cmdline_parse_token_string_t cmd_config_dcb_port =
3293 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3294 cmdline_parse_token_string_t cmd_config_dcb_config =
3295 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3296 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3297 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3298 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3299 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3300 cmdline_parse_token_string_t cmd_config_dcb_vt =
3301 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3302 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3303 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3304 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3305 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3306 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3307 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3308 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3309 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3311 cmdline_parse_inst_t cmd_config_dcb = {
3312 .f = cmd_config_dcb_parsed,
3314 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3316 (void *)&cmd_config_dcb_port,
3317 (void *)&cmd_config_dcb_config,
3318 (void *)&cmd_config_dcb_port_id,
3319 (void *)&cmd_config_dcb_dcb,
3320 (void *)&cmd_config_dcb_vt,
3321 (void *)&cmd_config_dcb_vt_en,
3322 (void *)&cmd_config_dcb_num_tcs,
3323 (void *)&cmd_config_dcb_pfc,
3324 (void *)&cmd_config_dcb_pfc_en,
3329 /* *** configure number of packets per burst *** */
3330 struct cmd_config_burst {
3331 cmdline_fixed_string_t port;
3332 cmdline_fixed_string_t keyword;
3333 cmdline_fixed_string_t all;
3334 cmdline_fixed_string_t name;
3339 cmd_config_burst_parsed(void *parsed_result,
3340 __rte_unused struct cmdline *cl,
3341 __rte_unused void *data)
3343 struct cmd_config_burst *res = parsed_result;
3344 struct rte_eth_dev_info dev_info;
3345 uint16_t rec_nb_pkts;
3348 if (!all_ports_stopped()) {
3349 printf("Please stop all ports first\n");
3353 if (!strcmp(res->name, "burst")) {
3354 if (res->value == 0) {
3355 /* If user gives a value of zero, query the PMD for
3356 * its recommended Rx burst size. Testpmd uses a single
3357 * size for all ports, so assume all ports are the same
3358 * NIC model and use the values from Port 0.
3360 ret = eth_dev_info_get_print_err(0, &dev_info);
3364 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3366 if (rec_nb_pkts == 0) {
3367 printf("PMD does not recommend a burst size.\n"
3368 "User provided value must be between"
3369 " 1 and %d\n", MAX_PKT_BURST);
3371 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3372 printf("PMD recommended burst size of %d"
3373 " exceeds maximum value of %d\n",
3374 rec_nb_pkts, MAX_PKT_BURST);
3377 printf("Using PMD-provided burst value of %d\n",
3379 nb_pkt_per_burst = rec_nb_pkts;
3380 } else if (res->value > MAX_PKT_BURST) {
3381 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3384 nb_pkt_per_burst = res->value;
3386 printf("Unknown parameter\n");
3392 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3395 cmdline_parse_token_string_t cmd_config_burst_port =
3396 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3397 cmdline_parse_token_string_t cmd_config_burst_keyword =
3398 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3399 cmdline_parse_token_string_t cmd_config_burst_all =
3400 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3401 cmdline_parse_token_string_t cmd_config_burst_name =
3402 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3403 cmdline_parse_token_num_t cmd_config_burst_value =
3404 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3406 cmdline_parse_inst_t cmd_config_burst = {
3407 .f = cmd_config_burst_parsed,
3409 .help_str = "port config all burst <value>",
3411 (void *)&cmd_config_burst_port,
3412 (void *)&cmd_config_burst_keyword,
3413 (void *)&cmd_config_burst_all,
3414 (void *)&cmd_config_burst_name,
3415 (void *)&cmd_config_burst_value,
3420 /* *** configure rx/tx queues *** */
3421 struct cmd_config_thresh {
3422 cmdline_fixed_string_t port;
3423 cmdline_fixed_string_t keyword;
3424 cmdline_fixed_string_t all;
3425 cmdline_fixed_string_t name;
3430 cmd_config_thresh_parsed(void *parsed_result,
3431 __rte_unused struct cmdline *cl,
3432 __rte_unused void *data)
3434 struct cmd_config_thresh *res = parsed_result;
3436 if (!all_ports_stopped()) {
3437 printf("Please stop all ports first\n");
3441 if (!strcmp(res->name, "txpt"))
3442 tx_pthresh = res->value;
3443 else if(!strcmp(res->name, "txht"))
3444 tx_hthresh = res->value;
3445 else if(!strcmp(res->name, "txwt"))
3446 tx_wthresh = res->value;
3447 else if(!strcmp(res->name, "rxpt"))
3448 rx_pthresh = res->value;
3449 else if(!strcmp(res->name, "rxht"))
3450 rx_hthresh = res->value;
3451 else if(!strcmp(res->name, "rxwt"))
3452 rx_wthresh = res->value;
3454 printf("Unknown parameter\n");
3460 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3463 cmdline_parse_token_string_t cmd_config_thresh_port =
3464 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3465 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3466 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3467 cmdline_parse_token_string_t cmd_config_thresh_all =
3468 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3469 cmdline_parse_token_string_t cmd_config_thresh_name =
3470 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3471 "txpt#txht#txwt#rxpt#rxht#rxwt");
3472 cmdline_parse_token_num_t cmd_config_thresh_value =
3473 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3475 cmdline_parse_inst_t cmd_config_thresh = {
3476 .f = cmd_config_thresh_parsed,
3478 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3480 (void *)&cmd_config_thresh_port,
3481 (void *)&cmd_config_thresh_keyword,
3482 (void *)&cmd_config_thresh_all,
3483 (void *)&cmd_config_thresh_name,
3484 (void *)&cmd_config_thresh_value,
3489 /* *** configure free/rs threshold *** */
3490 struct cmd_config_threshold {
3491 cmdline_fixed_string_t port;
3492 cmdline_fixed_string_t keyword;
3493 cmdline_fixed_string_t all;
3494 cmdline_fixed_string_t name;
3499 cmd_config_threshold_parsed(void *parsed_result,
3500 __rte_unused struct cmdline *cl,
3501 __rte_unused void *data)
3503 struct cmd_config_threshold *res = parsed_result;
3505 if (!all_ports_stopped()) {
3506 printf("Please stop all ports first\n");
3510 if (!strcmp(res->name, "txfreet"))
3511 tx_free_thresh = res->value;
3512 else if (!strcmp(res->name, "txrst"))
3513 tx_rs_thresh = res->value;
3514 else if (!strcmp(res->name, "rxfreet"))
3515 rx_free_thresh = res->value;
3517 printf("Unknown parameter\n");
3523 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3526 cmdline_parse_token_string_t cmd_config_threshold_port =
3527 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3528 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3529 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3531 cmdline_parse_token_string_t cmd_config_threshold_all =
3532 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3533 cmdline_parse_token_string_t cmd_config_threshold_name =
3534 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3535 "txfreet#txrst#rxfreet");
3536 cmdline_parse_token_num_t cmd_config_threshold_value =
3537 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3539 cmdline_parse_inst_t cmd_config_threshold = {
3540 .f = cmd_config_threshold_parsed,
3542 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3544 (void *)&cmd_config_threshold_port,
3545 (void *)&cmd_config_threshold_keyword,
3546 (void *)&cmd_config_threshold_all,
3547 (void *)&cmd_config_threshold_name,
3548 (void *)&cmd_config_threshold_value,
3554 struct cmd_stop_result {
3555 cmdline_fixed_string_t stop;
3558 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3559 __rte_unused struct cmdline *cl,
3560 __rte_unused void *data)
3562 stop_packet_forwarding();
3565 cmdline_parse_token_string_t cmd_stop_stop =
3566 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3568 cmdline_parse_inst_t cmd_stop = {
3569 .f = cmd_stop_parsed,
3571 .help_str = "stop: Stop packet forwarding",
3573 (void *)&cmd_stop_stop,
3578 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3581 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3582 unsigned int *parsed_items, int check_unique_values)
3584 unsigned int nb_item;
3592 * First parse all items in the list and store their value.
3597 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3599 if ((c >= '0') && (c <= '9')) {
3600 value = (unsigned int) (value * 10 + (c - '0'));
3605 printf("character %c is not a decimal digit\n", c);
3609 printf("No valid value before comma\n");
3612 if (nb_item < max_items) {
3613 parsed_items[nb_item] = value;
3619 if (nb_item >= max_items) {
3620 printf("Number of %s = %u > %u (maximum items)\n",
3621 item_name, nb_item + 1, max_items);
3624 parsed_items[nb_item++] = value;
3625 if (! check_unique_values)
3629 * Then, check that all values in the list are differents.
3630 * No optimization here...
3632 for (i = 0; i < nb_item; i++) {
3633 for (j = i + 1; j < nb_item; j++) {
3634 if (parsed_items[j] == parsed_items[i]) {
3635 printf("duplicated %s %u at index %u and %u\n",
3636 item_name, parsed_items[i], i, j);
3644 struct cmd_set_list_result {
3645 cmdline_fixed_string_t cmd_keyword;
3646 cmdline_fixed_string_t list_name;
3647 cmdline_fixed_string_t list_of_items;
3650 static void cmd_set_list_parsed(void *parsed_result,
3651 __rte_unused struct cmdline *cl,
3652 __rte_unused void *data)
3654 struct cmd_set_list_result *res;
3656 unsigned int lcorelist[RTE_MAX_LCORE];
3657 unsigned int portlist[RTE_MAX_ETHPORTS];
3659 unsigned int nb_item;
3661 if (test_done == 0) {
3662 printf("Please stop forwarding first\n");
3666 res = parsed_result;
3667 if (!strcmp(res->list_name, "corelist")) {
3668 nb_item = parse_item_list(res->list_of_items, "core",
3670 parsed_items.lcorelist, 1);
3672 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3677 if (!strcmp(res->list_name, "portlist")) {
3678 nb_item = parse_item_list(res->list_of_items, "port",
3680 parsed_items.portlist, 1);
3682 set_fwd_ports_list(parsed_items.portlist, nb_item);
3688 cmdline_parse_token_string_t cmd_set_list_keyword =
3689 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3691 cmdline_parse_token_string_t cmd_set_list_name =
3692 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3693 "corelist#portlist");
3694 cmdline_parse_token_string_t cmd_set_list_of_items =
3695 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3698 cmdline_parse_inst_t cmd_set_fwd_list = {
3699 .f = cmd_set_list_parsed,
3701 .help_str = "set corelist|portlist <list0[,list1]*>",
3703 (void *)&cmd_set_list_keyword,
3704 (void *)&cmd_set_list_name,
3705 (void *)&cmd_set_list_of_items,
3710 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3712 struct cmd_setmask_result {
3713 cmdline_fixed_string_t set;
3714 cmdline_fixed_string_t mask;
3718 static void cmd_set_mask_parsed(void *parsed_result,
3719 __rte_unused struct cmdline *cl,
3720 __rte_unused void *data)
3722 struct cmd_setmask_result *res = parsed_result;
3724 if (test_done == 0) {
3725 printf("Please stop forwarding first\n");
3728 if (!strcmp(res->mask, "coremask")) {
3729 set_fwd_lcores_mask(res->hexavalue);
3731 } else if (!strcmp(res->mask, "portmask")) {
3732 set_fwd_ports_mask(res->hexavalue);
3737 cmdline_parse_token_string_t cmd_setmask_set =
3738 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3739 cmdline_parse_token_string_t cmd_setmask_mask =
3740 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3741 "coremask#portmask");
3742 cmdline_parse_token_num_t cmd_setmask_value =
3743 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3745 cmdline_parse_inst_t cmd_set_fwd_mask = {
3746 .f = cmd_set_mask_parsed,
3748 .help_str = "set coremask|portmask <hexadecimal value>",
3750 (void *)&cmd_setmask_set,
3751 (void *)&cmd_setmask_mask,
3752 (void *)&cmd_setmask_value,
3758 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3760 struct cmd_set_result {
3761 cmdline_fixed_string_t set;
3762 cmdline_fixed_string_t what;
3766 static void cmd_set_parsed(void *parsed_result,
3767 __rte_unused struct cmdline *cl,
3768 __rte_unused void *data)
3770 struct cmd_set_result *res = parsed_result;
3771 if (!strcmp(res->what, "nbport")) {
3772 set_fwd_ports_number(res->value);
3774 } else if (!strcmp(res->what, "nbcore")) {
3775 set_fwd_lcores_number(res->value);
3777 } else if (!strcmp(res->what, "burst"))
3778 set_nb_pkt_per_burst(res->value);
3779 else if (!strcmp(res->what, "verbose"))
3780 set_verbose_level(res->value);
3783 cmdline_parse_token_string_t cmd_set_set =
3784 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3785 cmdline_parse_token_string_t cmd_set_what =
3786 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3787 "nbport#nbcore#burst#verbose");
3788 cmdline_parse_token_num_t cmd_set_value =
3789 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3791 cmdline_parse_inst_t cmd_set_numbers = {
3792 .f = cmd_set_parsed,
3794 .help_str = "set nbport|nbcore|burst|verbose <value>",
3796 (void *)&cmd_set_set,
3797 (void *)&cmd_set_what,
3798 (void *)&cmd_set_value,
3803 /* *** SET LOG LEVEL CONFIGURATION *** */
3805 struct cmd_set_log_result {
3806 cmdline_fixed_string_t set;
3807 cmdline_fixed_string_t log;
3808 cmdline_fixed_string_t type;
3813 cmd_set_log_parsed(void *parsed_result,
3814 __rte_unused struct cmdline *cl,
3815 __rte_unused void *data)
3817 struct cmd_set_log_result *res;
3820 res = parsed_result;
3821 if (!strcmp(res->type, "global"))
3822 rte_log_set_global_level(res->level);
3824 ret = rte_log_set_level_regexp(res->type, res->level);
3826 printf("Unable to set log level\n");
3830 cmdline_parse_token_string_t cmd_set_log_set =
3831 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3832 cmdline_parse_token_string_t cmd_set_log_log =
3833 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3834 cmdline_parse_token_string_t cmd_set_log_type =
3835 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3836 cmdline_parse_token_num_t cmd_set_log_level =
3837 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3839 cmdline_parse_inst_t cmd_set_log = {
3840 .f = cmd_set_log_parsed,
3842 .help_str = "set log global|<type> <level>",
3844 (void *)&cmd_set_log_set,
3845 (void *)&cmd_set_log_log,
3846 (void *)&cmd_set_log_type,
3847 (void *)&cmd_set_log_level,
3852 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3854 struct cmd_set_rxoffs_result {
3855 cmdline_fixed_string_t cmd_keyword;
3856 cmdline_fixed_string_t rxoffs;
3857 cmdline_fixed_string_t seg_offsets;
3861 cmd_set_rxoffs_parsed(void *parsed_result,
3862 __rte_unused struct cmdline *cl,
3863 __rte_unused void *data)
3865 struct cmd_set_rxoffs_result *res;
3866 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3867 unsigned int nb_segs;
3869 res = parsed_result;
3870 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3871 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3873 set_rx_pkt_offsets(seg_offsets, nb_segs);
3876 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3877 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3878 cmd_keyword, "set");
3879 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3880 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3882 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3883 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3886 cmdline_parse_inst_t cmd_set_rxoffs = {
3887 .f = cmd_set_rxoffs_parsed,
3889 .help_str = "set rxoffs <len0[,len1]*>",
3891 (void *)&cmd_set_rxoffs_keyword,
3892 (void *)&cmd_set_rxoffs_name,
3893 (void *)&cmd_set_rxoffs_offsets,
3898 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3900 struct cmd_set_rxpkts_result {
3901 cmdline_fixed_string_t cmd_keyword;
3902 cmdline_fixed_string_t rxpkts;
3903 cmdline_fixed_string_t seg_lengths;
3907 cmd_set_rxpkts_parsed(void *parsed_result,
3908 __rte_unused struct cmdline *cl,
3909 __rte_unused void *data)
3911 struct cmd_set_rxpkts_result *res;
3912 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3913 unsigned int nb_segs;
3915 res = parsed_result;
3916 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3917 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3919 set_rx_pkt_segments(seg_lengths, nb_segs);
3922 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3923 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3924 cmd_keyword, "set");
3925 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3926 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3928 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3929 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3932 cmdline_parse_inst_t cmd_set_rxpkts = {
3933 .f = cmd_set_rxpkts_parsed,
3935 .help_str = "set rxpkts <len0[,len1]*>",
3937 (void *)&cmd_set_rxpkts_keyword,
3938 (void *)&cmd_set_rxpkts_name,
3939 (void *)&cmd_set_rxpkts_lengths,
3944 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3946 struct cmd_set_txpkts_result {
3947 cmdline_fixed_string_t cmd_keyword;
3948 cmdline_fixed_string_t txpkts;
3949 cmdline_fixed_string_t seg_lengths;
3953 cmd_set_txpkts_parsed(void *parsed_result,
3954 __rte_unused struct cmdline *cl,
3955 __rte_unused void *data)
3957 struct cmd_set_txpkts_result *res;
3958 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3959 unsigned int nb_segs;
3961 res = parsed_result;
3962 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3963 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3965 set_tx_pkt_segments(seg_lengths, nb_segs);
3968 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3969 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3970 cmd_keyword, "set");
3971 cmdline_parse_token_string_t cmd_set_txpkts_name =
3972 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3974 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3975 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3978 cmdline_parse_inst_t cmd_set_txpkts = {
3979 .f = cmd_set_txpkts_parsed,
3981 .help_str = "set txpkts <len0[,len1]*>",
3983 (void *)&cmd_set_txpkts_keyword,
3984 (void *)&cmd_set_txpkts_name,
3985 (void *)&cmd_set_txpkts_lengths,
3990 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3992 struct cmd_set_txsplit_result {
3993 cmdline_fixed_string_t cmd_keyword;
3994 cmdline_fixed_string_t txsplit;
3995 cmdline_fixed_string_t mode;
3999 cmd_set_txsplit_parsed(void *parsed_result,
4000 __rte_unused struct cmdline *cl,
4001 __rte_unused void *data)
4003 struct cmd_set_txsplit_result *res;
4005 res = parsed_result;
4006 set_tx_pkt_split(res->mode);
4009 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4010 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4011 cmd_keyword, "set");
4012 cmdline_parse_token_string_t cmd_set_txsplit_name =
4013 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4014 txsplit, "txsplit");
4015 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4016 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4019 cmdline_parse_inst_t cmd_set_txsplit = {
4020 .f = cmd_set_txsplit_parsed,
4022 .help_str = "set txsplit on|off|rand",
4024 (void *)&cmd_set_txsplit_keyword,
4025 (void *)&cmd_set_txsplit_name,
4026 (void *)&cmd_set_txsplit_mode,
4031 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4033 struct cmd_set_txtimes_result {
4034 cmdline_fixed_string_t cmd_keyword;
4035 cmdline_fixed_string_t txtimes;
4036 cmdline_fixed_string_t tx_times;
4040 cmd_set_txtimes_parsed(void *parsed_result,
4041 __rte_unused struct cmdline *cl,
4042 __rte_unused void *data)
4044 struct cmd_set_txtimes_result *res;
4045 unsigned int tx_times[2] = {0, 0};
4046 unsigned int n_times;
4048 res = parsed_result;
4049 n_times = parse_item_list(res->tx_times, "tx times",
4052 set_tx_pkt_times(tx_times);
4055 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4056 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4057 cmd_keyword, "set");
4058 cmdline_parse_token_string_t cmd_set_txtimes_name =
4059 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4060 txtimes, "txtimes");
4061 cmdline_parse_token_string_t cmd_set_txtimes_value =
4062 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4065 cmdline_parse_inst_t cmd_set_txtimes = {
4066 .f = cmd_set_txtimes_parsed,
4068 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4070 (void *)&cmd_set_txtimes_keyword,
4071 (void *)&cmd_set_txtimes_name,
4072 (void *)&cmd_set_txtimes_value,
4077 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4078 struct cmd_rx_vlan_filter_all_result {
4079 cmdline_fixed_string_t rx_vlan;
4080 cmdline_fixed_string_t what;
4081 cmdline_fixed_string_t all;
4086 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4087 __rte_unused struct cmdline *cl,
4088 __rte_unused void *data)
4090 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4092 if (!strcmp(res->what, "add"))
4093 rx_vlan_all_filter_set(res->port_id, 1);
4095 rx_vlan_all_filter_set(res->port_id, 0);
4098 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4099 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4100 rx_vlan, "rx_vlan");
4101 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4102 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4104 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4105 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4107 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4108 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4111 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4112 .f = cmd_rx_vlan_filter_all_parsed,
4114 .help_str = "rx_vlan add|rm all <port_id>: "
4115 "Add/Remove all identifiers to/from the set of VLAN "
4116 "identifiers filtered by a port",
4118 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4119 (void *)&cmd_rx_vlan_filter_all_what,
4120 (void *)&cmd_rx_vlan_filter_all_all,
4121 (void *)&cmd_rx_vlan_filter_all_portid,
4126 /* *** VLAN OFFLOAD SET ON A PORT *** */
4127 struct cmd_vlan_offload_result {
4128 cmdline_fixed_string_t vlan;
4129 cmdline_fixed_string_t set;
4130 cmdline_fixed_string_t vlan_type;
4131 cmdline_fixed_string_t what;
4132 cmdline_fixed_string_t on;
4133 cmdline_fixed_string_t port_id;
4137 cmd_vlan_offload_parsed(void *parsed_result,
4138 __rte_unused struct cmdline *cl,
4139 __rte_unused void *data)
4142 struct cmd_vlan_offload_result *res = parsed_result;
4145 portid_t port_id = 0;
4149 len = strnlen(str, STR_TOKEN_SIZE);
4151 /* Get port_id first */
4159 tmp = strtoul(str, NULL, 0);
4160 /* If port_id greater that what portid_t can represent, return */
4161 if(tmp >= RTE_MAX_ETHPORTS)
4163 port_id = (portid_t)tmp;
4165 if (!strcmp(res->on, "on"))
4170 if (!strcmp(res->what, "strip"))
4171 rx_vlan_strip_set(port_id, on);
4172 else if(!strcmp(res->what, "stripq")){
4173 uint16_t queue_id = 0;
4175 /* No queue_id, return */
4177 printf("must specify (port,queue_id)\n");
4180 tmp = strtoul(str + i + 1, NULL, 0);
4181 /* If queue_id greater that what 16-bits can represent, return */
4185 queue_id = (uint16_t)tmp;
4186 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4188 else if (!strcmp(res->what, "filter"))
4189 rx_vlan_filter_set(port_id, on);
4190 else if (!strcmp(res->what, "qinq_strip"))
4191 rx_vlan_qinq_strip_set(port_id, on);
4193 vlan_extend_set(port_id, on);
4198 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4199 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4201 cmdline_parse_token_string_t cmd_vlan_offload_set =
4202 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4204 cmdline_parse_token_string_t cmd_vlan_offload_what =
4205 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4206 what, "strip#filter#qinq_strip#extend#stripq");
4207 cmdline_parse_token_string_t cmd_vlan_offload_on =
4208 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4210 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4211 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4214 cmdline_parse_inst_t cmd_vlan_offload = {
4215 .f = cmd_vlan_offload_parsed,
4217 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4218 "<port_id[,queue_id]>: "
4219 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4221 (void *)&cmd_vlan_offload_vlan,
4222 (void *)&cmd_vlan_offload_set,
4223 (void *)&cmd_vlan_offload_what,
4224 (void *)&cmd_vlan_offload_on,
4225 (void *)&cmd_vlan_offload_portid,
4230 /* *** VLAN TPID SET ON A PORT *** */
4231 struct cmd_vlan_tpid_result {
4232 cmdline_fixed_string_t vlan;
4233 cmdline_fixed_string_t set;
4234 cmdline_fixed_string_t vlan_type;
4235 cmdline_fixed_string_t what;
4241 cmd_vlan_tpid_parsed(void *parsed_result,
4242 __rte_unused struct cmdline *cl,
4243 __rte_unused void *data)
4245 struct cmd_vlan_tpid_result *res = parsed_result;
4246 enum rte_vlan_type vlan_type;
4248 if (!strcmp(res->vlan_type, "inner"))
4249 vlan_type = ETH_VLAN_TYPE_INNER;
4250 else if (!strcmp(res->vlan_type, "outer"))
4251 vlan_type = ETH_VLAN_TYPE_OUTER;
4253 printf("Unknown vlan type\n");
4256 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4259 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4260 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4262 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4263 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4265 cmdline_parse_token_string_t cmd_vlan_type =
4266 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4267 vlan_type, "inner#outer");
4268 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4269 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4271 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4272 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4274 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4275 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4278 cmdline_parse_inst_t cmd_vlan_tpid = {
4279 .f = cmd_vlan_tpid_parsed,
4281 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4282 "Set the VLAN Ether type",
4284 (void *)&cmd_vlan_tpid_vlan,
4285 (void *)&cmd_vlan_tpid_set,
4286 (void *)&cmd_vlan_type,
4287 (void *)&cmd_vlan_tpid_what,
4288 (void *)&cmd_vlan_tpid_tpid,
4289 (void *)&cmd_vlan_tpid_portid,
4294 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4295 struct cmd_rx_vlan_filter_result {
4296 cmdline_fixed_string_t rx_vlan;
4297 cmdline_fixed_string_t what;
4303 cmd_rx_vlan_filter_parsed(void *parsed_result,
4304 __rte_unused struct cmdline *cl,
4305 __rte_unused void *data)
4307 struct cmd_rx_vlan_filter_result *res = parsed_result;
4309 if (!strcmp(res->what, "add"))
4310 rx_vft_set(res->port_id, res->vlan_id, 1);
4312 rx_vft_set(res->port_id, res->vlan_id, 0);
4315 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4316 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4317 rx_vlan, "rx_vlan");
4318 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4319 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4321 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4322 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4324 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4325 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4328 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4329 .f = cmd_rx_vlan_filter_parsed,
4331 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4332 "Add/Remove a VLAN identifier to/from the set of VLAN "
4333 "identifiers filtered by a port",
4335 (void *)&cmd_rx_vlan_filter_rx_vlan,
4336 (void *)&cmd_rx_vlan_filter_what,
4337 (void *)&cmd_rx_vlan_filter_vlanid,
4338 (void *)&cmd_rx_vlan_filter_portid,
4343 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4344 struct cmd_tx_vlan_set_result {
4345 cmdline_fixed_string_t tx_vlan;
4346 cmdline_fixed_string_t set;
4352 cmd_tx_vlan_set_parsed(void *parsed_result,
4353 __rte_unused struct cmdline *cl,
4354 __rte_unused void *data)
4356 struct cmd_tx_vlan_set_result *res = parsed_result;
4358 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4361 if (!port_is_stopped(res->port_id)) {
4362 printf("Please stop port %d first\n", res->port_id);
4366 tx_vlan_set(res->port_id, res->vlan_id);
4368 cmd_reconfig_device_queue(res->port_id, 1, 1);
4371 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4372 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4373 tx_vlan, "tx_vlan");
4374 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4375 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4377 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4378 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4380 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4381 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4384 cmdline_parse_inst_t cmd_tx_vlan_set = {
4385 .f = cmd_tx_vlan_set_parsed,
4387 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4388 "Enable hardware insertion of a single VLAN header "
4389 "with a given TAG Identifier in packets sent on a port",
4391 (void *)&cmd_tx_vlan_set_tx_vlan,
4392 (void *)&cmd_tx_vlan_set_set,
4393 (void *)&cmd_tx_vlan_set_portid,
4394 (void *)&cmd_tx_vlan_set_vlanid,
4399 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4400 struct cmd_tx_vlan_set_qinq_result {
4401 cmdline_fixed_string_t tx_vlan;
4402 cmdline_fixed_string_t set;
4405 uint16_t vlan_id_outer;
4409 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4410 __rte_unused struct cmdline *cl,
4411 __rte_unused void *data)
4413 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4415 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4418 if (!port_is_stopped(res->port_id)) {
4419 printf("Please stop port %d first\n", res->port_id);
4423 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4425 cmd_reconfig_device_queue(res->port_id, 1, 1);
4428 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4429 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4430 tx_vlan, "tx_vlan");
4431 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4432 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4434 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4435 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4437 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4438 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4440 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4441 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4442 vlan_id_outer, UINT16);
4444 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4445 .f = cmd_tx_vlan_set_qinq_parsed,
4447 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4448 "Enable hardware insertion of double VLAN header "
4449 "with given TAG Identifiers in packets sent on a port",
4451 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4452 (void *)&cmd_tx_vlan_set_qinq_set,
4453 (void *)&cmd_tx_vlan_set_qinq_portid,
4454 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4455 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4460 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4461 struct cmd_tx_vlan_set_pvid_result {
4462 cmdline_fixed_string_t tx_vlan;
4463 cmdline_fixed_string_t set;
4464 cmdline_fixed_string_t pvid;
4467 cmdline_fixed_string_t mode;
4471 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4472 __rte_unused struct cmdline *cl,
4473 __rte_unused void *data)
4475 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4477 if (strcmp(res->mode, "on") == 0)
4478 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4480 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4483 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4484 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4485 tx_vlan, "tx_vlan");
4486 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4487 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4489 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4490 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4492 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4493 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4495 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4496 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4498 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4499 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4502 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4503 .f = cmd_tx_vlan_set_pvid_parsed,
4505 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4507 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4508 (void *)&cmd_tx_vlan_set_pvid_set,
4509 (void *)&cmd_tx_vlan_set_pvid_pvid,
4510 (void *)&cmd_tx_vlan_set_pvid_port_id,
4511 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4512 (void *)&cmd_tx_vlan_set_pvid_mode,
4517 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4518 struct cmd_tx_vlan_reset_result {
4519 cmdline_fixed_string_t tx_vlan;
4520 cmdline_fixed_string_t reset;
4525 cmd_tx_vlan_reset_parsed(void *parsed_result,
4526 __rte_unused struct cmdline *cl,
4527 __rte_unused void *data)
4529 struct cmd_tx_vlan_reset_result *res = parsed_result;
4531 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4534 if (!port_is_stopped(res->port_id)) {
4535 printf("Please stop port %d first\n", res->port_id);
4539 tx_vlan_reset(res->port_id);
4541 cmd_reconfig_device_queue(res->port_id, 1, 1);
4544 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4545 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4546 tx_vlan, "tx_vlan");
4547 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4548 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4550 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4551 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4554 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4555 .f = cmd_tx_vlan_reset_parsed,
4557 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4558 "VLAN header in packets sent on a port",
4560 (void *)&cmd_tx_vlan_reset_tx_vlan,
4561 (void *)&cmd_tx_vlan_reset_reset,
4562 (void *)&cmd_tx_vlan_reset_portid,
4568 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4569 struct cmd_csum_result {
4570 cmdline_fixed_string_t csum;
4571 cmdline_fixed_string_t mode;
4572 cmdline_fixed_string_t proto;
4573 cmdline_fixed_string_t hwsw;
4578 csum_show(int port_id)
4580 struct rte_eth_dev_info dev_info;
4581 uint64_t tx_offloads;
4584 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4585 printf("Parse tunnel is %s\n",
4586 (ports[port_id].parse_tunnel) ? "on" : "off");
4587 printf("IP checksum offload is %s\n",
4588 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4589 printf("UDP checksum offload is %s\n",
4590 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4591 printf("TCP checksum offload is %s\n",
4592 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4593 printf("SCTP checksum offload is %s\n",
4594 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4595 printf("Outer-Ip checksum offload is %s\n",
4596 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4597 printf("Outer-Udp checksum offload is %s\n",
4598 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4600 /* display warnings if configuration is not supported by the NIC */
4601 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4605 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4606 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4607 printf("Warning: hardware IP checksum enabled but not "
4608 "supported by port %d\n", port_id);
4610 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4611 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4612 printf("Warning: hardware UDP checksum enabled but not "
4613 "supported by port %d\n", port_id);
4615 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4616 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4617 printf("Warning: hardware TCP checksum enabled but not "
4618 "supported by port %d\n", port_id);
4620 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4621 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4622 printf("Warning: hardware SCTP checksum enabled but not "
4623 "supported by port %d\n", port_id);
4625 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4626 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4627 printf("Warning: hardware outer IP checksum enabled but not "
4628 "supported by port %d\n", port_id);
4630 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4631 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4633 printf("Warning: hardware outer UDP checksum enabled but not "
4634 "supported by port %d\n", port_id);
4639 cmd_config_queue_tx_offloads(struct rte_port *port)
4643 /* Apply queue tx offloads configuration */
4644 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4645 port->tx_conf[k].offloads =
4646 port->dev_conf.txmode.offloads;
4650 cmd_csum_parsed(void *parsed_result,
4651 __rte_unused struct cmdline *cl,
4652 __rte_unused void *data)
4654 struct cmd_csum_result *res = parsed_result;
4656 uint64_t csum_offloads = 0;
4657 struct rte_eth_dev_info dev_info;
4660 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4661 printf("invalid port %d\n", res->port_id);
4664 if (!port_is_stopped(res->port_id)) {
4665 printf("Please stop port %d first\n", res->port_id);
4669 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4673 if (!strcmp(res->mode, "set")) {
4675 if (!strcmp(res->hwsw, "hw"))
4678 if (!strcmp(res->proto, "ip")) {
4679 if (hw == 0 || (dev_info.tx_offload_capa &
4680 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4681 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4683 printf("IP checksum offload is not supported "
4684 "by port %u\n", res->port_id);
4686 } else if (!strcmp(res->proto, "udp")) {
4687 if (hw == 0 || (dev_info.tx_offload_capa &
4688 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4689 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4691 printf("UDP checksum offload is not supported "
4692 "by port %u\n", res->port_id);
4694 } else if (!strcmp(res->proto, "tcp")) {
4695 if (hw == 0 || (dev_info.tx_offload_capa &
4696 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4697 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4699 printf("TCP checksum offload is not supported "
4700 "by port %u\n", res->port_id);
4702 } else if (!strcmp(res->proto, "sctp")) {
4703 if (hw == 0 || (dev_info.tx_offload_capa &
4704 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4705 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4707 printf("SCTP checksum offload is not supported "
4708 "by port %u\n", res->port_id);
4710 } else if (!strcmp(res->proto, "outer-ip")) {
4711 if (hw == 0 || (dev_info.tx_offload_capa &
4712 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4714 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4716 printf("Outer IP checksum offload is not "
4717 "supported by port %u\n", res->port_id);
4719 } else if (!strcmp(res->proto, "outer-udp")) {
4720 if (hw == 0 || (dev_info.tx_offload_capa &
4721 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4723 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4725 printf("Outer UDP checksum offload is not "
4726 "supported by port %u\n", res->port_id);
4731 ports[res->port_id].dev_conf.txmode.offloads |=
4734 ports[res->port_id].dev_conf.txmode.offloads &=
4737 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4739 csum_show(res->port_id);
4741 cmd_reconfig_device_queue(res->port_id, 1, 1);
4744 cmdline_parse_token_string_t cmd_csum_csum =
4745 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4747 cmdline_parse_token_string_t cmd_csum_mode =
4748 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4750 cmdline_parse_token_string_t cmd_csum_proto =
4751 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4752 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4753 cmdline_parse_token_string_t cmd_csum_hwsw =
4754 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4756 cmdline_parse_token_num_t cmd_csum_portid =
4757 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4760 cmdline_parse_inst_t cmd_csum_set = {
4761 .f = cmd_csum_parsed,
4763 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4764 "Enable/Disable hardware calculation of L3/L4 checksum when "
4765 "using csum forward engine",
4767 (void *)&cmd_csum_csum,
4768 (void *)&cmd_csum_mode,
4769 (void *)&cmd_csum_proto,
4770 (void *)&cmd_csum_hwsw,
4771 (void *)&cmd_csum_portid,
4776 cmdline_parse_token_string_t cmd_csum_mode_show =
4777 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4780 cmdline_parse_inst_t cmd_csum_show = {
4781 .f = cmd_csum_parsed,
4783 .help_str = "csum show <port_id>: Show checksum offload configuration",
4785 (void *)&cmd_csum_csum,
4786 (void *)&cmd_csum_mode_show,
4787 (void *)&cmd_csum_portid,
4792 /* Enable/disable tunnel parsing */
4793 struct cmd_csum_tunnel_result {
4794 cmdline_fixed_string_t csum;
4795 cmdline_fixed_string_t parse;
4796 cmdline_fixed_string_t onoff;
4801 cmd_csum_tunnel_parsed(void *parsed_result,
4802 __rte_unused struct cmdline *cl,
4803 __rte_unused void *data)
4805 struct cmd_csum_tunnel_result *res = parsed_result;
4807 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4810 if (!strcmp(res->onoff, "on"))
4811 ports[res->port_id].parse_tunnel = 1;
4813 ports[res->port_id].parse_tunnel = 0;
4815 csum_show(res->port_id);
4818 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4819 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4821 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4822 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4823 parse, "parse-tunnel");
4824 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4825 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4827 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4828 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4831 cmdline_parse_inst_t cmd_csum_tunnel = {
4832 .f = cmd_csum_tunnel_parsed,
4834 .help_str = "csum parse-tunnel on|off <port_id>: "
4835 "Enable/Disable parsing of tunnels for csum engine",
4837 (void *)&cmd_csum_tunnel_csum,
4838 (void *)&cmd_csum_tunnel_parse,
4839 (void *)&cmd_csum_tunnel_onoff,
4840 (void *)&cmd_csum_tunnel_portid,
4845 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4846 struct cmd_tso_set_result {
4847 cmdline_fixed_string_t tso;
4848 cmdline_fixed_string_t mode;
4854 cmd_tso_set_parsed(void *parsed_result,
4855 __rte_unused struct cmdline *cl,
4856 __rte_unused void *data)
4858 struct cmd_tso_set_result *res = parsed_result;
4859 struct rte_eth_dev_info dev_info;
4862 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4864 if (!port_is_stopped(res->port_id)) {
4865 printf("Please stop port %d first\n", res->port_id);
4869 if (!strcmp(res->mode, "set"))
4870 ports[res->port_id].tso_segsz = res->tso_segsz;
4872 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4876 if ((ports[res->port_id].tso_segsz != 0) &&
4877 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4878 printf("Error: TSO is not supported by port %d\n",
4883 if (ports[res->port_id].tso_segsz == 0) {
4884 ports[res->port_id].dev_conf.txmode.offloads &=
4885 ~DEV_TX_OFFLOAD_TCP_TSO;
4886 printf("TSO for non-tunneled packets is disabled\n");
4888 ports[res->port_id].dev_conf.txmode.offloads |=
4889 DEV_TX_OFFLOAD_TCP_TSO;
4890 printf("TSO segment size for non-tunneled packets is %d\n",
4891 ports[res->port_id].tso_segsz);
4893 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4895 /* display warnings if configuration is not supported by the NIC */
4896 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4900 if ((ports[res->port_id].tso_segsz != 0) &&
4901 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4902 printf("Warning: TSO enabled but not "
4903 "supported by port %d\n", res->port_id);
4906 cmd_reconfig_device_queue(res->port_id, 1, 1);
4909 cmdline_parse_token_string_t cmd_tso_set_tso =
4910 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4912 cmdline_parse_token_string_t cmd_tso_set_mode =
4913 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4915 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4916 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4918 cmdline_parse_token_num_t cmd_tso_set_portid =
4919 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4922 cmdline_parse_inst_t cmd_tso_set = {
4923 .f = cmd_tso_set_parsed,
4925 .help_str = "tso set <tso_segsz> <port_id>: "
4926 "Set TSO segment size of non-tunneled packets for csum engine "
4929 (void *)&cmd_tso_set_tso,
4930 (void *)&cmd_tso_set_mode,
4931 (void *)&cmd_tso_set_tso_segsz,
4932 (void *)&cmd_tso_set_portid,
4937 cmdline_parse_token_string_t cmd_tso_show_mode =
4938 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4942 cmdline_parse_inst_t cmd_tso_show = {
4943 .f = cmd_tso_set_parsed,
4945 .help_str = "tso show <port_id>: "
4946 "Show TSO segment size of non-tunneled packets for csum engine",
4948 (void *)&cmd_tso_set_tso,
4949 (void *)&cmd_tso_show_mode,
4950 (void *)&cmd_tso_set_portid,
4955 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4956 struct cmd_tunnel_tso_set_result {
4957 cmdline_fixed_string_t tso;
4958 cmdline_fixed_string_t mode;
4963 static struct rte_eth_dev_info
4964 check_tunnel_tso_nic_support(portid_t port_id)
4966 struct rte_eth_dev_info dev_info;
4968 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4971 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4972 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4973 "not enabled for port %d\n", port_id);
4974 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4975 printf("Warning: GRE TUNNEL TSO not supported therefore "
4976 "not enabled for port %d\n", port_id);
4977 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4978 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4979 "not enabled for port %d\n", port_id);
4980 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4981 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4982 "not enabled for port %d\n", port_id);
4983 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4984 printf("Warning: IP TUNNEL TSO not supported therefore "
4985 "not enabled for port %d\n", port_id);
4986 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4987 printf("Warning: UDP TUNNEL TSO not supported therefore "
4988 "not enabled for port %d\n", port_id);
4993 cmd_tunnel_tso_set_parsed(void *parsed_result,
4994 __rte_unused struct cmdline *cl,
4995 __rte_unused void *data)
4997 struct cmd_tunnel_tso_set_result *res = parsed_result;
4998 struct rte_eth_dev_info dev_info;
5000 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5002 if (!port_is_stopped(res->port_id)) {
5003 printf("Please stop port %d first\n", res->port_id);
5007 if (!strcmp(res->mode, "set"))
5008 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5010 dev_info = check_tunnel_tso_nic_support(res->port_id);
5011 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5012 ports[res->port_id].dev_conf.txmode.offloads &=
5013 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5014 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5015 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5016 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5017 DEV_TX_OFFLOAD_IP_TNL_TSO |
5018 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5019 printf("TSO for tunneled packets is disabled\n");
5021 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5022 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5023 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5024 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5025 DEV_TX_OFFLOAD_IP_TNL_TSO |
5026 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5028 ports[res->port_id].dev_conf.txmode.offloads |=
5029 (tso_offloads & dev_info.tx_offload_capa);
5030 printf("TSO segment size for tunneled packets is %d\n",
5031 ports[res->port_id].tunnel_tso_segsz);
5033 /* Below conditions are needed to make it work:
5034 * (1) tunnel TSO is supported by the NIC;
5035 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5037 * (3) for tunneled pkts with outer L3 of IPv4,
5038 * "csum set outer-ip" must be set to hw, because after tso,
5039 * total_len of outer IP header is changed, and the checksum
5040 * of outer IP header calculated by sw should be wrong; that
5041 * is not necessary for IPv6 tunneled pkts because there's no
5042 * checksum in IP header anymore.
5045 if (!ports[res->port_id].parse_tunnel)
5046 printf("Warning: csum parse_tunnel must be set "
5047 "so that tunneled packets are recognized\n");
5048 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5049 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5050 printf("Warning: csum set outer-ip must be set to hw "
5051 "if outer L3 is IPv4; not necessary for IPv6\n");
5054 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5055 cmd_reconfig_device_queue(res->port_id, 1, 1);
5058 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5059 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5061 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5062 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5064 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5065 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5067 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5068 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5071 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5072 .f = cmd_tunnel_tso_set_parsed,
5074 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5075 "Set TSO segment size of tunneled packets for csum engine "
5078 (void *)&cmd_tunnel_tso_set_tso,
5079 (void *)&cmd_tunnel_tso_set_mode,
5080 (void *)&cmd_tunnel_tso_set_tso_segsz,
5081 (void *)&cmd_tunnel_tso_set_portid,
5086 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5087 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5091 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5092 .f = cmd_tunnel_tso_set_parsed,
5094 .help_str = "tunnel_tso show <port_id> "
5095 "Show TSO segment size of tunneled packets for csum engine",
5097 (void *)&cmd_tunnel_tso_set_tso,
5098 (void *)&cmd_tunnel_tso_show_mode,
5099 (void *)&cmd_tunnel_tso_set_portid,
5104 /* *** SET GRO FOR A PORT *** */
5105 struct cmd_gro_enable_result {
5106 cmdline_fixed_string_t cmd_set;
5107 cmdline_fixed_string_t cmd_port;
5108 cmdline_fixed_string_t cmd_keyword;
5109 cmdline_fixed_string_t cmd_onoff;
5114 cmd_gro_enable_parsed(void *parsed_result,
5115 __rte_unused struct cmdline *cl,
5116 __rte_unused void *data)
5118 struct cmd_gro_enable_result *res;
5120 res = parsed_result;
5121 if (!strcmp(res->cmd_keyword, "gro"))
5122 setup_gro(res->cmd_onoff, res->cmd_pid);
5125 cmdline_parse_token_string_t cmd_gro_enable_set =
5126 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5128 cmdline_parse_token_string_t cmd_gro_enable_port =
5129 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5130 cmd_keyword, "port");
5131 cmdline_parse_token_num_t cmd_gro_enable_pid =
5132 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5134 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5135 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5136 cmd_keyword, "gro");
5137 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5138 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5139 cmd_onoff, "on#off");
5141 cmdline_parse_inst_t cmd_gro_enable = {
5142 .f = cmd_gro_enable_parsed,
5144 .help_str = "set port <port_id> gro on|off",
5146 (void *)&cmd_gro_enable_set,
5147 (void *)&cmd_gro_enable_port,
5148 (void *)&cmd_gro_enable_pid,
5149 (void *)&cmd_gro_enable_keyword,
5150 (void *)&cmd_gro_enable_onoff,
5155 /* *** DISPLAY GRO CONFIGURATION *** */
5156 struct cmd_gro_show_result {
5157 cmdline_fixed_string_t cmd_show;
5158 cmdline_fixed_string_t cmd_port;
5159 cmdline_fixed_string_t cmd_keyword;
5164 cmd_gro_show_parsed(void *parsed_result,
5165 __rte_unused struct cmdline *cl,
5166 __rte_unused void *data)
5168 struct cmd_gro_show_result *res;
5170 res = parsed_result;
5171 if (!strcmp(res->cmd_keyword, "gro"))
5172 show_gro(res->cmd_pid);
5175 cmdline_parse_token_string_t cmd_gro_show_show =
5176 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5178 cmdline_parse_token_string_t cmd_gro_show_port =
5179 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5181 cmdline_parse_token_num_t cmd_gro_show_pid =
5182 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5184 cmdline_parse_token_string_t cmd_gro_show_keyword =
5185 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5186 cmd_keyword, "gro");
5188 cmdline_parse_inst_t cmd_gro_show = {
5189 .f = cmd_gro_show_parsed,
5191 .help_str = "show port <port_id> gro",
5193 (void *)&cmd_gro_show_show,
5194 (void *)&cmd_gro_show_port,
5195 (void *)&cmd_gro_show_pid,
5196 (void *)&cmd_gro_show_keyword,
5201 /* *** SET FLUSH CYCLES FOR GRO *** */
5202 struct cmd_gro_flush_result {
5203 cmdline_fixed_string_t cmd_set;
5204 cmdline_fixed_string_t cmd_keyword;
5205 cmdline_fixed_string_t cmd_flush;
5210 cmd_gro_flush_parsed(void *parsed_result,
5211 __rte_unused struct cmdline *cl,
5212 __rte_unused void *data)
5214 struct cmd_gro_flush_result *res;
5216 res = parsed_result;
5217 if ((!strcmp(res->cmd_keyword, "gro")) &&
5218 (!strcmp(res->cmd_flush, "flush")))
5219 setup_gro_flush_cycles(res->cmd_cycles);
5222 cmdline_parse_token_string_t cmd_gro_flush_set =
5223 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5225 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5226 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5227 cmd_keyword, "gro");
5228 cmdline_parse_token_string_t cmd_gro_flush_flush =
5229 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5230 cmd_flush, "flush");
5231 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5232 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5235 cmdline_parse_inst_t cmd_gro_flush = {
5236 .f = cmd_gro_flush_parsed,
5238 .help_str = "set gro flush <cycles>",
5240 (void *)&cmd_gro_flush_set,
5241 (void *)&cmd_gro_flush_keyword,
5242 (void *)&cmd_gro_flush_flush,
5243 (void *)&cmd_gro_flush_cycles,
5248 /* *** ENABLE/DISABLE GSO *** */
5249 struct cmd_gso_enable_result {
5250 cmdline_fixed_string_t cmd_set;
5251 cmdline_fixed_string_t cmd_port;
5252 cmdline_fixed_string_t cmd_keyword;
5253 cmdline_fixed_string_t cmd_mode;
5258 cmd_gso_enable_parsed(void *parsed_result,
5259 __rte_unused struct cmdline *cl,
5260 __rte_unused void *data)
5262 struct cmd_gso_enable_result *res;
5264 res = parsed_result;
5265 if (!strcmp(res->cmd_keyword, "gso"))
5266 setup_gso(res->cmd_mode, res->cmd_pid);
5269 cmdline_parse_token_string_t cmd_gso_enable_set =
5270 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5272 cmdline_parse_token_string_t cmd_gso_enable_port =
5273 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5275 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5276 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5277 cmd_keyword, "gso");
5278 cmdline_parse_token_string_t cmd_gso_enable_mode =
5279 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5280 cmd_mode, "on#off");
5281 cmdline_parse_token_num_t cmd_gso_enable_pid =
5282 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5285 cmdline_parse_inst_t cmd_gso_enable = {
5286 .f = cmd_gso_enable_parsed,
5288 .help_str = "set port <port_id> gso on|off",
5290 (void *)&cmd_gso_enable_set,
5291 (void *)&cmd_gso_enable_port,
5292 (void *)&cmd_gso_enable_pid,
5293 (void *)&cmd_gso_enable_keyword,
5294 (void *)&cmd_gso_enable_mode,
5299 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5300 struct cmd_gso_size_result {
5301 cmdline_fixed_string_t cmd_set;
5302 cmdline_fixed_string_t cmd_keyword;
5303 cmdline_fixed_string_t cmd_segsz;
5308 cmd_gso_size_parsed(void *parsed_result,
5309 __rte_unused struct cmdline *cl,
5310 __rte_unused void *data)
5312 struct cmd_gso_size_result *res = parsed_result;
5314 if (test_done == 0) {
5315 printf("Before setting GSO segsz, please first"
5316 " stop forwarding\n");
5320 if (!strcmp(res->cmd_keyword, "gso") &&
5321 !strcmp(res->cmd_segsz, "segsz")) {
5322 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5323 printf("gso_size should be larger than %zu."
5324 " Please input a legal value\n",
5325 RTE_GSO_SEG_SIZE_MIN);
5327 gso_max_segment_size = res->cmd_size;
5331 cmdline_parse_token_string_t cmd_gso_size_set =
5332 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5334 cmdline_parse_token_string_t cmd_gso_size_keyword =
5335 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5336 cmd_keyword, "gso");
5337 cmdline_parse_token_string_t cmd_gso_size_segsz =
5338 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5339 cmd_segsz, "segsz");
5340 cmdline_parse_token_num_t cmd_gso_size_size =
5341 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5344 cmdline_parse_inst_t cmd_gso_size = {
5345 .f = cmd_gso_size_parsed,
5347 .help_str = "set gso segsz <length>",
5349 (void *)&cmd_gso_size_set,
5350 (void *)&cmd_gso_size_keyword,
5351 (void *)&cmd_gso_size_segsz,
5352 (void *)&cmd_gso_size_size,
5357 /* *** SHOW GSO CONFIGURATION *** */
5358 struct cmd_gso_show_result {
5359 cmdline_fixed_string_t cmd_show;
5360 cmdline_fixed_string_t cmd_port;
5361 cmdline_fixed_string_t cmd_keyword;
5366 cmd_gso_show_parsed(void *parsed_result,
5367 __rte_unused struct cmdline *cl,
5368 __rte_unused void *data)
5370 struct cmd_gso_show_result *res = parsed_result;
5372 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5373 printf("invalid port id %u\n", res->cmd_pid);
5376 if (!strcmp(res->cmd_keyword, "gso")) {
5377 if (gso_ports[res->cmd_pid].enable) {
5378 printf("Max GSO'd packet size: %uB\n"
5379 "Supported GSO types: TCP/IPv4, "
5380 "UDP/IPv4, VxLAN with inner "
5381 "TCP/IPv4 packet, GRE with inner "
5382 "TCP/IPv4 packet\n",
5383 gso_max_segment_size);
5385 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5389 cmdline_parse_token_string_t cmd_gso_show_show =
5390 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5392 cmdline_parse_token_string_t cmd_gso_show_port =
5393 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5395 cmdline_parse_token_string_t cmd_gso_show_keyword =
5396 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5397 cmd_keyword, "gso");
5398 cmdline_parse_token_num_t cmd_gso_show_pid =
5399 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5402 cmdline_parse_inst_t cmd_gso_show = {
5403 .f = cmd_gso_show_parsed,
5405 .help_str = "show port <port_id> gso",
5407 (void *)&cmd_gso_show_show,
5408 (void *)&cmd_gso_show_port,
5409 (void *)&cmd_gso_show_pid,
5410 (void *)&cmd_gso_show_keyword,
5415 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5416 struct cmd_set_flush_rx {
5417 cmdline_fixed_string_t set;
5418 cmdline_fixed_string_t flush_rx;
5419 cmdline_fixed_string_t mode;
5423 cmd_set_flush_rx_parsed(void *parsed_result,
5424 __rte_unused struct cmdline *cl,
5425 __rte_unused void *data)
5427 struct cmd_set_flush_rx *res = parsed_result;
5428 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5431 cmdline_parse_token_string_t cmd_setflushrx_set =
5432 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5434 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5435 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5436 flush_rx, "flush_rx");
5437 cmdline_parse_token_string_t cmd_setflushrx_mode =
5438 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5442 cmdline_parse_inst_t cmd_set_flush_rx = {
5443 .f = cmd_set_flush_rx_parsed,
5444 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5447 (void *)&cmd_setflushrx_set,
5448 (void *)&cmd_setflushrx_flush_rx,
5449 (void *)&cmd_setflushrx_mode,
5454 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5455 struct cmd_set_link_check {
5456 cmdline_fixed_string_t set;
5457 cmdline_fixed_string_t link_check;
5458 cmdline_fixed_string_t mode;
5462 cmd_set_link_check_parsed(void *parsed_result,
5463 __rte_unused struct cmdline *cl,
5464 __rte_unused void *data)
5466 struct cmd_set_link_check *res = parsed_result;
5467 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5470 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5471 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5473 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5474 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5475 link_check, "link_check");
5476 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5477 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5481 cmdline_parse_inst_t cmd_set_link_check = {
5482 .f = cmd_set_link_check_parsed,
5483 .help_str = "set link_check on|off: Enable/Disable link status check "
5484 "when starting/stopping a port",
5487 (void *)&cmd_setlinkcheck_set,
5488 (void *)&cmd_setlinkcheck_link_check,
5489 (void *)&cmd_setlinkcheck_mode,
5494 /* *** SET NIC BYPASS MODE *** */
5495 struct cmd_set_bypass_mode_result {
5496 cmdline_fixed_string_t set;
5497 cmdline_fixed_string_t bypass;
5498 cmdline_fixed_string_t mode;
5499 cmdline_fixed_string_t value;
5504 cmd_set_bypass_mode_parsed(void *parsed_result,
5505 __rte_unused struct cmdline *cl,
5506 __rte_unused void *data)
5508 struct cmd_set_bypass_mode_result *res = parsed_result;
5509 portid_t port_id = res->port_id;
5510 int32_t rc = -EINVAL;
5512 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5513 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5515 if (!strcmp(res->value, "bypass"))
5516 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5517 else if (!strcmp(res->value, "isolate"))
5518 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5520 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5522 /* Set the bypass mode for the relevant port. */
5523 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5526 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5529 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5530 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5532 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5533 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5535 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5536 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5538 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5539 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5540 value, "normal#bypass#isolate");
5541 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5542 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5545 cmdline_parse_inst_t cmd_set_bypass_mode = {
5546 .f = cmd_set_bypass_mode_parsed,
5547 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5548 "Set the NIC bypass mode for port_id",
5551 (void *)&cmd_setbypass_mode_set,
5552 (void *)&cmd_setbypass_mode_bypass,
5553 (void *)&cmd_setbypass_mode_mode,
5554 (void *)&cmd_setbypass_mode_value,
5555 (void *)&cmd_setbypass_mode_port,
5560 /* *** SET NIC BYPASS EVENT *** */
5561 struct cmd_set_bypass_event_result {
5562 cmdline_fixed_string_t set;
5563 cmdline_fixed_string_t bypass;
5564 cmdline_fixed_string_t event;
5565 cmdline_fixed_string_t event_value;
5566 cmdline_fixed_string_t mode;
5567 cmdline_fixed_string_t mode_value;
5572 cmd_set_bypass_event_parsed(void *parsed_result,
5573 __rte_unused struct cmdline *cl,
5574 __rte_unused void *data)
5576 int32_t rc = -EINVAL;
5577 struct cmd_set_bypass_event_result *res = parsed_result;
5578 portid_t port_id = res->port_id;
5580 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5581 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5582 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5584 if (!strcmp(res->event_value, "timeout"))
5585 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5586 else if (!strcmp(res->event_value, "os_on"))
5587 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5588 else if (!strcmp(res->event_value, "os_off"))
5589 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5590 else if (!strcmp(res->event_value, "power_on"))
5591 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5592 else if (!strcmp(res->event_value, "power_off"))
5593 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5595 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5597 if (!strcmp(res->mode_value, "bypass"))
5598 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5599 else if (!strcmp(res->mode_value, "isolate"))
5600 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5602 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5604 /* Set the watchdog timeout. */
5605 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5608 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5609 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5613 printf("Failed to set timeout value %u "
5614 "for port %d, errto code: %d.\n",
5615 bypass_timeout, port_id, rc);
5619 /* Set the bypass event to transition to bypass mode. */
5620 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5625 printf("\t Failed to set bypass event for port = %d.\n",
5629 cmdline_parse_token_string_t cmd_setbypass_event_set =
5630 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5632 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5633 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5635 cmdline_parse_token_string_t cmd_setbypass_event_event =
5636 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5638 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5639 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5640 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5641 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5642 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5644 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5645 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5646 mode_value, "normal#bypass#isolate");
5647 cmdline_parse_token_num_t cmd_setbypass_event_port =
5648 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5651 cmdline_parse_inst_t cmd_set_bypass_event = {
5652 .f = cmd_set_bypass_event_parsed,
5653 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5654 "power_off mode normal|bypass|isolate <port_id>: "
5655 "Set the NIC bypass event mode for port_id",
5658 (void *)&cmd_setbypass_event_set,
5659 (void *)&cmd_setbypass_event_bypass,
5660 (void *)&cmd_setbypass_event_event,
5661 (void *)&cmd_setbypass_event_event_value,
5662 (void *)&cmd_setbypass_event_mode,
5663 (void *)&cmd_setbypass_event_mode_value,
5664 (void *)&cmd_setbypass_event_port,
5670 /* *** SET NIC BYPASS TIMEOUT *** */
5671 struct cmd_set_bypass_timeout_result {
5672 cmdline_fixed_string_t set;
5673 cmdline_fixed_string_t bypass;
5674 cmdline_fixed_string_t timeout;
5675 cmdline_fixed_string_t value;
5679 cmd_set_bypass_timeout_parsed(void *parsed_result,
5680 __rte_unused struct cmdline *cl,
5681 __rte_unused void *data)
5683 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5685 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5686 if (!strcmp(res->value, "1.5"))
5687 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5688 else if (!strcmp(res->value, "2"))
5689 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5690 else if (!strcmp(res->value, "3"))
5691 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5692 else if (!strcmp(res->value, "4"))
5693 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5694 else if (!strcmp(res->value, "8"))
5695 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5696 else if (!strcmp(res->value, "16"))
5697 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5698 else if (!strcmp(res->value, "32"))
5699 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5701 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5705 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5706 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5708 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5709 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5711 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5712 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5713 timeout, "timeout");
5714 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5715 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5716 value, "0#1.5#2#3#4#8#16#32");
5718 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5719 .f = cmd_set_bypass_timeout_parsed,
5720 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5721 "Set the NIC bypass watchdog timeout in seconds",
5724 (void *)&cmd_setbypass_timeout_set,
5725 (void *)&cmd_setbypass_timeout_bypass,
5726 (void *)&cmd_setbypass_timeout_timeout,
5727 (void *)&cmd_setbypass_timeout_value,
5732 /* *** SHOW NIC BYPASS MODE *** */
5733 struct cmd_show_bypass_config_result {
5734 cmdline_fixed_string_t show;
5735 cmdline_fixed_string_t bypass;
5736 cmdline_fixed_string_t config;
5741 cmd_show_bypass_config_parsed(void *parsed_result,
5742 __rte_unused struct cmdline *cl,
5743 __rte_unused void *data)
5745 struct cmd_show_bypass_config_result *res = parsed_result;
5746 portid_t port_id = res->port_id;
5748 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5749 uint32_t event_mode;
5750 uint32_t bypass_mode;
5751 uint32_t timeout = bypass_timeout;
5754 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5755 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5756 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5757 {"UNKNOWN", "normal", "bypass", "isolate"};
5758 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5766 /* Display the bypass mode.*/
5767 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5768 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5772 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5773 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5775 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5778 /* Display the bypass timeout.*/
5779 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5780 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5782 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5784 /* Display the bypass events and associated modes. */
5785 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5787 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5788 printf("\tFailed to get bypass mode for event = %s\n",
5791 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5792 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5794 printf("\tbypass event: %-16s = %s\n", events[i],
5800 printf("\tFailed to get bypass configuration for port = %d\n",
5804 cmdline_parse_token_string_t cmd_showbypass_config_show =
5805 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5807 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5808 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5810 cmdline_parse_token_string_t cmd_showbypass_config_config =
5811 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5813 cmdline_parse_token_num_t cmd_showbypass_config_port =
5814 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5817 cmdline_parse_inst_t cmd_show_bypass_config = {
5818 .f = cmd_show_bypass_config_parsed,
5819 .help_str = "show bypass config <port_id>: "
5820 "Show the NIC bypass config for port_id",
5823 (void *)&cmd_showbypass_config_show,
5824 (void *)&cmd_showbypass_config_bypass,
5825 (void *)&cmd_showbypass_config_config,
5826 (void *)&cmd_showbypass_config_port,
5832 /* *** SET BONDING MODE *** */
5833 struct cmd_set_bonding_mode_result {
5834 cmdline_fixed_string_t set;
5835 cmdline_fixed_string_t bonding;
5836 cmdline_fixed_string_t mode;
5841 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5842 __rte_unused struct cmdline *cl,
5843 __rte_unused void *data)
5845 struct cmd_set_bonding_mode_result *res = parsed_result;
5846 portid_t port_id = res->port_id;
5848 /* Set the bonding mode for the relevant port. */
5849 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5850 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5853 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5854 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5856 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5857 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5858 bonding, "bonding");
5859 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5860 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5862 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5863 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5865 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5866 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5869 cmdline_parse_inst_t cmd_set_bonding_mode = {
5870 .f = cmd_set_bonding_mode_parsed,
5871 .help_str = "set bonding mode <mode_value> <port_id>: "
5872 "Set the bonding mode for port_id",
5875 (void *) &cmd_setbonding_mode_set,
5876 (void *) &cmd_setbonding_mode_bonding,
5877 (void *) &cmd_setbonding_mode_mode,
5878 (void *) &cmd_setbonding_mode_value,
5879 (void *) &cmd_setbonding_mode_port,
5884 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5885 struct cmd_set_bonding_lacp_dedicated_queues_result {
5886 cmdline_fixed_string_t set;
5887 cmdline_fixed_string_t bonding;
5888 cmdline_fixed_string_t lacp;
5889 cmdline_fixed_string_t dedicated_queues;
5891 cmdline_fixed_string_t mode;
5894 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5895 __rte_unused struct cmdline *cl,
5896 __rte_unused void *data)
5898 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5899 portid_t port_id = res->port_id;
5900 struct rte_port *port;
5902 port = &ports[port_id];
5904 /** Check if the port is not started **/
5905 if (port->port_status != RTE_PORT_STOPPED) {
5906 printf("Please stop port %d first\n", port_id);
5910 if (!strcmp(res->mode, "enable")) {
5911 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5912 printf("Dedicate queues for LACP control packets"
5915 printf("Enabling dedicate queues for LACP control "
5916 "packets on port %d failed\n", port_id);
5917 } else if (!strcmp(res->mode, "disable")) {
5918 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5919 printf("Dedicated queues for LACP control packets "
5922 printf("Disabling dedicated queues for LACP control "
5923 "traffic on port %d failed\n", port_id);
5927 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5928 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5930 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5931 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5932 bonding, "bonding");
5933 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5934 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5936 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5937 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5938 dedicated_queues, "dedicated_queues");
5939 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5940 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5942 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5943 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5944 mode, "enable#disable");
5946 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5947 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5948 .help_str = "set bonding lacp dedicated_queues <port_id> "
5950 "Enable/disable dedicated queues for LACP control traffic for port_id",
5953 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5954 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5955 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5956 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5957 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5958 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5963 /* *** SET BALANCE XMIT POLICY *** */
5964 struct cmd_set_bonding_balance_xmit_policy_result {
5965 cmdline_fixed_string_t set;
5966 cmdline_fixed_string_t bonding;
5967 cmdline_fixed_string_t balance_xmit_policy;
5969 cmdline_fixed_string_t policy;
5972 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5973 __rte_unused struct cmdline *cl,
5974 __rte_unused void *data)
5976 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5977 portid_t port_id = res->port_id;
5980 if (!strcmp(res->policy, "l2")) {
5981 policy = BALANCE_XMIT_POLICY_LAYER2;
5982 } else if (!strcmp(res->policy, "l23")) {
5983 policy = BALANCE_XMIT_POLICY_LAYER23;
5984 } else if (!strcmp(res->policy, "l34")) {
5985 policy = BALANCE_XMIT_POLICY_LAYER34;
5987 printf("\t Invalid xmit policy selection");
5991 /* Set the bonding mode for the relevant port. */
5992 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5993 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5998 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5999 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6001 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6002 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6003 bonding, "bonding");
6004 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6005 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6006 balance_xmit_policy, "balance_xmit_policy");
6007 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6008 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6010 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6011 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6012 policy, "l2#l23#l34");
6014 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6015 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6016 .help_str = "set bonding balance_xmit_policy <port_id> "
6018 "Set the bonding balance_xmit_policy for port_id",
6021 (void *)&cmd_setbonding_balance_xmit_policy_set,
6022 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6023 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6024 (void *)&cmd_setbonding_balance_xmit_policy_port,
6025 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6030 /* *** SHOW NIC BONDING CONFIGURATION *** */
6031 struct cmd_show_bonding_config_result {
6032 cmdline_fixed_string_t show;
6033 cmdline_fixed_string_t bonding;
6034 cmdline_fixed_string_t config;
6038 static void cmd_show_bonding_config_parsed(void *parsed_result,
6039 __rte_unused struct cmdline *cl,
6040 __rte_unused void *data)
6042 struct cmd_show_bonding_config_result *res = parsed_result;
6043 int bonding_mode, agg_mode;
6044 portid_t slaves[RTE_MAX_ETHPORTS];
6045 int num_slaves, num_active_slaves;
6048 portid_t port_id = res->port_id;
6050 /* Display the bonding mode.*/
6051 bonding_mode = rte_eth_bond_mode_get(port_id);
6052 if (bonding_mode < 0) {
6053 printf("\tFailed to get bonding mode for port = %d\n", port_id);
6056 printf("\tBonding mode: %d\n", bonding_mode);
6058 if (bonding_mode == BONDING_MODE_BALANCE) {
6059 int balance_xmit_policy;
6061 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6062 if (balance_xmit_policy < 0) {
6063 printf("\tFailed to get balance xmit policy for port = %d\n",
6067 printf("\tBalance Xmit Policy: ");
6069 switch (balance_xmit_policy) {
6070 case BALANCE_XMIT_POLICY_LAYER2:
6071 printf("BALANCE_XMIT_POLICY_LAYER2");
6073 case BALANCE_XMIT_POLICY_LAYER23:
6074 printf("BALANCE_XMIT_POLICY_LAYER23");
6076 case BALANCE_XMIT_POLICY_LAYER34:
6077 printf("BALANCE_XMIT_POLICY_LAYER34");
6084 if (bonding_mode == BONDING_MODE_8023AD) {
6085 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6086 printf("\tIEEE802.3AD Aggregator Mode: ");
6089 printf("bandwidth");
6101 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6103 if (num_slaves < 0) {
6104 printf("\tFailed to get slave list for port = %d\n", port_id);
6107 if (num_slaves > 0) {
6108 printf("\tSlaves (%d): [", num_slaves);
6109 for (i = 0; i < num_slaves - 1; i++)
6110 printf("%d ", slaves[i]);
6112 printf("%d]\n", slaves[num_slaves - 1]);
6114 printf("\tSlaves: []\n");
6118 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6121 if (num_active_slaves < 0) {
6122 printf("\tFailed to get active slave list for port = %d\n", port_id);
6125 if (num_active_slaves > 0) {
6126 printf("\tActive Slaves (%d): [", num_active_slaves);
6127 for (i = 0; i < num_active_slaves - 1; i++)
6128 printf("%d ", slaves[i]);
6130 printf("%d]\n", slaves[num_active_slaves - 1]);
6133 printf("\tActive Slaves: []\n");
6137 primary_id = rte_eth_bond_primary_get(port_id);
6138 if (primary_id < 0) {
6139 printf("\tFailed to get primary slave for port = %d\n", port_id);
6142 printf("\tPrimary: [%d]\n", primary_id);
6146 cmdline_parse_token_string_t cmd_showbonding_config_show =
6147 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6149 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6150 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6151 bonding, "bonding");
6152 cmdline_parse_token_string_t cmd_showbonding_config_config =
6153 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6155 cmdline_parse_token_num_t cmd_showbonding_config_port =
6156 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6159 cmdline_parse_inst_t cmd_show_bonding_config = {
6160 .f = cmd_show_bonding_config_parsed,
6161 .help_str = "show bonding config <port_id>: "
6162 "Show the bonding config for port_id",
6165 (void *)&cmd_showbonding_config_show,
6166 (void *)&cmd_showbonding_config_bonding,
6167 (void *)&cmd_showbonding_config_config,
6168 (void *)&cmd_showbonding_config_port,
6173 /* *** SET BONDING PRIMARY *** */
6174 struct cmd_set_bonding_primary_result {
6175 cmdline_fixed_string_t set;
6176 cmdline_fixed_string_t bonding;
6177 cmdline_fixed_string_t primary;
6182 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6183 __rte_unused struct cmdline *cl,
6184 __rte_unused void *data)
6186 struct cmd_set_bonding_primary_result *res = parsed_result;
6187 portid_t master_port_id = res->port_id;
6188 portid_t slave_port_id = res->slave_id;
6190 /* Set the primary slave for a bonded device. */
6191 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6192 printf("\t Failed to set primary slave for port = %d.\n",
6199 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6200 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6202 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6203 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6204 bonding, "bonding");
6205 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6206 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6207 primary, "primary");
6208 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6209 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6211 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6212 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6215 cmdline_parse_inst_t cmd_set_bonding_primary = {
6216 .f = cmd_set_bonding_primary_parsed,
6217 .help_str = "set bonding primary <slave_id> <port_id>: "
6218 "Set the primary slave for port_id",
6221 (void *)&cmd_setbonding_primary_set,
6222 (void *)&cmd_setbonding_primary_bonding,
6223 (void *)&cmd_setbonding_primary_primary,
6224 (void *)&cmd_setbonding_primary_slave,
6225 (void *)&cmd_setbonding_primary_port,
6230 /* *** ADD SLAVE *** */
6231 struct cmd_add_bonding_slave_result {
6232 cmdline_fixed_string_t add;
6233 cmdline_fixed_string_t bonding;
6234 cmdline_fixed_string_t slave;
6239 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6240 __rte_unused struct cmdline *cl,
6241 __rte_unused void *data)
6243 struct cmd_add_bonding_slave_result *res = parsed_result;
6244 portid_t master_port_id = res->port_id;
6245 portid_t slave_port_id = res->slave_id;
6247 /* add the slave for a bonded device. */
6248 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6249 printf("\t Failed to add slave %d to master port = %d.\n",
6250 slave_port_id, master_port_id);
6254 set_port_slave_flag(slave_port_id);
6257 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6258 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6260 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6261 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6262 bonding, "bonding");
6263 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6264 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6266 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6267 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6269 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6270 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6273 cmdline_parse_inst_t cmd_add_bonding_slave = {
6274 .f = cmd_add_bonding_slave_parsed,
6275 .help_str = "add bonding slave <slave_id> <port_id>: "
6276 "Add a slave device to a bonded device",
6279 (void *)&cmd_addbonding_slave_add,
6280 (void *)&cmd_addbonding_slave_bonding,
6281 (void *)&cmd_addbonding_slave_slave,
6282 (void *)&cmd_addbonding_slave_slaveid,
6283 (void *)&cmd_addbonding_slave_port,
6288 /* *** REMOVE SLAVE *** */
6289 struct cmd_remove_bonding_slave_result {
6290 cmdline_fixed_string_t remove;
6291 cmdline_fixed_string_t bonding;
6292 cmdline_fixed_string_t slave;
6297 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6298 __rte_unused struct cmdline *cl,
6299 __rte_unused void *data)
6301 struct cmd_remove_bonding_slave_result *res = parsed_result;
6302 portid_t master_port_id = res->port_id;
6303 portid_t slave_port_id = res->slave_id;
6305 /* remove the slave from a bonded device. */
6306 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6307 printf("\t Failed to remove slave %d from master port = %d.\n",
6308 slave_port_id, master_port_id);
6312 clear_port_slave_flag(slave_port_id);
6315 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6316 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6318 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6319 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6320 bonding, "bonding");
6321 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6322 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6324 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6325 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6327 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6328 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6331 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6332 .f = cmd_remove_bonding_slave_parsed,
6333 .help_str = "remove bonding slave <slave_id> <port_id>: "
6334 "Remove a slave device from a bonded device",
6337 (void *)&cmd_removebonding_slave_remove,
6338 (void *)&cmd_removebonding_slave_bonding,
6339 (void *)&cmd_removebonding_slave_slave,
6340 (void *)&cmd_removebonding_slave_slaveid,
6341 (void *)&cmd_removebonding_slave_port,
6346 /* *** CREATE BONDED DEVICE *** */
6347 struct cmd_create_bonded_device_result {
6348 cmdline_fixed_string_t create;
6349 cmdline_fixed_string_t bonded;
6350 cmdline_fixed_string_t device;
6355 static int bond_dev_num = 0;
6357 static void cmd_create_bonded_device_parsed(void *parsed_result,
6358 __rte_unused struct cmdline *cl,
6359 __rte_unused void *data)
6361 struct cmd_create_bonded_device_result *res = parsed_result;
6362 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6366 if (test_done == 0) {
6367 printf("Please stop forwarding first\n");
6371 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6374 /* Create a new bonded device. */
6375 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6377 printf("\t Failed to create bonded device.\n");
6380 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6383 /* Update number of ports */
6384 nb_ports = rte_eth_dev_count_avail();
6385 reconfig(port_id, res->socket);
6386 ret = rte_eth_promiscuous_enable(port_id);
6388 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6389 port_id, rte_strerror(-ret));
6391 ports[port_id].need_setup = 0;
6392 ports[port_id].port_status = RTE_PORT_STOPPED;
6397 cmdline_parse_token_string_t cmd_createbonded_device_create =
6398 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6400 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6401 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6403 cmdline_parse_token_string_t cmd_createbonded_device_device =
6404 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6406 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6407 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6409 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6410 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6413 cmdline_parse_inst_t cmd_create_bonded_device = {
6414 .f = cmd_create_bonded_device_parsed,
6415 .help_str = "create bonded device <mode> <socket>: "
6416 "Create a new bonded device with specific bonding mode and socket",
6419 (void *)&cmd_createbonded_device_create,
6420 (void *)&cmd_createbonded_device_bonded,
6421 (void *)&cmd_createbonded_device_device,
6422 (void *)&cmd_createbonded_device_mode,
6423 (void *)&cmd_createbonded_device_socket,
6428 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6429 struct cmd_set_bond_mac_addr_result {
6430 cmdline_fixed_string_t set;
6431 cmdline_fixed_string_t bonding;
6432 cmdline_fixed_string_t mac_addr;
6434 struct rte_ether_addr address;
6437 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6438 __rte_unused struct cmdline *cl,
6439 __rte_unused void *data)
6441 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6444 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6447 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6449 /* check the return value and print it if is < 0 */
6451 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6454 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6455 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6456 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6457 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6459 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6460 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6462 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6463 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6465 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6466 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6468 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6469 .f = cmd_set_bond_mac_addr_parsed,
6471 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6473 (void *)&cmd_set_bond_mac_addr_set,
6474 (void *)&cmd_set_bond_mac_addr_bonding,
6475 (void *)&cmd_set_bond_mac_addr_mac,
6476 (void *)&cmd_set_bond_mac_addr_portnum,
6477 (void *)&cmd_set_bond_mac_addr_addr,
6483 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6484 struct cmd_set_bond_mon_period_result {
6485 cmdline_fixed_string_t set;
6486 cmdline_fixed_string_t bonding;
6487 cmdline_fixed_string_t mon_period;
6492 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6493 __rte_unused struct cmdline *cl,
6494 __rte_unused void *data)
6496 struct cmd_set_bond_mon_period_result *res = parsed_result;
6499 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6501 /* check the return value and print it if is < 0 */
6503 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6506 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6507 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6509 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6510 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6511 bonding, "bonding");
6512 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6513 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6514 mon_period, "mon_period");
6515 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6516 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6518 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6519 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6522 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6523 .f = cmd_set_bond_mon_period_parsed,
6525 .help_str = "set bonding mon_period <port_id> <period_ms>",
6527 (void *)&cmd_set_bond_mon_period_set,
6528 (void *)&cmd_set_bond_mon_period_bonding,
6529 (void *)&cmd_set_bond_mon_period_mon_period,
6530 (void *)&cmd_set_bond_mon_period_portnum,
6531 (void *)&cmd_set_bond_mon_period_period_ms,
6538 struct cmd_set_bonding_agg_mode_policy_result {
6539 cmdline_fixed_string_t set;
6540 cmdline_fixed_string_t bonding;
6541 cmdline_fixed_string_t agg_mode;
6543 cmdline_fixed_string_t policy;
6548 cmd_set_bonding_agg_mode(void *parsed_result,
6549 __rte_unused struct cmdline *cl,
6550 __rte_unused void *data)
6552 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6553 uint8_t policy = AGG_BANDWIDTH;
6555 if (!strcmp(res->policy, "bandwidth"))
6556 policy = AGG_BANDWIDTH;
6557 else if (!strcmp(res->policy, "stable"))
6558 policy = AGG_STABLE;
6559 else if (!strcmp(res->policy, "count"))
6562 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6566 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6567 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6569 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6570 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6571 bonding, "bonding");
6573 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6574 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6575 agg_mode, "agg_mode");
6577 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6578 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6581 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6582 TOKEN_STRING_INITIALIZER(
6583 struct cmd_set_bonding_balance_xmit_policy_result,
6584 policy, "stable#bandwidth#count");
6586 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6587 .f = cmd_set_bonding_agg_mode,
6589 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6591 (void *)&cmd_set_bonding_agg_mode_set,
6592 (void *)&cmd_set_bonding_agg_mode_bonding,
6593 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6594 (void *)&cmd_set_bonding_agg_mode_portnum,
6595 (void *)&cmd_set_bonding_agg_mode_policy_string,
6601 #endif /* RTE_NET_BOND */
6603 /* *** SET FORWARDING MODE *** */
6604 struct cmd_set_fwd_mode_result {
6605 cmdline_fixed_string_t set;
6606 cmdline_fixed_string_t fwd;
6607 cmdline_fixed_string_t mode;
6610 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6611 __rte_unused struct cmdline *cl,
6612 __rte_unused void *data)
6614 struct cmd_set_fwd_mode_result *res = parsed_result;
6617 set_pkt_forwarding_mode(res->mode);
6620 cmdline_parse_token_string_t cmd_setfwd_set =
6621 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6622 cmdline_parse_token_string_t cmd_setfwd_fwd =
6623 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6624 cmdline_parse_token_string_t cmd_setfwd_mode =
6625 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6626 "" /* defined at init */);
6628 cmdline_parse_inst_t cmd_set_fwd_mode = {
6629 .f = cmd_set_fwd_mode_parsed,
6631 .help_str = NULL, /* defined at init */
6633 (void *)&cmd_setfwd_set,
6634 (void *)&cmd_setfwd_fwd,
6635 (void *)&cmd_setfwd_mode,
6640 static void cmd_set_fwd_mode_init(void)
6643 static char token[128];
6644 static char help[256];
6645 cmdline_parse_token_string_t *token_struct;
6647 modes = list_pkt_forwarding_modes();
6648 snprintf(help, sizeof(help), "set fwd %s: "
6649 "Set packet forwarding mode", modes);
6650 cmd_set_fwd_mode.help_str = help;
6652 /* string token separator is # */
6653 for (c = token; *modes != '\0'; modes++)
6658 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6659 token_struct->string_data.str = token;
6662 /* *** SET RETRY FORWARDING MODE *** */
6663 struct cmd_set_fwd_retry_mode_result {
6664 cmdline_fixed_string_t set;
6665 cmdline_fixed_string_t fwd;
6666 cmdline_fixed_string_t mode;
6667 cmdline_fixed_string_t retry;
6670 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6671 __rte_unused struct cmdline *cl,
6672 __rte_unused void *data)
6674 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6677 set_pkt_forwarding_mode(res->mode);
6680 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6681 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6683 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6684 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6686 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6687 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6689 "" /* defined at init */);
6690 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6691 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6694 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6695 .f = cmd_set_fwd_retry_mode_parsed,
6697 .help_str = NULL, /* defined at init */
6699 (void *)&cmd_setfwd_retry_set,
6700 (void *)&cmd_setfwd_retry_fwd,
6701 (void *)&cmd_setfwd_retry_mode,
6702 (void *)&cmd_setfwd_retry_retry,
6707 static void cmd_set_fwd_retry_mode_init(void)
6710 static char token[128];
6711 static char help[256];
6712 cmdline_parse_token_string_t *token_struct;
6714 modes = list_pkt_forwarding_retry_modes();
6715 snprintf(help, sizeof(help), "set fwd %s retry: "
6716 "Set packet forwarding mode with retry", modes);
6717 cmd_set_fwd_retry_mode.help_str = help;
6719 /* string token separator is # */
6720 for (c = token; *modes != '\0'; modes++)
6725 token_struct = (cmdline_parse_token_string_t *)
6726 cmd_set_fwd_retry_mode.tokens[2];
6727 token_struct->string_data.str = token;
6730 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6731 struct cmd_set_burst_tx_retry_result {
6732 cmdline_fixed_string_t set;
6733 cmdline_fixed_string_t burst;
6734 cmdline_fixed_string_t tx;
6735 cmdline_fixed_string_t delay;
6737 cmdline_fixed_string_t retry;
6741 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6742 __rte_unused struct cmdline *cl,
6743 __rte_unused void *data)
6745 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6747 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6748 && !strcmp(res->tx, "tx")) {
6749 if (!strcmp(res->delay, "delay"))
6750 burst_tx_delay_time = res->time;
6751 if (!strcmp(res->retry, "retry"))
6752 burst_tx_retry_num = res->retry_num;
6757 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6758 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6759 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6760 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6762 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6763 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6764 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6765 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6766 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6767 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6768 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6769 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6770 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6771 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6773 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6774 .f = cmd_set_burst_tx_retry_parsed,
6775 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6777 (void *)&cmd_set_burst_tx_retry_set,
6778 (void *)&cmd_set_burst_tx_retry_burst,
6779 (void *)&cmd_set_burst_tx_retry_tx,
6780 (void *)&cmd_set_burst_tx_retry_delay,
6781 (void *)&cmd_set_burst_tx_retry_time,
6782 (void *)&cmd_set_burst_tx_retry_retry,
6783 (void *)&cmd_set_burst_tx_retry_retry_num,
6788 /* *** SET PROMISC MODE *** */
6789 struct cmd_set_promisc_mode_result {
6790 cmdline_fixed_string_t set;
6791 cmdline_fixed_string_t promisc;
6792 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6793 uint16_t port_num; /* valid if "allports" argument == 0 */
6794 cmdline_fixed_string_t mode;
6797 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6798 __rte_unused struct cmdline *cl,
6801 struct cmd_set_promisc_mode_result *res = parsed_result;
6805 if (!strcmp(res->mode, "on"))
6812 RTE_ETH_FOREACH_DEV(i)
6813 eth_set_promisc_mode(i, enable);
6815 eth_set_promisc_mode(res->port_num, enable);
6819 cmdline_parse_token_string_t cmd_setpromisc_set =
6820 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6821 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6822 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6824 cmdline_parse_token_string_t cmd_setpromisc_portall =
6825 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6827 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6828 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6830 cmdline_parse_token_string_t cmd_setpromisc_mode =
6831 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6834 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6835 .f = cmd_set_promisc_mode_parsed,
6837 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6839 (void *)&cmd_setpromisc_set,
6840 (void *)&cmd_setpromisc_promisc,
6841 (void *)&cmd_setpromisc_portall,
6842 (void *)&cmd_setpromisc_mode,
6847 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6848 .f = cmd_set_promisc_mode_parsed,
6850 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6852 (void *)&cmd_setpromisc_set,
6853 (void *)&cmd_setpromisc_promisc,
6854 (void *)&cmd_setpromisc_portnum,
6855 (void *)&cmd_setpromisc_mode,
6860 /* *** SET ALLMULTI MODE *** */
6861 struct cmd_set_allmulti_mode_result {
6862 cmdline_fixed_string_t set;
6863 cmdline_fixed_string_t allmulti;
6864 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6865 uint16_t port_num; /* valid if "allports" argument == 0 */
6866 cmdline_fixed_string_t mode;
6869 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6870 __rte_unused struct cmdline *cl,
6873 struct cmd_set_allmulti_mode_result *res = parsed_result;
6877 if (!strcmp(res->mode, "on"))
6884 RTE_ETH_FOREACH_DEV(i) {
6885 eth_set_allmulticast_mode(i, enable);
6889 eth_set_allmulticast_mode(res->port_num, enable);
6893 cmdline_parse_token_string_t cmd_setallmulti_set =
6894 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6895 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6896 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6898 cmdline_parse_token_string_t cmd_setallmulti_portall =
6899 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6901 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6902 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6904 cmdline_parse_token_string_t cmd_setallmulti_mode =
6905 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6908 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6909 .f = cmd_set_allmulti_mode_parsed,
6911 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6913 (void *)&cmd_setallmulti_set,
6914 (void *)&cmd_setallmulti_allmulti,
6915 (void *)&cmd_setallmulti_portall,
6916 (void *)&cmd_setallmulti_mode,
6921 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6922 .f = cmd_set_allmulti_mode_parsed,
6924 .help_str = "set allmulti <port_id> on|off: "
6925 "Set allmulti mode on port_id",
6927 (void *)&cmd_setallmulti_set,
6928 (void *)&cmd_setallmulti_allmulti,
6929 (void *)&cmd_setallmulti_portnum,
6930 (void *)&cmd_setallmulti_mode,
6935 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6936 struct cmd_link_flow_ctrl_set_result {
6937 cmdline_fixed_string_t set;
6938 cmdline_fixed_string_t flow_ctrl;
6939 cmdline_fixed_string_t rx;
6940 cmdline_fixed_string_t rx_lfc_mode;
6941 cmdline_fixed_string_t tx;
6942 cmdline_fixed_string_t tx_lfc_mode;
6943 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6944 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6945 cmdline_fixed_string_t autoneg_str;
6946 cmdline_fixed_string_t autoneg;
6947 cmdline_fixed_string_t hw_str;
6948 uint32_t high_water;
6949 cmdline_fixed_string_t lw_str;
6951 cmdline_fixed_string_t pt_str;
6952 uint16_t pause_time;
6953 cmdline_fixed_string_t xon_str;
6958 cmdline_parse_token_string_t cmd_lfc_set_set =
6959 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6961 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6962 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6963 flow_ctrl, "flow_ctrl");
6964 cmdline_parse_token_string_t cmd_lfc_set_rx =
6965 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6967 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6968 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6969 rx_lfc_mode, "on#off");
6970 cmdline_parse_token_string_t cmd_lfc_set_tx =
6971 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6973 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6974 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6975 tx_lfc_mode, "on#off");
6976 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6977 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6978 hw_str, "high_water");
6979 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6980 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6981 high_water, UINT32);
6982 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6983 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6984 lw_str, "low_water");
6985 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6986 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6988 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6989 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6990 pt_str, "pause_time");
6991 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6992 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6993 pause_time, UINT16);
6994 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6995 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6996 xon_str, "send_xon");
6997 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6998 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7000 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7001 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7002 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7003 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7004 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7005 mac_ctrl_frame_fwd_mode, "on#off");
7006 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7007 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7008 autoneg_str, "autoneg");
7009 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7010 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7012 cmdline_parse_token_num_t cmd_lfc_set_portid =
7013 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7016 /* forward declaration */
7018 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7021 cmdline_parse_inst_t cmd_link_flow_control_set = {
7022 .f = cmd_link_flow_ctrl_set_parsed,
7024 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7025 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7026 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7028 (void *)&cmd_lfc_set_set,
7029 (void *)&cmd_lfc_set_flow_ctrl,
7030 (void *)&cmd_lfc_set_rx,
7031 (void *)&cmd_lfc_set_rx_mode,
7032 (void *)&cmd_lfc_set_tx,
7033 (void *)&cmd_lfc_set_tx_mode,
7034 (void *)&cmd_lfc_set_high_water,
7035 (void *)&cmd_lfc_set_low_water,
7036 (void *)&cmd_lfc_set_pause_time,
7037 (void *)&cmd_lfc_set_send_xon,
7038 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7039 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7040 (void *)&cmd_lfc_set_autoneg_str,
7041 (void *)&cmd_lfc_set_autoneg,
7042 (void *)&cmd_lfc_set_portid,
7047 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7048 .f = cmd_link_flow_ctrl_set_parsed,
7049 .data = (void *)&cmd_link_flow_control_set_rx,
7050 .help_str = "set flow_ctrl rx on|off <port_id>: "
7051 "Change rx flow control parameter",
7053 (void *)&cmd_lfc_set_set,
7054 (void *)&cmd_lfc_set_flow_ctrl,
7055 (void *)&cmd_lfc_set_rx,
7056 (void *)&cmd_lfc_set_rx_mode,
7057 (void *)&cmd_lfc_set_portid,
7062 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7063 .f = cmd_link_flow_ctrl_set_parsed,
7064 .data = (void *)&cmd_link_flow_control_set_tx,
7065 .help_str = "set flow_ctrl tx on|off <port_id>: "
7066 "Change tx flow control parameter",
7068 (void *)&cmd_lfc_set_set,
7069 (void *)&cmd_lfc_set_flow_ctrl,
7070 (void *)&cmd_lfc_set_tx,
7071 (void *)&cmd_lfc_set_tx_mode,
7072 (void *)&cmd_lfc_set_portid,
7077 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7078 .f = cmd_link_flow_ctrl_set_parsed,
7079 .data = (void *)&cmd_link_flow_control_set_hw,
7080 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7081 "Change high water flow control parameter",
7083 (void *)&cmd_lfc_set_set,
7084 (void *)&cmd_lfc_set_flow_ctrl,
7085 (void *)&cmd_lfc_set_high_water_str,
7086 (void *)&cmd_lfc_set_high_water,
7087 (void *)&cmd_lfc_set_portid,
7092 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7093 .f = cmd_link_flow_ctrl_set_parsed,
7094 .data = (void *)&cmd_link_flow_control_set_lw,
7095 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7096 "Change low water flow control parameter",
7098 (void *)&cmd_lfc_set_set,
7099 (void *)&cmd_lfc_set_flow_ctrl,
7100 (void *)&cmd_lfc_set_low_water_str,
7101 (void *)&cmd_lfc_set_low_water,
7102 (void *)&cmd_lfc_set_portid,
7107 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7108 .f = cmd_link_flow_ctrl_set_parsed,
7109 .data = (void *)&cmd_link_flow_control_set_pt,
7110 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7111 "Change pause time flow control parameter",
7113 (void *)&cmd_lfc_set_set,
7114 (void *)&cmd_lfc_set_flow_ctrl,
7115 (void *)&cmd_lfc_set_pause_time_str,
7116 (void *)&cmd_lfc_set_pause_time,
7117 (void *)&cmd_lfc_set_portid,
7122 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7123 .f = cmd_link_flow_ctrl_set_parsed,
7124 .data = (void *)&cmd_link_flow_control_set_xon,
7125 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7126 "Change send_xon flow control parameter",
7128 (void *)&cmd_lfc_set_set,
7129 (void *)&cmd_lfc_set_flow_ctrl,
7130 (void *)&cmd_lfc_set_send_xon_str,
7131 (void *)&cmd_lfc_set_send_xon,
7132 (void *)&cmd_lfc_set_portid,
7137 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7138 .f = cmd_link_flow_ctrl_set_parsed,
7139 .data = (void *)&cmd_link_flow_control_set_macfwd,
7140 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7141 "Change mac ctrl fwd flow control parameter",
7143 (void *)&cmd_lfc_set_set,
7144 (void *)&cmd_lfc_set_flow_ctrl,
7145 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7146 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7147 (void *)&cmd_lfc_set_portid,
7152 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7153 .f = cmd_link_flow_ctrl_set_parsed,
7154 .data = (void *)&cmd_link_flow_control_set_autoneg,
7155 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7156 "Change autoneg flow control parameter",
7158 (void *)&cmd_lfc_set_set,
7159 (void *)&cmd_lfc_set_flow_ctrl,
7160 (void *)&cmd_lfc_set_autoneg_str,
7161 (void *)&cmd_lfc_set_autoneg,
7162 (void *)&cmd_lfc_set_portid,
7168 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7169 __rte_unused struct cmdline *cl,
7172 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7173 cmdline_parse_inst_t *cmd = data;
7174 struct rte_eth_fc_conf fc_conf;
7180 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7181 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7182 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7183 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7185 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7186 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7189 /* Partial command line, retrieve current configuration */
7191 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7193 printf("cannot get current flow ctrl parameters, return"
7194 "code = %d\n", ret);
7198 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7199 (fc_conf.mode == RTE_FC_FULL))
7201 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7202 (fc_conf.mode == RTE_FC_FULL))
7206 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7207 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7209 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7210 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7212 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7214 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7215 fc_conf.high_water = res->high_water;
7217 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7218 fc_conf.low_water = res->low_water;
7220 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7221 fc_conf.pause_time = res->pause_time;
7223 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7224 fc_conf.send_xon = res->send_xon;
7226 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7227 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7228 fc_conf.mac_ctrl_frame_fwd = 1;
7230 fc_conf.mac_ctrl_frame_fwd = 0;
7233 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7234 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7236 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7238 printf("bad flow contrl parameter, return code = %d \n", ret);
7241 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7242 struct cmd_priority_flow_ctrl_set_result {
7243 cmdline_fixed_string_t set;
7244 cmdline_fixed_string_t pfc_ctrl;
7245 cmdline_fixed_string_t rx;
7246 cmdline_fixed_string_t rx_pfc_mode;
7247 cmdline_fixed_string_t tx;
7248 cmdline_fixed_string_t tx_pfc_mode;
7249 uint32_t high_water;
7251 uint16_t pause_time;
7257 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7258 __rte_unused struct cmdline *cl,
7259 __rte_unused void *data)
7261 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7262 struct rte_eth_pfc_conf pfc_conf;
7263 int rx_fc_enable, tx_fc_enable;
7267 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7268 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7269 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7270 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7272 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7273 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7276 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7277 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7278 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7279 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7280 pfc_conf.fc.high_water = res->high_water;
7281 pfc_conf.fc.low_water = res->low_water;
7282 pfc_conf.fc.pause_time = res->pause_time;
7283 pfc_conf.priority = res->priority;
7285 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7287 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7290 cmdline_parse_token_string_t cmd_pfc_set_set =
7291 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7293 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7294 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7295 pfc_ctrl, "pfc_ctrl");
7296 cmdline_parse_token_string_t cmd_pfc_set_rx =
7297 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7299 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7300 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7301 rx_pfc_mode, "on#off");
7302 cmdline_parse_token_string_t cmd_pfc_set_tx =
7303 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7305 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7306 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7307 tx_pfc_mode, "on#off");
7308 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7309 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7310 high_water, UINT32);
7311 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7312 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7314 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7315 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7316 pause_time, UINT16);
7317 cmdline_parse_token_num_t cmd_pfc_set_priority =
7318 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7320 cmdline_parse_token_num_t cmd_pfc_set_portid =
7321 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7324 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7325 .f = cmd_priority_flow_ctrl_set_parsed,
7327 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7328 "<pause_time> <priority> <port_id>: "
7329 "Configure the Ethernet priority flow control",
7331 (void *)&cmd_pfc_set_set,
7332 (void *)&cmd_pfc_set_flow_ctrl,
7333 (void *)&cmd_pfc_set_rx,
7334 (void *)&cmd_pfc_set_rx_mode,
7335 (void *)&cmd_pfc_set_tx,
7336 (void *)&cmd_pfc_set_tx_mode,
7337 (void *)&cmd_pfc_set_high_water,
7338 (void *)&cmd_pfc_set_low_water,
7339 (void *)&cmd_pfc_set_pause_time,
7340 (void *)&cmd_pfc_set_priority,
7341 (void *)&cmd_pfc_set_portid,
7346 /* *** RESET CONFIGURATION *** */
7347 struct cmd_reset_result {
7348 cmdline_fixed_string_t reset;
7349 cmdline_fixed_string_t def;
7352 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7354 __rte_unused void *data)
7356 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7357 set_def_fwd_config();
7360 cmdline_parse_token_string_t cmd_reset_set =
7361 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7362 cmdline_parse_token_string_t cmd_reset_def =
7363 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7366 cmdline_parse_inst_t cmd_reset = {
7367 .f = cmd_reset_parsed,
7369 .help_str = "set default: Reset default forwarding configuration",
7371 (void *)&cmd_reset_set,
7372 (void *)&cmd_reset_def,
7377 /* *** START FORWARDING *** */
7378 struct cmd_start_result {
7379 cmdline_fixed_string_t start;
7382 cmdline_parse_token_string_t cmd_start_start =
7383 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7385 static void cmd_start_parsed(__rte_unused void *parsed_result,
7386 __rte_unused struct cmdline *cl,
7387 __rte_unused void *data)
7389 start_packet_forwarding(0);
7392 cmdline_parse_inst_t cmd_start = {
7393 .f = cmd_start_parsed,
7395 .help_str = "start: Start packet forwarding",
7397 (void *)&cmd_start_start,
7402 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7403 struct cmd_start_tx_first_result {
7404 cmdline_fixed_string_t start;
7405 cmdline_fixed_string_t tx_first;
7409 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7410 __rte_unused struct cmdline *cl,
7411 __rte_unused void *data)
7413 start_packet_forwarding(1);
7416 cmdline_parse_token_string_t cmd_start_tx_first_start =
7417 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7419 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7420 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7421 tx_first, "tx_first");
7423 cmdline_parse_inst_t cmd_start_tx_first = {
7424 .f = cmd_start_tx_first_parsed,
7426 .help_str = "start tx_first: Start packet forwarding, "
7427 "after sending 1 burst of packets",
7429 (void *)&cmd_start_tx_first_start,
7430 (void *)&cmd_start_tx_first_tx_first,
7435 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7436 struct cmd_start_tx_first_n_result {
7437 cmdline_fixed_string_t start;
7438 cmdline_fixed_string_t tx_first;
7443 cmd_start_tx_first_n_parsed(void *parsed_result,
7444 __rte_unused struct cmdline *cl,
7445 __rte_unused void *data)
7447 struct cmd_start_tx_first_n_result *res = parsed_result;
7449 start_packet_forwarding(res->tx_num);
7452 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7453 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7455 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7456 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7457 tx_first, "tx_first");
7458 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7459 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7462 cmdline_parse_inst_t cmd_start_tx_first_n = {
7463 .f = cmd_start_tx_first_n_parsed,
7465 .help_str = "start tx_first <num>: "
7466 "packet forwarding, after sending <num> bursts of packets",
7468 (void *)&cmd_start_tx_first_n_start,
7469 (void *)&cmd_start_tx_first_n_tx_first,
7470 (void *)&cmd_start_tx_first_n_tx_num,
7475 /* *** SET LINK UP *** */
7476 struct cmd_set_link_up_result {
7477 cmdline_fixed_string_t set;
7478 cmdline_fixed_string_t link_up;
7479 cmdline_fixed_string_t port;
7483 cmdline_parse_token_string_t cmd_set_link_up_set =
7484 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7485 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7486 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7488 cmdline_parse_token_string_t cmd_set_link_up_port =
7489 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7490 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7491 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7493 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7494 __rte_unused struct cmdline *cl,
7495 __rte_unused void *data)
7497 struct cmd_set_link_up_result *res = parsed_result;
7498 dev_set_link_up(res->port_id);
7501 cmdline_parse_inst_t cmd_set_link_up = {
7502 .f = cmd_set_link_up_parsed,
7504 .help_str = "set link-up port <port id>",
7506 (void *)&cmd_set_link_up_set,
7507 (void *)&cmd_set_link_up_link_up,
7508 (void *)&cmd_set_link_up_port,
7509 (void *)&cmd_set_link_up_port_id,
7514 /* *** SET LINK DOWN *** */
7515 struct cmd_set_link_down_result {
7516 cmdline_fixed_string_t set;
7517 cmdline_fixed_string_t link_down;
7518 cmdline_fixed_string_t port;
7522 cmdline_parse_token_string_t cmd_set_link_down_set =
7523 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7524 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7525 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7527 cmdline_parse_token_string_t cmd_set_link_down_port =
7528 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7529 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7530 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7532 static void cmd_set_link_down_parsed(
7533 __rte_unused void *parsed_result,
7534 __rte_unused struct cmdline *cl,
7535 __rte_unused void *data)
7537 struct cmd_set_link_down_result *res = parsed_result;
7538 dev_set_link_down(res->port_id);
7541 cmdline_parse_inst_t cmd_set_link_down = {
7542 .f = cmd_set_link_down_parsed,
7544 .help_str = "set link-down port <port id>",
7546 (void *)&cmd_set_link_down_set,
7547 (void *)&cmd_set_link_down_link_down,
7548 (void *)&cmd_set_link_down_port,
7549 (void *)&cmd_set_link_down_port_id,
7554 /* *** SHOW CFG *** */
7555 struct cmd_showcfg_result {
7556 cmdline_fixed_string_t show;
7557 cmdline_fixed_string_t cfg;
7558 cmdline_fixed_string_t what;
7561 static void cmd_showcfg_parsed(void *parsed_result,
7562 __rte_unused struct cmdline *cl,
7563 __rte_unused void *data)
7565 struct cmd_showcfg_result *res = parsed_result;
7566 if (!strcmp(res->what, "rxtx"))
7567 rxtx_config_display();
7568 else if (!strcmp(res->what, "cores"))
7569 fwd_lcores_config_display();
7570 else if (!strcmp(res->what, "fwd"))
7571 pkt_fwd_config_display(&cur_fwd_config);
7572 else if (!strcmp(res->what, "rxoffs"))
7573 show_rx_pkt_offsets();
7574 else if (!strcmp(res->what, "rxpkts"))
7575 show_rx_pkt_segments();
7576 else if (!strcmp(res->what, "txpkts"))
7577 show_tx_pkt_segments();
7578 else if (!strcmp(res->what, "txtimes"))
7579 show_tx_pkt_times();
7582 cmdline_parse_token_string_t cmd_showcfg_show =
7583 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7584 cmdline_parse_token_string_t cmd_showcfg_port =
7585 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7586 cmdline_parse_token_string_t cmd_showcfg_what =
7587 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7588 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7590 cmdline_parse_inst_t cmd_showcfg = {
7591 .f = cmd_showcfg_parsed,
7593 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7595 (void *)&cmd_showcfg_show,
7596 (void *)&cmd_showcfg_port,
7597 (void *)&cmd_showcfg_what,
7602 /* *** SHOW ALL PORT INFO *** */
7603 struct cmd_showportall_result {
7604 cmdline_fixed_string_t show;
7605 cmdline_fixed_string_t port;
7606 cmdline_fixed_string_t what;
7607 cmdline_fixed_string_t all;
7610 static void cmd_showportall_parsed(void *parsed_result,
7611 __rte_unused struct cmdline *cl,
7612 __rte_unused void *data)
7616 struct cmd_showportall_result *res = parsed_result;
7617 if (!strcmp(res->show, "clear")) {
7618 if (!strcmp(res->what, "stats"))
7619 RTE_ETH_FOREACH_DEV(i)
7621 else if (!strcmp(res->what, "xstats"))
7622 RTE_ETH_FOREACH_DEV(i)
7623 nic_xstats_clear(i);
7624 } else if (!strcmp(res->what, "info"))
7625 RTE_ETH_FOREACH_DEV(i)
7626 port_infos_display(i);
7627 else if (!strcmp(res->what, "summary")) {
7628 port_summary_header_display();
7629 RTE_ETH_FOREACH_DEV(i)
7630 port_summary_display(i);
7632 else if (!strcmp(res->what, "stats"))
7633 RTE_ETH_FOREACH_DEV(i)
7634 nic_stats_display(i);
7635 else if (!strcmp(res->what, "xstats"))
7636 RTE_ETH_FOREACH_DEV(i)
7637 nic_xstats_display(i);
7638 else if (!strcmp(res->what, "fdir"))
7639 RTE_ETH_FOREACH_DEV(i)
7641 else if (!strcmp(res->what, "stat_qmap"))
7642 RTE_ETH_FOREACH_DEV(i)
7643 nic_stats_mapping_display(i);
7644 else if (!strcmp(res->what, "dcb_tc"))
7645 RTE_ETH_FOREACH_DEV(i)
7646 port_dcb_info_display(i);
7647 else if (!strcmp(res->what, "cap"))
7648 RTE_ETH_FOREACH_DEV(i)
7649 port_offload_cap_display(i);
7652 cmdline_parse_token_string_t cmd_showportall_show =
7653 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7655 cmdline_parse_token_string_t cmd_showportall_port =
7656 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7657 cmdline_parse_token_string_t cmd_showportall_what =
7658 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7659 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7660 cmdline_parse_token_string_t cmd_showportall_all =
7661 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7662 cmdline_parse_inst_t cmd_showportall = {
7663 .f = cmd_showportall_parsed,
7665 .help_str = "show|clear port "
7666 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7668 (void *)&cmd_showportall_show,
7669 (void *)&cmd_showportall_port,
7670 (void *)&cmd_showportall_what,
7671 (void *)&cmd_showportall_all,
7676 /* *** SHOW PORT INFO *** */
7677 struct cmd_showport_result {
7678 cmdline_fixed_string_t show;
7679 cmdline_fixed_string_t port;
7680 cmdline_fixed_string_t what;
7684 static void cmd_showport_parsed(void *parsed_result,
7685 __rte_unused struct cmdline *cl,
7686 __rte_unused void *data)
7688 struct cmd_showport_result *res = parsed_result;
7689 if (!strcmp(res->show, "clear")) {
7690 if (!strcmp(res->what, "stats"))
7691 nic_stats_clear(res->portnum);
7692 else if (!strcmp(res->what, "xstats"))
7693 nic_xstats_clear(res->portnum);
7694 } else if (!strcmp(res->what, "info"))
7695 port_infos_display(res->portnum);
7696 else if (!strcmp(res->what, "summary")) {
7697 port_summary_header_display();
7698 port_summary_display(res->portnum);
7700 else if (!strcmp(res->what, "stats"))
7701 nic_stats_display(res->portnum);
7702 else if (!strcmp(res->what, "xstats"))
7703 nic_xstats_display(res->portnum);
7704 else if (!strcmp(res->what, "fdir"))
7705 fdir_get_infos(res->portnum);
7706 else if (!strcmp(res->what, "stat_qmap"))
7707 nic_stats_mapping_display(res->portnum);
7708 else if (!strcmp(res->what, "dcb_tc"))
7709 port_dcb_info_display(res->portnum);
7710 else if (!strcmp(res->what, "cap"))
7711 port_offload_cap_display(res->portnum);
7714 cmdline_parse_token_string_t cmd_showport_show =
7715 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7717 cmdline_parse_token_string_t cmd_showport_port =
7718 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7719 cmdline_parse_token_string_t cmd_showport_what =
7720 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7721 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7722 cmdline_parse_token_num_t cmd_showport_portnum =
7723 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7725 cmdline_parse_inst_t cmd_showport = {
7726 .f = cmd_showport_parsed,
7728 .help_str = "show|clear port "
7729 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7732 (void *)&cmd_showport_show,
7733 (void *)&cmd_showport_port,
7734 (void *)&cmd_showport_what,
7735 (void *)&cmd_showport_portnum,
7740 /* *** SHOW DEVICE INFO *** */
7741 struct cmd_showdevice_result {
7742 cmdline_fixed_string_t show;
7743 cmdline_fixed_string_t device;
7744 cmdline_fixed_string_t what;
7745 cmdline_fixed_string_t identifier;
7748 static void cmd_showdevice_parsed(void *parsed_result,
7749 __rte_unused struct cmdline *cl,
7750 __rte_unused void *data)
7752 struct cmd_showdevice_result *res = parsed_result;
7753 if (!strcmp(res->what, "info")) {
7754 if (!strcmp(res->identifier, "all"))
7755 device_infos_display(NULL);
7757 device_infos_display(res->identifier);
7761 cmdline_parse_token_string_t cmd_showdevice_show =
7762 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7764 cmdline_parse_token_string_t cmd_showdevice_device =
7765 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7766 cmdline_parse_token_string_t cmd_showdevice_what =
7767 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7769 cmdline_parse_token_string_t cmd_showdevice_identifier =
7770 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7773 cmdline_parse_inst_t cmd_showdevice = {
7774 .f = cmd_showdevice_parsed,
7776 .help_str = "show device info <identifier>|all",
7778 (void *)&cmd_showdevice_show,
7779 (void *)&cmd_showdevice_device,
7780 (void *)&cmd_showdevice_what,
7781 (void *)&cmd_showdevice_identifier,
7786 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7787 struct cmd_showeeprom_result {
7788 cmdline_fixed_string_t show;
7789 cmdline_fixed_string_t port;
7791 cmdline_fixed_string_t type;
7794 static void cmd_showeeprom_parsed(void *parsed_result,
7795 __rte_unused struct cmdline *cl,
7796 __rte_unused void *data)
7798 struct cmd_showeeprom_result *res = parsed_result;
7800 if (!strcmp(res->type, "eeprom"))
7801 port_eeprom_display(res->portnum);
7802 else if (!strcmp(res->type, "module_eeprom"))
7803 port_module_eeprom_display(res->portnum);
7805 printf("Unknown argument\n");
7808 cmdline_parse_token_string_t cmd_showeeprom_show =
7809 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7810 cmdline_parse_token_string_t cmd_showeeprom_port =
7811 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7812 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7813 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum, UINT16);
7814 cmdline_parse_token_string_t cmd_showeeprom_type =
7815 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7817 cmdline_parse_inst_t cmd_showeeprom = {
7818 .f = cmd_showeeprom_parsed,
7820 .help_str = "show port <port_id> module_eeprom|eeprom",
7822 (void *)&cmd_showeeprom_show,
7823 (void *)&cmd_showeeprom_port,
7824 (void *)&cmd_showeeprom_portnum,
7825 (void *)&cmd_showeeprom_type,
7830 /* *** SHOW QUEUE INFO *** */
7831 struct cmd_showqueue_result {
7832 cmdline_fixed_string_t show;
7833 cmdline_fixed_string_t type;
7834 cmdline_fixed_string_t what;
7840 cmd_showqueue_parsed(void *parsed_result,
7841 __rte_unused struct cmdline *cl,
7842 __rte_unused void *data)
7844 struct cmd_showqueue_result *res = parsed_result;
7846 if (!strcmp(res->type, "rxq"))
7847 rx_queue_infos_display(res->portnum, res->queuenum);
7848 else if (!strcmp(res->type, "txq"))
7849 tx_queue_infos_display(res->portnum, res->queuenum);
7852 cmdline_parse_token_string_t cmd_showqueue_show =
7853 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7854 cmdline_parse_token_string_t cmd_showqueue_type =
7855 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7856 cmdline_parse_token_string_t cmd_showqueue_what =
7857 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7858 cmdline_parse_token_num_t cmd_showqueue_portnum =
7859 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7860 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7861 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7863 cmdline_parse_inst_t cmd_showqueue = {
7864 .f = cmd_showqueue_parsed,
7866 .help_str = "show rxq|txq info <port_id> <queue_id>",
7868 (void *)&cmd_showqueue_show,
7869 (void *)&cmd_showqueue_type,
7870 (void *)&cmd_showqueue_what,
7871 (void *)&cmd_showqueue_portnum,
7872 (void *)&cmd_showqueue_queuenum,
7877 /* show/clear fwd engine statistics */
7879 cmdline_fixed_string_t action;
7880 cmdline_fixed_string_t fwd;
7881 cmdline_fixed_string_t stats;
7882 cmdline_fixed_string_t all;
7885 cmdline_parse_token_string_t cmd_fwd_action =
7886 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7887 cmdline_parse_token_string_t cmd_fwd_fwd =
7888 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7889 cmdline_parse_token_string_t cmd_fwd_stats =
7890 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7891 cmdline_parse_token_string_t cmd_fwd_all =
7892 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7895 cmd_showfwdall_parsed(void *parsed_result,
7896 __rte_unused struct cmdline *cl,
7897 __rte_unused void *data)
7899 struct fwd_result *res = parsed_result;
7901 if (!strcmp(res->action, "show"))
7902 fwd_stats_display();
7907 static cmdline_parse_inst_t cmd_showfwdall = {
7908 .f = cmd_showfwdall_parsed,
7910 .help_str = "show|clear fwd stats all",
7912 (void *)&cmd_fwd_action,
7913 (void *)&cmd_fwd_fwd,
7914 (void *)&cmd_fwd_stats,
7915 (void *)&cmd_fwd_all,
7920 /* *** READ PORT REGISTER *** */
7921 struct cmd_read_reg_result {
7922 cmdline_fixed_string_t read;
7923 cmdline_fixed_string_t reg;
7929 cmd_read_reg_parsed(void *parsed_result,
7930 __rte_unused struct cmdline *cl,
7931 __rte_unused void *data)
7933 struct cmd_read_reg_result *res = parsed_result;
7934 port_reg_display(res->port_id, res->reg_off);
7937 cmdline_parse_token_string_t cmd_read_reg_read =
7938 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7939 cmdline_parse_token_string_t cmd_read_reg_reg =
7940 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7941 cmdline_parse_token_num_t cmd_read_reg_port_id =
7942 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7943 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7944 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7946 cmdline_parse_inst_t cmd_read_reg = {
7947 .f = cmd_read_reg_parsed,
7949 .help_str = "read reg <port_id> <reg_off>",
7951 (void *)&cmd_read_reg_read,
7952 (void *)&cmd_read_reg_reg,
7953 (void *)&cmd_read_reg_port_id,
7954 (void *)&cmd_read_reg_reg_off,
7959 /* *** READ PORT REGISTER BIT FIELD *** */
7960 struct cmd_read_reg_bit_field_result {
7961 cmdline_fixed_string_t read;
7962 cmdline_fixed_string_t regfield;
7970 cmd_read_reg_bit_field_parsed(void *parsed_result,
7971 __rte_unused struct cmdline *cl,
7972 __rte_unused void *data)
7974 struct cmd_read_reg_bit_field_result *res = parsed_result;
7975 port_reg_bit_field_display(res->port_id, res->reg_off,
7976 res->bit1_pos, res->bit2_pos);
7979 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7980 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7982 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7983 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7984 regfield, "regfield");
7985 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7986 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7988 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7989 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7991 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7992 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7994 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7995 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7998 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7999 .f = cmd_read_reg_bit_field_parsed,
8001 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8002 "Read register bit field between bit_x and bit_y included",
8004 (void *)&cmd_read_reg_bit_field_read,
8005 (void *)&cmd_read_reg_bit_field_regfield,
8006 (void *)&cmd_read_reg_bit_field_port_id,
8007 (void *)&cmd_read_reg_bit_field_reg_off,
8008 (void *)&cmd_read_reg_bit_field_bit1_pos,
8009 (void *)&cmd_read_reg_bit_field_bit2_pos,
8014 /* *** READ PORT REGISTER BIT *** */
8015 struct cmd_read_reg_bit_result {
8016 cmdline_fixed_string_t read;
8017 cmdline_fixed_string_t regbit;
8024 cmd_read_reg_bit_parsed(void *parsed_result,
8025 __rte_unused struct cmdline *cl,
8026 __rte_unused void *data)
8028 struct cmd_read_reg_bit_result *res = parsed_result;
8029 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8032 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8033 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8034 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8035 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8037 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8038 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
8039 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8040 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
8041 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8042 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
8044 cmdline_parse_inst_t cmd_read_reg_bit = {
8045 .f = cmd_read_reg_bit_parsed,
8047 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8049 (void *)&cmd_read_reg_bit_read,
8050 (void *)&cmd_read_reg_bit_regbit,
8051 (void *)&cmd_read_reg_bit_port_id,
8052 (void *)&cmd_read_reg_bit_reg_off,
8053 (void *)&cmd_read_reg_bit_bit_pos,
8058 /* *** WRITE PORT REGISTER *** */
8059 struct cmd_write_reg_result {
8060 cmdline_fixed_string_t write;
8061 cmdline_fixed_string_t reg;
8068 cmd_write_reg_parsed(void *parsed_result,
8069 __rte_unused struct cmdline *cl,
8070 __rte_unused void *data)
8072 struct cmd_write_reg_result *res = parsed_result;
8073 port_reg_set(res->port_id, res->reg_off, res->value);
8076 cmdline_parse_token_string_t cmd_write_reg_write =
8077 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8078 cmdline_parse_token_string_t cmd_write_reg_reg =
8079 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8080 cmdline_parse_token_num_t cmd_write_reg_port_id =
8081 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
8082 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8083 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
8084 cmdline_parse_token_num_t cmd_write_reg_value =
8085 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
8087 cmdline_parse_inst_t cmd_write_reg = {
8088 .f = cmd_write_reg_parsed,
8090 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8092 (void *)&cmd_write_reg_write,
8093 (void *)&cmd_write_reg_reg,
8094 (void *)&cmd_write_reg_port_id,
8095 (void *)&cmd_write_reg_reg_off,
8096 (void *)&cmd_write_reg_value,
8101 /* *** WRITE PORT REGISTER BIT FIELD *** */
8102 struct cmd_write_reg_bit_field_result {
8103 cmdline_fixed_string_t write;
8104 cmdline_fixed_string_t regfield;
8113 cmd_write_reg_bit_field_parsed(void *parsed_result,
8114 __rte_unused struct cmdline *cl,
8115 __rte_unused void *data)
8117 struct cmd_write_reg_bit_field_result *res = parsed_result;
8118 port_reg_bit_field_set(res->port_id, res->reg_off,
8119 res->bit1_pos, res->bit2_pos, res->value);
8122 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8123 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8125 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8126 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8127 regfield, "regfield");
8128 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8129 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8131 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8132 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8134 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8135 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8137 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8138 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8140 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8141 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8144 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8145 .f = cmd_write_reg_bit_field_parsed,
8147 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8149 "Set register bit field between bit_x and bit_y included",
8151 (void *)&cmd_write_reg_bit_field_write,
8152 (void *)&cmd_write_reg_bit_field_regfield,
8153 (void *)&cmd_write_reg_bit_field_port_id,
8154 (void *)&cmd_write_reg_bit_field_reg_off,
8155 (void *)&cmd_write_reg_bit_field_bit1_pos,
8156 (void *)&cmd_write_reg_bit_field_bit2_pos,
8157 (void *)&cmd_write_reg_bit_field_value,
8162 /* *** WRITE PORT REGISTER BIT *** */
8163 struct cmd_write_reg_bit_result {
8164 cmdline_fixed_string_t write;
8165 cmdline_fixed_string_t regbit;
8173 cmd_write_reg_bit_parsed(void *parsed_result,
8174 __rte_unused struct cmdline *cl,
8175 __rte_unused void *data)
8177 struct cmd_write_reg_bit_result *res = parsed_result;
8178 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8181 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8182 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8184 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8185 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8187 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8188 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
8189 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8190 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
8191 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8192 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
8193 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8194 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
8196 cmdline_parse_inst_t cmd_write_reg_bit = {
8197 .f = cmd_write_reg_bit_parsed,
8199 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8202 (void *)&cmd_write_reg_bit_write,
8203 (void *)&cmd_write_reg_bit_regbit,
8204 (void *)&cmd_write_reg_bit_port_id,
8205 (void *)&cmd_write_reg_bit_reg_off,
8206 (void *)&cmd_write_reg_bit_bit_pos,
8207 (void *)&cmd_write_reg_bit_value,
8212 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8213 struct cmd_read_rxd_txd_result {
8214 cmdline_fixed_string_t read;
8215 cmdline_fixed_string_t rxd_txd;
8222 cmd_read_rxd_txd_parsed(void *parsed_result,
8223 __rte_unused struct cmdline *cl,
8224 __rte_unused void *data)
8226 struct cmd_read_rxd_txd_result *res = parsed_result;
8228 if (!strcmp(res->rxd_txd, "rxd"))
8229 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8230 else if (!strcmp(res->rxd_txd, "txd"))
8231 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8234 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8235 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8236 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8237 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8239 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8240 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8241 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8242 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8243 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8244 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8246 cmdline_parse_inst_t cmd_read_rxd_txd = {
8247 .f = cmd_read_rxd_txd_parsed,
8249 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8251 (void *)&cmd_read_rxd_txd_read,
8252 (void *)&cmd_read_rxd_txd_rxd_txd,
8253 (void *)&cmd_read_rxd_txd_port_id,
8254 (void *)&cmd_read_rxd_txd_queue_id,
8255 (void *)&cmd_read_rxd_txd_desc_id,
8261 struct cmd_quit_result {
8262 cmdline_fixed_string_t quit;
8265 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8267 __rte_unused void *data)
8272 cmdline_parse_token_string_t cmd_quit_quit =
8273 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8275 cmdline_parse_inst_t cmd_quit = {
8276 .f = cmd_quit_parsed,
8278 .help_str = "quit: Exit application",
8280 (void *)&cmd_quit_quit,
8285 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8286 struct cmd_mac_addr_result {
8287 cmdline_fixed_string_t mac_addr_cmd;
8288 cmdline_fixed_string_t what;
8290 struct rte_ether_addr address;
8293 static void cmd_mac_addr_parsed(void *parsed_result,
8294 __rte_unused struct cmdline *cl,
8295 __rte_unused void *data)
8297 struct cmd_mac_addr_result *res = parsed_result;
8300 if (strcmp(res->what, "add") == 0)
8301 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8302 else if (strcmp(res->what, "set") == 0)
8303 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8306 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8308 /* check the return value and print it if is < 0 */
8310 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8314 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8315 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8317 cmdline_parse_token_string_t cmd_mac_addr_what =
8318 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8320 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8321 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8323 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8324 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8326 cmdline_parse_inst_t cmd_mac_addr = {
8327 .f = cmd_mac_addr_parsed,
8329 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8330 "Add/Remove/Set MAC address on port_id",
8332 (void *)&cmd_mac_addr_cmd,
8333 (void *)&cmd_mac_addr_what,
8334 (void *)&cmd_mac_addr_portnum,
8335 (void *)&cmd_mac_addr_addr,
8340 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8341 struct cmd_eth_peer_result {
8342 cmdline_fixed_string_t set;
8343 cmdline_fixed_string_t eth_peer;
8345 cmdline_fixed_string_t peer_addr;
8348 static void cmd_set_eth_peer_parsed(void *parsed_result,
8349 __rte_unused struct cmdline *cl,
8350 __rte_unused void *data)
8352 struct cmd_eth_peer_result *res = parsed_result;
8354 if (test_done == 0) {
8355 printf("Please stop forwarding first\n");
8358 if (!strcmp(res->eth_peer, "eth-peer")) {
8359 set_fwd_eth_peer(res->port_id, res->peer_addr);
8363 cmdline_parse_token_string_t cmd_eth_peer_set =
8364 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8365 cmdline_parse_token_string_t cmd_eth_peer =
8366 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8367 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8368 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8369 cmdline_parse_token_string_t cmd_eth_peer_addr =
8370 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8372 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8373 .f = cmd_set_eth_peer_parsed,
8375 .help_str = "set eth-peer <port_id> <peer_mac>",
8377 (void *)&cmd_eth_peer_set,
8378 (void *)&cmd_eth_peer,
8379 (void *)&cmd_eth_peer_port_id,
8380 (void *)&cmd_eth_peer_addr,
8385 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8386 struct cmd_set_qmap_result {
8387 cmdline_fixed_string_t set;
8388 cmdline_fixed_string_t qmap;
8389 cmdline_fixed_string_t what;
8396 cmd_set_qmap_parsed(void *parsed_result,
8397 __rte_unused struct cmdline *cl,
8398 __rte_unused void *data)
8400 struct cmd_set_qmap_result *res = parsed_result;
8401 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8403 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8406 cmdline_parse_token_string_t cmd_setqmap_set =
8407 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8409 cmdline_parse_token_string_t cmd_setqmap_qmap =
8410 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8412 cmdline_parse_token_string_t cmd_setqmap_what =
8413 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8415 cmdline_parse_token_num_t cmd_setqmap_portid =
8416 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8418 cmdline_parse_token_num_t cmd_setqmap_queueid =
8419 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8421 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8422 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8425 cmdline_parse_inst_t cmd_set_qmap = {
8426 .f = cmd_set_qmap_parsed,
8428 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8429 "Set statistics mapping value on tx|rx queue_id of port_id",
8431 (void *)&cmd_setqmap_set,
8432 (void *)&cmd_setqmap_qmap,
8433 (void *)&cmd_setqmap_what,
8434 (void *)&cmd_setqmap_portid,
8435 (void *)&cmd_setqmap_queueid,
8436 (void *)&cmd_setqmap_mapvalue,
8441 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8442 struct cmd_set_xstats_hide_zero_result {
8443 cmdline_fixed_string_t keyword;
8444 cmdline_fixed_string_t name;
8445 cmdline_fixed_string_t on_off;
8449 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8450 __rte_unused struct cmdline *cl,
8451 __rte_unused void *data)
8453 struct cmd_set_xstats_hide_zero_result *res;
8454 uint16_t on_off = 0;
8456 res = parsed_result;
8457 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8458 set_xstats_hide_zero(on_off);
8461 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8462 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8464 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8465 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8466 name, "xstats-hide-zero");
8467 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8468 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8471 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8472 .f = cmd_set_xstats_hide_zero_parsed,
8474 .help_str = "set xstats-hide-zero on|off",
8476 (void *)&cmd_set_xstats_hide_zero_keyword,
8477 (void *)&cmd_set_xstats_hide_zero_name,
8478 (void *)&cmd_set_xstats_hide_zero_on_off,
8483 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8484 struct cmd_set_record_core_cycles_result {
8485 cmdline_fixed_string_t keyword;
8486 cmdline_fixed_string_t name;
8487 cmdline_fixed_string_t on_off;
8491 cmd_set_record_core_cycles_parsed(void *parsed_result,
8492 __rte_unused struct cmdline *cl,
8493 __rte_unused void *data)
8495 struct cmd_set_record_core_cycles_result *res;
8496 uint16_t on_off = 0;
8498 res = parsed_result;
8499 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8500 set_record_core_cycles(on_off);
8503 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8504 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8506 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8507 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8508 name, "record-core-cycles");
8509 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8510 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8513 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8514 .f = cmd_set_record_core_cycles_parsed,
8516 .help_str = "set record-core-cycles on|off",
8518 (void *)&cmd_set_record_core_cycles_keyword,
8519 (void *)&cmd_set_record_core_cycles_name,
8520 (void *)&cmd_set_record_core_cycles_on_off,
8525 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8526 struct cmd_set_record_burst_stats_result {
8527 cmdline_fixed_string_t keyword;
8528 cmdline_fixed_string_t name;
8529 cmdline_fixed_string_t on_off;
8533 cmd_set_record_burst_stats_parsed(void *parsed_result,
8534 __rte_unused struct cmdline *cl,
8535 __rte_unused void *data)
8537 struct cmd_set_record_burst_stats_result *res;
8538 uint16_t on_off = 0;
8540 res = parsed_result;
8541 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8542 set_record_burst_stats(on_off);
8545 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8546 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8548 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8549 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8550 name, "record-burst-stats");
8551 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8552 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8555 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8556 .f = cmd_set_record_burst_stats_parsed,
8558 .help_str = "set record-burst-stats on|off",
8560 (void *)&cmd_set_record_burst_stats_keyword,
8561 (void *)&cmd_set_record_burst_stats_name,
8562 (void *)&cmd_set_record_burst_stats_on_off,
8567 /* *** CONFIGURE UNICAST HASH TABLE *** */
8568 struct cmd_set_uc_hash_table {
8569 cmdline_fixed_string_t set;
8570 cmdline_fixed_string_t port;
8572 cmdline_fixed_string_t what;
8573 struct rte_ether_addr address;
8574 cmdline_fixed_string_t mode;
8578 cmd_set_uc_hash_parsed(void *parsed_result,
8579 __rte_unused struct cmdline *cl,
8580 __rte_unused void *data)
8583 struct cmd_set_uc_hash_table *res = parsed_result;
8585 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8587 if (strcmp(res->what, "uta") == 0)
8588 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8589 &res->address,(uint8_t)is_on);
8591 printf("bad unicast hash table parameter, return code = %d \n", ret);
8595 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8596 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8598 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8599 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8601 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8602 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8604 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8605 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8607 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8608 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8610 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8611 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8614 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8615 .f = cmd_set_uc_hash_parsed,
8617 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8619 (void *)&cmd_set_uc_hash_set,
8620 (void *)&cmd_set_uc_hash_port,
8621 (void *)&cmd_set_uc_hash_portid,
8622 (void *)&cmd_set_uc_hash_what,
8623 (void *)&cmd_set_uc_hash_mac,
8624 (void *)&cmd_set_uc_hash_mode,
8629 struct cmd_set_uc_all_hash_table {
8630 cmdline_fixed_string_t set;
8631 cmdline_fixed_string_t port;
8633 cmdline_fixed_string_t what;
8634 cmdline_fixed_string_t value;
8635 cmdline_fixed_string_t mode;
8639 cmd_set_uc_all_hash_parsed(void *parsed_result,
8640 __rte_unused struct cmdline *cl,
8641 __rte_unused void *data)
8644 struct cmd_set_uc_all_hash_table *res = parsed_result;
8646 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8648 if ((strcmp(res->what, "uta") == 0) &&
8649 (strcmp(res->value, "all") == 0))
8650 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8652 printf("bad unicast hash table parameter,"
8653 "return code = %d \n", ret);
8656 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8657 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8659 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8660 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8662 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8663 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8665 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8666 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8668 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8669 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8671 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8672 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8675 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8676 .f = cmd_set_uc_all_hash_parsed,
8678 .help_str = "set port <port_id> uta all on|off",
8680 (void *)&cmd_set_uc_all_hash_set,
8681 (void *)&cmd_set_uc_all_hash_port,
8682 (void *)&cmd_set_uc_all_hash_portid,
8683 (void *)&cmd_set_uc_all_hash_what,
8684 (void *)&cmd_set_uc_all_hash_value,
8685 (void *)&cmd_set_uc_all_hash_mode,
8690 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8691 struct cmd_set_vf_traffic {
8692 cmdline_fixed_string_t set;
8693 cmdline_fixed_string_t port;
8695 cmdline_fixed_string_t vf;
8697 cmdline_fixed_string_t what;
8698 cmdline_fixed_string_t mode;
8702 cmd_set_vf_traffic_parsed(void *parsed_result,
8703 __rte_unused struct cmdline *cl,
8704 __rte_unused void *data)
8706 struct cmd_set_vf_traffic *res = parsed_result;
8707 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8708 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8710 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8713 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8714 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8716 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8717 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8719 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8720 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8722 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8723 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8725 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8726 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8728 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8729 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8731 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8732 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8735 cmdline_parse_inst_t cmd_set_vf_traffic = {
8736 .f = cmd_set_vf_traffic_parsed,
8738 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8740 (void *)&cmd_setvf_traffic_set,
8741 (void *)&cmd_setvf_traffic_port,
8742 (void *)&cmd_setvf_traffic_portid,
8743 (void *)&cmd_setvf_traffic_vf,
8744 (void *)&cmd_setvf_traffic_vfid,
8745 (void *)&cmd_setvf_traffic_what,
8746 (void *)&cmd_setvf_traffic_mode,
8751 /* *** CONFIGURE VF RECEIVE MODE *** */
8752 struct cmd_set_vf_rxmode {
8753 cmdline_fixed_string_t set;
8754 cmdline_fixed_string_t port;
8756 cmdline_fixed_string_t vf;
8758 cmdline_fixed_string_t what;
8759 cmdline_fixed_string_t mode;
8760 cmdline_fixed_string_t on;
8764 cmd_set_vf_rxmode_parsed(void *parsed_result,
8765 __rte_unused struct cmdline *cl,
8766 __rte_unused void *data)
8769 uint16_t vf_rxmode = 0;
8770 struct cmd_set_vf_rxmode *res = parsed_result;
8772 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8773 if (!strcmp(res->what,"rxmode")) {
8774 if (!strcmp(res->mode, "AUPE"))
8775 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8776 else if (!strcmp(res->mode, "ROPE"))
8777 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8778 else if (!strcmp(res->mode, "BAM"))
8779 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8780 else if (!strncmp(res->mode, "MPE",3))
8781 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8784 RTE_SET_USED(is_on);
8786 #ifdef RTE_NET_IXGBE
8787 if (ret == -ENOTSUP)
8788 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8789 vf_rxmode, (uint8_t)is_on);
8792 if (ret == -ENOTSUP)
8793 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8794 vf_rxmode, (uint8_t)is_on);
8797 printf("bad VF receive mode parameter, return code = %d \n",
8801 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8802 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8804 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8805 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8807 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8808 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8810 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8811 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8813 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8814 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8816 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8817 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8819 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8820 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8821 mode, "AUPE#ROPE#BAM#MPE");
8822 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8823 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8826 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8827 .f = cmd_set_vf_rxmode_parsed,
8829 .help_str = "set port <port_id> vf <vf_id> rxmode "
8830 "AUPE|ROPE|BAM|MPE on|off",
8832 (void *)&cmd_set_vf_rxmode_set,
8833 (void *)&cmd_set_vf_rxmode_port,
8834 (void *)&cmd_set_vf_rxmode_portid,
8835 (void *)&cmd_set_vf_rxmode_vf,
8836 (void *)&cmd_set_vf_rxmode_vfid,
8837 (void *)&cmd_set_vf_rxmode_what,
8838 (void *)&cmd_set_vf_rxmode_mode,
8839 (void *)&cmd_set_vf_rxmode_on,
8844 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8845 struct cmd_vf_mac_addr_result {
8846 cmdline_fixed_string_t mac_addr_cmd;
8847 cmdline_fixed_string_t what;
8848 cmdline_fixed_string_t port;
8850 cmdline_fixed_string_t vf;
8852 struct rte_ether_addr address;
8855 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8856 __rte_unused struct cmdline *cl,
8857 __rte_unused void *data)
8859 struct cmd_vf_mac_addr_result *res = parsed_result;
8862 if (strcmp(res->what, "add") != 0)
8866 if (ret == -ENOTSUP)
8867 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8871 if (ret == -ENOTSUP)
8872 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8877 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8881 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8882 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8883 mac_addr_cmd,"mac_addr");
8884 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8885 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8887 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8888 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8890 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8891 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8893 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8894 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8896 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8897 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8899 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8900 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8903 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8904 .f = cmd_vf_mac_addr_parsed,
8906 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8907 "Add MAC address filtering for a VF on port_id",
8909 (void *)&cmd_vf_mac_addr_cmd,
8910 (void *)&cmd_vf_mac_addr_what,
8911 (void *)&cmd_vf_mac_addr_port,
8912 (void *)&cmd_vf_mac_addr_portnum,
8913 (void *)&cmd_vf_mac_addr_vf,
8914 (void *)&cmd_vf_mac_addr_vfnum,
8915 (void *)&cmd_vf_mac_addr_addr,
8920 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8921 struct cmd_vf_rx_vlan_filter {
8922 cmdline_fixed_string_t rx_vlan;
8923 cmdline_fixed_string_t what;
8925 cmdline_fixed_string_t port;
8927 cmdline_fixed_string_t vf;
8932 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8933 __rte_unused struct cmdline *cl,
8934 __rte_unused void *data)
8936 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8939 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8941 #ifdef RTE_NET_IXGBE
8942 if (ret == -ENOTSUP)
8943 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8944 res->vlan_id, res->vf_mask, is_add);
8947 if (ret == -ENOTSUP)
8948 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8949 res->vlan_id, res->vf_mask, is_add);
8952 if (ret == -ENOTSUP)
8953 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8954 res->vlan_id, res->vf_mask, is_add);
8961 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8962 res->vlan_id, res->vf_mask);
8965 printf("invalid port_id %d\n", res->port_id);
8968 printf("function not implemented or supported\n");
8971 printf("programming error: (%s)\n", strerror(-ret));
8975 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8976 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8977 rx_vlan, "rx_vlan");
8978 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8979 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8981 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8982 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8984 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8985 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8987 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8988 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8990 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8991 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8993 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8994 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8997 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8998 .f = cmd_vf_rx_vlan_filter_parsed,
9000 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9001 "(vf_mask = hexadecimal VF mask)",
9003 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9004 (void *)&cmd_vf_rx_vlan_filter_what,
9005 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9006 (void *)&cmd_vf_rx_vlan_filter_port,
9007 (void *)&cmd_vf_rx_vlan_filter_portid,
9008 (void *)&cmd_vf_rx_vlan_filter_vf,
9009 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9014 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9015 struct cmd_queue_rate_limit_result {
9016 cmdline_fixed_string_t set;
9017 cmdline_fixed_string_t port;
9019 cmdline_fixed_string_t queue;
9021 cmdline_fixed_string_t rate;
9025 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9026 __rte_unused struct cmdline *cl,
9027 __rte_unused void *data)
9029 struct cmd_queue_rate_limit_result *res = parsed_result;
9032 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9033 && (strcmp(res->queue, "queue") == 0)
9034 && (strcmp(res->rate, "rate") == 0))
9035 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9038 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
9042 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9043 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9045 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9046 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9048 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9049 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9051 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9052 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9054 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9055 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9057 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9058 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9060 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9061 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9064 cmdline_parse_inst_t cmd_queue_rate_limit = {
9065 .f = cmd_queue_rate_limit_parsed,
9067 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9068 "Set rate limit for a queue on port_id",
9070 (void *)&cmd_queue_rate_limit_set,
9071 (void *)&cmd_queue_rate_limit_port,
9072 (void *)&cmd_queue_rate_limit_portnum,
9073 (void *)&cmd_queue_rate_limit_queue,
9074 (void *)&cmd_queue_rate_limit_queuenum,
9075 (void *)&cmd_queue_rate_limit_rate,
9076 (void *)&cmd_queue_rate_limit_ratenum,
9081 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9082 struct cmd_vf_rate_limit_result {
9083 cmdline_fixed_string_t set;
9084 cmdline_fixed_string_t port;
9086 cmdline_fixed_string_t vf;
9088 cmdline_fixed_string_t rate;
9090 cmdline_fixed_string_t q_msk;
9094 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9095 __rte_unused struct cmdline *cl,
9096 __rte_unused void *data)
9098 struct cmd_vf_rate_limit_result *res = parsed_result;
9101 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9102 && (strcmp(res->vf, "vf") == 0)
9103 && (strcmp(res->rate, "rate") == 0)
9104 && (strcmp(res->q_msk, "queue_mask") == 0))
9105 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9106 res->rate_num, res->q_msk_val);
9108 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9112 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9113 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9115 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9116 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9118 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9119 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9121 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9122 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9124 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9125 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9127 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9128 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9130 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9131 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9133 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9134 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9135 q_msk, "queue_mask");
9136 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9137 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9140 cmdline_parse_inst_t cmd_vf_rate_limit = {
9141 .f = cmd_vf_rate_limit_parsed,
9143 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9144 "queue_mask <queue_mask_value>: "
9145 "Set rate limit for queues of VF on port_id",
9147 (void *)&cmd_vf_rate_limit_set,
9148 (void *)&cmd_vf_rate_limit_port,
9149 (void *)&cmd_vf_rate_limit_portnum,
9150 (void *)&cmd_vf_rate_limit_vf,
9151 (void *)&cmd_vf_rate_limit_vfnum,
9152 (void *)&cmd_vf_rate_limit_rate,
9153 (void *)&cmd_vf_rate_limit_ratenum,
9154 (void *)&cmd_vf_rate_limit_q_msk,
9155 (void *)&cmd_vf_rate_limit_q_msk_val,
9160 /* *** CONFIGURE TUNNEL UDP PORT *** */
9161 struct cmd_tunnel_udp_config {
9162 cmdline_fixed_string_t cmd;
9163 cmdline_fixed_string_t what;
9169 cmd_tunnel_udp_config_parsed(void *parsed_result,
9170 __rte_unused struct cmdline *cl,
9171 __rte_unused void *data)
9173 struct cmd_tunnel_udp_config *res = parsed_result;
9174 struct rte_eth_udp_tunnel tunnel_udp;
9177 tunnel_udp.udp_port = res->udp_port;
9179 if (!strcmp(res->cmd, "rx_vxlan_port"))
9180 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9182 if (!strcmp(res->what, "add"))
9183 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9186 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9190 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9193 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9194 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9195 cmd, "rx_vxlan_port");
9196 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9197 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9199 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9200 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9202 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9203 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9206 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9207 .f = cmd_tunnel_udp_config_parsed,
9209 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9210 "Add/Remove a tunneling UDP port filter",
9212 (void *)&cmd_tunnel_udp_config_cmd,
9213 (void *)&cmd_tunnel_udp_config_what,
9214 (void *)&cmd_tunnel_udp_config_udp_port,
9215 (void *)&cmd_tunnel_udp_config_port_id,
9220 struct cmd_config_tunnel_udp_port {
9221 cmdline_fixed_string_t port;
9222 cmdline_fixed_string_t config;
9224 cmdline_fixed_string_t udp_tunnel_port;
9225 cmdline_fixed_string_t action;
9226 cmdline_fixed_string_t tunnel_type;
9231 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9232 __rte_unused struct cmdline *cl,
9233 __rte_unused void *data)
9235 struct cmd_config_tunnel_udp_port *res = parsed_result;
9236 struct rte_eth_udp_tunnel tunnel_udp;
9239 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9242 tunnel_udp.udp_port = res->udp_port;
9244 if (!strcmp(res->tunnel_type, "vxlan")) {
9245 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9246 } else if (!strcmp(res->tunnel_type, "geneve")) {
9247 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9248 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9249 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9251 printf("Invalid tunnel type\n");
9255 if (!strcmp(res->action, "add"))
9256 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9259 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9263 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9266 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9267 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9269 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9270 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9272 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9273 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9275 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9276 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9279 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9280 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9282 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9283 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9284 "vxlan#geneve#vxlan-gpe");
9285 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9286 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9289 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9290 .f = cmd_cfg_tunnel_udp_port_parsed,
9292 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9294 (void *)&cmd_config_tunnel_udp_port_port,
9295 (void *)&cmd_config_tunnel_udp_port_config,
9296 (void *)&cmd_config_tunnel_udp_port_port_id,
9297 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9298 (void *)&cmd_config_tunnel_udp_port_action,
9299 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9300 (void *)&cmd_config_tunnel_udp_port_value,
9305 /* *** GLOBAL CONFIG *** */
9306 struct cmd_global_config_result {
9307 cmdline_fixed_string_t cmd;
9309 cmdline_fixed_string_t cfg_type;
9314 cmd_global_config_parsed(void *parsed_result,
9315 __rte_unused struct cmdline *cl,
9316 __rte_unused void *data)
9318 struct cmd_global_config_result *res = parsed_result;
9319 struct rte_eth_global_cfg conf;
9322 memset(&conf, 0, sizeof(conf));
9323 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9324 conf.cfg.gre_key_len = res->len;
9325 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9326 RTE_ETH_FILTER_SET, &conf);
9328 if (ret == -ENOTSUP)
9329 ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len);
9332 printf("Global config error\n");
9335 cmdline_parse_token_string_t cmd_global_config_cmd =
9336 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9338 cmdline_parse_token_num_t cmd_global_config_port_id =
9339 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9341 cmdline_parse_token_string_t cmd_global_config_type =
9342 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9343 cfg_type, "gre-key-len");
9344 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9345 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9348 cmdline_parse_inst_t cmd_global_config = {
9349 .f = cmd_global_config_parsed,
9350 .data = (void *)NULL,
9351 .help_str = "global_config <port_id> gre-key-len <key_len>",
9353 (void *)&cmd_global_config_cmd,
9354 (void *)&cmd_global_config_port_id,
9355 (void *)&cmd_global_config_type,
9356 (void *)&cmd_global_config_gre_key_len,
9361 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9362 struct cmd_set_mirror_mask_result {
9363 cmdline_fixed_string_t set;
9364 cmdline_fixed_string_t port;
9366 cmdline_fixed_string_t mirror;
9368 cmdline_fixed_string_t what;
9369 cmdline_fixed_string_t value;
9370 cmdline_fixed_string_t dstpool;
9372 cmdline_fixed_string_t on;
9375 cmdline_parse_token_string_t cmd_mirror_mask_set =
9376 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9378 cmdline_parse_token_string_t cmd_mirror_mask_port =
9379 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9381 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9382 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9384 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9385 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9386 mirror, "mirror-rule");
9387 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9388 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9390 cmdline_parse_token_string_t cmd_mirror_mask_what =
9391 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9392 what, "pool-mirror-up#pool-mirror-down"
9394 cmdline_parse_token_string_t cmd_mirror_mask_value =
9395 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9397 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9398 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9399 dstpool, "dst-pool");
9400 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9401 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9403 cmdline_parse_token_string_t cmd_mirror_mask_on =
9404 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9408 cmd_set_mirror_mask_parsed(void *parsed_result,
9409 __rte_unused struct cmdline *cl,
9410 __rte_unused void *data)
9413 struct cmd_set_mirror_mask_result *res = parsed_result;
9414 struct rte_eth_mirror_conf mr_conf;
9416 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9418 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9420 mr_conf.dst_pool = res->dstpool_id;
9422 if (!strcmp(res->what, "pool-mirror-up")) {
9423 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9424 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9425 } else if (!strcmp(res->what, "pool-mirror-down")) {
9426 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9427 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9428 } else if (!strcmp(res->what, "vlan-mirror")) {
9429 mr_conf.rule_type = ETH_MIRROR_VLAN;
9430 nb_item = parse_item_list(res->value, "vlan",
9431 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9435 for (i = 0; i < nb_item; i++) {
9436 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9437 printf("Invalid vlan_id: must be < 4096\n");
9441 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9442 mr_conf.vlan.vlan_mask |= 1ULL << i;
9446 if (!strcmp(res->on, "on"))
9447 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9450 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9453 printf("mirror rule add error: (%s)\n", strerror(-ret));
9456 cmdline_parse_inst_t cmd_set_mirror_mask = {
9457 .f = cmd_set_mirror_mask_parsed,
9459 .help_str = "set port <port_id> mirror-rule <rule_id> "
9460 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9461 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9463 (void *)&cmd_mirror_mask_set,
9464 (void *)&cmd_mirror_mask_port,
9465 (void *)&cmd_mirror_mask_portid,
9466 (void *)&cmd_mirror_mask_mirror,
9467 (void *)&cmd_mirror_mask_ruleid,
9468 (void *)&cmd_mirror_mask_what,
9469 (void *)&cmd_mirror_mask_value,
9470 (void *)&cmd_mirror_mask_dstpool,
9471 (void *)&cmd_mirror_mask_poolid,
9472 (void *)&cmd_mirror_mask_on,
9477 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9478 struct cmd_set_mirror_link_result {
9479 cmdline_fixed_string_t set;
9480 cmdline_fixed_string_t port;
9482 cmdline_fixed_string_t mirror;
9484 cmdline_fixed_string_t what;
9485 cmdline_fixed_string_t dstpool;
9487 cmdline_fixed_string_t on;
9490 cmdline_parse_token_string_t cmd_mirror_link_set =
9491 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9493 cmdline_parse_token_string_t cmd_mirror_link_port =
9494 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9496 cmdline_parse_token_num_t cmd_mirror_link_portid =
9497 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9499 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9500 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9501 mirror, "mirror-rule");
9502 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9503 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9505 cmdline_parse_token_string_t cmd_mirror_link_what =
9506 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9507 what, "uplink-mirror#downlink-mirror");
9508 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9509 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9510 dstpool, "dst-pool");
9511 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9512 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9514 cmdline_parse_token_string_t cmd_mirror_link_on =
9515 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9519 cmd_set_mirror_link_parsed(void *parsed_result,
9520 __rte_unused struct cmdline *cl,
9521 __rte_unused void *data)
9524 struct cmd_set_mirror_link_result *res = parsed_result;
9525 struct rte_eth_mirror_conf mr_conf;
9527 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9528 if (!strcmp(res->what, "uplink-mirror"))
9529 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9531 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9533 mr_conf.dst_pool = res->dstpool_id;
9535 if (!strcmp(res->on, "on"))
9536 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9539 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9542 /* check the return value and print it if is < 0 */
9544 printf("mirror rule add error: (%s)\n", strerror(-ret));
9548 cmdline_parse_inst_t cmd_set_mirror_link = {
9549 .f = cmd_set_mirror_link_parsed,
9551 .help_str = "set port <port_id> mirror-rule <rule_id> "
9552 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9554 (void *)&cmd_mirror_link_set,
9555 (void *)&cmd_mirror_link_port,
9556 (void *)&cmd_mirror_link_portid,
9557 (void *)&cmd_mirror_link_mirror,
9558 (void *)&cmd_mirror_link_ruleid,
9559 (void *)&cmd_mirror_link_what,
9560 (void *)&cmd_mirror_link_dstpool,
9561 (void *)&cmd_mirror_link_poolid,
9562 (void *)&cmd_mirror_link_on,
9567 /* *** RESET VM MIRROR RULE *** */
9568 struct cmd_rm_mirror_rule_result {
9569 cmdline_fixed_string_t reset;
9570 cmdline_fixed_string_t port;
9572 cmdline_fixed_string_t mirror;
9576 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9577 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9579 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9580 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9582 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9583 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9585 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9586 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9587 mirror, "mirror-rule");
9588 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9589 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9593 cmd_reset_mirror_rule_parsed(void *parsed_result,
9594 __rte_unused struct cmdline *cl,
9595 __rte_unused void *data)
9598 struct cmd_set_mirror_link_result *res = parsed_result;
9600 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9602 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9605 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9606 .f = cmd_reset_mirror_rule_parsed,
9608 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9610 (void *)&cmd_rm_mirror_rule_reset,
9611 (void *)&cmd_rm_mirror_rule_port,
9612 (void *)&cmd_rm_mirror_rule_portid,
9613 (void *)&cmd_rm_mirror_rule_mirror,
9614 (void *)&cmd_rm_mirror_rule_ruleid,
9619 /* ******************************************************************************** */
9621 struct cmd_dump_result {
9622 cmdline_fixed_string_t dump;
9626 dump_struct_sizes(void)
9628 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9629 DUMP_SIZE(struct rte_mbuf);
9630 DUMP_SIZE(struct rte_mempool);
9631 DUMP_SIZE(struct rte_ring);
9636 /* Dump the socket memory statistics on console */
9638 dump_socket_mem(FILE *f)
9640 struct rte_malloc_socket_stats socket_stats;
9645 unsigned int n_alloc = 0;
9646 unsigned int n_free = 0;
9647 static size_t last_allocs;
9648 static size_t last_total;
9651 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9652 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9653 !socket_stats.heap_totalsz_bytes)
9655 total += socket_stats.heap_totalsz_bytes;
9656 alloc += socket_stats.heap_allocsz_bytes;
9657 free += socket_stats.heap_freesz_bytes;
9658 n_alloc += socket_stats.alloc_count;
9659 n_free += socket_stats.free_count;
9661 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9663 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9664 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9665 (double)socket_stats.heap_allocsz_bytes * 100 /
9666 (double)socket_stats.heap_totalsz_bytes,
9667 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9668 socket_stats.alloc_count,
9669 socket_stats.free_count);
9672 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9673 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9674 (double)alloc * 100 / (double)total,
9675 (double)free / (1024 * 1024),
9678 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9679 ((double)total - (double)last_total) / (1024 * 1024),
9680 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9681 last_allocs = alloc;
9685 static void cmd_dump_parsed(void *parsed_result,
9686 __rte_unused struct cmdline *cl,
9687 __rte_unused void *data)
9689 struct cmd_dump_result *res = parsed_result;
9691 if (!strcmp(res->dump, "dump_physmem"))
9692 rte_dump_physmem_layout(stdout);
9693 else if (!strcmp(res->dump, "dump_socket_mem"))
9694 dump_socket_mem(stdout);
9695 else if (!strcmp(res->dump, "dump_memzone"))
9696 rte_memzone_dump(stdout);
9697 else if (!strcmp(res->dump, "dump_struct_sizes"))
9698 dump_struct_sizes();
9699 else if (!strcmp(res->dump, "dump_ring"))
9700 rte_ring_list_dump(stdout);
9701 else if (!strcmp(res->dump, "dump_mempool"))
9702 rte_mempool_list_dump(stdout);
9703 else if (!strcmp(res->dump, "dump_devargs"))
9704 rte_devargs_dump(stdout);
9705 else if (!strcmp(res->dump, "dump_log_types"))
9706 rte_log_dump(stdout);
9709 cmdline_parse_token_string_t cmd_dump_dump =
9710 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9714 "dump_struct_sizes#"
9720 cmdline_parse_inst_t cmd_dump = {
9721 .f = cmd_dump_parsed, /* function to call */
9722 .data = NULL, /* 2nd arg of func */
9723 .help_str = "Dump status",
9724 .tokens = { /* token list, NULL terminated */
9725 (void *)&cmd_dump_dump,
9730 /* ******************************************************************************** */
9732 struct cmd_dump_one_result {
9733 cmdline_fixed_string_t dump;
9734 cmdline_fixed_string_t name;
9737 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9738 __rte_unused void *data)
9740 struct cmd_dump_one_result *res = parsed_result;
9742 if (!strcmp(res->dump, "dump_ring")) {
9744 r = rte_ring_lookup(res->name);
9746 cmdline_printf(cl, "Cannot find ring\n");
9749 rte_ring_dump(stdout, r);
9750 } else if (!strcmp(res->dump, "dump_mempool")) {
9751 struct rte_mempool *mp;
9752 mp = rte_mempool_lookup(res->name);
9754 cmdline_printf(cl, "Cannot find mempool\n");
9757 rte_mempool_dump(stdout, mp);
9761 cmdline_parse_token_string_t cmd_dump_one_dump =
9762 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9763 "dump_ring#dump_mempool");
9765 cmdline_parse_token_string_t cmd_dump_one_name =
9766 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9768 cmdline_parse_inst_t cmd_dump_one = {
9769 .f = cmd_dump_one_parsed, /* function to call */
9770 .data = NULL, /* 2nd arg of func */
9771 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9772 .tokens = { /* token list, NULL terminated */
9773 (void *)&cmd_dump_one_dump,
9774 (void *)&cmd_dump_one_name,
9779 /* *** queue region set *** */
9780 struct cmd_queue_region_result {
9781 cmdline_fixed_string_t set;
9782 cmdline_fixed_string_t port;
9784 cmdline_fixed_string_t cmd;
9785 cmdline_fixed_string_t region;
9787 cmdline_fixed_string_t queue_start_index;
9789 cmdline_fixed_string_t queue_num;
9790 uint8_t queue_num_value;
9794 cmd_queue_region_parsed(void *parsed_result,
9795 __rte_unused struct cmdline *cl,
9796 __rte_unused void *data)
9798 struct cmd_queue_region_result *res = parsed_result;
9801 struct rte_pmd_i40e_queue_region_conf region_conf;
9802 enum rte_pmd_i40e_queue_region_op op_type;
9805 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9809 memset(®ion_conf, 0, sizeof(region_conf));
9810 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9811 region_conf.region_id = res->region_id;
9812 region_conf.queue_num = res->queue_num_value;
9813 region_conf.queue_start_index = res->queue_id;
9815 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9816 op_type, ®ion_conf);
9823 printf("function not implemented or supported\n");
9826 printf("queue region config error: (%s)\n", strerror(-ret));
9830 cmdline_parse_token_string_t cmd_queue_region_set =
9831 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9833 cmdline_parse_token_string_t cmd_queue_region_port =
9834 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9835 cmdline_parse_token_num_t cmd_queue_region_port_id =
9836 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9838 cmdline_parse_token_string_t cmd_queue_region_cmd =
9839 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9840 cmd, "queue-region");
9841 cmdline_parse_token_string_t cmd_queue_region_id =
9842 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9843 region, "region_id");
9844 cmdline_parse_token_num_t cmd_queue_region_index =
9845 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9847 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9848 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9849 queue_start_index, "queue_start_index");
9850 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9851 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9853 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9854 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9855 queue_num, "queue_num");
9856 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9857 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9858 queue_num_value, UINT8);
9860 cmdline_parse_inst_t cmd_queue_region = {
9861 .f = cmd_queue_region_parsed,
9863 .help_str = "set port <port_id> queue-region region_id <value> "
9864 "queue_start_index <value> queue_num <value>: Set a queue region",
9866 (void *)&cmd_queue_region_set,
9867 (void *)&cmd_queue_region_port,
9868 (void *)&cmd_queue_region_port_id,
9869 (void *)&cmd_queue_region_cmd,
9870 (void *)&cmd_queue_region_id,
9871 (void *)&cmd_queue_region_index,
9872 (void *)&cmd_queue_region_queue_start_index,
9873 (void *)&cmd_queue_region_queue_id,
9874 (void *)&cmd_queue_region_queue_num,
9875 (void *)&cmd_queue_region_queue_num_value,
9880 /* *** queue region and flowtype set *** */
9881 struct cmd_region_flowtype_result {
9882 cmdline_fixed_string_t set;
9883 cmdline_fixed_string_t port;
9885 cmdline_fixed_string_t cmd;
9886 cmdline_fixed_string_t region;
9888 cmdline_fixed_string_t flowtype;
9889 uint8_t flowtype_id;
9893 cmd_region_flowtype_parsed(void *parsed_result,
9894 __rte_unused struct cmdline *cl,
9895 __rte_unused void *data)
9897 struct cmd_region_flowtype_result *res = parsed_result;
9900 struct rte_pmd_i40e_queue_region_conf region_conf;
9901 enum rte_pmd_i40e_queue_region_op op_type;
9904 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9908 memset(®ion_conf, 0, sizeof(region_conf));
9910 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9911 region_conf.region_id = res->region_id;
9912 region_conf.hw_flowtype = res->flowtype_id;
9914 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9915 op_type, ®ion_conf);
9922 printf("function not implemented or supported\n");
9925 printf("region flowtype config error: (%s)\n", strerror(-ret));
9929 cmdline_parse_token_string_t cmd_region_flowtype_set =
9930 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9932 cmdline_parse_token_string_t cmd_region_flowtype_port =
9933 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9935 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9936 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9938 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9939 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9940 cmd, "queue-region");
9941 cmdline_parse_token_string_t cmd_region_flowtype_index =
9942 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9943 region, "region_id");
9944 cmdline_parse_token_num_t cmd_region_flowtype_id =
9945 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9947 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9948 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9949 flowtype, "flowtype");
9950 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9951 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9952 flowtype_id, UINT8);
9953 cmdline_parse_inst_t cmd_region_flowtype = {
9954 .f = cmd_region_flowtype_parsed,
9956 .help_str = "set port <port_id> queue-region region_id <value> "
9957 "flowtype <value>: Set a flowtype region index",
9959 (void *)&cmd_region_flowtype_set,
9960 (void *)&cmd_region_flowtype_port,
9961 (void *)&cmd_region_flowtype_port_index,
9962 (void *)&cmd_region_flowtype_cmd,
9963 (void *)&cmd_region_flowtype_index,
9964 (void *)&cmd_region_flowtype_id,
9965 (void *)&cmd_region_flowtype_flow_index,
9966 (void *)&cmd_region_flowtype_flow_id,
9971 /* *** User Priority (UP) to queue region (region_id) set *** */
9972 struct cmd_user_priority_region_result {
9973 cmdline_fixed_string_t set;
9974 cmdline_fixed_string_t port;
9976 cmdline_fixed_string_t cmd;
9977 cmdline_fixed_string_t user_priority;
9978 uint8_t user_priority_id;
9979 cmdline_fixed_string_t region;
9984 cmd_user_priority_region_parsed(void *parsed_result,
9985 __rte_unused struct cmdline *cl,
9986 __rte_unused void *data)
9988 struct cmd_user_priority_region_result *res = parsed_result;
9991 struct rte_pmd_i40e_queue_region_conf region_conf;
9992 enum rte_pmd_i40e_queue_region_op op_type;
9995 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9999 memset(®ion_conf, 0, sizeof(region_conf));
10000 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10001 region_conf.user_priority = res->user_priority_id;
10002 region_conf.region_id = res->region_id;
10004 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10005 op_type, ®ion_conf);
10012 printf("function not implemented or supported\n");
10015 printf("user_priority region config error: (%s)\n",
10020 cmdline_parse_token_string_t cmd_user_priority_region_set =
10021 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10023 cmdline_parse_token_string_t cmd_user_priority_region_port =
10024 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10026 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10027 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10029 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10030 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10031 cmd, "queue-region");
10032 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10033 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10034 user_priority, "UP");
10035 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10036 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10037 user_priority_id, UINT8);
10038 cmdline_parse_token_string_t cmd_user_priority_region_region =
10039 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10040 region, "region_id");
10041 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10042 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10045 cmdline_parse_inst_t cmd_user_priority_region = {
10046 .f = cmd_user_priority_region_parsed,
10048 .help_str = "set port <port_id> queue-region UP <value> "
10049 "region_id <value>: Set the mapping of User Priority (UP) "
10050 "to queue region (region_id) ",
10052 (void *)&cmd_user_priority_region_set,
10053 (void *)&cmd_user_priority_region_port,
10054 (void *)&cmd_user_priority_region_port_index,
10055 (void *)&cmd_user_priority_region_cmd,
10056 (void *)&cmd_user_priority_region_UP,
10057 (void *)&cmd_user_priority_region_UP_id,
10058 (void *)&cmd_user_priority_region_region,
10059 (void *)&cmd_user_priority_region_region_id,
10064 /* *** flush all queue region related configuration *** */
10065 struct cmd_flush_queue_region_result {
10066 cmdline_fixed_string_t set;
10067 cmdline_fixed_string_t port;
10069 cmdline_fixed_string_t cmd;
10070 cmdline_fixed_string_t flush;
10071 cmdline_fixed_string_t what;
10075 cmd_flush_queue_region_parsed(void *parsed_result,
10076 __rte_unused struct cmdline *cl,
10077 __rte_unused void *data)
10079 struct cmd_flush_queue_region_result *res = parsed_result;
10080 int ret = -ENOTSUP;
10081 #ifdef RTE_NET_I40E
10082 struct rte_pmd_i40e_queue_region_conf region_conf;
10083 enum rte_pmd_i40e_queue_region_op op_type;
10086 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10089 #ifdef RTE_NET_I40E
10090 memset(®ion_conf, 0, sizeof(region_conf));
10092 if (strcmp(res->what, "on") == 0)
10093 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10095 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10097 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10098 op_type, ®ion_conf);
10105 printf("function not implemented or supported\n");
10108 printf("queue region config flush error: (%s)\n",
10113 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10114 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10116 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10117 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10119 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10120 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10122 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10123 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10124 cmd, "queue-region");
10125 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10126 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10128 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10129 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10132 cmdline_parse_inst_t cmd_flush_queue_region = {
10133 .f = cmd_flush_queue_region_parsed,
10135 .help_str = "set port <port_id> queue-region flush on|off"
10136 ": flush all queue region related configuration",
10138 (void *)&cmd_flush_queue_region_set,
10139 (void *)&cmd_flush_queue_region_port,
10140 (void *)&cmd_flush_queue_region_port_index,
10141 (void *)&cmd_flush_queue_region_cmd,
10142 (void *)&cmd_flush_queue_region_flush,
10143 (void *)&cmd_flush_queue_region_what,
10148 /* *** get all queue region related configuration info *** */
10149 struct cmd_show_queue_region_info {
10150 cmdline_fixed_string_t show;
10151 cmdline_fixed_string_t port;
10153 cmdline_fixed_string_t cmd;
10157 cmd_show_queue_region_info_parsed(void *parsed_result,
10158 __rte_unused struct cmdline *cl,
10159 __rte_unused void *data)
10161 struct cmd_show_queue_region_info *res = parsed_result;
10162 int ret = -ENOTSUP;
10163 #ifdef RTE_NET_I40E
10164 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10165 enum rte_pmd_i40e_queue_region_op op_type;
10168 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10171 #ifdef RTE_NET_I40E
10172 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10174 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10176 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10177 op_type, &rte_pmd_regions);
10179 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10186 printf("function not implemented or supported\n");
10189 printf("queue region config info show error: (%s)\n",
10194 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10195 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10197 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10198 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10200 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10201 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10203 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10204 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10205 cmd, "queue-region");
10207 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10208 .f = cmd_show_queue_region_info_parsed,
10210 .help_str = "show port <port_id> queue-region"
10211 ": show all queue region related configuration info",
10213 (void *)&cmd_show_queue_region_info_get,
10214 (void *)&cmd_show_queue_region_info_port,
10215 (void *)&cmd_show_queue_region_info_port_index,
10216 (void *)&cmd_show_queue_region_info_cmd,
10221 /* *** Filters Control *** */
10223 /* *** deal with flow director filter *** */
10224 struct cmd_flow_director_result {
10225 cmdline_fixed_string_t flow_director_filter;
10227 cmdline_fixed_string_t mode;
10228 cmdline_fixed_string_t mode_value;
10229 cmdline_fixed_string_t ops;
10230 cmdline_fixed_string_t flow;
10231 cmdline_fixed_string_t flow_type;
10232 cmdline_fixed_string_t ether;
10233 uint16_t ether_type;
10234 cmdline_fixed_string_t src;
10235 cmdline_ipaddr_t ip_src;
10237 cmdline_fixed_string_t dst;
10238 cmdline_ipaddr_t ip_dst;
10240 cmdline_fixed_string_t verify_tag;
10241 uint32_t verify_tag_value;
10242 cmdline_fixed_string_t tos;
10244 cmdline_fixed_string_t proto;
10245 uint8_t proto_value;
10246 cmdline_fixed_string_t ttl;
10248 cmdline_fixed_string_t vlan;
10249 uint16_t vlan_value;
10250 cmdline_fixed_string_t flexbytes;
10251 cmdline_fixed_string_t flexbytes_value;
10252 cmdline_fixed_string_t pf_vf;
10253 cmdline_fixed_string_t drop;
10254 cmdline_fixed_string_t queue;
10256 cmdline_fixed_string_t fd_id;
10257 uint32_t fd_id_value;
10258 cmdline_fixed_string_t mac;
10259 struct rte_ether_addr mac_addr;
10260 cmdline_fixed_string_t tunnel;
10261 cmdline_fixed_string_t tunnel_type;
10262 cmdline_fixed_string_t tunnel_id;
10263 uint32_t tunnel_id_value;
10264 cmdline_fixed_string_t packet;
10269 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10272 const char *p, *p0 = q_arg;
10274 unsigned long int_fld;
10275 char *str_fld[max_num];
10280 p = strchr(p0, '(');
10284 p0 = strchr(p, ')');
10289 if (size >= sizeof(s))
10292 snprintf(s, sizeof(s), "%.*s", size, p);
10293 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10294 if (ret < 0 || ret > max_num)
10296 for (i = 0; i < ret; i++) {
10298 int_fld = strtoul(str_fld[i], &end, 0);
10299 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10301 flexbytes[i] = (uint8_t)int_fld;
10307 str2flowtype(char *string)
10310 static const struct {
10313 } flowtype_str[] = {
10314 {"raw", RTE_ETH_FLOW_RAW},
10315 {"ipv4", RTE_ETH_FLOW_IPV4},
10316 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10317 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10318 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10319 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10320 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10321 {"ipv6", RTE_ETH_FLOW_IPV6},
10322 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10323 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10324 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10325 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10326 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10327 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10330 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10331 if (!strcmp(flowtype_str[i].str, string))
10332 return flowtype_str[i].type;
10335 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10336 return (uint16_t)atoi(string);
10338 return RTE_ETH_FLOW_UNKNOWN;
10341 static enum rte_eth_fdir_tunnel_type
10342 str2fdir_tunneltype(char *string)
10346 static const struct {
10348 enum rte_eth_fdir_tunnel_type type;
10349 } tunneltype_str[] = {
10350 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10351 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10354 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10355 if (!strcmp(tunneltype_str[i].str, string))
10356 return tunneltype_str[i].type;
10358 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10361 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10363 if ((ip_addr).family == AF_INET) \
10364 (ip) = (ip_addr).addr.ipv4.s_addr; \
10366 printf("invalid parameter.\n"); \
10371 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10373 if ((ip_addr).family == AF_INET6) \
10374 rte_memcpy(&(ip), \
10375 &((ip_addr).addr.ipv6), \
10376 sizeof(struct in6_addr)); \
10378 printf("invalid parameter.\n"); \
10384 cmd_flow_director_filter_parsed(void *parsed_result,
10385 __rte_unused struct cmdline *cl,
10386 __rte_unused void *data)
10388 struct cmd_flow_director_result *res = parsed_result;
10389 struct rte_eth_fdir_filter entry;
10390 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10392 unsigned long vf_id;
10395 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10397 printf("flow director is not supported on port %u.\n",
10401 memset(flexbytes, 0, sizeof(flexbytes));
10402 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10404 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10405 if (strcmp(res->mode_value, "MAC-VLAN")) {
10406 printf("Please set mode to MAC-VLAN.\n");
10409 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10410 if (strcmp(res->mode_value, "Tunnel")) {
10411 printf("Please set mode to Tunnel.\n");
10415 if (!strcmp(res->mode_value, "raw")) {
10416 #ifdef RTE_NET_I40E
10417 struct rte_pmd_i40e_flow_type_mapping
10418 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10419 struct rte_pmd_i40e_pkt_template_conf conf;
10420 uint16_t flow_type = str2flowtype(res->flow_type);
10421 uint16_t i, port = res->port_id;
10424 memset(&conf, 0, sizeof(conf));
10426 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10427 printf("Invalid flow type specified.\n");
10430 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10434 if (mapping[flow_type].pctype == 0ULL) {
10435 printf("Invalid flow type specified.\n");
10438 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10439 if (mapping[flow_type].pctype & (1ULL << i)) {
10440 conf.input.pctype = i;
10445 conf.input.packet = open_file(res->filepath,
10446 &conf.input.length);
10447 if (!conf.input.packet)
10449 if (!strcmp(res->drop, "drop"))
10450 conf.action.behavior =
10451 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10453 conf.action.behavior =
10454 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10455 conf.action.report_status =
10456 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10457 conf.action.rx_queue = res->queue_id;
10458 conf.soft_id = res->fd_id_value;
10459 add = strcmp(res->ops, "del") ? 1 : 0;
10460 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10464 printf("flow director config error: (%s)\n",
10466 close_file(conf.input.packet);
10469 } else if (strcmp(res->mode_value, "IP")) {
10470 printf("Please set mode to IP or raw.\n");
10473 entry.input.flow_type = str2flowtype(res->flow_type);
10476 ret = parse_flexbytes(res->flexbytes_value,
10478 RTE_ETH_FDIR_MAX_FLEXLEN);
10480 printf("error: Cannot parse flexbytes input.\n");
10484 switch (entry.input.flow_type) {
10485 case RTE_ETH_FLOW_FRAG_IPV4:
10486 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10487 entry.input.flow.ip4_flow.proto = res->proto_value;
10489 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10490 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10491 IPV4_ADDR_TO_UINT(res->ip_dst,
10492 entry.input.flow.ip4_flow.dst_ip);
10493 IPV4_ADDR_TO_UINT(res->ip_src,
10494 entry.input.flow.ip4_flow.src_ip);
10495 entry.input.flow.ip4_flow.tos = res->tos_value;
10496 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10497 /* need convert to big endian. */
10498 entry.input.flow.udp4_flow.dst_port =
10499 rte_cpu_to_be_16(res->port_dst);
10500 entry.input.flow.udp4_flow.src_port =
10501 rte_cpu_to_be_16(res->port_src);
10503 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10504 IPV4_ADDR_TO_UINT(res->ip_dst,
10505 entry.input.flow.sctp4_flow.ip.dst_ip);
10506 IPV4_ADDR_TO_UINT(res->ip_src,
10507 entry.input.flow.sctp4_flow.ip.src_ip);
10508 entry.input.flow.ip4_flow.tos = res->tos_value;
10509 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10510 /* need convert to big endian. */
10511 entry.input.flow.sctp4_flow.dst_port =
10512 rte_cpu_to_be_16(res->port_dst);
10513 entry.input.flow.sctp4_flow.src_port =
10514 rte_cpu_to_be_16(res->port_src);
10515 entry.input.flow.sctp4_flow.verify_tag =
10516 rte_cpu_to_be_32(res->verify_tag_value);
10518 case RTE_ETH_FLOW_FRAG_IPV6:
10519 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10520 entry.input.flow.ipv6_flow.proto = res->proto_value;
10522 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10523 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10524 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10525 entry.input.flow.ipv6_flow.dst_ip);
10526 IPV6_ADDR_TO_ARRAY(res->ip_src,
10527 entry.input.flow.ipv6_flow.src_ip);
10528 entry.input.flow.ipv6_flow.tc = res->tos_value;
10529 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10530 /* need convert to big endian. */
10531 entry.input.flow.udp6_flow.dst_port =
10532 rte_cpu_to_be_16(res->port_dst);
10533 entry.input.flow.udp6_flow.src_port =
10534 rte_cpu_to_be_16(res->port_src);
10536 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10537 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10538 entry.input.flow.sctp6_flow.ip.dst_ip);
10539 IPV6_ADDR_TO_ARRAY(res->ip_src,
10540 entry.input.flow.sctp6_flow.ip.src_ip);
10541 entry.input.flow.ipv6_flow.tc = res->tos_value;
10542 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10543 /* need convert to big endian. */
10544 entry.input.flow.sctp6_flow.dst_port =
10545 rte_cpu_to_be_16(res->port_dst);
10546 entry.input.flow.sctp6_flow.src_port =
10547 rte_cpu_to_be_16(res->port_src);
10548 entry.input.flow.sctp6_flow.verify_tag =
10549 rte_cpu_to_be_32(res->verify_tag_value);
10551 case RTE_ETH_FLOW_L2_PAYLOAD:
10552 entry.input.flow.l2_flow.ether_type =
10553 rte_cpu_to_be_16(res->ether_type);
10559 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10560 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10562 sizeof(struct rte_ether_addr));
10564 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10565 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10567 sizeof(struct rte_ether_addr));
10568 entry.input.flow.tunnel_flow.tunnel_type =
10569 str2fdir_tunneltype(res->tunnel_type);
10570 entry.input.flow.tunnel_flow.tunnel_id =
10571 rte_cpu_to_be_32(res->tunnel_id_value);
10574 rte_memcpy(entry.input.flow_ext.flexbytes,
10576 RTE_ETH_FDIR_MAX_FLEXLEN);
10578 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10580 entry.action.flex_off = 0; /*use 0 by default */
10581 if (!strcmp(res->drop, "drop"))
10582 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10584 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10586 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10587 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10588 if (!strcmp(res->pf_vf, "pf"))
10589 entry.input.flow_ext.is_vf = 0;
10590 else if (!strncmp(res->pf_vf, "vf", 2)) {
10591 struct rte_eth_dev_info dev_info;
10593 ret = eth_dev_info_get_print_err(res->port_id,
10599 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10600 if (errno != 0 || *end != '\0' ||
10601 vf_id >= dev_info.max_vfs) {
10602 printf("invalid parameter %s.\n", res->pf_vf);
10605 entry.input.flow_ext.is_vf = 1;
10606 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10608 printf("invalid parameter %s.\n", res->pf_vf);
10613 /* set to report FD ID by default */
10614 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10615 entry.action.rx_queue = res->queue_id;
10616 entry.soft_id = res->fd_id_value;
10617 if (!strcmp(res->ops, "add"))
10618 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10619 RTE_ETH_FILTER_ADD, &entry);
10620 else if (!strcmp(res->ops, "del"))
10621 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10622 RTE_ETH_FILTER_DELETE, &entry);
10624 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10625 RTE_ETH_FILTER_UPDATE, &entry);
10627 printf("flow director programming error: (%s)\n",
10631 cmdline_parse_token_string_t cmd_flow_director_filter =
10632 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10633 flow_director_filter, "flow_director_filter");
10634 cmdline_parse_token_num_t cmd_flow_director_port_id =
10635 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10637 cmdline_parse_token_string_t cmd_flow_director_ops =
10638 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10639 ops, "add#del#update");
10640 cmdline_parse_token_string_t cmd_flow_director_flow =
10641 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10643 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10644 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10646 cmdline_parse_token_string_t cmd_flow_director_ether =
10647 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10649 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10650 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10651 ether_type, UINT16);
10652 cmdline_parse_token_string_t cmd_flow_director_src =
10653 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10655 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10656 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10658 cmdline_parse_token_num_t cmd_flow_director_port_src =
10659 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10661 cmdline_parse_token_string_t cmd_flow_director_dst =
10662 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10664 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10665 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10667 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10668 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10670 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10671 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10672 verify_tag, "verify_tag");
10673 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10674 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10675 verify_tag_value, UINT32);
10676 cmdline_parse_token_string_t cmd_flow_director_tos =
10677 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10679 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10680 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10682 cmdline_parse_token_string_t cmd_flow_director_proto =
10683 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10685 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10686 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10687 proto_value, UINT8);
10688 cmdline_parse_token_string_t cmd_flow_director_ttl =
10689 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10691 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10692 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10694 cmdline_parse_token_string_t cmd_flow_director_vlan =
10695 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10697 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10698 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10699 vlan_value, UINT16);
10700 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10701 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10702 flexbytes, "flexbytes");
10703 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10704 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10705 flexbytes_value, NULL);
10706 cmdline_parse_token_string_t cmd_flow_director_drop =
10707 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10709 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10710 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10712 cmdline_parse_token_string_t cmd_flow_director_queue =
10713 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10715 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10716 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10718 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10719 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10721 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10722 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10723 fd_id_value, UINT32);
10725 cmdline_parse_token_string_t cmd_flow_director_mode =
10726 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10728 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10729 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10731 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10732 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10733 mode_value, "MAC-VLAN");
10734 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10735 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10736 mode_value, "Tunnel");
10737 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10738 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10739 mode_value, "raw");
10740 cmdline_parse_token_string_t cmd_flow_director_mac =
10741 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10743 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10744 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10746 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10747 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10749 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10750 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10751 tunnel_type, "NVGRE#VxLAN");
10752 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10753 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10754 tunnel_id, "tunnel-id");
10755 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10756 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10757 tunnel_id_value, UINT32);
10758 cmdline_parse_token_string_t cmd_flow_director_packet =
10759 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10761 cmdline_parse_token_string_t cmd_flow_director_filepath =
10762 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10765 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10766 .f = cmd_flow_director_filter_parsed,
10768 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10769 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10770 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10771 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10772 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10773 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10774 "fd_id <fd_id_value>: "
10775 "Add or delete an ip flow director entry on NIC",
10777 (void *)&cmd_flow_director_filter,
10778 (void *)&cmd_flow_director_port_id,
10779 (void *)&cmd_flow_director_mode,
10780 (void *)&cmd_flow_director_mode_ip,
10781 (void *)&cmd_flow_director_ops,
10782 (void *)&cmd_flow_director_flow,
10783 (void *)&cmd_flow_director_flow_type,
10784 (void *)&cmd_flow_director_src,
10785 (void *)&cmd_flow_director_ip_src,
10786 (void *)&cmd_flow_director_dst,
10787 (void *)&cmd_flow_director_ip_dst,
10788 (void *)&cmd_flow_director_tos,
10789 (void *)&cmd_flow_director_tos_value,
10790 (void *)&cmd_flow_director_proto,
10791 (void *)&cmd_flow_director_proto_value,
10792 (void *)&cmd_flow_director_ttl,
10793 (void *)&cmd_flow_director_ttl_value,
10794 (void *)&cmd_flow_director_vlan,
10795 (void *)&cmd_flow_director_vlan_value,
10796 (void *)&cmd_flow_director_flexbytes,
10797 (void *)&cmd_flow_director_flexbytes_value,
10798 (void *)&cmd_flow_director_drop,
10799 (void *)&cmd_flow_director_pf_vf,
10800 (void *)&cmd_flow_director_queue,
10801 (void *)&cmd_flow_director_queue_id,
10802 (void *)&cmd_flow_director_fd_id,
10803 (void *)&cmd_flow_director_fd_id_value,
10808 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10809 .f = cmd_flow_director_filter_parsed,
10811 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10812 "director entry on NIC",
10814 (void *)&cmd_flow_director_filter,
10815 (void *)&cmd_flow_director_port_id,
10816 (void *)&cmd_flow_director_mode,
10817 (void *)&cmd_flow_director_mode_ip,
10818 (void *)&cmd_flow_director_ops,
10819 (void *)&cmd_flow_director_flow,
10820 (void *)&cmd_flow_director_flow_type,
10821 (void *)&cmd_flow_director_src,
10822 (void *)&cmd_flow_director_ip_src,
10823 (void *)&cmd_flow_director_port_src,
10824 (void *)&cmd_flow_director_dst,
10825 (void *)&cmd_flow_director_ip_dst,
10826 (void *)&cmd_flow_director_port_dst,
10827 (void *)&cmd_flow_director_tos,
10828 (void *)&cmd_flow_director_tos_value,
10829 (void *)&cmd_flow_director_ttl,
10830 (void *)&cmd_flow_director_ttl_value,
10831 (void *)&cmd_flow_director_vlan,
10832 (void *)&cmd_flow_director_vlan_value,
10833 (void *)&cmd_flow_director_flexbytes,
10834 (void *)&cmd_flow_director_flexbytes_value,
10835 (void *)&cmd_flow_director_drop,
10836 (void *)&cmd_flow_director_pf_vf,
10837 (void *)&cmd_flow_director_queue,
10838 (void *)&cmd_flow_director_queue_id,
10839 (void *)&cmd_flow_director_fd_id,
10840 (void *)&cmd_flow_director_fd_id_value,
10845 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10846 .f = cmd_flow_director_filter_parsed,
10848 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10849 "director entry on NIC",
10851 (void *)&cmd_flow_director_filter,
10852 (void *)&cmd_flow_director_port_id,
10853 (void *)&cmd_flow_director_mode,
10854 (void *)&cmd_flow_director_mode_ip,
10855 (void *)&cmd_flow_director_ops,
10856 (void *)&cmd_flow_director_flow,
10857 (void *)&cmd_flow_director_flow_type,
10858 (void *)&cmd_flow_director_src,
10859 (void *)&cmd_flow_director_ip_src,
10860 (void *)&cmd_flow_director_port_src,
10861 (void *)&cmd_flow_director_dst,
10862 (void *)&cmd_flow_director_ip_dst,
10863 (void *)&cmd_flow_director_port_dst,
10864 (void *)&cmd_flow_director_verify_tag,
10865 (void *)&cmd_flow_director_verify_tag_value,
10866 (void *)&cmd_flow_director_tos,
10867 (void *)&cmd_flow_director_tos_value,
10868 (void *)&cmd_flow_director_ttl,
10869 (void *)&cmd_flow_director_ttl_value,
10870 (void *)&cmd_flow_director_vlan,
10871 (void *)&cmd_flow_director_vlan_value,
10872 (void *)&cmd_flow_director_flexbytes,
10873 (void *)&cmd_flow_director_flexbytes_value,
10874 (void *)&cmd_flow_director_drop,
10875 (void *)&cmd_flow_director_pf_vf,
10876 (void *)&cmd_flow_director_queue,
10877 (void *)&cmd_flow_director_queue_id,
10878 (void *)&cmd_flow_director_fd_id,
10879 (void *)&cmd_flow_director_fd_id_value,
10884 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10885 .f = cmd_flow_director_filter_parsed,
10887 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10888 "director entry on NIC",
10890 (void *)&cmd_flow_director_filter,
10891 (void *)&cmd_flow_director_port_id,
10892 (void *)&cmd_flow_director_mode,
10893 (void *)&cmd_flow_director_mode_ip,
10894 (void *)&cmd_flow_director_ops,
10895 (void *)&cmd_flow_director_flow,
10896 (void *)&cmd_flow_director_flow_type,
10897 (void *)&cmd_flow_director_ether,
10898 (void *)&cmd_flow_director_ether_type,
10899 (void *)&cmd_flow_director_flexbytes,
10900 (void *)&cmd_flow_director_flexbytes_value,
10901 (void *)&cmd_flow_director_drop,
10902 (void *)&cmd_flow_director_pf_vf,
10903 (void *)&cmd_flow_director_queue,
10904 (void *)&cmd_flow_director_queue_id,
10905 (void *)&cmd_flow_director_fd_id,
10906 (void *)&cmd_flow_director_fd_id_value,
10911 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10912 .f = cmd_flow_director_filter_parsed,
10914 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10915 "director entry on NIC",
10917 (void *)&cmd_flow_director_filter,
10918 (void *)&cmd_flow_director_port_id,
10919 (void *)&cmd_flow_director_mode,
10920 (void *)&cmd_flow_director_mode_mac_vlan,
10921 (void *)&cmd_flow_director_ops,
10922 (void *)&cmd_flow_director_mac,
10923 (void *)&cmd_flow_director_mac_addr,
10924 (void *)&cmd_flow_director_vlan,
10925 (void *)&cmd_flow_director_vlan_value,
10926 (void *)&cmd_flow_director_flexbytes,
10927 (void *)&cmd_flow_director_flexbytes_value,
10928 (void *)&cmd_flow_director_drop,
10929 (void *)&cmd_flow_director_queue,
10930 (void *)&cmd_flow_director_queue_id,
10931 (void *)&cmd_flow_director_fd_id,
10932 (void *)&cmd_flow_director_fd_id_value,
10937 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10938 .f = cmd_flow_director_filter_parsed,
10940 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10941 "director entry on NIC",
10943 (void *)&cmd_flow_director_filter,
10944 (void *)&cmd_flow_director_port_id,
10945 (void *)&cmd_flow_director_mode,
10946 (void *)&cmd_flow_director_mode_tunnel,
10947 (void *)&cmd_flow_director_ops,
10948 (void *)&cmd_flow_director_mac,
10949 (void *)&cmd_flow_director_mac_addr,
10950 (void *)&cmd_flow_director_vlan,
10951 (void *)&cmd_flow_director_vlan_value,
10952 (void *)&cmd_flow_director_tunnel,
10953 (void *)&cmd_flow_director_tunnel_type,
10954 (void *)&cmd_flow_director_tunnel_id,
10955 (void *)&cmd_flow_director_tunnel_id_value,
10956 (void *)&cmd_flow_director_flexbytes,
10957 (void *)&cmd_flow_director_flexbytes_value,
10958 (void *)&cmd_flow_director_drop,
10959 (void *)&cmd_flow_director_queue,
10960 (void *)&cmd_flow_director_queue_id,
10961 (void *)&cmd_flow_director_fd_id,
10962 (void *)&cmd_flow_director_fd_id_value,
10967 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10968 .f = cmd_flow_director_filter_parsed,
10970 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10971 "director entry on NIC",
10973 (void *)&cmd_flow_director_filter,
10974 (void *)&cmd_flow_director_port_id,
10975 (void *)&cmd_flow_director_mode,
10976 (void *)&cmd_flow_director_mode_raw,
10977 (void *)&cmd_flow_director_ops,
10978 (void *)&cmd_flow_director_flow,
10979 (void *)&cmd_flow_director_flow_type,
10980 (void *)&cmd_flow_director_drop,
10981 (void *)&cmd_flow_director_queue,
10982 (void *)&cmd_flow_director_queue_id,
10983 (void *)&cmd_flow_director_fd_id,
10984 (void *)&cmd_flow_director_fd_id_value,
10985 (void *)&cmd_flow_director_packet,
10986 (void *)&cmd_flow_director_filepath,
10991 struct cmd_flush_flow_director_result {
10992 cmdline_fixed_string_t flush_flow_director;
10996 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10997 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10998 flush_flow_director, "flush_flow_director");
10999 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11000 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11004 cmd_flush_flow_director_parsed(void *parsed_result,
11005 __rte_unused struct cmdline *cl,
11006 __rte_unused void *data)
11008 struct cmd_flow_director_result *res = parsed_result;
11011 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11013 printf("flow director is not supported on port %u.\n",
11018 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11019 RTE_ETH_FILTER_FLUSH, NULL);
11021 printf("flow director table flushing error: (%s)\n",
11025 cmdline_parse_inst_t cmd_flush_flow_director = {
11026 .f = cmd_flush_flow_director_parsed,
11028 .help_str = "flush_flow_director <port_id>: "
11029 "Flush all flow director entries of a device on NIC",
11031 (void *)&cmd_flush_flow_director_flush,
11032 (void *)&cmd_flush_flow_director_port_id,
11037 /* *** deal with flow director mask *** */
11038 struct cmd_flow_director_mask_result {
11039 cmdline_fixed_string_t flow_director_mask;
11041 cmdline_fixed_string_t mode;
11042 cmdline_fixed_string_t mode_value;
11043 cmdline_fixed_string_t vlan;
11044 uint16_t vlan_mask;
11045 cmdline_fixed_string_t src_mask;
11046 cmdline_ipaddr_t ipv4_src;
11047 cmdline_ipaddr_t ipv6_src;
11049 cmdline_fixed_string_t dst_mask;
11050 cmdline_ipaddr_t ipv4_dst;
11051 cmdline_ipaddr_t ipv6_dst;
11053 cmdline_fixed_string_t mac;
11054 uint8_t mac_addr_byte_mask;
11055 cmdline_fixed_string_t tunnel_id;
11056 uint32_t tunnel_id_mask;
11057 cmdline_fixed_string_t tunnel_type;
11058 uint8_t tunnel_type_mask;
11062 cmd_flow_director_mask_parsed(void *parsed_result,
11063 __rte_unused struct cmdline *cl,
11064 __rte_unused void *data)
11066 struct cmd_flow_director_mask_result *res = parsed_result;
11067 struct rte_eth_fdir_masks *mask;
11068 struct rte_port *port;
11070 port = &ports[res->port_id];
11071 /** Check if the port is not started **/
11072 if (port->port_status != RTE_PORT_STOPPED) {
11073 printf("Please stop port %d first\n", res->port_id);
11077 mask = &port->dev_conf.fdir_conf.mask;
11079 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11080 if (strcmp(res->mode_value, "MAC-VLAN")) {
11081 printf("Please set mode to MAC-VLAN.\n");
11085 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11086 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11087 if (strcmp(res->mode_value, "Tunnel")) {
11088 printf("Please set mode to Tunnel.\n");
11092 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11093 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11094 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11095 mask->tunnel_type_mask = res->tunnel_type_mask;
11097 if (strcmp(res->mode_value, "IP")) {
11098 printf("Please set mode to IP.\n");
11102 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11103 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11104 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11105 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11106 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11107 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11108 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11111 cmd_reconfig_device_queue(res->port_id, 1, 1);
11114 cmdline_parse_token_string_t cmd_flow_director_mask =
11115 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11116 flow_director_mask, "flow_director_mask");
11117 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11118 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11120 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11121 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11123 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11124 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11125 vlan_mask, UINT16);
11126 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11127 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11128 src_mask, "src_mask");
11129 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11130 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11132 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11133 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11135 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11136 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11138 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11139 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11140 dst_mask, "dst_mask");
11141 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11142 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11144 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11145 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11147 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11148 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11151 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11152 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11154 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11155 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11157 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11158 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11159 mode_value, "MAC-VLAN");
11160 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11161 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11162 mode_value, "Tunnel");
11163 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11164 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11166 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11167 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11168 mac_addr_byte_mask, UINT8);
11169 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11170 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11171 tunnel_type, "tunnel-type");
11172 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11173 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11174 tunnel_type_mask, UINT8);
11175 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11176 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11177 tunnel_id, "tunnel-id");
11178 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11179 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11180 tunnel_id_mask, UINT32);
11182 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11183 .f = cmd_flow_director_mask_parsed,
11185 .help_str = "flow_director_mask ... : "
11186 "Set IP mode flow director's mask on NIC",
11188 (void *)&cmd_flow_director_mask,
11189 (void *)&cmd_flow_director_mask_port_id,
11190 (void *)&cmd_flow_director_mask_mode,
11191 (void *)&cmd_flow_director_mask_mode_ip,
11192 (void *)&cmd_flow_director_mask_vlan,
11193 (void *)&cmd_flow_director_mask_vlan_value,
11194 (void *)&cmd_flow_director_mask_src,
11195 (void *)&cmd_flow_director_mask_ipv4_src,
11196 (void *)&cmd_flow_director_mask_ipv6_src,
11197 (void *)&cmd_flow_director_mask_port_src,
11198 (void *)&cmd_flow_director_mask_dst,
11199 (void *)&cmd_flow_director_mask_ipv4_dst,
11200 (void *)&cmd_flow_director_mask_ipv6_dst,
11201 (void *)&cmd_flow_director_mask_port_dst,
11206 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11207 .f = cmd_flow_director_mask_parsed,
11209 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11210 "flow director's mask on NIC",
11212 (void *)&cmd_flow_director_mask,
11213 (void *)&cmd_flow_director_mask_port_id,
11214 (void *)&cmd_flow_director_mask_mode,
11215 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11216 (void *)&cmd_flow_director_mask_vlan,
11217 (void *)&cmd_flow_director_mask_vlan_value,
11222 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11223 .f = cmd_flow_director_mask_parsed,
11225 .help_str = "flow_director_mask ... : Set tunnel mode "
11226 "flow director's mask on NIC",
11228 (void *)&cmd_flow_director_mask,
11229 (void *)&cmd_flow_director_mask_port_id,
11230 (void *)&cmd_flow_director_mask_mode,
11231 (void *)&cmd_flow_director_mask_mode_tunnel,
11232 (void *)&cmd_flow_director_mask_vlan,
11233 (void *)&cmd_flow_director_mask_vlan_value,
11234 (void *)&cmd_flow_director_mask_mac,
11235 (void *)&cmd_flow_director_mask_mac_value,
11236 (void *)&cmd_flow_director_mask_tunnel_type,
11237 (void *)&cmd_flow_director_mask_tunnel_type_value,
11238 (void *)&cmd_flow_director_mask_tunnel_id,
11239 (void *)&cmd_flow_director_mask_tunnel_id_value,
11244 /* *** deal with flow director mask on flexible payload *** */
11245 struct cmd_flow_director_flex_mask_result {
11246 cmdline_fixed_string_t flow_director_flexmask;
11248 cmdline_fixed_string_t flow;
11249 cmdline_fixed_string_t flow_type;
11250 cmdline_fixed_string_t mask;
11254 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11255 __rte_unused struct cmdline *cl,
11256 __rte_unused void *data)
11258 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11259 struct rte_eth_fdir_info fdir_info;
11260 struct rte_eth_fdir_flex_mask flex_mask;
11261 struct rte_port *port;
11262 uint64_t flow_type_mask;
11266 port = &ports[res->port_id];
11267 /** Check if the port is not started **/
11268 if (port->port_status != RTE_PORT_STOPPED) {
11269 printf("Please stop port %d first\n", res->port_id);
11273 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11274 ret = parse_flexbytes(res->mask,
11276 RTE_ETH_FDIR_MAX_FLEXLEN);
11278 printf("error: Cannot parse mask input.\n");
11282 memset(&fdir_info, 0, sizeof(fdir_info));
11283 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11284 RTE_ETH_FILTER_INFO, &fdir_info);
11286 printf("Cannot get FDir filter info\n");
11290 if (!strcmp(res->flow_type, "none")) {
11291 /* means don't specify the flow type */
11292 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11293 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11294 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11295 0, sizeof(struct rte_eth_fdir_flex_mask));
11296 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11297 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11299 sizeof(struct rte_eth_fdir_flex_mask));
11300 cmd_reconfig_device_queue(res->port_id, 1, 1);
11303 flow_type_mask = fdir_info.flow_types_mask[0];
11304 if (!strcmp(res->flow_type, "all")) {
11305 if (!flow_type_mask) {
11306 printf("No flow type supported\n");
11309 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11310 if (flow_type_mask & (1ULL << i)) {
11311 flex_mask.flow_type = i;
11312 fdir_set_flex_mask(res->port_id, &flex_mask);
11315 cmd_reconfig_device_queue(res->port_id, 1, 1);
11318 flex_mask.flow_type = str2flowtype(res->flow_type);
11319 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11320 printf("Flow type %s not supported on port %d\n",
11321 res->flow_type, res->port_id);
11324 fdir_set_flex_mask(res->port_id, &flex_mask);
11325 cmd_reconfig_device_queue(res->port_id, 1, 1);
11328 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11329 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11330 flow_director_flexmask,
11331 "flow_director_flex_mask");
11332 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11333 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11335 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11336 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11338 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11339 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11340 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11341 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11342 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11343 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11346 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11347 .f = cmd_flow_director_flex_mask_parsed,
11349 .help_str = "flow_director_flex_mask ... : "
11350 "Set flow director's flex mask on NIC",
11352 (void *)&cmd_flow_director_flexmask,
11353 (void *)&cmd_flow_director_flexmask_port_id,
11354 (void *)&cmd_flow_director_flexmask_flow,
11355 (void *)&cmd_flow_director_flexmask_flow_type,
11356 (void *)&cmd_flow_director_flexmask_mask,
11361 /* *** deal with flow director flexible payload configuration *** */
11362 struct cmd_flow_director_flexpayload_result {
11363 cmdline_fixed_string_t flow_director_flexpayload;
11365 cmdline_fixed_string_t payload_layer;
11366 cmdline_fixed_string_t payload_cfg;
11370 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11373 const char *p, *p0 = q_arg;
11375 unsigned long int_fld;
11376 char *str_fld[max_num];
11381 p = strchr(p0, '(');
11385 p0 = strchr(p, ')');
11390 if (size >= sizeof(s))
11393 snprintf(s, sizeof(s), "%.*s", size, p);
11394 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11395 if (ret < 0 || ret > max_num)
11397 for (i = 0; i < ret; i++) {
11399 int_fld = strtoul(str_fld[i], &end, 0);
11400 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11402 offsets[i] = (uint16_t)int_fld;
11408 cmd_flow_director_flxpld_parsed(void *parsed_result,
11409 __rte_unused struct cmdline *cl,
11410 __rte_unused void *data)
11412 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11413 struct rte_eth_flex_payload_cfg flex_cfg;
11414 struct rte_port *port;
11417 port = &ports[res->port_id];
11418 /** Check if the port is not started **/
11419 if (port->port_status != RTE_PORT_STOPPED) {
11420 printf("Please stop port %d first\n", res->port_id);
11424 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11426 if (!strcmp(res->payload_layer, "raw"))
11427 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11428 else if (!strcmp(res->payload_layer, "l2"))
11429 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11430 else if (!strcmp(res->payload_layer, "l3"))
11431 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11432 else if (!strcmp(res->payload_layer, "l4"))
11433 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11435 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11436 RTE_ETH_FDIR_MAX_FLEXLEN);
11438 printf("error: Cannot parse flex payload input.\n");
11442 fdir_set_flex_payload(res->port_id, &flex_cfg);
11443 cmd_reconfig_device_queue(res->port_id, 1, 1);
11446 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11447 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11448 flow_director_flexpayload,
11449 "flow_director_flex_payload");
11450 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11451 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11453 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11454 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11455 payload_layer, "raw#l2#l3#l4");
11456 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11457 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11458 payload_cfg, NULL);
11460 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11461 .f = cmd_flow_director_flxpld_parsed,
11463 .help_str = "flow_director_flexpayload ... : "
11464 "Set flow director's flex payload on NIC",
11466 (void *)&cmd_flow_director_flexpayload,
11467 (void *)&cmd_flow_director_flexpayload_port_id,
11468 (void *)&cmd_flow_director_flexpayload_payload_layer,
11469 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11474 /* Generic flow interface command. */
11475 extern cmdline_parse_inst_t cmd_flow;
11477 /* *** Classification Filters Control *** */
11479 static enum rte_eth_input_set_field
11480 str2inset(char *string)
11484 static const struct {
11486 enum rte_eth_input_set_field inset;
11487 } inset_table[] = {
11488 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11489 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11490 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11491 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11492 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11493 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11494 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11495 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11496 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11497 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11498 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11499 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11500 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11501 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11502 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11503 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11504 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11505 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11506 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11507 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11508 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11509 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11510 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11511 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11512 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11513 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11514 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11515 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11516 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11517 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11518 {"none", RTE_ETH_INPUT_SET_NONE},
11521 for (i = 0; i < RTE_DIM(inset_table); i++) {
11522 if (!strcmp(string, inset_table[i].str))
11523 return inset_table[i].inset;
11526 return RTE_ETH_INPUT_SET_UNKNOWN;
11529 /* Set flow director input set */
11530 struct cmd_set_fdir_input_set_result {
11531 cmdline_fixed_string_t set_fdir_input_set;
11533 cmdline_fixed_string_t flow_type;
11534 cmdline_fixed_string_t inset_field;
11535 cmdline_fixed_string_t select;
11539 cmd_set_fdir_input_set_parsed(void *parsed_result,
11540 __rte_unused struct cmdline *cl,
11541 __rte_unused void *data)
11543 struct cmd_set_fdir_input_set_result *res = parsed_result;
11544 struct rte_eth_fdir_filter_info info;
11546 memset(&info, 0, sizeof(info));
11547 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11548 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11549 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11550 info.info.input_set_conf.inset_size = 1;
11551 if (!strcmp(res->select, "select"))
11552 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11553 else if (!strcmp(res->select, "add"))
11554 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11555 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11556 RTE_ETH_FILTER_SET, &info);
11559 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11560 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11561 set_fdir_input_set, "set_fdir_input_set");
11562 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11563 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11565 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11566 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11568 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11569 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11570 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11571 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11573 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11574 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11575 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11576 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11577 "sctp-veri-tag#none");
11578 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11579 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11580 select, "select#add");
11582 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11583 .f = cmd_set_fdir_input_set_parsed,
11585 .help_str = "set_fdir_input_set <port_id> "
11586 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11587 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11588 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11589 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11590 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11591 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11592 "sctp-veri-tag|none select|add",
11594 (void *)&cmd_set_fdir_input_set_cmd,
11595 (void *)&cmd_set_fdir_input_set_port_id,
11596 (void *)&cmd_set_fdir_input_set_flow_type,
11597 (void *)&cmd_set_fdir_input_set_field,
11598 (void *)&cmd_set_fdir_input_set_select,
11603 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11604 struct cmd_mcast_addr_result {
11605 cmdline_fixed_string_t mcast_addr_cmd;
11606 cmdline_fixed_string_t what;
11608 struct rte_ether_addr mc_addr;
11611 static void cmd_mcast_addr_parsed(void *parsed_result,
11612 __rte_unused struct cmdline *cl,
11613 __rte_unused void *data)
11615 struct cmd_mcast_addr_result *res = parsed_result;
11617 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
11618 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11619 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11620 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11621 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11624 if (strcmp(res->what, "add") == 0)
11625 mcast_addr_add(res->port_num, &res->mc_addr);
11627 mcast_addr_remove(res->port_num, &res->mc_addr);
11630 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11631 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11632 mcast_addr_cmd, "mcast_addr");
11633 cmdline_parse_token_string_t cmd_mcast_addr_what =
11634 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11636 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11637 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11638 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11639 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11641 cmdline_parse_inst_t cmd_mcast_addr = {
11642 .f = cmd_mcast_addr_parsed,
11644 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11645 "Add/Remove multicast MAC address on port_id",
11647 (void *)&cmd_mcast_addr_cmd,
11648 (void *)&cmd_mcast_addr_what,
11649 (void *)&cmd_mcast_addr_portnum,
11650 (void *)&cmd_mcast_addr_addr,
11655 /* l2 tunnel config
11656 * only support E-tag now.
11659 /* Ether type config */
11660 struct cmd_config_l2_tunnel_eth_type_result {
11661 cmdline_fixed_string_t port;
11662 cmdline_fixed_string_t config;
11663 cmdline_fixed_string_t all;
11665 cmdline_fixed_string_t l2_tunnel;
11666 cmdline_fixed_string_t l2_tunnel_type;
11667 cmdline_fixed_string_t eth_type;
11668 uint16_t eth_type_val;
11671 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11672 TOKEN_STRING_INITIALIZER
11673 (struct cmd_config_l2_tunnel_eth_type_result,
11675 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11676 TOKEN_STRING_INITIALIZER
11677 (struct cmd_config_l2_tunnel_eth_type_result,
11679 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11680 TOKEN_STRING_INITIALIZER
11681 (struct cmd_config_l2_tunnel_eth_type_result,
11683 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11684 TOKEN_NUM_INITIALIZER
11685 (struct cmd_config_l2_tunnel_eth_type_result,
11687 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11688 TOKEN_STRING_INITIALIZER
11689 (struct cmd_config_l2_tunnel_eth_type_result,
11690 l2_tunnel, "l2-tunnel");
11691 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11692 TOKEN_STRING_INITIALIZER
11693 (struct cmd_config_l2_tunnel_eth_type_result,
11694 l2_tunnel_type, "E-tag");
11695 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11696 TOKEN_STRING_INITIALIZER
11697 (struct cmd_config_l2_tunnel_eth_type_result,
11698 eth_type, "ether-type");
11699 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11700 TOKEN_NUM_INITIALIZER
11701 (struct cmd_config_l2_tunnel_eth_type_result,
11702 eth_type_val, UINT16);
11704 static enum rte_eth_tunnel_type
11705 str2fdir_l2_tunnel_type(char *string)
11709 static const struct {
11711 enum rte_eth_tunnel_type type;
11712 } l2_tunnel_type_str[] = {
11713 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11716 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11717 if (!strcmp(l2_tunnel_type_str[i].str, string))
11718 return l2_tunnel_type_str[i].type;
11720 return RTE_TUNNEL_TYPE_NONE;
11723 /* ether type config for all ports */
11725 cmd_config_l2_tunnel_eth_type_all_parsed
11726 (void *parsed_result,
11727 __rte_unused struct cmdline *cl,
11728 __rte_unused void *data)
11730 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11731 struct rte_eth_l2_tunnel_conf entry;
11734 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11735 entry.ether_type = res->eth_type_val;
11737 RTE_ETH_FOREACH_DEV(pid) {
11738 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11742 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11743 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11745 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11747 (void *)&cmd_config_l2_tunnel_eth_type_port,
11748 (void *)&cmd_config_l2_tunnel_eth_type_config,
11749 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11750 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11751 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11752 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11753 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11758 /* ether type config for a specific port */
11760 cmd_config_l2_tunnel_eth_type_specific_parsed(
11761 void *parsed_result,
11762 __rte_unused struct cmdline *cl,
11763 __rte_unused void *data)
11765 struct cmd_config_l2_tunnel_eth_type_result *res =
11767 struct rte_eth_l2_tunnel_conf entry;
11769 if (port_id_is_invalid(res->id, ENABLED_WARN))
11772 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11773 entry.ether_type = res->eth_type_val;
11775 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11778 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11779 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11781 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11783 (void *)&cmd_config_l2_tunnel_eth_type_port,
11784 (void *)&cmd_config_l2_tunnel_eth_type_config,
11785 (void *)&cmd_config_l2_tunnel_eth_type_id,
11786 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11787 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11788 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11789 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11794 /* Enable/disable l2 tunnel */
11795 struct cmd_config_l2_tunnel_en_dis_result {
11796 cmdline_fixed_string_t port;
11797 cmdline_fixed_string_t config;
11798 cmdline_fixed_string_t all;
11800 cmdline_fixed_string_t l2_tunnel;
11801 cmdline_fixed_string_t l2_tunnel_type;
11802 cmdline_fixed_string_t en_dis;
11805 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11806 TOKEN_STRING_INITIALIZER
11807 (struct cmd_config_l2_tunnel_en_dis_result,
11809 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11810 TOKEN_STRING_INITIALIZER
11811 (struct cmd_config_l2_tunnel_en_dis_result,
11813 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11814 TOKEN_STRING_INITIALIZER
11815 (struct cmd_config_l2_tunnel_en_dis_result,
11817 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11818 TOKEN_NUM_INITIALIZER
11819 (struct cmd_config_l2_tunnel_en_dis_result,
11821 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11822 TOKEN_STRING_INITIALIZER
11823 (struct cmd_config_l2_tunnel_en_dis_result,
11824 l2_tunnel, "l2-tunnel");
11825 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11826 TOKEN_STRING_INITIALIZER
11827 (struct cmd_config_l2_tunnel_en_dis_result,
11828 l2_tunnel_type, "E-tag");
11829 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11830 TOKEN_STRING_INITIALIZER
11831 (struct cmd_config_l2_tunnel_en_dis_result,
11832 en_dis, "enable#disable");
11834 /* enable/disable l2 tunnel for all ports */
11836 cmd_config_l2_tunnel_en_dis_all_parsed(
11837 void *parsed_result,
11838 __rte_unused struct cmdline *cl,
11839 __rte_unused void *data)
11841 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11842 struct rte_eth_l2_tunnel_conf entry;
11846 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11848 if (!strcmp("enable", res->en_dis))
11853 RTE_ETH_FOREACH_DEV(pid) {
11854 rte_eth_dev_l2_tunnel_offload_set(pid,
11856 ETH_L2_TUNNEL_ENABLE_MASK,
11861 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11862 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11864 .help_str = "port config all l2-tunnel E-tag enable|disable",
11866 (void *)&cmd_config_l2_tunnel_en_dis_port,
11867 (void *)&cmd_config_l2_tunnel_en_dis_config,
11868 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11869 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11870 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11871 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11876 /* enable/disable l2 tunnel for a port */
11878 cmd_config_l2_tunnel_en_dis_specific_parsed(
11879 void *parsed_result,
11880 __rte_unused struct cmdline *cl,
11881 __rte_unused void *data)
11883 struct cmd_config_l2_tunnel_en_dis_result *res =
11885 struct rte_eth_l2_tunnel_conf entry;
11887 if (port_id_is_invalid(res->id, ENABLED_WARN))
11890 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11892 if (!strcmp("enable", res->en_dis))
11893 rte_eth_dev_l2_tunnel_offload_set(res->id,
11895 ETH_L2_TUNNEL_ENABLE_MASK,
11898 rte_eth_dev_l2_tunnel_offload_set(res->id,
11900 ETH_L2_TUNNEL_ENABLE_MASK,
11904 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11905 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11907 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11909 (void *)&cmd_config_l2_tunnel_en_dis_port,
11910 (void *)&cmd_config_l2_tunnel_en_dis_config,
11911 (void *)&cmd_config_l2_tunnel_en_dis_id,
11912 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11913 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11914 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11919 /* E-tag configuration */
11921 /* Common result structure for all E-tag configuration */
11922 struct cmd_config_e_tag_result {
11923 cmdline_fixed_string_t e_tag;
11924 cmdline_fixed_string_t set;
11925 cmdline_fixed_string_t insertion;
11926 cmdline_fixed_string_t stripping;
11927 cmdline_fixed_string_t forwarding;
11928 cmdline_fixed_string_t filter;
11929 cmdline_fixed_string_t add;
11930 cmdline_fixed_string_t del;
11931 cmdline_fixed_string_t on;
11932 cmdline_fixed_string_t off;
11933 cmdline_fixed_string_t on_off;
11934 cmdline_fixed_string_t port_tag_id;
11935 uint32_t port_tag_id_val;
11936 cmdline_fixed_string_t e_tag_id;
11937 uint16_t e_tag_id_val;
11938 cmdline_fixed_string_t dst_pool;
11939 uint8_t dst_pool_val;
11940 cmdline_fixed_string_t port;
11942 cmdline_fixed_string_t vf;
11946 /* Common CLI fields for all E-tag configuration */
11947 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11948 TOKEN_STRING_INITIALIZER
11949 (struct cmd_config_e_tag_result,
11951 cmdline_parse_token_string_t cmd_config_e_tag_set =
11952 TOKEN_STRING_INITIALIZER
11953 (struct cmd_config_e_tag_result,
11955 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11956 TOKEN_STRING_INITIALIZER
11957 (struct cmd_config_e_tag_result,
11958 insertion, "insertion");
11959 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11960 TOKEN_STRING_INITIALIZER
11961 (struct cmd_config_e_tag_result,
11962 stripping, "stripping");
11963 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11964 TOKEN_STRING_INITIALIZER
11965 (struct cmd_config_e_tag_result,
11966 forwarding, "forwarding");
11967 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11968 TOKEN_STRING_INITIALIZER
11969 (struct cmd_config_e_tag_result,
11971 cmdline_parse_token_string_t cmd_config_e_tag_add =
11972 TOKEN_STRING_INITIALIZER
11973 (struct cmd_config_e_tag_result,
11975 cmdline_parse_token_string_t cmd_config_e_tag_del =
11976 TOKEN_STRING_INITIALIZER
11977 (struct cmd_config_e_tag_result,
11979 cmdline_parse_token_string_t cmd_config_e_tag_on =
11980 TOKEN_STRING_INITIALIZER
11981 (struct cmd_config_e_tag_result,
11983 cmdline_parse_token_string_t cmd_config_e_tag_off =
11984 TOKEN_STRING_INITIALIZER
11985 (struct cmd_config_e_tag_result,
11987 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11988 TOKEN_STRING_INITIALIZER
11989 (struct cmd_config_e_tag_result,
11991 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11992 TOKEN_STRING_INITIALIZER
11993 (struct cmd_config_e_tag_result,
11994 port_tag_id, "port-tag-id");
11995 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11996 TOKEN_NUM_INITIALIZER
11997 (struct cmd_config_e_tag_result,
11998 port_tag_id_val, UINT32);
11999 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12000 TOKEN_STRING_INITIALIZER
12001 (struct cmd_config_e_tag_result,
12002 e_tag_id, "e-tag-id");
12003 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12004 TOKEN_NUM_INITIALIZER
12005 (struct cmd_config_e_tag_result,
12006 e_tag_id_val, UINT16);
12007 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12008 TOKEN_STRING_INITIALIZER
12009 (struct cmd_config_e_tag_result,
12010 dst_pool, "dst-pool");
12011 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12012 TOKEN_NUM_INITIALIZER
12013 (struct cmd_config_e_tag_result,
12014 dst_pool_val, UINT8);
12015 cmdline_parse_token_string_t cmd_config_e_tag_port =
12016 TOKEN_STRING_INITIALIZER
12017 (struct cmd_config_e_tag_result,
12019 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12020 TOKEN_NUM_INITIALIZER
12021 (struct cmd_config_e_tag_result,
12023 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12024 TOKEN_STRING_INITIALIZER
12025 (struct cmd_config_e_tag_result,
12027 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12028 TOKEN_NUM_INITIALIZER
12029 (struct cmd_config_e_tag_result,
12032 /* E-tag insertion configuration */
12034 cmd_config_e_tag_insertion_en_parsed(
12035 void *parsed_result,
12036 __rte_unused struct cmdline *cl,
12037 __rte_unused void *data)
12039 struct cmd_config_e_tag_result *res =
12041 struct rte_eth_l2_tunnel_conf entry;
12043 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12046 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12047 entry.tunnel_id = res->port_tag_id_val;
12048 entry.vf_id = res->vf_id;
12049 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12051 ETH_L2_TUNNEL_INSERTION_MASK,
12056 cmd_config_e_tag_insertion_dis_parsed(
12057 void *parsed_result,
12058 __rte_unused struct cmdline *cl,
12059 __rte_unused void *data)
12061 struct cmd_config_e_tag_result *res =
12063 struct rte_eth_l2_tunnel_conf entry;
12065 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12068 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12069 entry.vf_id = res->vf_id;
12071 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12073 ETH_L2_TUNNEL_INSERTION_MASK,
12077 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12078 .f = cmd_config_e_tag_insertion_en_parsed,
12080 .help_str = "E-tag ... : E-tag insertion enable",
12082 (void *)&cmd_config_e_tag_e_tag,
12083 (void *)&cmd_config_e_tag_set,
12084 (void *)&cmd_config_e_tag_insertion,
12085 (void *)&cmd_config_e_tag_on,
12086 (void *)&cmd_config_e_tag_port_tag_id,
12087 (void *)&cmd_config_e_tag_port_tag_id_val,
12088 (void *)&cmd_config_e_tag_port,
12089 (void *)&cmd_config_e_tag_port_id,
12090 (void *)&cmd_config_e_tag_vf,
12091 (void *)&cmd_config_e_tag_vf_id,
12096 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12097 .f = cmd_config_e_tag_insertion_dis_parsed,
12099 .help_str = "E-tag ... : E-tag insertion disable",
12101 (void *)&cmd_config_e_tag_e_tag,
12102 (void *)&cmd_config_e_tag_set,
12103 (void *)&cmd_config_e_tag_insertion,
12104 (void *)&cmd_config_e_tag_off,
12105 (void *)&cmd_config_e_tag_port,
12106 (void *)&cmd_config_e_tag_port_id,
12107 (void *)&cmd_config_e_tag_vf,
12108 (void *)&cmd_config_e_tag_vf_id,
12113 /* E-tag stripping configuration */
12115 cmd_config_e_tag_stripping_parsed(
12116 void *parsed_result,
12117 __rte_unused struct cmdline *cl,
12118 __rte_unused void *data)
12120 struct cmd_config_e_tag_result *res =
12122 struct rte_eth_l2_tunnel_conf entry;
12124 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12127 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12129 if (!strcmp(res->on_off, "on"))
12130 rte_eth_dev_l2_tunnel_offload_set
12133 ETH_L2_TUNNEL_STRIPPING_MASK,
12136 rte_eth_dev_l2_tunnel_offload_set
12139 ETH_L2_TUNNEL_STRIPPING_MASK,
12143 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12144 .f = cmd_config_e_tag_stripping_parsed,
12146 .help_str = "E-tag ... : E-tag stripping enable/disable",
12148 (void *)&cmd_config_e_tag_e_tag,
12149 (void *)&cmd_config_e_tag_set,
12150 (void *)&cmd_config_e_tag_stripping,
12151 (void *)&cmd_config_e_tag_on_off,
12152 (void *)&cmd_config_e_tag_port,
12153 (void *)&cmd_config_e_tag_port_id,
12158 /* E-tag forwarding configuration */
12160 cmd_config_e_tag_forwarding_parsed(
12161 void *parsed_result,
12162 __rte_unused struct cmdline *cl,
12163 __rte_unused void *data)
12165 struct cmd_config_e_tag_result *res = parsed_result;
12166 struct rte_eth_l2_tunnel_conf entry;
12168 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12171 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12173 if (!strcmp(res->on_off, "on"))
12174 rte_eth_dev_l2_tunnel_offload_set
12177 ETH_L2_TUNNEL_FORWARDING_MASK,
12180 rte_eth_dev_l2_tunnel_offload_set
12183 ETH_L2_TUNNEL_FORWARDING_MASK,
12187 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12188 .f = cmd_config_e_tag_forwarding_parsed,
12190 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12192 (void *)&cmd_config_e_tag_e_tag,
12193 (void *)&cmd_config_e_tag_set,
12194 (void *)&cmd_config_e_tag_forwarding,
12195 (void *)&cmd_config_e_tag_on_off,
12196 (void *)&cmd_config_e_tag_port,
12197 (void *)&cmd_config_e_tag_port_id,
12202 /* E-tag filter configuration */
12204 cmd_config_e_tag_filter_add_parsed(
12205 void *parsed_result,
12206 __rte_unused struct cmdline *cl,
12207 __rte_unused void *data)
12209 struct cmd_config_e_tag_result *res = parsed_result;
12210 struct rte_eth_l2_tunnel_conf entry;
12213 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12216 if (res->e_tag_id_val > 0x3fff) {
12217 printf("e-tag-id must be equal or less than 0x3fff.\n");
12221 ret = rte_eth_dev_filter_supported(res->port_id,
12222 RTE_ETH_FILTER_L2_TUNNEL);
12224 printf("E-tag filter is not supported on port %u.\n",
12229 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12230 entry.tunnel_id = res->e_tag_id_val;
12231 entry.pool = res->dst_pool_val;
12233 ret = rte_eth_dev_filter_ctrl(res->port_id,
12234 RTE_ETH_FILTER_L2_TUNNEL,
12235 RTE_ETH_FILTER_ADD,
12238 printf("E-tag filter programming error: (%s)\n",
12242 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12243 .f = cmd_config_e_tag_filter_add_parsed,
12245 .help_str = "E-tag ... : E-tag filter add",
12247 (void *)&cmd_config_e_tag_e_tag,
12248 (void *)&cmd_config_e_tag_set,
12249 (void *)&cmd_config_e_tag_filter,
12250 (void *)&cmd_config_e_tag_add,
12251 (void *)&cmd_config_e_tag_e_tag_id,
12252 (void *)&cmd_config_e_tag_e_tag_id_val,
12253 (void *)&cmd_config_e_tag_dst_pool,
12254 (void *)&cmd_config_e_tag_dst_pool_val,
12255 (void *)&cmd_config_e_tag_port,
12256 (void *)&cmd_config_e_tag_port_id,
12262 cmd_config_e_tag_filter_del_parsed(
12263 void *parsed_result,
12264 __rte_unused struct cmdline *cl,
12265 __rte_unused void *data)
12267 struct cmd_config_e_tag_result *res = parsed_result;
12268 struct rte_eth_l2_tunnel_conf entry;
12271 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12274 if (res->e_tag_id_val > 0x3fff) {
12275 printf("e-tag-id must be less than 0x3fff.\n");
12279 ret = rte_eth_dev_filter_supported(res->port_id,
12280 RTE_ETH_FILTER_L2_TUNNEL);
12282 printf("E-tag filter is not supported on port %u.\n",
12287 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12288 entry.tunnel_id = res->e_tag_id_val;
12290 ret = rte_eth_dev_filter_ctrl(res->port_id,
12291 RTE_ETH_FILTER_L2_TUNNEL,
12292 RTE_ETH_FILTER_DELETE,
12295 printf("E-tag filter programming error: (%s)\n",
12299 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12300 .f = cmd_config_e_tag_filter_del_parsed,
12302 .help_str = "E-tag ... : E-tag filter delete",
12304 (void *)&cmd_config_e_tag_e_tag,
12305 (void *)&cmd_config_e_tag_set,
12306 (void *)&cmd_config_e_tag_filter,
12307 (void *)&cmd_config_e_tag_del,
12308 (void *)&cmd_config_e_tag_e_tag_id,
12309 (void *)&cmd_config_e_tag_e_tag_id_val,
12310 (void *)&cmd_config_e_tag_port,
12311 (void *)&cmd_config_e_tag_port_id,
12316 /* vf vlan anti spoof configuration */
12318 /* Common result structure for vf vlan anti spoof */
12319 struct cmd_vf_vlan_anti_spoof_result {
12320 cmdline_fixed_string_t set;
12321 cmdline_fixed_string_t vf;
12322 cmdline_fixed_string_t vlan;
12323 cmdline_fixed_string_t antispoof;
12326 cmdline_fixed_string_t on_off;
12329 /* Common CLI fields for vf vlan anti spoof enable disable */
12330 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12331 TOKEN_STRING_INITIALIZER
12332 (struct cmd_vf_vlan_anti_spoof_result,
12334 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12335 TOKEN_STRING_INITIALIZER
12336 (struct cmd_vf_vlan_anti_spoof_result,
12338 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12339 TOKEN_STRING_INITIALIZER
12340 (struct cmd_vf_vlan_anti_spoof_result,
12342 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12343 TOKEN_STRING_INITIALIZER
12344 (struct cmd_vf_vlan_anti_spoof_result,
12345 antispoof, "antispoof");
12346 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12347 TOKEN_NUM_INITIALIZER
12348 (struct cmd_vf_vlan_anti_spoof_result,
12350 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12351 TOKEN_NUM_INITIALIZER
12352 (struct cmd_vf_vlan_anti_spoof_result,
12354 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12355 TOKEN_STRING_INITIALIZER
12356 (struct cmd_vf_vlan_anti_spoof_result,
12360 cmd_set_vf_vlan_anti_spoof_parsed(
12361 void *parsed_result,
12362 __rte_unused struct cmdline *cl,
12363 __rte_unused void *data)
12365 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12366 int ret = -ENOTSUP;
12368 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12370 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12373 #ifdef RTE_NET_IXGBE
12374 if (ret == -ENOTSUP)
12375 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12376 res->vf_id, is_on);
12378 #ifdef RTE_NET_I40E
12379 if (ret == -ENOTSUP)
12380 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12381 res->vf_id, is_on);
12383 #ifdef RTE_NET_BNXT
12384 if (ret == -ENOTSUP)
12385 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12386 res->vf_id, is_on);
12393 printf("invalid vf_id %d\n", res->vf_id);
12396 printf("invalid port_id %d\n", res->port_id);
12399 printf("function not implemented\n");
12402 printf("programming error: (%s)\n", strerror(-ret));
12406 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12407 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12409 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12411 (void *)&cmd_vf_vlan_anti_spoof_set,
12412 (void *)&cmd_vf_vlan_anti_spoof_vf,
12413 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12414 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12415 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12416 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12417 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12422 /* vf mac anti spoof configuration */
12424 /* Common result structure for vf mac anti spoof */
12425 struct cmd_vf_mac_anti_spoof_result {
12426 cmdline_fixed_string_t set;
12427 cmdline_fixed_string_t vf;
12428 cmdline_fixed_string_t mac;
12429 cmdline_fixed_string_t antispoof;
12432 cmdline_fixed_string_t on_off;
12435 /* Common CLI fields for vf mac anti spoof enable disable */
12436 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12437 TOKEN_STRING_INITIALIZER
12438 (struct cmd_vf_mac_anti_spoof_result,
12440 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12441 TOKEN_STRING_INITIALIZER
12442 (struct cmd_vf_mac_anti_spoof_result,
12444 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12445 TOKEN_STRING_INITIALIZER
12446 (struct cmd_vf_mac_anti_spoof_result,
12448 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12449 TOKEN_STRING_INITIALIZER
12450 (struct cmd_vf_mac_anti_spoof_result,
12451 antispoof, "antispoof");
12452 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12453 TOKEN_NUM_INITIALIZER
12454 (struct cmd_vf_mac_anti_spoof_result,
12456 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12457 TOKEN_NUM_INITIALIZER
12458 (struct cmd_vf_mac_anti_spoof_result,
12460 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12461 TOKEN_STRING_INITIALIZER
12462 (struct cmd_vf_mac_anti_spoof_result,
12466 cmd_set_vf_mac_anti_spoof_parsed(
12467 void *parsed_result,
12468 __rte_unused struct cmdline *cl,
12469 __rte_unused void *data)
12471 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12472 int ret = -ENOTSUP;
12474 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12476 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12479 #ifdef RTE_NET_IXGBE
12480 if (ret == -ENOTSUP)
12481 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12482 res->vf_id, is_on);
12484 #ifdef RTE_NET_I40E
12485 if (ret == -ENOTSUP)
12486 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12487 res->vf_id, is_on);
12489 #ifdef RTE_NET_BNXT
12490 if (ret == -ENOTSUP)
12491 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12492 res->vf_id, is_on);
12499 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12502 printf("invalid port_id %d\n", res->port_id);
12505 printf("function not implemented\n");
12508 printf("programming error: (%s)\n", strerror(-ret));
12512 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12513 .f = cmd_set_vf_mac_anti_spoof_parsed,
12515 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12517 (void *)&cmd_vf_mac_anti_spoof_set,
12518 (void *)&cmd_vf_mac_anti_spoof_vf,
12519 (void *)&cmd_vf_mac_anti_spoof_mac,
12520 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12521 (void *)&cmd_vf_mac_anti_spoof_port_id,
12522 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12523 (void *)&cmd_vf_mac_anti_spoof_on_off,
12528 /* vf vlan strip queue configuration */
12530 /* Common result structure for vf mac anti spoof */
12531 struct cmd_vf_vlan_stripq_result {
12532 cmdline_fixed_string_t set;
12533 cmdline_fixed_string_t vf;
12534 cmdline_fixed_string_t vlan;
12535 cmdline_fixed_string_t stripq;
12538 cmdline_fixed_string_t on_off;
12541 /* Common CLI fields for vf vlan strip enable disable */
12542 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12543 TOKEN_STRING_INITIALIZER
12544 (struct cmd_vf_vlan_stripq_result,
12546 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12547 TOKEN_STRING_INITIALIZER
12548 (struct cmd_vf_vlan_stripq_result,
12550 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12551 TOKEN_STRING_INITIALIZER
12552 (struct cmd_vf_vlan_stripq_result,
12554 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12555 TOKEN_STRING_INITIALIZER
12556 (struct cmd_vf_vlan_stripq_result,
12558 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12559 TOKEN_NUM_INITIALIZER
12560 (struct cmd_vf_vlan_stripq_result,
12562 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12563 TOKEN_NUM_INITIALIZER
12564 (struct cmd_vf_vlan_stripq_result,
12566 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12567 TOKEN_STRING_INITIALIZER
12568 (struct cmd_vf_vlan_stripq_result,
12572 cmd_set_vf_vlan_stripq_parsed(
12573 void *parsed_result,
12574 __rte_unused struct cmdline *cl,
12575 __rte_unused void *data)
12577 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12578 int ret = -ENOTSUP;
12580 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12582 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12585 #ifdef RTE_NET_IXGBE
12586 if (ret == -ENOTSUP)
12587 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12588 res->vf_id, is_on);
12590 #ifdef RTE_NET_I40E
12591 if (ret == -ENOTSUP)
12592 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12593 res->vf_id, is_on);
12595 #ifdef RTE_NET_BNXT
12596 if (ret == -ENOTSUP)
12597 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12598 res->vf_id, is_on);
12605 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12608 printf("invalid port_id %d\n", res->port_id);
12611 printf("function not implemented\n");
12614 printf("programming error: (%s)\n", strerror(-ret));
12618 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12619 .f = cmd_set_vf_vlan_stripq_parsed,
12621 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12623 (void *)&cmd_vf_vlan_stripq_set,
12624 (void *)&cmd_vf_vlan_stripq_vf,
12625 (void *)&cmd_vf_vlan_stripq_vlan,
12626 (void *)&cmd_vf_vlan_stripq_stripq,
12627 (void *)&cmd_vf_vlan_stripq_port_id,
12628 (void *)&cmd_vf_vlan_stripq_vf_id,
12629 (void *)&cmd_vf_vlan_stripq_on_off,
12634 /* vf vlan insert configuration */
12636 /* Common result structure for vf vlan insert */
12637 struct cmd_vf_vlan_insert_result {
12638 cmdline_fixed_string_t set;
12639 cmdline_fixed_string_t vf;
12640 cmdline_fixed_string_t vlan;
12641 cmdline_fixed_string_t insert;
12647 /* Common CLI fields for vf vlan insert enable disable */
12648 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12649 TOKEN_STRING_INITIALIZER
12650 (struct cmd_vf_vlan_insert_result,
12652 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12653 TOKEN_STRING_INITIALIZER
12654 (struct cmd_vf_vlan_insert_result,
12656 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12657 TOKEN_STRING_INITIALIZER
12658 (struct cmd_vf_vlan_insert_result,
12660 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12661 TOKEN_STRING_INITIALIZER
12662 (struct cmd_vf_vlan_insert_result,
12664 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12665 TOKEN_NUM_INITIALIZER
12666 (struct cmd_vf_vlan_insert_result,
12668 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12669 TOKEN_NUM_INITIALIZER
12670 (struct cmd_vf_vlan_insert_result,
12672 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12673 TOKEN_NUM_INITIALIZER
12674 (struct cmd_vf_vlan_insert_result,
12678 cmd_set_vf_vlan_insert_parsed(
12679 void *parsed_result,
12680 __rte_unused struct cmdline *cl,
12681 __rte_unused void *data)
12683 struct cmd_vf_vlan_insert_result *res = parsed_result;
12684 int ret = -ENOTSUP;
12686 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12689 #ifdef RTE_NET_IXGBE
12690 if (ret == -ENOTSUP)
12691 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12694 #ifdef RTE_NET_I40E
12695 if (ret == -ENOTSUP)
12696 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12699 #ifdef RTE_NET_BNXT
12700 if (ret == -ENOTSUP)
12701 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12709 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12712 printf("invalid port_id %d\n", res->port_id);
12715 printf("function not implemented\n");
12718 printf("programming error: (%s)\n", strerror(-ret));
12722 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12723 .f = cmd_set_vf_vlan_insert_parsed,
12725 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12727 (void *)&cmd_vf_vlan_insert_set,
12728 (void *)&cmd_vf_vlan_insert_vf,
12729 (void *)&cmd_vf_vlan_insert_vlan,
12730 (void *)&cmd_vf_vlan_insert_insert,
12731 (void *)&cmd_vf_vlan_insert_port_id,
12732 (void *)&cmd_vf_vlan_insert_vf_id,
12733 (void *)&cmd_vf_vlan_insert_vlan_id,
12738 /* tx loopback configuration */
12740 /* Common result structure for tx loopback */
12741 struct cmd_tx_loopback_result {
12742 cmdline_fixed_string_t set;
12743 cmdline_fixed_string_t tx;
12744 cmdline_fixed_string_t loopback;
12746 cmdline_fixed_string_t on_off;
12749 /* Common CLI fields for tx loopback enable disable */
12750 cmdline_parse_token_string_t cmd_tx_loopback_set =
12751 TOKEN_STRING_INITIALIZER
12752 (struct cmd_tx_loopback_result,
12754 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12755 TOKEN_STRING_INITIALIZER
12756 (struct cmd_tx_loopback_result,
12758 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12759 TOKEN_STRING_INITIALIZER
12760 (struct cmd_tx_loopback_result,
12761 loopback, "loopback");
12762 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12763 TOKEN_NUM_INITIALIZER
12764 (struct cmd_tx_loopback_result,
12766 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12767 TOKEN_STRING_INITIALIZER
12768 (struct cmd_tx_loopback_result,
12772 cmd_set_tx_loopback_parsed(
12773 void *parsed_result,
12774 __rte_unused struct cmdline *cl,
12775 __rte_unused void *data)
12777 struct cmd_tx_loopback_result *res = parsed_result;
12778 int ret = -ENOTSUP;
12780 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12782 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12785 #ifdef RTE_NET_IXGBE
12786 if (ret == -ENOTSUP)
12787 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12789 #ifdef RTE_NET_I40E
12790 if (ret == -ENOTSUP)
12791 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12793 #ifdef RTE_NET_BNXT
12794 if (ret == -ENOTSUP)
12795 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12797 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
12798 if (ret == -ENOTSUP)
12799 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
12806 printf("invalid is_on %d\n", is_on);
12809 printf("invalid port_id %d\n", res->port_id);
12812 printf("function not implemented\n");
12815 printf("programming error: (%s)\n", strerror(-ret));
12819 cmdline_parse_inst_t cmd_set_tx_loopback = {
12820 .f = cmd_set_tx_loopback_parsed,
12822 .help_str = "set tx loopback <port_id> on|off",
12824 (void *)&cmd_tx_loopback_set,
12825 (void *)&cmd_tx_loopback_tx,
12826 (void *)&cmd_tx_loopback_loopback,
12827 (void *)&cmd_tx_loopback_port_id,
12828 (void *)&cmd_tx_loopback_on_off,
12833 /* all queues drop enable configuration */
12835 /* Common result structure for all queues drop enable */
12836 struct cmd_all_queues_drop_en_result {
12837 cmdline_fixed_string_t set;
12838 cmdline_fixed_string_t all;
12839 cmdline_fixed_string_t queues;
12840 cmdline_fixed_string_t drop;
12842 cmdline_fixed_string_t on_off;
12845 /* Common CLI fields for tx loopback enable disable */
12846 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12847 TOKEN_STRING_INITIALIZER
12848 (struct cmd_all_queues_drop_en_result,
12850 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12851 TOKEN_STRING_INITIALIZER
12852 (struct cmd_all_queues_drop_en_result,
12854 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12855 TOKEN_STRING_INITIALIZER
12856 (struct cmd_all_queues_drop_en_result,
12858 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12859 TOKEN_STRING_INITIALIZER
12860 (struct cmd_all_queues_drop_en_result,
12862 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12863 TOKEN_NUM_INITIALIZER
12864 (struct cmd_all_queues_drop_en_result,
12866 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12867 TOKEN_STRING_INITIALIZER
12868 (struct cmd_all_queues_drop_en_result,
12872 cmd_set_all_queues_drop_en_parsed(
12873 void *parsed_result,
12874 __rte_unused struct cmdline *cl,
12875 __rte_unused void *data)
12877 struct cmd_all_queues_drop_en_result *res = parsed_result;
12878 int ret = -ENOTSUP;
12879 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12881 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12884 #ifdef RTE_NET_IXGBE
12885 if (ret == -ENOTSUP)
12886 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12888 #ifdef RTE_NET_BNXT
12889 if (ret == -ENOTSUP)
12890 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12896 printf("invalid is_on %d\n", is_on);
12899 printf("invalid port_id %d\n", res->port_id);
12902 printf("function not implemented\n");
12905 printf("programming error: (%s)\n", strerror(-ret));
12909 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12910 .f = cmd_set_all_queues_drop_en_parsed,
12912 .help_str = "set all queues drop <port_id> on|off",
12914 (void *)&cmd_all_queues_drop_en_set,
12915 (void *)&cmd_all_queues_drop_en_all,
12916 (void *)&cmd_all_queues_drop_en_queues,
12917 (void *)&cmd_all_queues_drop_en_drop,
12918 (void *)&cmd_all_queues_drop_en_port_id,
12919 (void *)&cmd_all_queues_drop_en_on_off,
12924 /* vf split drop enable configuration */
12926 /* Common result structure for vf split drop enable */
12927 struct cmd_vf_split_drop_en_result {
12928 cmdline_fixed_string_t set;
12929 cmdline_fixed_string_t vf;
12930 cmdline_fixed_string_t split;
12931 cmdline_fixed_string_t drop;
12934 cmdline_fixed_string_t on_off;
12937 /* Common CLI fields for vf split drop enable disable */
12938 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12939 TOKEN_STRING_INITIALIZER
12940 (struct cmd_vf_split_drop_en_result,
12942 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12943 TOKEN_STRING_INITIALIZER
12944 (struct cmd_vf_split_drop_en_result,
12946 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12947 TOKEN_STRING_INITIALIZER
12948 (struct cmd_vf_split_drop_en_result,
12950 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12951 TOKEN_STRING_INITIALIZER
12952 (struct cmd_vf_split_drop_en_result,
12954 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12955 TOKEN_NUM_INITIALIZER
12956 (struct cmd_vf_split_drop_en_result,
12958 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12959 TOKEN_NUM_INITIALIZER
12960 (struct cmd_vf_split_drop_en_result,
12962 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12963 TOKEN_STRING_INITIALIZER
12964 (struct cmd_vf_split_drop_en_result,
12968 cmd_set_vf_split_drop_en_parsed(
12969 void *parsed_result,
12970 __rte_unused struct cmdline *cl,
12971 __rte_unused void *data)
12973 struct cmd_vf_split_drop_en_result *res = parsed_result;
12974 int ret = -ENOTSUP;
12975 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12977 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12980 #ifdef RTE_NET_IXGBE
12981 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
12988 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12991 printf("invalid port_id %d\n", res->port_id);
12994 printf("not supported on port %d\n", res->port_id);
12997 printf("programming error: (%s)\n", strerror(-ret));
13001 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13002 .f = cmd_set_vf_split_drop_en_parsed,
13004 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13006 (void *)&cmd_vf_split_drop_en_set,
13007 (void *)&cmd_vf_split_drop_en_vf,
13008 (void *)&cmd_vf_split_drop_en_split,
13009 (void *)&cmd_vf_split_drop_en_drop,
13010 (void *)&cmd_vf_split_drop_en_port_id,
13011 (void *)&cmd_vf_split_drop_en_vf_id,
13012 (void *)&cmd_vf_split_drop_en_on_off,
13017 /* vf mac address configuration */
13019 /* Common result structure for vf mac address */
13020 struct cmd_set_vf_mac_addr_result {
13021 cmdline_fixed_string_t set;
13022 cmdline_fixed_string_t vf;
13023 cmdline_fixed_string_t mac;
13024 cmdline_fixed_string_t addr;
13027 struct rte_ether_addr mac_addr;
13031 /* Common CLI fields for vf split drop enable disable */
13032 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13033 TOKEN_STRING_INITIALIZER
13034 (struct cmd_set_vf_mac_addr_result,
13036 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13037 TOKEN_STRING_INITIALIZER
13038 (struct cmd_set_vf_mac_addr_result,
13040 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13041 TOKEN_STRING_INITIALIZER
13042 (struct cmd_set_vf_mac_addr_result,
13044 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13045 TOKEN_STRING_INITIALIZER
13046 (struct cmd_set_vf_mac_addr_result,
13048 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13049 TOKEN_NUM_INITIALIZER
13050 (struct cmd_set_vf_mac_addr_result,
13052 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13053 TOKEN_NUM_INITIALIZER
13054 (struct cmd_set_vf_mac_addr_result,
13056 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13057 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13061 cmd_set_vf_mac_addr_parsed(
13062 void *parsed_result,
13063 __rte_unused struct cmdline *cl,
13064 __rte_unused void *data)
13066 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13067 int ret = -ENOTSUP;
13069 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13072 #ifdef RTE_NET_IXGBE
13073 if (ret == -ENOTSUP)
13074 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13077 #ifdef RTE_NET_I40E
13078 if (ret == -ENOTSUP)
13079 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13082 #ifdef RTE_NET_BNXT
13083 if (ret == -ENOTSUP)
13084 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13092 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13095 printf("invalid port_id %d\n", res->port_id);
13098 printf("function not implemented\n");
13101 printf("programming error: (%s)\n", strerror(-ret));
13105 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13106 .f = cmd_set_vf_mac_addr_parsed,
13108 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13110 (void *)&cmd_set_vf_mac_addr_set,
13111 (void *)&cmd_set_vf_mac_addr_vf,
13112 (void *)&cmd_set_vf_mac_addr_mac,
13113 (void *)&cmd_set_vf_mac_addr_addr,
13114 (void *)&cmd_set_vf_mac_addr_port_id,
13115 (void *)&cmd_set_vf_mac_addr_vf_id,
13116 (void *)&cmd_set_vf_mac_addr_mac_addr,
13121 /* MACsec configuration */
13123 /* Common result structure for MACsec offload enable */
13124 struct cmd_macsec_offload_on_result {
13125 cmdline_fixed_string_t set;
13126 cmdline_fixed_string_t macsec;
13127 cmdline_fixed_string_t offload;
13129 cmdline_fixed_string_t on;
13130 cmdline_fixed_string_t encrypt;
13131 cmdline_fixed_string_t en_on_off;
13132 cmdline_fixed_string_t replay_protect;
13133 cmdline_fixed_string_t rp_on_off;
13136 /* Common CLI fields for MACsec offload disable */
13137 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13138 TOKEN_STRING_INITIALIZER
13139 (struct cmd_macsec_offload_on_result,
13141 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13142 TOKEN_STRING_INITIALIZER
13143 (struct cmd_macsec_offload_on_result,
13145 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13146 TOKEN_STRING_INITIALIZER
13147 (struct cmd_macsec_offload_on_result,
13148 offload, "offload");
13149 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13150 TOKEN_NUM_INITIALIZER
13151 (struct cmd_macsec_offload_on_result,
13153 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13154 TOKEN_STRING_INITIALIZER
13155 (struct cmd_macsec_offload_on_result,
13157 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13158 TOKEN_STRING_INITIALIZER
13159 (struct cmd_macsec_offload_on_result,
13160 encrypt, "encrypt");
13161 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13162 TOKEN_STRING_INITIALIZER
13163 (struct cmd_macsec_offload_on_result,
13164 en_on_off, "on#off");
13165 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13166 TOKEN_STRING_INITIALIZER
13167 (struct cmd_macsec_offload_on_result,
13168 replay_protect, "replay-protect");
13169 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13170 TOKEN_STRING_INITIALIZER
13171 (struct cmd_macsec_offload_on_result,
13172 rp_on_off, "on#off");
13175 cmd_set_macsec_offload_on_parsed(
13176 void *parsed_result,
13177 __rte_unused struct cmdline *cl,
13178 __rte_unused void *data)
13180 struct cmd_macsec_offload_on_result *res = parsed_result;
13181 int ret = -ENOTSUP;
13182 portid_t port_id = res->port_id;
13183 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13184 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13185 struct rte_eth_dev_info dev_info;
13187 if (port_id_is_invalid(port_id, ENABLED_WARN))
13189 if (!port_is_stopped(port_id)) {
13190 printf("Please stop port %d first\n", port_id);
13194 ret = eth_dev_info_get_print_err(port_id, &dev_info);
13198 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13199 #ifdef RTE_NET_IXGBE
13200 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13208 ports[port_id].dev_conf.txmode.offloads |=
13209 DEV_TX_OFFLOAD_MACSEC_INSERT;
13210 cmd_reconfig_device_queue(port_id, 1, 1);
13213 printf("invalid port_id %d\n", port_id);
13216 printf("not supported on port %d\n", port_id);
13219 printf("programming error: (%s)\n", strerror(-ret));
13223 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13224 .f = cmd_set_macsec_offload_on_parsed,
13226 .help_str = "set macsec offload <port_id> on "
13227 "encrypt on|off replay-protect on|off",
13229 (void *)&cmd_macsec_offload_on_set,
13230 (void *)&cmd_macsec_offload_on_macsec,
13231 (void *)&cmd_macsec_offload_on_offload,
13232 (void *)&cmd_macsec_offload_on_port_id,
13233 (void *)&cmd_macsec_offload_on_on,
13234 (void *)&cmd_macsec_offload_on_encrypt,
13235 (void *)&cmd_macsec_offload_on_en_on_off,
13236 (void *)&cmd_macsec_offload_on_replay_protect,
13237 (void *)&cmd_macsec_offload_on_rp_on_off,
13242 /* Common result structure for MACsec offload disable */
13243 struct cmd_macsec_offload_off_result {
13244 cmdline_fixed_string_t set;
13245 cmdline_fixed_string_t macsec;
13246 cmdline_fixed_string_t offload;
13248 cmdline_fixed_string_t off;
13251 /* Common CLI fields for MACsec offload disable */
13252 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13253 TOKEN_STRING_INITIALIZER
13254 (struct cmd_macsec_offload_off_result,
13256 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13257 TOKEN_STRING_INITIALIZER
13258 (struct cmd_macsec_offload_off_result,
13260 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13261 TOKEN_STRING_INITIALIZER
13262 (struct cmd_macsec_offload_off_result,
13263 offload, "offload");
13264 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13265 TOKEN_NUM_INITIALIZER
13266 (struct cmd_macsec_offload_off_result,
13268 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13269 TOKEN_STRING_INITIALIZER
13270 (struct cmd_macsec_offload_off_result,
13274 cmd_set_macsec_offload_off_parsed(
13275 void *parsed_result,
13276 __rte_unused struct cmdline *cl,
13277 __rte_unused void *data)
13279 struct cmd_macsec_offload_off_result *res = parsed_result;
13280 int ret = -ENOTSUP;
13281 struct rte_eth_dev_info dev_info;
13282 portid_t port_id = res->port_id;
13284 if (port_id_is_invalid(port_id, ENABLED_WARN))
13286 if (!port_is_stopped(port_id)) {
13287 printf("Please stop port %d first\n", port_id);
13291 ret = eth_dev_info_get_print_err(port_id, &dev_info);
13295 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13296 #ifdef RTE_NET_IXGBE
13297 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13302 ports[port_id].dev_conf.txmode.offloads &=
13303 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13304 cmd_reconfig_device_queue(port_id, 1, 1);
13307 printf("invalid port_id %d\n", port_id);
13310 printf("not supported on port %d\n", port_id);
13313 printf("programming error: (%s)\n", strerror(-ret));
13317 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13318 .f = cmd_set_macsec_offload_off_parsed,
13320 .help_str = "set macsec offload <port_id> off",
13322 (void *)&cmd_macsec_offload_off_set,
13323 (void *)&cmd_macsec_offload_off_macsec,
13324 (void *)&cmd_macsec_offload_off_offload,
13325 (void *)&cmd_macsec_offload_off_port_id,
13326 (void *)&cmd_macsec_offload_off_off,
13331 /* Common result structure for MACsec secure connection configure */
13332 struct cmd_macsec_sc_result {
13333 cmdline_fixed_string_t set;
13334 cmdline_fixed_string_t macsec;
13335 cmdline_fixed_string_t sc;
13336 cmdline_fixed_string_t tx_rx;
13338 struct rte_ether_addr mac;
13342 /* Common CLI fields for MACsec secure connection configure */
13343 cmdline_parse_token_string_t cmd_macsec_sc_set =
13344 TOKEN_STRING_INITIALIZER
13345 (struct cmd_macsec_sc_result,
13347 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13348 TOKEN_STRING_INITIALIZER
13349 (struct cmd_macsec_sc_result,
13351 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13352 TOKEN_STRING_INITIALIZER
13353 (struct cmd_macsec_sc_result,
13355 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13356 TOKEN_STRING_INITIALIZER
13357 (struct cmd_macsec_sc_result,
13359 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13360 TOKEN_NUM_INITIALIZER
13361 (struct cmd_macsec_sc_result,
13363 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13364 TOKEN_ETHERADDR_INITIALIZER
13365 (struct cmd_macsec_sc_result,
13367 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13368 TOKEN_NUM_INITIALIZER
13369 (struct cmd_macsec_sc_result,
13373 cmd_set_macsec_sc_parsed(
13374 void *parsed_result,
13375 __rte_unused struct cmdline *cl,
13376 __rte_unused void *data)
13378 struct cmd_macsec_sc_result *res = parsed_result;
13379 int ret = -ENOTSUP;
13380 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13382 #ifdef RTE_NET_IXGBE
13384 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13385 res->mac.addr_bytes) :
13386 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13387 res->mac.addr_bytes, res->pi);
13389 RTE_SET_USED(is_tx);
13395 printf("invalid port_id %d\n", res->port_id);
13398 printf("not supported on port %d\n", res->port_id);
13401 printf("programming error: (%s)\n", strerror(-ret));
13405 cmdline_parse_inst_t cmd_set_macsec_sc = {
13406 .f = cmd_set_macsec_sc_parsed,
13408 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13410 (void *)&cmd_macsec_sc_set,
13411 (void *)&cmd_macsec_sc_macsec,
13412 (void *)&cmd_macsec_sc_sc,
13413 (void *)&cmd_macsec_sc_tx_rx,
13414 (void *)&cmd_macsec_sc_port_id,
13415 (void *)&cmd_macsec_sc_mac,
13416 (void *)&cmd_macsec_sc_pi,
13421 /* Common result structure for MACsec secure connection configure */
13422 struct cmd_macsec_sa_result {
13423 cmdline_fixed_string_t set;
13424 cmdline_fixed_string_t macsec;
13425 cmdline_fixed_string_t sa;
13426 cmdline_fixed_string_t tx_rx;
13431 cmdline_fixed_string_t key;
13434 /* Common CLI fields for MACsec secure connection configure */
13435 cmdline_parse_token_string_t cmd_macsec_sa_set =
13436 TOKEN_STRING_INITIALIZER
13437 (struct cmd_macsec_sa_result,
13439 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13440 TOKEN_STRING_INITIALIZER
13441 (struct cmd_macsec_sa_result,
13443 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13444 TOKEN_STRING_INITIALIZER
13445 (struct cmd_macsec_sa_result,
13447 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13448 TOKEN_STRING_INITIALIZER
13449 (struct cmd_macsec_sa_result,
13451 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13452 TOKEN_NUM_INITIALIZER
13453 (struct cmd_macsec_sa_result,
13455 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13456 TOKEN_NUM_INITIALIZER
13457 (struct cmd_macsec_sa_result,
13459 cmdline_parse_token_num_t cmd_macsec_sa_an =
13460 TOKEN_NUM_INITIALIZER
13461 (struct cmd_macsec_sa_result,
13463 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13464 TOKEN_NUM_INITIALIZER
13465 (struct cmd_macsec_sa_result,
13467 cmdline_parse_token_string_t cmd_macsec_sa_key =
13468 TOKEN_STRING_INITIALIZER
13469 (struct cmd_macsec_sa_result,
13473 cmd_set_macsec_sa_parsed(
13474 void *parsed_result,
13475 __rte_unused struct cmdline *cl,
13476 __rte_unused void *data)
13478 struct cmd_macsec_sa_result *res = parsed_result;
13479 int ret = -ENOTSUP;
13480 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13481 uint8_t key[16] = { 0 };
13487 key_len = strlen(res->key) / 2;
13491 for (i = 0; i < key_len; i++) {
13492 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13495 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13498 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13501 #ifdef RTE_NET_IXGBE
13503 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13504 res->idx, res->an, res->pn, key) :
13505 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13506 res->idx, res->an, res->pn, key);
13508 RTE_SET_USED(is_tx);
13515 printf("invalid idx %d or an %d\n", res->idx, res->an);
13518 printf("invalid port_id %d\n", res->port_id);
13521 printf("not supported on port %d\n", res->port_id);
13524 printf("programming error: (%s)\n", strerror(-ret));
13528 cmdline_parse_inst_t cmd_set_macsec_sa = {
13529 .f = cmd_set_macsec_sa_parsed,
13531 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13533 (void *)&cmd_macsec_sa_set,
13534 (void *)&cmd_macsec_sa_macsec,
13535 (void *)&cmd_macsec_sa_sa,
13536 (void *)&cmd_macsec_sa_tx_rx,
13537 (void *)&cmd_macsec_sa_port_id,
13538 (void *)&cmd_macsec_sa_idx,
13539 (void *)&cmd_macsec_sa_an,
13540 (void *)&cmd_macsec_sa_pn,
13541 (void *)&cmd_macsec_sa_key,
13546 /* VF unicast promiscuous mode configuration */
13548 /* Common result structure for VF unicast promiscuous mode */
13549 struct cmd_vf_promisc_result {
13550 cmdline_fixed_string_t set;
13551 cmdline_fixed_string_t vf;
13552 cmdline_fixed_string_t promisc;
13555 cmdline_fixed_string_t on_off;
13558 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13559 cmdline_parse_token_string_t cmd_vf_promisc_set =
13560 TOKEN_STRING_INITIALIZER
13561 (struct cmd_vf_promisc_result,
13563 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13564 TOKEN_STRING_INITIALIZER
13565 (struct cmd_vf_promisc_result,
13567 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13568 TOKEN_STRING_INITIALIZER
13569 (struct cmd_vf_promisc_result,
13570 promisc, "promisc");
13571 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13572 TOKEN_NUM_INITIALIZER
13573 (struct cmd_vf_promisc_result,
13575 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13576 TOKEN_NUM_INITIALIZER
13577 (struct cmd_vf_promisc_result,
13579 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13580 TOKEN_STRING_INITIALIZER
13581 (struct cmd_vf_promisc_result,
13585 cmd_set_vf_promisc_parsed(
13586 void *parsed_result,
13587 __rte_unused struct cmdline *cl,
13588 __rte_unused void *data)
13590 struct cmd_vf_promisc_result *res = parsed_result;
13591 int ret = -ENOTSUP;
13593 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13595 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13598 #ifdef RTE_NET_I40E
13599 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13600 res->vf_id, is_on);
13607 printf("invalid vf_id %d\n", res->vf_id);
13610 printf("invalid port_id %d\n", res->port_id);
13613 printf("function not implemented\n");
13616 printf("programming error: (%s)\n", strerror(-ret));
13620 cmdline_parse_inst_t cmd_set_vf_promisc = {
13621 .f = cmd_set_vf_promisc_parsed,
13623 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13624 "Set unicast promiscuous mode for a VF from the PF",
13626 (void *)&cmd_vf_promisc_set,
13627 (void *)&cmd_vf_promisc_vf,
13628 (void *)&cmd_vf_promisc_promisc,
13629 (void *)&cmd_vf_promisc_port_id,
13630 (void *)&cmd_vf_promisc_vf_id,
13631 (void *)&cmd_vf_promisc_on_off,
13636 /* VF multicast promiscuous mode configuration */
13638 /* Common result structure for VF multicast promiscuous mode */
13639 struct cmd_vf_allmulti_result {
13640 cmdline_fixed_string_t set;
13641 cmdline_fixed_string_t vf;
13642 cmdline_fixed_string_t allmulti;
13645 cmdline_fixed_string_t on_off;
13648 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13649 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13650 TOKEN_STRING_INITIALIZER
13651 (struct cmd_vf_allmulti_result,
13653 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13654 TOKEN_STRING_INITIALIZER
13655 (struct cmd_vf_allmulti_result,
13657 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13658 TOKEN_STRING_INITIALIZER
13659 (struct cmd_vf_allmulti_result,
13660 allmulti, "allmulti");
13661 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13662 TOKEN_NUM_INITIALIZER
13663 (struct cmd_vf_allmulti_result,
13665 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13666 TOKEN_NUM_INITIALIZER
13667 (struct cmd_vf_allmulti_result,
13669 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13670 TOKEN_STRING_INITIALIZER
13671 (struct cmd_vf_allmulti_result,
13675 cmd_set_vf_allmulti_parsed(
13676 void *parsed_result,
13677 __rte_unused struct cmdline *cl,
13678 __rte_unused void *data)
13680 struct cmd_vf_allmulti_result *res = parsed_result;
13681 int ret = -ENOTSUP;
13683 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13685 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13688 #ifdef RTE_NET_I40E
13689 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13690 res->vf_id, is_on);
13697 printf("invalid vf_id %d\n", res->vf_id);
13700 printf("invalid port_id %d\n", res->port_id);
13703 printf("function not implemented\n");
13706 printf("programming error: (%s)\n", strerror(-ret));
13710 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13711 .f = cmd_set_vf_allmulti_parsed,
13713 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13714 "Set multicast promiscuous mode for a VF from the PF",
13716 (void *)&cmd_vf_allmulti_set,
13717 (void *)&cmd_vf_allmulti_vf,
13718 (void *)&cmd_vf_allmulti_allmulti,
13719 (void *)&cmd_vf_allmulti_port_id,
13720 (void *)&cmd_vf_allmulti_vf_id,
13721 (void *)&cmd_vf_allmulti_on_off,
13726 /* vf broadcast mode configuration */
13728 /* Common result structure for vf broadcast */
13729 struct cmd_set_vf_broadcast_result {
13730 cmdline_fixed_string_t set;
13731 cmdline_fixed_string_t vf;
13732 cmdline_fixed_string_t broadcast;
13735 cmdline_fixed_string_t on_off;
13738 /* Common CLI fields for vf broadcast enable disable */
13739 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13740 TOKEN_STRING_INITIALIZER
13741 (struct cmd_set_vf_broadcast_result,
13743 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13744 TOKEN_STRING_INITIALIZER
13745 (struct cmd_set_vf_broadcast_result,
13747 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13748 TOKEN_STRING_INITIALIZER
13749 (struct cmd_set_vf_broadcast_result,
13750 broadcast, "broadcast");
13751 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13752 TOKEN_NUM_INITIALIZER
13753 (struct cmd_set_vf_broadcast_result,
13755 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13756 TOKEN_NUM_INITIALIZER
13757 (struct cmd_set_vf_broadcast_result,
13759 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13760 TOKEN_STRING_INITIALIZER
13761 (struct cmd_set_vf_broadcast_result,
13765 cmd_set_vf_broadcast_parsed(
13766 void *parsed_result,
13767 __rte_unused struct cmdline *cl,
13768 __rte_unused void *data)
13770 struct cmd_set_vf_broadcast_result *res = parsed_result;
13771 int ret = -ENOTSUP;
13773 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13775 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13778 #ifdef RTE_NET_I40E
13779 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13780 res->vf_id, is_on);
13787 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13790 printf("invalid port_id %d\n", res->port_id);
13793 printf("function not implemented\n");
13796 printf("programming error: (%s)\n", strerror(-ret));
13800 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13801 .f = cmd_set_vf_broadcast_parsed,
13803 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13805 (void *)&cmd_set_vf_broadcast_set,
13806 (void *)&cmd_set_vf_broadcast_vf,
13807 (void *)&cmd_set_vf_broadcast_broadcast,
13808 (void *)&cmd_set_vf_broadcast_port_id,
13809 (void *)&cmd_set_vf_broadcast_vf_id,
13810 (void *)&cmd_set_vf_broadcast_on_off,
13815 /* vf vlan tag configuration */
13817 /* Common result structure for vf vlan tag */
13818 struct cmd_set_vf_vlan_tag_result {
13819 cmdline_fixed_string_t set;
13820 cmdline_fixed_string_t vf;
13821 cmdline_fixed_string_t vlan;
13822 cmdline_fixed_string_t tag;
13825 cmdline_fixed_string_t on_off;
13828 /* Common CLI fields for vf vlan tag enable disable */
13829 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13830 TOKEN_STRING_INITIALIZER
13831 (struct cmd_set_vf_vlan_tag_result,
13833 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13834 TOKEN_STRING_INITIALIZER
13835 (struct cmd_set_vf_vlan_tag_result,
13837 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13838 TOKEN_STRING_INITIALIZER
13839 (struct cmd_set_vf_vlan_tag_result,
13841 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13842 TOKEN_STRING_INITIALIZER
13843 (struct cmd_set_vf_vlan_tag_result,
13845 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13846 TOKEN_NUM_INITIALIZER
13847 (struct cmd_set_vf_vlan_tag_result,
13849 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13850 TOKEN_NUM_INITIALIZER
13851 (struct cmd_set_vf_vlan_tag_result,
13853 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13854 TOKEN_STRING_INITIALIZER
13855 (struct cmd_set_vf_vlan_tag_result,
13859 cmd_set_vf_vlan_tag_parsed(
13860 void *parsed_result,
13861 __rte_unused struct cmdline *cl,
13862 __rte_unused void *data)
13864 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13865 int ret = -ENOTSUP;
13867 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13869 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13872 #ifdef RTE_NET_I40E
13873 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13874 res->vf_id, is_on);
13881 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13884 printf("invalid port_id %d\n", res->port_id);
13887 printf("function not implemented\n");
13890 printf("programming error: (%s)\n", strerror(-ret));
13894 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13895 .f = cmd_set_vf_vlan_tag_parsed,
13897 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13899 (void *)&cmd_set_vf_vlan_tag_set,
13900 (void *)&cmd_set_vf_vlan_tag_vf,
13901 (void *)&cmd_set_vf_vlan_tag_vlan,
13902 (void *)&cmd_set_vf_vlan_tag_tag,
13903 (void *)&cmd_set_vf_vlan_tag_port_id,
13904 (void *)&cmd_set_vf_vlan_tag_vf_id,
13905 (void *)&cmd_set_vf_vlan_tag_on_off,
13910 /* Common definition of VF and TC TX bandwidth configuration */
13911 struct cmd_vf_tc_bw_result {
13912 cmdline_fixed_string_t set;
13913 cmdline_fixed_string_t vf;
13914 cmdline_fixed_string_t tc;
13915 cmdline_fixed_string_t tx;
13916 cmdline_fixed_string_t min_bw;
13917 cmdline_fixed_string_t max_bw;
13918 cmdline_fixed_string_t strict_link_prio;
13923 cmdline_fixed_string_t bw_list;
13927 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13928 TOKEN_STRING_INITIALIZER
13929 (struct cmd_vf_tc_bw_result,
13931 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13932 TOKEN_STRING_INITIALIZER
13933 (struct cmd_vf_tc_bw_result,
13935 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13936 TOKEN_STRING_INITIALIZER
13937 (struct cmd_vf_tc_bw_result,
13939 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13940 TOKEN_STRING_INITIALIZER
13941 (struct cmd_vf_tc_bw_result,
13943 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13944 TOKEN_STRING_INITIALIZER
13945 (struct cmd_vf_tc_bw_result,
13946 strict_link_prio, "strict-link-priority");
13947 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13948 TOKEN_STRING_INITIALIZER
13949 (struct cmd_vf_tc_bw_result,
13950 min_bw, "min-bandwidth");
13951 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13952 TOKEN_STRING_INITIALIZER
13953 (struct cmd_vf_tc_bw_result,
13954 max_bw, "max-bandwidth");
13955 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13956 TOKEN_NUM_INITIALIZER
13957 (struct cmd_vf_tc_bw_result,
13959 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13960 TOKEN_NUM_INITIALIZER
13961 (struct cmd_vf_tc_bw_result,
13963 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13964 TOKEN_NUM_INITIALIZER
13965 (struct cmd_vf_tc_bw_result,
13967 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13968 TOKEN_NUM_INITIALIZER
13969 (struct cmd_vf_tc_bw_result,
13971 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13972 TOKEN_STRING_INITIALIZER
13973 (struct cmd_vf_tc_bw_result,
13975 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13976 TOKEN_NUM_INITIALIZER
13977 (struct cmd_vf_tc_bw_result,
13980 /* VF max bandwidth setting */
13982 cmd_vf_max_bw_parsed(
13983 void *parsed_result,
13984 __rte_unused struct cmdline *cl,
13985 __rte_unused void *data)
13987 struct cmd_vf_tc_bw_result *res = parsed_result;
13988 int ret = -ENOTSUP;
13990 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13993 #ifdef RTE_NET_I40E
13994 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
13995 res->vf_id, res->bw);
14002 printf("invalid vf_id %d or bandwidth %d\n",
14003 res->vf_id, res->bw);
14006 printf("invalid port_id %d\n", res->port_id);
14009 printf("function not implemented\n");
14012 printf("programming error: (%s)\n", strerror(-ret));
14016 cmdline_parse_inst_t cmd_vf_max_bw = {
14017 .f = cmd_vf_max_bw_parsed,
14019 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14021 (void *)&cmd_vf_tc_bw_set,
14022 (void *)&cmd_vf_tc_bw_vf,
14023 (void *)&cmd_vf_tc_bw_tx,
14024 (void *)&cmd_vf_tc_bw_max_bw,
14025 (void *)&cmd_vf_tc_bw_port_id,
14026 (void *)&cmd_vf_tc_bw_vf_id,
14027 (void *)&cmd_vf_tc_bw_bw,
14033 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14038 const char *p, *p0 = str;
14045 p = strchr(p0, '(');
14047 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14051 p0 = strchr(p, ')');
14053 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14057 if (size >= sizeof(s)) {
14058 printf("The string size exceeds the internal buffer size\n");
14061 snprintf(s, sizeof(s), "%.*s", size, p);
14062 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14064 printf("Failed to get the bandwidth list. ");
14068 for (i = 0; i < ret; i++)
14069 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14074 /* TC min bandwidth setting */
14076 cmd_vf_tc_min_bw_parsed(
14077 void *parsed_result,
14078 __rte_unused struct cmdline *cl,
14079 __rte_unused void *data)
14081 struct cmd_vf_tc_bw_result *res = parsed_result;
14084 int ret = -ENOTSUP;
14086 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14089 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14093 #ifdef RTE_NET_I40E
14094 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14102 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14105 printf("invalid port_id %d\n", res->port_id);
14108 printf("function not implemented\n");
14111 printf("programming error: (%s)\n", strerror(-ret));
14115 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14116 .f = cmd_vf_tc_min_bw_parsed,
14118 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14119 " <bw1, bw2, ...>",
14121 (void *)&cmd_vf_tc_bw_set,
14122 (void *)&cmd_vf_tc_bw_vf,
14123 (void *)&cmd_vf_tc_bw_tc,
14124 (void *)&cmd_vf_tc_bw_tx,
14125 (void *)&cmd_vf_tc_bw_min_bw,
14126 (void *)&cmd_vf_tc_bw_port_id,
14127 (void *)&cmd_vf_tc_bw_vf_id,
14128 (void *)&cmd_vf_tc_bw_bw_list,
14134 cmd_tc_min_bw_parsed(
14135 void *parsed_result,
14136 __rte_unused struct cmdline *cl,
14137 __rte_unused void *data)
14139 struct cmd_vf_tc_bw_result *res = parsed_result;
14140 struct rte_port *port;
14143 int ret = -ENOTSUP;
14145 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14148 port = &ports[res->port_id];
14149 /** Check if the port is not started **/
14150 if (port->port_status != RTE_PORT_STOPPED) {
14151 printf("Please stop port %d first\n", res->port_id);
14155 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14159 #ifdef RTE_NET_IXGBE
14160 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14167 printf("invalid bandwidth\n");
14170 printf("invalid port_id %d\n", res->port_id);
14173 printf("function not implemented\n");
14176 printf("programming error: (%s)\n", strerror(-ret));
14180 cmdline_parse_inst_t cmd_tc_min_bw = {
14181 .f = cmd_tc_min_bw_parsed,
14183 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14185 (void *)&cmd_vf_tc_bw_set,
14186 (void *)&cmd_vf_tc_bw_tc,
14187 (void *)&cmd_vf_tc_bw_tx,
14188 (void *)&cmd_vf_tc_bw_min_bw,
14189 (void *)&cmd_vf_tc_bw_port_id,
14190 (void *)&cmd_vf_tc_bw_bw_list,
14195 /* TC max bandwidth setting */
14197 cmd_vf_tc_max_bw_parsed(
14198 void *parsed_result,
14199 __rte_unused struct cmdline *cl,
14200 __rte_unused void *data)
14202 struct cmd_vf_tc_bw_result *res = parsed_result;
14203 int ret = -ENOTSUP;
14205 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14208 #ifdef RTE_NET_I40E
14209 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14210 res->tc_no, res->bw);
14217 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14218 res->vf_id, res->tc_no, res->bw);
14221 printf("invalid port_id %d\n", res->port_id);
14224 printf("function not implemented\n");
14227 printf("programming error: (%s)\n", strerror(-ret));
14231 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14232 .f = cmd_vf_tc_max_bw_parsed,
14234 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14237 (void *)&cmd_vf_tc_bw_set,
14238 (void *)&cmd_vf_tc_bw_vf,
14239 (void *)&cmd_vf_tc_bw_tc,
14240 (void *)&cmd_vf_tc_bw_tx,
14241 (void *)&cmd_vf_tc_bw_max_bw,
14242 (void *)&cmd_vf_tc_bw_port_id,
14243 (void *)&cmd_vf_tc_bw_vf_id,
14244 (void *)&cmd_vf_tc_bw_tc_no,
14245 (void *)&cmd_vf_tc_bw_bw,
14250 /** Set VXLAN encapsulation details */
14251 struct cmd_set_vxlan_result {
14252 cmdline_fixed_string_t set;
14253 cmdline_fixed_string_t vxlan;
14254 cmdline_fixed_string_t pos_token;
14255 cmdline_fixed_string_t ip_version;
14256 uint32_t vlan_present:1;
14260 cmdline_ipaddr_t ip_src;
14261 cmdline_ipaddr_t ip_dst;
14265 struct rte_ether_addr eth_src;
14266 struct rte_ether_addr eth_dst;
14269 cmdline_parse_token_string_t cmd_set_vxlan_set =
14270 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
14271 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
14272 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
14273 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
14274 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
14276 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
14277 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
14278 "vxlan-with-vlan");
14279 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
14280 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14282 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
14283 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
14285 cmdline_parse_token_string_t cmd_set_vxlan_vni =
14286 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14288 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
14289 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
14290 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
14291 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14293 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
14294 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
14295 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
14296 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14298 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
14299 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
14300 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
14301 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14303 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
14304 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
14305 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
14306 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14308 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
14309 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
14310 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
14311 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14313 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
14314 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
14315 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
14316 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14318 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
14319 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
14320 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
14321 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14323 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
14324 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
14325 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
14326 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14328 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
14329 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
14330 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
14331 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14333 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
14334 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
14336 static void cmd_set_vxlan_parsed(void *parsed_result,
14337 __rte_unused struct cmdline *cl,
14338 __rte_unused void *data)
14340 struct cmd_set_vxlan_result *res = parsed_result;
14345 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
14348 vxlan_encap_conf.select_tos_ttl = 0;
14349 if (strcmp(res->vxlan, "vxlan") == 0)
14350 vxlan_encap_conf.select_vlan = 0;
14351 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
14352 vxlan_encap_conf.select_vlan = 1;
14353 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
14354 vxlan_encap_conf.select_vlan = 0;
14355 vxlan_encap_conf.select_tos_ttl = 1;
14357 if (strcmp(res->ip_version, "ipv4") == 0)
14358 vxlan_encap_conf.select_ipv4 = 1;
14359 else if (strcmp(res->ip_version, "ipv6") == 0)
14360 vxlan_encap_conf.select_ipv4 = 0;
14363 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
14364 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
14365 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
14366 vxlan_encap_conf.ip_tos = res->tos;
14367 vxlan_encap_conf.ip_ttl = res->ttl;
14368 if (vxlan_encap_conf.select_ipv4) {
14369 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
14370 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
14372 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
14373 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
14375 if (vxlan_encap_conf.select_vlan)
14376 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
14377 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
14378 RTE_ETHER_ADDR_LEN);
14379 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
14380 RTE_ETHER_ADDR_LEN);
14383 cmdline_parse_inst_t cmd_set_vxlan = {
14384 .f = cmd_set_vxlan_parsed,
14386 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
14387 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
14388 " eth-src <eth-src> eth-dst <eth-dst>",
14390 (void *)&cmd_set_vxlan_set,
14391 (void *)&cmd_set_vxlan_vxlan,
14392 (void *)&cmd_set_vxlan_ip_version,
14393 (void *)&cmd_set_vxlan_ip_version_value,
14394 (void *)&cmd_set_vxlan_vni,
14395 (void *)&cmd_set_vxlan_vni_value,
14396 (void *)&cmd_set_vxlan_udp_src,
14397 (void *)&cmd_set_vxlan_udp_src_value,
14398 (void *)&cmd_set_vxlan_udp_dst,
14399 (void *)&cmd_set_vxlan_udp_dst_value,
14400 (void *)&cmd_set_vxlan_ip_src,
14401 (void *)&cmd_set_vxlan_ip_src_value,
14402 (void *)&cmd_set_vxlan_ip_dst,
14403 (void *)&cmd_set_vxlan_ip_dst_value,
14404 (void *)&cmd_set_vxlan_eth_src,
14405 (void *)&cmd_set_vxlan_eth_src_value,
14406 (void *)&cmd_set_vxlan_eth_dst,
14407 (void *)&cmd_set_vxlan_eth_dst_value,
14412 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
14413 .f = cmd_set_vxlan_parsed,
14415 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
14416 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
14417 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
14418 " eth-dst <eth-dst>",
14420 (void *)&cmd_set_vxlan_set,
14421 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
14422 (void *)&cmd_set_vxlan_ip_version,
14423 (void *)&cmd_set_vxlan_ip_version_value,
14424 (void *)&cmd_set_vxlan_vni,
14425 (void *)&cmd_set_vxlan_vni_value,
14426 (void *)&cmd_set_vxlan_udp_src,
14427 (void *)&cmd_set_vxlan_udp_src_value,
14428 (void *)&cmd_set_vxlan_udp_dst,
14429 (void *)&cmd_set_vxlan_udp_dst_value,
14430 (void *)&cmd_set_vxlan_ip_tos,
14431 (void *)&cmd_set_vxlan_ip_tos_value,
14432 (void *)&cmd_set_vxlan_ip_ttl,
14433 (void *)&cmd_set_vxlan_ip_ttl_value,
14434 (void *)&cmd_set_vxlan_ip_src,
14435 (void *)&cmd_set_vxlan_ip_src_value,
14436 (void *)&cmd_set_vxlan_ip_dst,
14437 (void *)&cmd_set_vxlan_ip_dst_value,
14438 (void *)&cmd_set_vxlan_eth_src,
14439 (void *)&cmd_set_vxlan_eth_src_value,
14440 (void *)&cmd_set_vxlan_eth_dst,
14441 (void *)&cmd_set_vxlan_eth_dst_value,
14446 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
14447 .f = cmd_set_vxlan_parsed,
14449 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
14450 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
14451 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
14454 (void *)&cmd_set_vxlan_set,
14455 (void *)&cmd_set_vxlan_vxlan_with_vlan,
14456 (void *)&cmd_set_vxlan_ip_version,
14457 (void *)&cmd_set_vxlan_ip_version_value,
14458 (void *)&cmd_set_vxlan_vni,
14459 (void *)&cmd_set_vxlan_vni_value,
14460 (void *)&cmd_set_vxlan_udp_src,
14461 (void *)&cmd_set_vxlan_udp_src_value,
14462 (void *)&cmd_set_vxlan_udp_dst,
14463 (void *)&cmd_set_vxlan_udp_dst_value,
14464 (void *)&cmd_set_vxlan_ip_src,
14465 (void *)&cmd_set_vxlan_ip_src_value,
14466 (void *)&cmd_set_vxlan_ip_dst,
14467 (void *)&cmd_set_vxlan_ip_dst_value,
14468 (void *)&cmd_set_vxlan_vlan,
14469 (void *)&cmd_set_vxlan_vlan_value,
14470 (void *)&cmd_set_vxlan_eth_src,
14471 (void *)&cmd_set_vxlan_eth_src_value,
14472 (void *)&cmd_set_vxlan_eth_dst,
14473 (void *)&cmd_set_vxlan_eth_dst_value,
14478 /** Set NVGRE encapsulation details */
14479 struct cmd_set_nvgre_result {
14480 cmdline_fixed_string_t set;
14481 cmdline_fixed_string_t nvgre;
14482 cmdline_fixed_string_t pos_token;
14483 cmdline_fixed_string_t ip_version;
14485 cmdline_ipaddr_t ip_src;
14486 cmdline_ipaddr_t ip_dst;
14488 struct rte_ether_addr eth_src;
14489 struct rte_ether_addr eth_dst;
14492 cmdline_parse_token_string_t cmd_set_nvgre_set =
14493 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
14494 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
14495 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
14496 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
14497 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
14498 "nvgre-with-vlan");
14499 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
14500 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14502 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
14503 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
14505 cmdline_parse_token_string_t cmd_set_nvgre_tni =
14506 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14508 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
14509 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
14510 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
14511 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14513 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
14514 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
14515 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
14516 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14518 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
14519 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
14520 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
14521 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14523 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
14524 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
14525 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
14526 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14528 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
14529 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
14530 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
14531 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14533 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
14534 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
14536 static void cmd_set_nvgre_parsed(void *parsed_result,
14537 __rte_unused struct cmdline *cl,
14538 __rte_unused void *data)
14540 struct cmd_set_nvgre_result *res = parsed_result;
14542 uint32_t nvgre_tni;
14545 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
14548 if (strcmp(res->nvgre, "nvgre") == 0)
14549 nvgre_encap_conf.select_vlan = 0;
14550 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
14551 nvgre_encap_conf.select_vlan = 1;
14552 if (strcmp(res->ip_version, "ipv4") == 0)
14553 nvgre_encap_conf.select_ipv4 = 1;
14554 else if (strcmp(res->ip_version, "ipv6") == 0)
14555 nvgre_encap_conf.select_ipv4 = 0;
14558 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
14559 if (nvgre_encap_conf.select_ipv4) {
14560 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
14561 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
14563 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
14564 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
14566 if (nvgre_encap_conf.select_vlan)
14567 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
14568 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
14569 RTE_ETHER_ADDR_LEN);
14570 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
14571 RTE_ETHER_ADDR_LEN);
14574 cmdline_parse_inst_t cmd_set_nvgre = {
14575 .f = cmd_set_nvgre_parsed,
14577 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
14578 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
14579 " eth-dst <eth-dst>",
14581 (void *)&cmd_set_nvgre_set,
14582 (void *)&cmd_set_nvgre_nvgre,
14583 (void *)&cmd_set_nvgre_ip_version,
14584 (void *)&cmd_set_nvgre_ip_version_value,
14585 (void *)&cmd_set_nvgre_tni,
14586 (void *)&cmd_set_nvgre_tni_value,
14587 (void *)&cmd_set_nvgre_ip_src,
14588 (void *)&cmd_set_nvgre_ip_src_value,
14589 (void *)&cmd_set_nvgre_ip_dst,
14590 (void *)&cmd_set_nvgre_ip_dst_value,
14591 (void *)&cmd_set_nvgre_eth_src,
14592 (void *)&cmd_set_nvgre_eth_src_value,
14593 (void *)&cmd_set_nvgre_eth_dst,
14594 (void *)&cmd_set_nvgre_eth_dst_value,
14599 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
14600 .f = cmd_set_nvgre_parsed,
14602 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
14603 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
14604 " eth-src <eth-src> eth-dst <eth-dst>",
14606 (void *)&cmd_set_nvgre_set,
14607 (void *)&cmd_set_nvgre_nvgre_with_vlan,
14608 (void *)&cmd_set_nvgre_ip_version,
14609 (void *)&cmd_set_nvgre_ip_version_value,
14610 (void *)&cmd_set_nvgre_tni,
14611 (void *)&cmd_set_nvgre_tni_value,
14612 (void *)&cmd_set_nvgre_ip_src,
14613 (void *)&cmd_set_nvgre_ip_src_value,
14614 (void *)&cmd_set_nvgre_ip_dst,
14615 (void *)&cmd_set_nvgre_ip_dst_value,
14616 (void *)&cmd_set_nvgre_vlan,
14617 (void *)&cmd_set_nvgre_vlan_value,
14618 (void *)&cmd_set_nvgre_eth_src,
14619 (void *)&cmd_set_nvgre_eth_src_value,
14620 (void *)&cmd_set_nvgre_eth_dst,
14621 (void *)&cmd_set_nvgre_eth_dst_value,
14626 /** Set L2 encapsulation details */
14627 struct cmd_set_l2_encap_result {
14628 cmdline_fixed_string_t set;
14629 cmdline_fixed_string_t l2_encap;
14630 cmdline_fixed_string_t pos_token;
14631 cmdline_fixed_string_t ip_version;
14632 uint32_t vlan_present:1;
14634 struct rte_ether_addr eth_src;
14635 struct rte_ether_addr eth_dst;
14638 cmdline_parse_token_string_t cmd_set_l2_encap_set =
14639 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
14640 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
14641 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
14642 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
14643 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
14644 "l2_encap-with-vlan");
14645 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
14646 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
14648 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
14649 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
14651 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
14652 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
14654 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
14655 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
14656 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
14657 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
14659 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
14660 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
14661 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
14662 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
14664 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
14665 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
14667 static void cmd_set_l2_encap_parsed(void *parsed_result,
14668 __rte_unused struct cmdline *cl,
14669 __rte_unused void *data)
14671 struct cmd_set_l2_encap_result *res = parsed_result;
14673 if (strcmp(res->l2_encap, "l2_encap") == 0)
14674 l2_encap_conf.select_vlan = 0;
14675 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
14676 l2_encap_conf.select_vlan = 1;
14677 if (strcmp(res->ip_version, "ipv4") == 0)
14678 l2_encap_conf.select_ipv4 = 1;
14679 else if (strcmp(res->ip_version, "ipv6") == 0)
14680 l2_encap_conf.select_ipv4 = 0;
14683 if (l2_encap_conf.select_vlan)
14684 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
14685 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
14686 RTE_ETHER_ADDR_LEN);
14687 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
14688 RTE_ETHER_ADDR_LEN);
14691 cmdline_parse_inst_t cmd_set_l2_encap = {
14692 .f = cmd_set_l2_encap_parsed,
14694 .help_str = "set l2_encap ip-version ipv4|ipv6"
14695 " eth-src <eth-src> eth-dst <eth-dst>",
14697 (void *)&cmd_set_l2_encap_set,
14698 (void *)&cmd_set_l2_encap_l2_encap,
14699 (void *)&cmd_set_l2_encap_ip_version,
14700 (void *)&cmd_set_l2_encap_ip_version_value,
14701 (void *)&cmd_set_l2_encap_eth_src,
14702 (void *)&cmd_set_l2_encap_eth_src_value,
14703 (void *)&cmd_set_l2_encap_eth_dst,
14704 (void *)&cmd_set_l2_encap_eth_dst_value,
14709 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
14710 .f = cmd_set_l2_encap_parsed,
14712 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
14713 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
14715 (void *)&cmd_set_l2_encap_set,
14716 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
14717 (void *)&cmd_set_l2_encap_ip_version,
14718 (void *)&cmd_set_l2_encap_ip_version_value,
14719 (void *)&cmd_set_l2_encap_vlan,
14720 (void *)&cmd_set_l2_encap_vlan_value,
14721 (void *)&cmd_set_l2_encap_eth_src,
14722 (void *)&cmd_set_l2_encap_eth_src_value,
14723 (void *)&cmd_set_l2_encap_eth_dst,
14724 (void *)&cmd_set_l2_encap_eth_dst_value,
14729 /** Set L2 decapsulation details */
14730 struct cmd_set_l2_decap_result {
14731 cmdline_fixed_string_t set;
14732 cmdline_fixed_string_t l2_decap;
14733 cmdline_fixed_string_t pos_token;
14734 uint32_t vlan_present:1;
14737 cmdline_parse_token_string_t cmd_set_l2_decap_set =
14738 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
14739 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
14740 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
14742 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
14743 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
14744 "l2_decap-with-vlan");
14746 static void cmd_set_l2_decap_parsed(void *parsed_result,
14747 __rte_unused struct cmdline *cl,
14748 __rte_unused void *data)
14750 struct cmd_set_l2_decap_result *res = parsed_result;
14752 if (strcmp(res->l2_decap, "l2_decap") == 0)
14753 l2_decap_conf.select_vlan = 0;
14754 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
14755 l2_decap_conf.select_vlan = 1;
14758 cmdline_parse_inst_t cmd_set_l2_decap = {
14759 .f = cmd_set_l2_decap_parsed,
14761 .help_str = "set l2_decap",
14763 (void *)&cmd_set_l2_decap_set,
14764 (void *)&cmd_set_l2_decap_l2_decap,
14769 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
14770 .f = cmd_set_l2_decap_parsed,
14772 .help_str = "set l2_decap-with-vlan",
14774 (void *)&cmd_set_l2_decap_set,
14775 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
14780 /** Set MPLSoGRE encapsulation details */
14781 struct cmd_set_mplsogre_encap_result {
14782 cmdline_fixed_string_t set;
14783 cmdline_fixed_string_t mplsogre;
14784 cmdline_fixed_string_t pos_token;
14785 cmdline_fixed_string_t ip_version;
14786 uint32_t vlan_present:1;
14788 cmdline_ipaddr_t ip_src;
14789 cmdline_ipaddr_t ip_dst;
14791 struct rte_ether_addr eth_src;
14792 struct rte_ether_addr eth_dst;
14795 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
14796 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
14798 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
14799 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
14801 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
14802 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14803 mplsogre, "mplsogre_encap-with-vlan");
14804 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
14805 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14806 pos_token, "ip-version");
14807 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
14808 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14809 ip_version, "ipv4#ipv6");
14810 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
14811 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14812 pos_token, "label");
14813 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
14814 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
14816 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
14817 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14818 pos_token, "ip-src");
14819 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
14820 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
14821 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
14822 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14823 pos_token, "ip-dst");
14824 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
14825 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
14826 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
14827 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14828 pos_token, "vlan-tci");
14829 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
14830 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
14832 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
14833 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14834 pos_token, "eth-src");
14835 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
14836 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14838 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
14839 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14840 pos_token, "eth-dst");
14841 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
14842 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14845 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
14846 __rte_unused struct cmdline *cl,
14847 __rte_unused void *data)
14849 struct cmd_set_mplsogre_encap_result *res = parsed_result;
14851 uint32_t mplsogre_label;
14854 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
14857 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
14858 mplsogre_encap_conf.select_vlan = 0;
14859 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
14860 mplsogre_encap_conf.select_vlan = 1;
14861 if (strcmp(res->ip_version, "ipv4") == 0)
14862 mplsogre_encap_conf.select_ipv4 = 1;
14863 else if (strcmp(res->ip_version, "ipv6") == 0)
14864 mplsogre_encap_conf.select_ipv4 = 0;
14867 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
14868 if (mplsogre_encap_conf.select_ipv4) {
14869 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
14870 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
14872 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
14873 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
14875 if (mplsogre_encap_conf.select_vlan)
14876 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
14877 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
14878 RTE_ETHER_ADDR_LEN);
14879 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
14880 RTE_ETHER_ADDR_LEN);
14883 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
14884 .f = cmd_set_mplsogre_encap_parsed,
14886 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
14887 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
14888 " eth-dst <eth-dst>",
14890 (void *)&cmd_set_mplsogre_encap_set,
14891 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
14892 (void *)&cmd_set_mplsogre_encap_ip_version,
14893 (void *)&cmd_set_mplsogre_encap_ip_version_value,
14894 (void *)&cmd_set_mplsogre_encap_label,
14895 (void *)&cmd_set_mplsogre_encap_label_value,
14896 (void *)&cmd_set_mplsogre_encap_ip_src,
14897 (void *)&cmd_set_mplsogre_encap_ip_src_value,
14898 (void *)&cmd_set_mplsogre_encap_ip_dst,
14899 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
14900 (void *)&cmd_set_mplsogre_encap_eth_src,
14901 (void *)&cmd_set_mplsogre_encap_eth_src_value,
14902 (void *)&cmd_set_mplsogre_encap_eth_dst,
14903 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
14908 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
14909 .f = cmd_set_mplsogre_encap_parsed,
14911 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
14912 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
14913 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
14915 (void *)&cmd_set_mplsogre_encap_set,
14916 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
14917 (void *)&cmd_set_mplsogre_encap_ip_version,
14918 (void *)&cmd_set_mplsogre_encap_ip_version_value,
14919 (void *)&cmd_set_mplsogre_encap_label,
14920 (void *)&cmd_set_mplsogre_encap_label_value,
14921 (void *)&cmd_set_mplsogre_encap_ip_src,
14922 (void *)&cmd_set_mplsogre_encap_ip_src_value,
14923 (void *)&cmd_set_mplsogre_encap_ip_dst,
14924 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
14925 (void *)&cmd_set_mplsogre_encap_vlan,
14926 (void *)&cmd_set_mplsogre_encap_vlan_value,
14927 (void *)&cmd_set_mplsogre_encap_eth_src,
14928 (void *)&cmd_set_mplsogre_encap_eth_src_value,
14929 (void *)&cmd_set_mplsogre_encap_eth_dst,
14930 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
14935 /** Set MPLSoGRE decapsulation details */
14936 struct cmd_set_mplsogre_decap_result {
14937 cmdline_fixed_string_t set;
14938 cmdline_fixed_string_t mplsogre;
14939 cmdline_fixed_string_t pos_token;
14940 cmdline_fixed_string_t ip_version;
14941 uint32_t vlan_present:1;
14944 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
14945 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
14947 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
14948 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
14950 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
14951 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
14952 mplsogre, "mplsogre_decap-with-vlan");
14953 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
14954 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
14955 pos_token, "ip-version");
14956 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
14957 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
14958 ip_version, "ipv4#ipv6");
14960 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
14961 __rte_unused struct cmdline *cl,
14962 __rte_unused void *data)
14964 struct cmd_set_mplsogre_decap_result *res = parsed_result;
14966 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
14967 mplsogre_decap_conf.select_vlan = 0;
14968 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
14969 mplsogre_decap_conf.select_vlan = 1;
14970 if (strcmp(res->ip_version, "ipv4") == 0)
14971 mplsogre_decap_conf.select_ipv4 = 1;
14972 else if (strcmp(res->ip_version, "ipv6") == 0)
14973 mplsogre_decap_conf.select_ipv4 = 0;
14976 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
14977 .f = cmd_set_mplsogre_decap_parsed,
14979 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
14981 (void *)&cmd_set_mplsogre_decap_set,
14982 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
14983 (void *)&cmd_set_mplsogre_decap_ip_version,
14984 (void *)&cmd_set_mplsogre_decap_ip_version_value,
14989 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
14990 .f = cmd_set_mplsogre_decap_parsed,
14992 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
14994 (void *)&cmd_set_mplsogre_decap_set,
14995 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
14996 (void *)&cmd_set_mplsogre_decap_ip_version,
14997 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15002 /** Set MPLSoUDP encapsulation details */
15003 struct cmd_set_mplsoudp_encap_result {
15004 cmdline_fixed_string_t set;
15005 cmdline_fixed_string_t mplsoudp;
15006 cmdline_fixed_string_t pos_token;
15007 cmdline_fixed_string_t ip_version;
15008 uint32_t vlan_present:1;
15012 cmdline_ipaddr_t ip_src;
15013 cmdline_ipaddr_t ip_dst;
15015 struct rte_ether_addr eth_src;
15016 struct rte_ether_addr eth_dst;
15019 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
15020 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
15022 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
15023 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
15025 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
15026 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15027 mplsoudp, "mplsoudp_encap-with-vlan");
15028 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
15029 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15030 pos_token, "ip-version");
15031 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
15032 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15033 ip_version, "ipv4#ipv6");
15034 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
15035 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15036 pos_token, "label");
15037 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
15038 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
15040 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
15041 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15042 pos_token, "udp-src");
15043 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
15044 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
15046 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
15047 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15048 pos_token, "udp-dst");
15049 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
15050 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
15052 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
15053 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15054 pos_token, "ip-src");
15055 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
15056 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
15057 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
15058 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15059 pos_token, "ip-dst");
15060 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
15061 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
15062 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
15063 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15064 pos_token, "vlan-tci");
15065 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
15066 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
15068 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
15069 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15070 pos_token, "eth-src");
15071 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
15072 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15074 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
15075 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15076 pos_token, "eth-dst");
15077 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
15078 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15081 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
15082 __rte_unused struct cmdline *cl,
15083 __rte_unused void *data)
15085 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
15087 uint32_t mplsoudp_label;
15090 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
15093 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
15094 mplsoudp_encap_conf.select_vlan = 0;
15095 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
15096 mplsoudp_encap_conf.select_vlan = 1;
15097 if (strcmp(res->ip_version, "ipv4") == 0)
15098 mplsoudp_encap_conf.select_ipv4 = 1;
15099 else if (strcmp(res->ip_version, "ipv6") == 0)
15100 mplsoudp_encap_conf.select_ipv4 = 0;
15103 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
15104 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15105 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15106 if (mplsoudp_encap_conf.select_ipv4) {
15107 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
15108 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
15110 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
15111 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
15113 if (mplsoudp_encap_conf.select_vlan)
15114 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15115 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
15116 RTE_ETHER_ADDR_LEN);
15117 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15118 RTE_ETHER_ADDR_LEN);
15121 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
15122 .f = cmd_set_mplsoudp_encap_parsed,
15124 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
15125 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
15126 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
15128 (void *)&cmd_set_mplsoudp_encap_set,
15129 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
15130 (void *)&cmd_set_mplsoudp_encap_ip_version,
15131 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
15132 (void *)&cmd_set_mplsoudp_encap_label,
15133 (void *)&cmd_set_mplsoudp_encap_label_value,
15134 (void *)&cmd_set_mplsoudp_encap_udp_src,
15135 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
15136 (void *)&cmd_set_mplsoudp_encap_udp_dst,
15137 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
15138 (void *)&cmd_set_mplsoudp_encap_ip_src,
15139 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
15140 (void *)&cmd_set_mplsoudp_encap_ip_dst,
15141 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
15142 (void *)&cmd_set_mplsoudp_encap_eth_src,
15143 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
15144 (void *)&cmd_set_mplsoudp_encap_eth_dst,
15145 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
15150 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
15151 .f = cmd_set_mplsoudp_encap_parsed,
15153 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
15154 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
15155 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15156 " eth-src <eth-src> eth-dst <eth-dst>",
15158 (void *)&cmd_set_mplsoudp_encap_set,
15159 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
15160 (void *)&cmd_set_mplsoudp_encap_ip_version,
15161 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
15162 (void *)&cmd_set_mplsoudp_encap_label,
15163 (void *)&cmd_set_mplsoudp_encap_label_value,
15164 (void *)&cmd_set_mplsoudp_encap_udp_src,
15165 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
15166 (void *)&cmd_set_mplsoudp_encap_udp_dst,
15167 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
15168 (void *)&cmd_set_mplsoudp_encap_ip_src,
15169 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
15170 (void *)&cmd_set_mplsoudp_encap_ip_dst,
15171 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
15172 (void *)&cmd_set_mplsoudp_encap_vlan,
15173 (void *)&cmd_set_mplsoudp_encap_vlan_value,
15174 (void *)&cmd_set_mplsoudp_encap_eth_src,
15175 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
15176 (void *)&cmd_set_mplsoudp_encap_eth_dst,
15177 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
15182 /** Set MPLSoUDP decapsulation details */
15183 struct cmd_set_mplsoudp_decap_result {
15184 cmdline_fixed_string_t set;
15185 cmdline_fixed_string_t mplsoudp;
15186 cmdline_fixed_string_t pos_token;
15187 cmdline_fixed_string_t ip_version;
15188 uint32_t vlan_present:1;
15191 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
15192 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
15194 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
15195 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
15197 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
15198 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15199 mplsoudp, "mplsoudp_decap-with-vlan");
15200 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
15201 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15202 pos_token, "ip-version");
15203 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
15204 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15205 ip_version, "ipv4#ipv6");
15207 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
15208 __rte_unused struct cmdline *cl,
15209 __rte_unused void *data)
15211 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
15213 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
15214 mplsoudp_decap_conf.select_vlan = 0;
15215 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
15216 mplsoudp_decap_conf.select_vlan = 1;
15217 if (strcmp(res->ip_version, "ipv4") == 0)
15218 mplsoudp_decap_conf.select_ipv4 = 1;
15219 else if (strcmp(res->ip_version, "ipv6") == 0)
15220 mplsoudp_decap_conf.select_ipv4 = 0;
15223 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
15224 .f = cmd_set_mplsoudp_decap_parsed,
15226 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
15228 (void *)&cmd_set_mplsoudp_decap_set,
15229 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
15230 (void *)&cmd_set_mplsoudp_decap_ip_version,
15231 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
15236 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
15237 .f = cmd_set_mplsoudp_decap_parsed,
15239 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
15241 (void *)&cmd_set_mplsoudp_decap_set,
15242 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
15243 (void *)&cmd_set_mplsoudp_decap_ip_version,
15244 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
15249 /* Strict link priority scheduling mode setting */
15251 cmd_strict_link_prio_parsed(
15252 void *parsed_result,
15253 __rte_unused struct cmdline *cl,
15254 __rte_unused void *data)
15256 struct cmd_vf_tc_bw_result *res = parsed_result;
15257 int ret = -ENOTSUP;
15259 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15262 #ifdef RTE_NET_I40E
15263 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
15270 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
15273 printf("invalid port_id %d\n", res->port_id);
15276 printf("function not implemented\n");
15279 printf("programming error: (%s)\n", strerror(-ret));
15283 cmdline_parse_inst_t cmd_strict_link_prio = {
15284 .f = cmd_strict_link_prio_parsed,
15286 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
15288 (void *)&cmd_vf_tc_bw_set,
15289 (void *)&cmd_vf_tc_bw_tx,
15290 (void *)&cmd_vf_tc_bw_strict_link_prio,
15291 (void *)&cmd_vf_tc_bw_port_id,
15292 (void *)&cmd_vf_tc_bw_tc_map,
15297 /* Load dynamic device personalization*/
15298 struct cmd_ddp_add_result {
15299 cmdline_fixed_string_t ddp;
15300 cmdline_fixed_string_t add;
15305 cmdline_parse_token_string_t cmd_ddp_add_ddp =
15306 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
15307 cmdline_parse_token_string_t cmd_ddp_add_add =
15308 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
15309 cmdline_parse_token_num_t cmd_ddp_add_port_id =
15310 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
15311 cmdline_parse_token_string_t cmd_ddp_add_filepath =
15312 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
15315 cmd_ddp_add_parsed(
15316 void *parsed_result,
15317 __rte_unused struct cmdline *cl,
15318 __rte_unused void *data)
15320 struct cmd_ddp_add_result *res = parsed_result;
15326 int ret = -ENOTSUP;
15328 if (!all_ports_stopped()) {
15329 printf("Please stop all ports first\n");
15333 filepath = strdup(res->filepath);
15334 if (filepath == NULL) {
15335 printf("Failed to allocate memory\n");
15338 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
15340 buff = open_file(file_fld[0], &size);
15342 free((void *)filepath);
15346 #ifdef RTE_NET_I40E
15347 if (ret == -ENOTSUP)
15348 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15350 RTE_PMD_I40E_PKG_OP_WR_ADD);
15353 if (ret == -EEXIST)
15354 printf("Profile has already existed.\n");
15356 printf("Failed to load profile.\n");
15357 else if (file_num == 2)
15358 save_file(file_fld[1], buff, size);
15361 free((void *)filepath);
15364 cmdline_parse_inst_t cmd_ddp_add = {
15365 .f = cmd_ddp_add_parsed,
15367 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
15369 (void *)&cmd_ddp_add_ddp,
15370 (void *)&cmd_ddp_add_add,
15371 (void *)&cmd_ddp_add_port_id,
15372 (void *)&cmd_ddp_add_filepath,
15377 /* Delete dynamic device personalization*/
15378 struct cmd_ddp_del_result {
15379 cmdline_fixed_string_t ddp;
15380 cmdline_fixed_string_t del;
15385 cmdline_parse_token_string_t cmd_ddp_del_ddp =
15386 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
15387 cmdline_parse_token_string_t cmd_ddp_del_del =
15388 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
15389 cmdline_parse_token_num_t cmd_ddp_del_port_id =
15390 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
15391 cmdline_parse_token_string_t cmd_ddp_del_filepath =
15392 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
15395 cmd_ddp_del_parsed(
15396 void *parsed_result,
15397 __rte_unused struct cmdline *cl,
15398 __rte_unused void *data)
15400 struct cmd_ddp_del_result *res = parsed_result;
15403 int ret = -ENOTSUP;
15405 if (!all_ports_stopped()) {
15406 printf("Please stop all ports first\n");
15410 buff = open_file(res->filepath, &size);
15414 #ifdef RTE_NET_I40E
15415 if (ret == -ENOTSUP)
15416 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15418 RTE_PMD_I40E_PKG_OP_WR_DEL);
15421 if (ret == -EACCES)
15422 printf("Profile does not exist.\n");
15424 printf("Failed to delete profile.\n");
15429 cmdline_parse_inst_t cmd_ddp_del = {
15430 .f = cmd_ddp_del_parsed,
15432 .help_str = "ddp del <port_id> <backup_profile_path>",
15434 (void *)&cmd_ddp_del_ddp,
15435 (void *)&cmd_ddp_del_del,
15436 (void *)&cmd_ddp_del_port_id,
15437 (void *)&cmd_ddp_del_filepath,
15442 /* Get dynamic device personalization profile info */
15443 struct cmd_ddp_info_result {
15444 cmdline_fixed_string_t ddp;
15445 cmdline_fixed_string_t get;
15446 cmdline_fixed_string_t info;
15450 cmdline_parse_token_string_t cmd_ddp_info_ddp =
15451 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
15452 cmdline_parse_token_string_t cmd_ddp_info_get =
15453 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
15454 cmdline_parse_token_string_t cmd_ddp_info_info =
15455 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
15456 cmdline_parse_token_string_t cmd_ddp_info_filepath =
15457 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
15460 cmd_ddp_info_parsed(
15461 void *parsed_result,
15462 __rte_unused struct cmdline *cl,
15463 __rte_unused void *data)
15465 struct cmd_ddp_info_result *res = parsed_result;
15468 int ret = -ENOTSUP;
15469 #ifdef RTE_NET_I40E
15472 uint32_t buff_size = 0;
15473 struct rte_pmd_i40e_profile_info info;
15474 uint32_t dev_num = 0;
15475 struct rte_pmd_i40e_ddp_device_id *devs;
15476 uint32_t proto_num = 0;
15477 struct rte_pmd_i40e_proto_info *proto = NULL;
15478 uint32_t pctype_num = 0;
15479 struct rte_pmd_i40e_ptype_info *pctype;
15480 uint32_t ptype_num = 0;
15481 struct rte_pmd_i40e_ptype_info *ptype;
15486 pkg = open_file(res->filepath, &pkg_size);
15490 #ifdef RTE_NET_I40E
15491 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15492 (uint8_t *)&info, sizeof(info),
15493 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
15495 printf("Global Track id: 0x%x\n", info.track_id);
15496 printf("Global Version: %d.%d.%d.%d\n",
15497 info.version.major,
15498 info.version.minor,
15499 info.version.update,
15500 info.version.draft);
15501 printf("Global Package name: %s\n\n", info.name);
15504 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15505 (uint8_t *)&info, sizeof(info),
15506 RTE_PMD_I40E_PKG_INFO_HEADER);
15508 printf("i40e Profile Track id: 0x%x\n", info.track_id);
15509 printf("i40e Profile Version: %d.%d.%d.%d\n",
15510 info.version.major,
15511 info.version.minor,
15512 info.version.update,
15513 info.version.draft);
15514 printf("i40e Profile name: %s\n\n", info.name);
15517 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15518 (uint8_t *)&buff_size, sizeof(buff_size),
15519 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
15520 if (!ret && buff_size) {
15521 buff = (uint8_t *)malloc(buff_size);
15523 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15525 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
15527 printf("Package Notes:\n%s\n\n", buff);
15532 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15533 (uint8_t *)&dev_num, sizeof(dev_num),
15534 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
15535 if (!ret && dev_num) {
15536 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
15537 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
15539 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15540 (uint8_t *)devs, buff_size,
15541 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
15543 printf("List of supported devices:\n");
15544 for (i = 0; i < dev_num; i++) {
15545 printf(" %04X:%04X %04X:%04X\n",
15546 devs[i].vendor_dev_id >> 16,
15547 devs[i].vendor_dev_id & 0xFFFF,
15548 devs[i].sub_vendor_dev_id >> 16,
15549 devs[i].sub_vendor_dev_id & 0xFFFF);
15557 /* get information about protocols and packet types */
15558 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15559 (uint8_t *)&proto_num, sizeof(proto_num),
15560 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
15561 if (ret || !proto_num)
15562 goto no_print_return;
15564 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
15565 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
15567 goto no_print_return;
15569 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
15571 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
15573 printf("List of used protocols:\n");
15574 for (i = 0; i < proto_num; i++)
15575 printf(" %2u: %s\n", proto[i].proto_id,
15579 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15580 (uint8_t *)&pctype_num, sizeof(pctype_num),
15581 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
15582 if (ret || !pctype_num)
15583 goto no_print_pctypes;
15585 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15586 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15588 goto no_print_pctypes;
15590 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
15592 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
15595 goto no_print_pctypes;
15598 printf("List of defined packet classification types:\n");
15599 for (i = 0; i < pctype_num; i++) {
15600 printf(" %2u:", pctype[i].ptype_id);
15601 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15602 proto_id = pctype[i].protocols[j];
15603 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15604 for (n = 0; n < proto_num; n++) {
15605 if (proto[n].proto_id == proto_id) {
15606 printf(" %s", proto[n].name);
15619 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
15621 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
15622 if (ret || !ptype_num)
15623 goto no_print_return;
15625 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15626 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15628 goto no_print_return;
15630 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
15632 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
15635 goto no_print_return;
15637 printf("List of defined packet types:\n");
15638 for (i = 0; i < ptype_num; i++) {
15639 printf(" %2u:", ptype[i].ptype_id);
15640 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15641 proto_id = ptype[i].protocols[j];
15642 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15643 for (n = 0; n < proto_num; n++) {
15644 if (proto[n].proto_id == proto_id) {
15645 printf(" %s", proto[n].name);
15661 if (ret == -ENOTSUP)
15662 printf("Function not supported in PMD driver\n");
15666 cmdline_parse_inst_t cmd_ddp_get_info = {
15667 .f = cmd_ddp_info_parsed,
15669 .help_str = "ddp get info <profile_path>",
15671 (void *)&cmd_ddp_info_ddp,
15672 (void *)&cmd_ddp_info_get,
15673 (void *)&cmd_ddp_info_info,
15674 (void *)&cmd_ddp_info_filepath,
15679 /* Get dynamic device personalization profile info list*/
15680 #define PROFILE_INFO_SIZE 48
15681 #define MAX_PROFILE_NUM 16
15683 struct cmd_ddp_get_list_result {
15684 cmdline_fixed_string_t ddp;
15685 cmdline_fixed_string_t get;
15686 cmdline_fixed_string_t list;
15690 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
15691 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
15692 cmdline_parse_token_string_t cmd_ddp_get_list_get =
15693 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
15694 cmdline_parse_token_string_t cmd_ddp_get_list_list =
15695 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
15696 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
15697 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
15700 cmd_ddp_get_list_parsed(
15701 __rte_unused void *parsed_result,
15702 __rte_unused struct cmdline *cl,
15703 __rte_unused void *data)
15705 #ifdef RTE_NET_I40E
15706 struct cmd_ddp_get_list_result *res = parsed_result;
15707 struct rte_pmd_i40e_profile_list *p_list;
15708 struct rte_pmd_i40e_profile_info *p_info;
15713 int ret = -ENOTSUP;
15715 #ifdef RTE_NET_I40E
15716 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
15717 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
15719 printf("%s: Failed to malloc buffer\n", __func__);
15723 if (ret == -ENOTSUP)
15724 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
15725 (uint8_t *)p_list, size);
15728 p_num = p_list->p_count;
15729 printf("Profile number is: %d\n\n", p_num);
15731 for (i = 0; i < p_num; i++) {
15732 p_info = &p_list->p_info[i];
15733 printf("Profile %d:\n", i);
15734 printf("Track id: 0x%x\n", p_info->track_id);
15735 printf("Version: %d.%d.%d.%d\n",
15736 p_info->version.major,
15737 p_info->version.minor,
15738 p_info->version.update,
15739 p_info->version.draft);
15740 printf("Profile name: %s\n\n", p_info->name);
15748 printf("Failed to get ddp list\n");
15751 cmdline_parse_inst_t cmd_ddp_get_list = {
15752 .f = cmd_ddp_get_list_parsed,
15754 .help_str = "ddp get list <port_id>",
15756 (void *)&cmd_ddp_get_list_ddp,
15757 (void *)&cmd_ddp_get_list_get,
15758 (void *)&cmd_ddp_get_list_list,
15759 (void *)&cmd_ddp_get_list_port_id,
15764 /* Configure input set */
15765 struct cmd_cfg_input_set_result {
15766 cmdline_fixed_string_t port;
15767 cmdline_fixed_string_t cfg;
15769 cmdline_fixed_string_t pctype;
15771 cmdline_fixed_string_t inset_type;
15772 cmdline_fixed_string_t opt;
15773 cmdline_fixed_string_t field;
15778 cmd_cfg_input_set_parsed(
15779 __rte_unused void *parsed_result,
15780 __rte_unused struct cmdline *cl,
15781 __rte_unused void *data)
15783 #ifdef RTE_NET_I40E
15784 struct cmd_cfg_input_set_result *res = parsed_result;
15785 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15786 struct rte_pmd_i40e_inset inset;
15788 int ret = -ENOTSUP;
15790 if (!all_ports_stopped()) {
15791 printf("Please stop all ports first\n");
15795 #ifdef RTE_NET_I40E
15796 if (!strcmp(res->inset_type, "hash_inset"))
15797 inset_type = INSET_HASH;
15798 else if (!strcmp(res->inset_type, "fdir_inset"))
15799 inset_type = INSET_FDIR;
15800 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15801 inset_type = INSET_FDIR_FLX;
15802 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15803 &inset, inset_type);
15805 printf("Failed to get input set.\n");
15809 if (!strcmp(res->opt, "get")) {
15810 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15813 printf("Field index %d is enabled.\n", res->field_idx);
15815 printf("Field index %d is disabled.\n", res->field_idx);
15817 } else if (!strcmp(res->opt, "set"))
15818 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15820 else if (!strcmp(res->opt, "clear"))
15821 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15824 printf("Failed to configure input set field.\n");
15828 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15829 &inset, inset_type);
15831 printf("Failed to set input set.\n");
15836 if (ret == -ENOTSUP)
15837 printf("Function not supported\n");
15840 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15841 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15843 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15844 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15846 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15847 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15849 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15850 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15852 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15853 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15855 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15856 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15858 "hash_inset#fdir_inset#fdir_flx_inset");
15859 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15860 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15861 opt, "get#set#clear");
15862 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15863 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15865 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15866 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15869 cmdline_parse_inst_t cmd_cfg_input_set = {
15870 .f = cmd_cfg_input_set_parsed,
15872 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15873 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15875 (void *)&cmd_cfg_input_set_port,
15876 (void *)&cmd_cfg_input_set_cfg,
15877 (void *)&cmd_cfg_input_set_port_id,
15878 (void *)&cmd_cfg_input_set_pctype,
15879 (void *)&cmd_cfg_input_set_pctype_id,
15880 (void *)&cmd_cfg_input_set_inset_type,
15881 (void *)&cmd_cfg_input_set_opt,
15882 (void *)&cmd_cfg_input_set_field,
15883 (void *)&cmd_cfg_input_set_field_idx,
15888 /* Clear input set */
15889 struct cmd_clear_input_set_result {
15890 cmdline_fixed_string_t port;
15891 cmdline_fixed_string_t cfg;
15893 cmdline_fixed_string_t pctype;
15895 cmdline_fixed_string_t inset_type;
15896 cmdline_fixed_string_t clear;
15897 cmdline_fixed_string_t all;
15901 cmd_clear_input_set_parsed(
15902 __rte_unused void *parsed_result,
15903 __rte_unused struct cmdline *cl,
15904 __rte_unused void *data)
15906 #ifdef RTE_NET_I40E
15907 struct cmd_clear_input_set_result *res = parsed_result;
15908 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15909 struct rte_pmd_i40e_inset inset;
15911 int ret = -ENOTSUP;
15913 if (!all_ports_stopped()) {
15914 printf("Please stop all ports first\n");
15918 #ifdef RTE_NET_I40E
15919 if (!strcmp(res->inset_type, "hash_inset"))
15920 inset_type = INSET_HASH;
15921 else if (!strcmp(res->inset_type, "fdir_inset"))
15922 inset_type = INSET_FDIR;
15923 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15924 inset_type = INSET_FDIR_FLX;
15926 memset(&inset, 0, sizeof(inset));
15928 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15929 &inset, inset_type);
15931 printf("Failed to clear input set.\n");
15937 if (ret == -ENOTSUP)
15938 printf("Function not supported\n");
15941 cmdline_parse_token_string_t cmd_clear_input_set_port =
15942 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15944 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15945 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15947 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15948 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15950 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15951 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15953 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15954 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15956 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15957 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15959 "hash_inset#fdir_inset#fdir_flx_inset");
15960 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15961 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15963 cmdline_parse_token_string_t cmd_clear_input_set_all =
15964 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15967 cmdline_parse_inst_t cmd_clear_input_set = {
15968 .f = cmd_clear_input_set_parsed,
15970 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15971 "fdir_inset|fdir_flx_inset clear all",
15973 (void *)&cmd_clear_input_set_port,
15974 (void *)&cmd_clear_input_set_cfg,
15975 (void *)&cmd_clear_input_set_port_id,
15976 (void *)&cmd_clear_input_set_pctype,
15977 (void *)&cmd_clear_input_set_pctype_id,
15978 (void *)&cmd_clear_input_set_inset_type,
15979 (void *)&cmd_clear_input_set_clear,
15980 (void *)&cmd_clear_input_set_all,
15985 /* show vf stats */
15987 /* Common result structure for show vf stats */
15988 struct cmd_show_vf_stats_result {
15989 cmdline_fixed_string_t show;
15990 cmdline_fixed_string_t vf;
15991 cmdline_fixed_string_t stats;
15996 /* Common CLI fields show vf stats*/
15997 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15998 TOKEN_STRING_INITIALIZER
15999 (struct cmd_show_vf_stats_result,
16001 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
16002 TOKEN_STRING_INITIALIZER
16003 (struct cmd_show_vf_stats_result,
16005 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
16006 TOKEN_STRING_INITIALIZER
16007 (struct cmd_show_vf_stats_result,
16009 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
16010 TOKEN_NUM_INITIALIZER
16011 (struct cmd_show_vf_stats_result,
16013 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
16014 TOKEN_NUM_INITIALIZER
16015 (struct cmd_show_vf_stats_result,
16019 cmd_show_vf_stats_parsed(
16020 void *parsed_result,
16021 __rte_unused struct cmdline *cl,
16022 __rte_unused void *data)
16024 struct cmd_show_vf_stats_result *res = parsed_result;
16025 struct rte_eth_stats stats;
16026 int ret = -ENOTSUP;
16027 static const char *nic_stats_border = "########################";
16029 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16032 memset(&stats, 0, sizeof(stats));
16034 #ifdef RTE_NET_I40E
16035 if (ret == -ENOTSUP)
16036 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
16040 #ifdef RTE_NET_BNXT
16041 if (ret == -ENOTSUP)
16042 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
16051 printf("invalid vf_id %d\n", res->vf_id);
16054 printf("invalid port_id %d\n", res->port_id);
16057 printf("function not implemented\n");
16060 printf("programming error: (%s)\n", strerror(-ret));
16063 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
16064 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
16066 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
16068 stats.ipackets, stats.imissed, stats.ibytes);
16069 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
16070 printf(" RX-nombuf: %-10"PRIu64"\n",
16072 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
16074 stats.opackets, stats.oerrors, stats.obytes);
16076 printf(" %s############################%s\n",
16077 nic_stats_border, nic_stats_border);
16080 cmdline_parse_inst_t cmd_show_vf_stats = {
16081 .f = cmd_show_vf_stats_parsed,
16083 .help_str = "show vf stats <port_id> <vf_id>",
16085 (void *)&cmd_show_vf_stats_show,
16086 (void *)&cmd_show_vf_stats_vf,
16087 (void *)&cmd_show_vf_stats_stats,
16088 (void *)&cmd_show_vf_stats_port_id,
16089 (void *)&cmd_show_vf_stats_vf_id,
16094 /* clear vf stats */
16096 /* Common result structure for clear vf stats */
16097 struct cmd_clear_vf_stats_result {
16098 cmdline_fixed_string_t clear;
16099 cmdline_fixed_string_t vf;
16100 cmdline_fixed_string_t stats;
16105 /* Common CLI fields clear vf stats*/
16106 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
16107 TOKEN_STRING_INITIALIZER
16108 (struct cmd_clear_vf_stats_result,
16110 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
16111 TOKEN_STRING_INITIALIZER
16112 (struct cmd_clear_vf_stats_result,
16114 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
16115 TOKEN_STRING_INITIALIZER
16116 (struct cmd_clear_vf_stats_result,
16118 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
16119 TOKEN_NUM_INITIALIZER
16120 (struct cmd_clear_vf_stats_result,
16122 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
16123 TOKEN_NUM_INITIALIZER
16124 (struct cmd_clear_vf_stats_result,
16128 cmd_clear_vf_stats_parsed(
16129 void *parsed_result,
16130 __rte_unused struct cmdline *cl,
16131 __rte_unused void *data)
16133 struct cmd_clear_vf_stats_result *res = parsed_result;
16134 int ret = -ENOTSUP;
16136 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16139 #ifdef RTE_NET_I40E
16140 if (ret == -ENOTSUP)
16141 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
16144 #ifdef RTE_NET_BNXT
16145 if (ret == -ENOTSUP)
16146 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
16154 printf("invalid vf_id %d\n", res->vf_id);
16157 printf("invalid port_id %d\n", res->port_id);
16160 printf("function not implemented\n");
16163 printf("programming error: (%s)\n", strerror(-ret));
16167 cmdline_parse_inst_t cmd_clear_vf_stats = {
16168 .f = cmd_clear_vf_stats_parsed,
16170 .help_str = "clear vf stats <port_id> <vf_id>",
16172 (void *)&cmd_clear_vf_stats_clear,
16173 (void *)&cmd_clear_vf_stats_vf,
16174 (void *)&cmd_clear_vf_stats_stats,
16175 (void *)&cmd_clear_vf_stats_port_id,
16176 (void *)&cmd_clear_vf_stats_vf_id,
16181 /* port config pctype mapping reset */
16183 /* Common result structure for port config pctype mapping reset */
16184 struct cmd_pctype_mapping_reset_result {
16185 cmdline_fixed_string_t port;
16186 cmdline_fixed_string_t config;
16188 cmdline_fixed_string_t pctype;
16189 cmdline_fixed_string_t mapping;
16190 cmdline_fixed_string_t reset;
16193 /* Common CLI fields for port config pctype mapping reset*/
16194 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
16195 TOKEN_STRING_INITIALIZER
16196 (struct cmd_pctype_mapping_reset_result,
16198 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
16199 TOKEN_STRING_INITIALIZER
16200 (struct cmd_pctype_mapping_reset_result,
16202 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
16203 TOKEN_NUM_INITIALIZER
16204 (struct cmd_pctype_mapping_reset_result,
16206 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
16207 TOKEN_STRING_INITIALIZER
16208 (struct cmd_pctype_mapping_reset_result,
16210 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
16211 TOKEN_STRING_INITIALIZER
16212 (struct cmd_pctype_mapping_reset_result,
16213 mapping, "mapping");
16214 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
16215 TOKEN_STRING_INITIALIZER
16216 (struct cmd_pctype_mapping_reset_result,
16220 cmd_pctype_mapping_reset_parsed(
16221 void *parsed_result,
16222 __rte_unused struct cmdline *cl,
16223 __rte_unused void *data)
16225 struct cmd_pctype_mapping_reset_result *res = parsed_result;
16226 int ret = -ENOTSUP;
16228 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16231 #ifdef RTE_NET_I40E
16232 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
16239 printf("invalid port_id %d\n", res->port_id);
16242 printf("function not implemented\n");
16245 printf("programming error: (%s)\n", strerror(-ret));
16249 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
16250 .f = cmd_pctype_mapping_reset_parsed,
16252 .help_str = "port config <port_id> pctype mapping reset",
16254 (void *)&cmd_pctype_mapping_reset_port,
16255 (void *)&cmd_pctype_mapping_reset_config,
16256 (void *)&cmd_pctype_mapping_reset_port_id,
16257 (void *)&cmd_pctype_mapping_reset_pctype,
16258 (void *)&cmd_pctype_mapping_reset_mapping,
16259 (void *)&cmd_pctype_mapping_reset_reset,
16264 /* show port pctype mapping */
16266 /* Common result structure for show port pctype mapping */
16267 struct cmd_pctype_mapping_get_result {
16268 cmdline_fixed_string_t show;
16269 cmdline_fixed_string_t port;
16271 cmdline_fixed_string_t pctype;
16272 cmdline_fixed_string_t mapping;
16275 /* Common CLI fields for pctype mapping get */
16276 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
16277 TOKEN_STRING_INITIALIZER
16278 (struct cmd_pctype_mapping_get_result,
16280 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
16281 TOKEN_STRING_INITIALIZER
16282 (struct cmd_pctype_mapping_get_result,
16284 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
16285 TOKEN_NUM_INITIALIZER
16286 (struct cmd_pctype_mapping_get_result,
16288 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
16289 TOKEN_STRING_INITIALIZER
16290 (struct cmd_pctype_mapping_get_result,
16292 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
16293 TOKEN_STRING_INITIALIZER
16294 (struct cmd_pctype_mapping_get_result,
16295 mapping, "mapping");
16298 cmd_pctype_mapping_get_parsed(
16299 void *parsed_result,
16300 __rte_unused struct cmdline *cl,
16301 __rte_unused void *data)
16303 struct cmd_pctype_mapping_get_result *res = parsed_result;
16304 int ret = -ENOTSUP;
16305 #ifdef RTE_NET_I40E
16306 struct rte_pmd_i40e_flow_type_mapping
16307 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
16308 int i, j, first_pctype;
16311 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16314 #ifdef RTE_NET_I40E
16315 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
16322 printf("invalid port_id %d\n", res->port_id);
16325 printf("function not implemented\n");
16328 printf("programming error: (%s)\n", strerror(-ret));
16332 #ifdef RTE_NET_I40E
16333 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
16334 if (mapping[i].pctype != 0ULL) {
16337 printf("pctype: ");
16338 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
16339 if (mapping[i].pctype & (1ULL << j)) {
16340 printf(first_pctype ?
16341 "%02d" : ",%02d", j);
16345 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
16351 cmdline_parse_inst_t cmd_pctype_mapping_get = {
16352 .f = cmd_pctype_mapping_get_parsed,
16354 .help_str = "show port <port_id> pctype mapping",
16356 (void *)&cmd_pctype_mapping_get_show,
16357 (void *)&cmd_pctype_mapping_get_port,
16358 (void *)&cmd_pctype_mapping_get_port_id,
16359 (void *)&cmd_pctype_mapping_get_pctype,
16360 (void *)&cmd_pctype_mapping_get_mapping,
16365 /* port config pctype mapping update */
16367 /* Common result structure for port config pctype mapping update */
16368 struct cmd_pctype_mapping_update_result {
16369 cmdline_fixed_string_t port;
16370 cmdline_fixed_string_t config;
16372 cmdline_fixed_string_t pctype;
16373 cmdline_fixed_string_t mapping;
16374 cmdline_fixed_string_t update;
16375 cmdline_fixed_string_t pctype_list;
16376 uint16_t flow_type;
16379 /* Common CLI fields for pctype mapping update*/
16380 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
16381 TOKEN_STRING_INITIALIZER
16382 (struct cmd_pctype_mapping_update_result,
16384 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
16385 TOKEN_STRING_INITIALIZER
16386 (struct cmd_pctype_mapping_update_result,
16388 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
16389 TOKEN_NUM_INITIALIZER
16390 (struct cmd_pctype_mapping_update_result,
16392 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
16393 TOKEN_STRING_INITIALIZER
16394 (struct cmd_pctype_mapping_update_result,
16396 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
16397 TOKEN_STRING_INITIALIZER
16398 (struct cmd_pctype_mapping_update_result,
16399 mapping, "mapping");
16400 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
16401 TOKEN_STRING_INITIALIZER
16402 (struct cmd_pctype_mapping_update_result,
16404 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
16405 TOKEN_STRING_INITIALIZER
16406 (struct cmd_pctype_mapping_update_result,
16407 pctype_list, NULL);
16408 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
16409 TOKEN_NUM_INITIALIZER
16410 (struct cmd_pctype_mapping_update_result,
16411 flow_type, UINT16);
16414 cmd_pctype_mapping_update_parsed(
16415 void *parsed_result,
16416 __rte_unused struct cmdline *cl,
16417 __rte_unused void *data)
16419 struct cmd_pctype_mapping_update_result *res = parsed_result;
16420 int ret = -ENOTSUP;
16421 #ifdef RTE_NET_I40E
16422 struct rte_pmd_i40e_flow_type_mapping mapping;
16424 unsigned int nb_item;
16425 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
16428 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16431 #ifdef RTE_NET_I40E
16432 nb_item = parse_item_list(res->pctype_list, "pctypes",
16433 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
16434 mapping.flow_type = res->flow_type;
16435 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
16436 mapping.pctype |= (1ULL << pctype_list[i]);
16437 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
16447 printf("invalid pctype or flow type\n");
16450 printf("invalid port_id %d\n", res->port_id);
16453 printf("function not implemented\n");
16456 printf("programming error: (%s)\n", strerror(-ret));
16460 cmdline_parse_inst_t cmd_pctype_mapping_update = {
16461 .f = cmd_pctype_mapping_update_parsed,
16463 .help_str = "port config <port_id> pctype mapping update"
16464 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
16466 (void *)&cmd_pctype_mapping_update_port,
16467 (void *)&cmd_pctype_mapping_update_config,
16468 (void *)&cmd_pctype_mapping_update_port_id,
16469 (void *)&cmd_pctype_mapping_update_pctype,
16470 (void *)&cmd_pctype_mapping_update_mapping,
16471 (void *)&cmd_pctype_mapping_update_update,
16472 (void *)&cmd_pctype_mapping_update_pc_type,
16473 (void *)&cmd_pctype_mapping_update_flow_type,
16478 /* ptype mapping get */
16480 /* Common result structure for ptype mapping get */
16481 struct cmd_ptype_mapping_get_result {
16482 cmdline_fixed_string_t ptype;
16483 cmdline_fixed_string_t mapping;
16484 cmdline_fixed_string_t get;
16486 uint8_t valid_only;
16489 /* Common CLI fields for ptype mapping get */
16490 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
16491 TOKEN_STRING_INITIALIZER
16492 (struct cmd_ptype_mapping_get_result,
16494 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
16495 TOKEN_STRING_INITIALIZER
16496 (struct cmd_ptype_mapping_get_result,
16497 mapping, "mapping");
16498 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
16499 TOKEN_STRING_INITIALIZER
16500 (struct cmd_ptype_mapping_get_result,
16502 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
16503 TOKEN_NUM_INITIALIZER
16504 (struct cmd_ptype_mapping_get_result,
16506 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
16507 TOKEN_NUM_INITIALIZER
16508 (struct cmd_ptype_mapping_get_result,
16509 valid_only, UINT8);
16512 cmd_ptype_mapping_get_parsed(
16513 void *parsed_result,
16514 __rte_unused struct cmdline *cl,
16515 __rte_unused void *data)
16517 struct cmd_ptype_mapping_get_result *res = parsed_result;
16518 int ret = -ENOTSUP;
16519 #ifdef RTE_NET_I40E
16520 int max_ptype_num = 256;
16521 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
16526 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16529 #ifdef RTE_NET_I40E
16530 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
16541 printf("invalid port_id %d\n", res->port_id);
16544 printf("function not implemented\n");
16547 printf("programming error: (%s)\n", strerror(-ret));
16550 #ifdef RTE_NET_I40E
16552 for (i = 0; i < count; i++)
16553 printf("%3d\t0x%08x\n",
16554 mapping[i].hw_ptype, mapping[i].sw_ptype);
16559 cmdline_parse_inst_t cmd_ptype_mapping_get = {
16560 .f = cmd_ptype_mapping_get_parsed,
16562 .help_str = "ptype mapping get <port_id> <valid_only>",
16564 (void *)&cmd_ptype_mapping_get_ptype,
16565 (void *)&cmd_ptype_mapping_get_mapping,
16566 (void *)&cmd_ptype_mapping_get_get,
16567 (void *)&cmd_ptype_mapping_get_port_id,
16568 (void *)&cmd_ptype_mapping_get_valid_only,
16573 /* ptype mapping replace */
16575 /* Common result structure for ptype mapping replace */
16576 struct cmd_ptype_mapping_replace_result {
16577 cmdline_fixed_string_t ptype;
16578 cmdline_fixed_string_t mapping;
16579 cmdline_fixed_string_t replace;
16586 /* Common CLI fields for ptype mapping replace */
16587 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
16588 TOKEN_STRING_INITIALIZER
16589 (struct cmd_ptype_mapping_replace_result,
16591 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
16592 TOKEN_STRING_INITIALIZER
16593 (struct cmd_ptype_mapping_replace_result,
16594 mapping, "mapping");
16595 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
16596 TOKEN_STRING_INITIALIZER
16597 (struct cmd_ptype_mapping_replace_result,
16598 replace, "replace");
16599 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
16600 TOKEN_NUM_INITIALIZER
16601 (struct cmd_ptype_mapping_replace_result,
16603 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
16604 TOKEN_NUM_INITIALIZER
16605 (struct cmd_ptype_mapping_replace_result,
16607 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
16608 TOKEN_NUM_INITIALIZER
16609 (struct cmd_ptype_mapping_replace_result,
16611 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
16612 TOKEN_NUM_INITIALIZER
16613 (struct cmd_ptype_mapping_replace_result,
16617 cmd_ptype_mapping_replace_parsed(
16618 void *parsed_result,
16619 __rte_unused struct cmdline *cl,
16620 __rte_unused void *data)
16622 struct cmd_ptype_mapping_replace_result *res = parsed_result;
16623 int ret = -ENOTSUP;
16625 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16628 #ifdef RTE_NET_I40E
16629 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
16639 printf("invalid ptype 0x%8x or 0x%8x\n",
16640 res->target, res->pkt_type);
16643 printf("invalid port_id %d\n", res->port_id);
16646 printf("function not implemented\n");
16649 printf("programming error: (%s)\n", strerror(-ret));
16653 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
16654 .f = cmd_ptype_mapping_replace_parsed,
16657 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
16659 (void *)&cmd_ptype_mapping_replace_ptype,
16660 (void *)&cmd_ptype_mapping_replace_mapping,
16661 (void *)&cmd_ptype_mapping_replace_replace,
16662 (void *)&cmd_ptype_mapping_replace_port_id,
16663 (void *)&cmd_ptype_mapping_replace_target,
16664 (void *)&cmd_ptype_mapping_replace_mask,
16665 (void *)&cmd_ptype_mapping_replace_pkt_type,
16670 /* ptype mapping reset */
16672 /* Common result structure for ptype mapping reset */
16673 struct cmd_ptype_mapping_reset_result {
16674 cmdline_fixed_string_t ptype;
16675 cmdline_fixed_string_t mapping;
16676 cmdline_fixed_string_t reset;
16680 /* Common CLI fields for ptype mapping reset*/
16681 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
16682 TOKEN_STRING_INITIALIZER
16683 (struct cmd_ptype_mapping_reset_result,
16685 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
16686 TOKEN_STRING_INITIALIZER
16687 (struct cmd_ptype_mapping_reset_result,
16688 mapping, "mapping");
16689 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
16690 TOKEN_STRING_INITIALIZER
16691 (struct cmd_ptype_mapping_reset_result,
16693 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
16694 TOKEN_NUM_INITIALIZER
16695 (struct cmd_ptype_mapping_reset_result,
16699 cmd_ptype_mapping_reset_parsed(
16700 void *parsed_result,
16701 __rte_unused struct cmdline *cl,
16702 __rte_unused void *data)
16704 struct cmd_ptype_mapping_reset_result *res = parsed_result;
16705 int ret = -ENOTSUP;
16707 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16710 #ifdef RTE_NET_I40E
16711 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
16718 printf("invalid port_id %d\n", res->port_id);
16721 printf("function not implemented\n");
16724 printf("programming error: (%s)\n", strerror(-ret));
16728 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
16729 .f = cmd_ptype_mapping_reset_parsed,
16731 .help_str = "ptype mapping reset <port_id>",
16733 (void *)&cmd_ptype_mapping_reset_ptype,
16734 (void *)&cmd_ptype_mapping_reset_mapping,
16735 (void *)&cmd_ptype_mapping_reset_reset,
16736 (void *)&cmd_ptype_mapping_reset_port_id,
16741 /* ptype mapping update */
16743 /* Common result structure for ptype mapping update */
16744 struct cmd_ptype_mapping_update_result {
16745 cmdline_fixed_string_t ptype;
16746 cmdline_fixed_string_t mapping;
16747 cmdline_fixed_string_t reset;
16753 /* Common CLI fields for ptype mapping update*/
16754 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16755 TOKEN_STRING_INITIALIZER
16756 (struct cmd_ptype_mapping_update_result,
16758 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16759 TOKEN_STRING_INITIALIZER
16760 (struct cmd_ptype_mapping_update_result,
16761 mapping, "mapping");
16762 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16763 TOKEN_STRING_INITIALIZER
16764 (struct cmd_ptype_mapping_update_result,
16766 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16767 TOKEN_NUM_INITIALIZER
16768 (struct cmd_ptype_mapping_update_result,
16770 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16771 TOKEN_NUM_INITIALIZER
16772 (struct cmd_ptype_mapping_update_result,
16774 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16775 TOKEN_NUM_INITIALIZER
16776 (struct cmd_ptype_mapping_update_result,
16780 cmd_ptype_mapping_update_parsed(
16781 void *parsed_result,
16782 __rte_unused struct cmdline *cl,
16783 __rte_unused void *data)
16785 struct cmd_ptype_mapping_update_result *res = parsed_result;
16786 int ret = -ENOTSUP;
16787 #ifdef RTE_NET_I40E
16788 struct rte_pmd_i40e_ptype_mapping mapping;
16790 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16793 #ifdef RTE_NET_I40E
16794 mapping.hw_ptype = res->hw_ptype;
16795 mapping.sw_ptype = res->sw_ptype;
16796 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16806 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16809 printf("invalid port_id %d\n", res->port_id);
16812 printf("function not implemented\n");
16815 printf("programming error: (%s)\n", strerror(-ret));
16819 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16820 .f = cmd_ptype_mapping_update_parsed,
16822 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16824 (void *)&cmd_ptype_mapping_update_ptype,
16825 (void *)&cmd_ptype_mapping_update_mapping,
16826 (void *)&cmd_ptype_mapping_update_update,
16827 (void *)&cmd_ptype_mapping_update_port_id,
16828 (void *)&cmd_ptype_mapping_update_hw_ptype,
16829 (void *)&cmd_ptype_mapping_update_sw_ptype,
16834 /* Common result structure for file commands */
16835 struct cmd_cmdfile_result {
16836 cmdline_fixed_string_t load;
16837 cmdline_fixed_string_t filename;
16840 /* Common CLI fields for file commands */
16841 cmdline_parse_token_string_t cmd_load_cmdfile =
16842 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16843 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16844 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16847 cmd_load_from_file_parsed(
16848 void *parsed_result,
16849 __rte_unused struct cmdline *cl,
16850 __rte_unused void *data)
16852 struct cmd_cmdfile_result *res = parsed_result;
16854 cmdline_read_from_file(res->filename);
16857 cmdline_parse_inst_t cmd_load_from_file = {
16858 .f = cmd_load_from_file_parsed,
16860 .help_str = "load <filename>",
16862 (void *)&cmd_load_cmdfile,
16863 (void *)&cmd_load_cmdfile_filename,
16868 /* Get Rx offloads capabilities */
16869 struct cmd_rx_offload_get_capa_result {
16870 cmdline_fixed_string_t show;
16871 cmdline_fixed_string_t port;
16873 cmdline_fixed_string_t rx_offload;
16874 cmdline_fixed_string_t capabilities;
16877 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
16878 TOKEN_STRING_INITIALIZER
16879 (struct cmd_rx_offload_get_capa_result,
16881 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
16882 TOKEN_STRING_INITIALIZER
16883 (struct cmd_rx_offload_get_capa_result,
16885 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
16886 TOKEN_NUM_INITIALIZER
16887 (struct cmd_rx_offload_get_capa_result,
16889 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
16890 TOKEN_STRING_INITIALIZER
16891 (struct cmd_rx_offload_get_capa_result,
16892 rx_offload, "rx_offload");
16893 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
16894 TOKEN_STRING_INITIALIZER
16895 (struct cmd_rx_offload_get_capa_result,
16896 capabilities, "capabilities");
16899 print_rx_offloads(uint64_t offloads)
16901 uint64_t single_offload;
16909 begin = __builtin_ctzll(offloads);
16910 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16912 single_offload = 1ULL << begin;
16913 for (bit = begin; bit < end; bit++) {
16914 if (offloads & single_offload)
16916 rte_eth_dev_rx_offload_name(single_offload));
16917 single_offload <<= 1;
16922 cmd_rx_offload_get_capa_parsed(
16923 void *parsed_result,
16924 __rte_unused struct cmdline *cl,
16925 __rte_unused void *data)
16927 struct cmd_rx_offload_get_capa_result *res = parsed_result;
16928 struct rte_eth_dev_info dev_info;
16929 portid_t port_id = res->port_id;
16930 uint64_t queue_offloads;
16931 uint64_t port_offloads;
16934 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16938 queue_offloads = dev_info.rx_queue_offload_capa;
16939 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
16941 printf("Rx Offloading Capabilities of port %d :\n", port_id);
16942 printf(" Per Queue :");
16943 print_rx_offloads(queue_offloads);
16946 printf(" Per Port :");
16947 print_rx_offloads(port_offloads);
16951 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16952 .f = cmd_rx_offload_get_capa_parsed,
16954 .help_str = "show port <port_id> rx_offload capabilities",
16956 (void *)&cmd_rx_offload_get_capa_show,
16957 (void *)&cmd_rx_offload_get_capa_port,
16958 (void *)&cmd_rx_offload_get_capa_port_id,
16959 (void *)&cmd_rx_offload_get_capa_rx_offload,
16960 (void *)&cmd_rx_offload_get_capa_capabilities,
16965 /* Get Rx offloads configuration */
16966 struct cmd_rx_offload_get_configuration_result {
16967 cmdline_fixed_string_t show;
16968 cmdline_fixed_string_t port;
16970 cmdline_fixed_string_t rx_offload;
16971 cmdline_fixed_string_t configuration;
16974 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16975 TOKEN_STRING_INITIALIZER
16976 (struct cmd_rx_offload_get_configuration_result,
16978 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16979 TOKEN_STRING_INITIALIZER
16980 (struct cmd_rx_offload_get_configuration_result,
16982 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16983 TOKEN_NUM_INITIALIZER
16984 (struct cmd_rx_offload_get_configuration_result,
16986 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16987 TOKEN_STRING_INITIALIZER
16988 (struct cmd_rx_offload_get_configuration_result,
16989 rx_offload, "rx_offload");
16990 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16991 TOKEN_STRING_INITIALIZER
16992 (struct cmd_rx_offload_get_configuration_result,
16993 configuration, "configuration");
16996 cmd_rx_offload_get_configuration_parsed(
16997 void *parsed_result,
16998 __rte_unused struct cmdline *cl,
16999 __rte_unused void *data)
17001 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
17002 struct rte_eth_dev_info dev_info;
17003 portid_t port_id = res->port_id;
17004 struct rte_port *port = &ports[port_id];
17005 uint64_t port_offloads;
17006 uint64_t queue_offloads;
17007 uint16_t nb_rx_queues;
17011 printf("Rx Offloading Configuration of port %d :\n", port_id);
17013 port_offloads = port->dev_conf.rxmode.offloads;
17015 print_rx_offloads(port_offloads);
17018 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17022 nb_rx_queues = dev_info.nb_rx_queues;
17023 for (q = 0; q < nb_rx_queues; q++) {
17024 queue_offloads = port->rx_conf[q].offloads;
17025 printf(" Queue[%2d] :", q);
17026 print_rx_offloads(queue_offloads);
17032 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
17033 .f = cmd_rx_offload_get_configuration_parsed,
17035 .help_str = "show port <port_id> rx_offload configuration",
17037 (void *)&cmd_rx_offload_get_configuration_show,
17038 (void *)&cmd_rx_offload_get_configuration_port,
17039 (void *)&cmd_rx_offload_get_configuration_port_id,
17040 (void *)&cmd_rx_offload_get_configuration_rx_offload,
17041 (void *)&cmd_rx_offload_get_configuration_configuration,
17046 /* Enable/Disable a per port offloading */
17047 struct cmd_config_per_port_rx_offload_result {
17048 cmdline_fixed_string_t port;
17049 cmdline_fixed_string_t config;
17051 cmdline_fixed_string_t rx_offload;
17052 cmdline_fixed_string_t offload;
17053 cmdline_fixed_string_t on_off;
17056 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
17057 TOKEN_STRING_INITIALIZER
17058 (struct cmd_config_per_port_rx_offload_result,
17060 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
17061 TOKEN_STRING_INITIALIZER
17062 (struct cmd_config_per_port_rx_offload_result,
17064 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
17065 TOKEN_NUM_INITIALIZER
17066 (struct cmd_config_per_port_rx_offload_result,
17068 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
17069 TOKEN_STRING_INITIALIZER
17070 (struct cmd_config_per_port_rx_offload_result,
17071 rx_offload, "rx_offload");
17072 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
17073 TOKEN_STRING_INITIALIZER
17074 (struct cmd_config_per_port_rx_offload_result,
17075 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17076 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17077 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17078 "scatter#buffer_split#timestamp#security#"
17079 "keep_crc#rss_hash");
17080 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
17081 TOKEN_STRING_INITIALIZER
17082 (struct cmd_config_per_port_rx_offload_result,
17086 search_rx_offload(const char *name)
17088 uint64_t single_offload;
17089 const char *single_name;
17093 single_offload = 1;
17094 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17095 single_name = rte_eth_dev_rx_offload_name(single_offload);
17096 if (!strcasecmp(single_name, name)) {
17100 single_offload <<= 1;
17104 return single_offload;
17110 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
17111 __rte_unused struct cmdline *cl,
17112 __rte_unused void *data)
17114 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
17115 portid_t port_id = res->port_id;
17116 struct rte_eth_dev_info dev_info;
17117 struct rte_port *port = &ports[port_id];
17118 uint64_t single_offload;
17119 uint16_t nb_rx_queues;
17123 if (port->port_status != RTE_PORT_STOPPED) {
17124 printf("Error: Can't config offload when Port %d "
17125 "is not stopped\n", port_id);
17129 single_offload = search_rx_offload(res->offload);
17130 if (single_offload == 0) {
17131 printf("Unknown offload name: %s\n", res->offload);
17135 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17139 nb_rx_queues = dev_info.nb_rx_queues;
17140 if (!strcmp(res->on_off, "on")) {
17141 port->dev_conf.rxmode.offloads |= single_offload;
17142 for (q = 0; q < nb_rx_queues; q++)
17143 port->rx_conf[q].offloads |= single_offload;
17145 port->dev_conf.rxmode.offloads &= ~single_offload;
17146 for (q = 0; q < nb_rx_queues; q++)
17147 port->rx_conf[q].offloads &= ~single_offload;
17150 cmd_reconfig_device_queue(port_id, 1, 1);
17153 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
17154 .f = cmd_config_per_port_rx_offload_parsed,
17156 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
17157 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17158 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17159 "jumbo_frame|scatter|buffer_split|timestamp|security|"
17160 "keep_crc|rss_hash on|off",
17162 (void *)&cmd_config_per_port_rx_offload_result_port,
17163 (void *)&cmd_config_per_port_rx_offload_result_config,
17164 (void *)&cmd_config_per_port_rx_offload_result_port_id,
17165 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
17166 (void *)&cmd_config_per_port_rx_offload_result_offload,
17167 (void *)&cmd_config_per_port_rx_offload_result_on_off,
17172 /* Enable/Disable a per queue offloading */
17173 struct cmd_config_per_queue_rx_offload_result {
17174 cmdline_fixed_string_t port;
17176 cmdline_fixed_string_t rxq;
17178 cmdline_fixed_string_t rx_offload;
17179 cmdline_fixed_string_t offload;
17180 cmdline_fixed_string_t on_off;
17183 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
17184 TOKEN_STRING_INITIALIZER
17185 (struct cmd_config_per_queue_rx_offload_result,
17187 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
17188 TOKEN_NUM_INITIALIZER
17189 (struct cmd_config_per_queue_rx_offload_result,
17191 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
17192 TOKEN_STRING_INITIALIZER
17193 (struct cmd_config_per_queue_rx_offload_result,
17195 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
17196 TOKEN_NUM_INITIALIZER
17197 (struct cmd_config_per_queue_rx_offload_result,
17199 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
17200 TOKEN_STRING_INITIALIZER
17201 (struct cmd_config_per_queue_rx_offload_result,
17202 rx_offload, "rx_offload");
17203 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
17204 TOKEN_STRING_INITIALIZER
17205 (struct cmd_config_per_queue_rx_offload_result,
17206 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17207 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17208 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17209 "scatter#buffer_split#timestamp#security#keep_crc");
17210 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
17211 TOKEN_STRING_INITIALIZER
17212 (struct cmd_config_per_queue_rx_offload_result,
17216 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
17217 __rte_unused struct cmdline *cl,
17218 __rte_unused void *data)
17220 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
17221 struct rte_eth_dev_info dev_info;
17222 portid_t port_id = res->port_id;
17223 uint16_t queue_id = res->queue_id;
17224 struct rte_port *port = &ports[port_id];
17225 uint64_t single_offload;
17228 if (port->port_status != RTE_PORT_STOPPED) {
17229 printf("Error: Can't config offload when Port %d "
17230 "is not stopped\n", port_id);
17234 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17238 if (queue_id >= dev_info.nb_rx_queues) {
17239 printf("Error: input queue_id should be 0 ... "
17240 "%d\n", dev_info.nb_rx_queues - 1);
17244 single_offload = search_rx_offload(res->offload);
17245 if (single_offload == 0) {
17246 printf("Unknown offload name: %s\n", res->offload);
17250 if (!strcmp(res->on_off, "on"))
17251 port->rx_conf[queue_id].offloads |= single_offload;
17253 port->rx_conf[queue_id].offloads &= ~single_offload;
17255 cmd_reconfig_device_queue(port_id, 1, 1);
17258 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
17259 .f = cmd_config_per_queue_rx_offload_parsed,
17261 .help_str = "port <port_id> rxq <queue_id> rx_offload "
17262 "vlan_strip|ipv4_cksum|"
17263 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17264 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17265 "jumbo_frame|scatter|buffer_split|timestamp|security|"
17268 (void *)&cmd_config_per_queue_rx_offload_result_port,
17269 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
17270 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
17271 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
17272 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
17273 (void *)&cmd_config_per_queue_rx_offload_result_offload,
17274 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
17279 /* Get Tx offloads capabilities */
17280 struct cmd_tx_offload_get_capa_result {
17281 cmdline_fixed_string_t show;
17282 cmdline_fixed_string_t port;
17284 cmdline_fixed_string_t tx_offload;
17285 cmdline_fixed_string_t capabilities;
17288 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
17289 TOKEN_STRING_INITIALIZER
17290 (struct cmd_tx_offload_get_capa_result,
17292 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
17293 TOKEN_STRING_INITIALIZER
17294 (struct cmd_tx_offload_get_capa_result,
17296 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
17297 TOKEN_NUM_INITIALIZER
17298 (struct cmd_tx_offload_get_capa_result,
17300 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
17301 TOKEN_STRING_INITIALIZER
17302 (struct cmd_tx_offload_get_capa_result,
17303 tx_offload, "tx_offload");
17304 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
17305 TOKEN_STRING_INITIALIZER
17306 (struct cmd_tx_offload_get_capa_result,
17307 capabilities, "capabilities");
17310 print_tx_offloads(uint64_t offloads)
17312 uint64_t single_offload;
17320 begin = __builtin_ctzll(offloads);
17321 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17323 single_offload = 1ULL << begin;
17324 for (bit = begin; bit < end; bit++) {
17325 if (offloads & single_offload)
17327 rte_eth_dev_tx_offload_name(single_offload));
17328 single_offload <<= 1;
17333 cmd_tx_offload_get_capa_parsed(
17334 void *parsed_result,
17335 __rte_unused struct cmdline *cl,
17336 __rte_unused void *data)
17338 struct cmd_tx_offload_get_capa_result *res = parsed_result;
17339 struct rte_eth_dev_info dev_info;
17340 portid_t port_id = res->port_id;
17341 uint64_t queue_offloads;
17342 uint64_t port_offloads;
17345 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17349 queue_offloads = dev_info.tx_queue_offload_capa;
17350 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
17352 printf("Tx Offloading Capabilities of port %d :\n", port_id);
17353 printf(" Per Queue :");
17354 print_tx_offloads(queue_offloads);
17357 printf(" Per Port :");
17358 print_tx_offloads(port_offloads);
17362 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
17363 .f = cmd_tx_offload_get_capa_parsed,
17365 .help_str = "show port <port_id> tx_offload capabilities",
17367 (void *)&cmd_tx_offload_get_capa_show,
17368 (void *)&cmd_tx_offload_get_capa_port,
17369 (void *)&cmd_tx_offload_get_capa_port_id,
17370 (void *)&cmd_tx_offload_get_capa_tx_offload,
17371 (void *)&cmd_tx_offload_get_capa_capabilities,
17376 /* Get Tx offloads configuration */
17377 struct cmd_tx_offload_get_configuration_result {
17378 cmdline_fixed_string_t show;
17379 cmdline_fixed_string_t port;
17381 cmdline_fixed_string_t tx_offload;
17382 cmdline_fixed_string_t configuration;
17385 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
17386 TOKEN_STRING_INITIALIZER
17387 (struct cmd_tx_offload_get_configuration_result,
17389 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
17390 TOKEN_STRING_INITIALIZER
17391 (struct cmd_tx_offload_get_configuration_result,
17393 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
17394 TOKEN_NUM_INITIALIZER
17395 (struct cmd_tx_offload_get_configuration_result,
17397 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
17398 TOKEN_STRING_INITIALIZER
17399 (struct cmd_tx_offload_get_configuration_result,
17400 tx_offload, "tx_offload");
17401 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
17402 TOKEN_STRING_INITIALIZER
17403 (struct cmd_tx_offload_get_configuration_result,
17404 configuration, "configuration");
17407 cmd_tx_offload_get_configuration_parsed(
17408 void *parsed_result,
17409 __rte_unused struct cmdline *cl,
17410 __rte_unused void *data)
17412 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
17413 struct rte_eth_dev_info dev_info;
17414 portid_t port_id = res->port_id;
17415 struct rte_port *port = &ports[port_id];
17416 uint64_t port_offloads;
17417 uint64_t queue_offloads;
17418 uint16_t nb_tx_queues;
17422 printf("Tx Offloading Configuration of port %d :\n", port_id);
17424 port_offloads = port->dev_conf.txmode.offloads;
17426 print_tx_offloads(port_offloads);
17429 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17433 nb_tx_queues = dev_info.nb_tx_queues;
17434 for (q = 0; q < nb_tx_queues; q++) {
17435 queue_offloads = port->tx_conf[q].offloads;
17436 printf(" Queue[%2d] :", q);
17437 print_tx_offloads(queue_offloads);
17443 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
17444 .f = cmd_tx_offload_get_configuration_parsed,
17446 .help_str = "show port <port_id> tx_offload configuration",
17448 (void *)&cmd_tx_offload_get_configuration_show,
17449 (void *)&cmd_tx_offload_get_configuration_port,
17450 (void *)&cmd_tx_offload_get_configuration_port_id,
17451 (void *)&cmd_tx_offload_get_configuration_tx_offload,
17452 (void *)&cmd_tx_offload_get_configuration_configuration,
17457 /* Enable/Disable a per port offloading */
17458 struct cmd_config_per_port_tx_offload_result {
17459 cmdline_fixed_string_t port;
17460 cmdline_fixed_string_t config;
17462 cmdline_fixed_string_t tx_offload;
17463 cmdline_fixed_string_t offload;
17464 cmdline_fixed_string_t on_off;
17467 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
17468 TOKEN_STRING_INITIALIZER
17469 (struct cmd_config_per_port_tx_offload_result,
17471 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
17472 TOKEN_STRING_INITIALIZER
17473 (struct cmd_config_per_port_tx_offload_result,
17475 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
17476 TOKEN_NUM_INITIALIZER
17477 (struct cmd_config_per_port_tx_offload_result,
17479 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
17480 TOKEN_STRING_INITIALIZER
17481 (struct cmd_config_per_port_tx_offload_result,
17482 tx_offload, "tx_offload");
17483 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
17484 TOKEN_STRING_INITIALIZER
17485 (struct cmd_config_per_port_tx_offload_result,
17486 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
17487 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17488 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17489 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17490 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
17491 "send_on_timestamp");
17492 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
17493 TOKEN_STRING_INITIALIZER
17494 (struct cmd_config_per_port_tx_offload_result,
17498 search_tx_offload(const char *name)
17500 uint64_t single_offload;
17501 const char *single_name;
17505 single_offload = 1;
17506 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17507 single_name = rte_eth_dev_tx_offload_name(single_offload);
17508 if (single_name == NULL)
17510 if (!strcasecmp(single_name, name)) {
17513 } else if (!strcasecmp(single_name, "UNKNOWN"))
17515 single_offload <<= 1;
17519 return single_offload;
17525 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
17526 __rte_unused struct cmdline *cl,
17527 __rte_unused void *data)
17529 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
17530 portid_t port_id = res->port_id;
17531 struct rte_eth_dev_info dev_info;
17532 struct rte_port *port = &ports[port_id];
17533 uint64_t single_offload;
17534 uint16_t nb_tx_queues;
17538 if (port->port_status != RTE_PORT_STOPPED) {
17539 printf("Error: Can't config offload when Port %d "
17540 "is not stopped\n", port_id);
17544 single_offload = search_tx_offload(res->offload);
17545 if (single_offload == 0) {
17546 printf("Unknown offload name: %s\n", res->offload);
17550 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17554 nb_tx_queues = dev_info.nb_tx_queues;
17555 if (!strcmp(res->on_off, "on")) {
17556 port->dev_conf.txmode.offloads |= single_offload;
17557 for (q = 0; q < nb_tx_queues; q++)
17558 port->tx_conf[q].offloads |= single_offload;
17560 port->dev_conf.txmode.offloads &= ~single_offload;
17561 for (q = 0; q < nb_tx_queues; q++)
17562 port->tx_conf[q].offloads &= ~single_offload;
17565 cmd_reconfig_device_queue(port_id, 1, 1);
17568 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
17569 .f = cmd_config_per_port_tx_offload_parsed,
17571 .help_str = "port config <port_id> tx_offload "
17572 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
17573 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17574 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17575 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17576 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
17577 "send_on_timestamp on|off",
17579 (void *)&cmd_config_per_port_tx_offload_result_port,
17580 (void *)&cmd_config_per_port_tx_offload_result_config,
17581 (void *)&cmd_config_per_port_tx_offload_result_port_id,
17582 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
17583 (void *)&cmd_config_per_port_tx_offload_result_offload,
17584 (void *)&cmd_config_per_port_tx_offload_result_on_off,
17589 /* Enable/Disable a per queue offloading */
17590 struct cmd_config_per_queue_tx_offload_result {
17591 cmdline_fixed_string_t port;
17593 cmdline_fixed_string_t txq;
17595 cmdline_fixed_string_t tx_offload;
17596 cmdline_fixed_string_t offload;
17597 cmdline_fixed_string_t on_off;
17600 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
17601 TOKEN_STRING_INITIALIZER
17602 (struct cmd_config_per_queue_tx_offload_result,
17604 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
17605 TOKEN_NUM_INITIALIZER
17606 (struct cmd_config_per_queue_tx_offload_result,
17608 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
17609 TOKEN_STRING_INITIALIZER
17610 (struct cmd_config_per_queue_tx_offload_result,
17612 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
17613 TOKEN_NUM_INITIALIZER
17614 (struct cmd_config_per_queue_tx_offload_result,
17616 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
17617 TOKEN_STRING_INITIALIZER
17618 (struct cmd_config_per_queue_tx_offload_result,
17619 tx_offload, "tx_offload");
17620 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
17621 TOKEN_STRING_INITIALIZER
17622 (struct cmd_config_per_queue_tx_offload_result,
17623 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
17624 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17625 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17626 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17627 "mt_lockfree#multi_segs#mbuf_fast_free#security");
17628 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
17629 TOKEN_STRING_INITIALIZER
17630 (struct cmd_config_per_queue_tx_offload_result,
17634 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
17635 __rte_unused struct cmdline *cl,
17636 __rte_unused void *data)
17638 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
17639 struct rte_eth_dev_info dev_info;
17640 portid_t port_id = res->port_id;
17641 uint16_t queue_id = res->queue_id;
17642 struct rte_port *port = &ports[port_id];
17643 uint64_t single_offload;
17646 if (port->port_status != RTE_PORT_STOPPED) {
17647 printf("Error: Can't config offload when Port %d "
17648 "is not stopped\n", port_id);
17652 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17656 if (queue_id >= dev_info.nb_tx_queues) {
17657 printf("Error: input queue_id should be 0 ... "
17658 "%d\n", dev_info.nb_tx_queues - 1);
17662 single_offload = search_tx_offload(res->offload);
17663 if (single_offload == 0) {
17664 printf("Unknown offload name: %s\n", res->offload);
17668 if (!strcmp(res->on_off, "on"))
17669 port->tx_conf[queue_id].offloads |= single_offload;
17671 port->tx_conf[queue_id].offloads &= ~single_offload;
17673 cmd_reconfig_device_queue(port_id, 1, 1);
17676 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
17677 .f = cmd_config_per_queue_tx_offload_parsed,
17679 .help_str = "port <port_id> txq <queue_id> tx_offload "
17680 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
17681 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17682 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17683 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17684 "mt_lockfree|multi_segs|mbuf_fast_free|security "
17687 (void *)&cmd_config_per_queue_tx_offload_result_port,
17688 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
17689 (void *)&cmd_config_per_queue_tx_offload_result_txq,
17690 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
17691 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
17692 (void *)&cmd_config_per_queue_tx_offload_result_offload,
17693 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
17698 /* *** configure tx_metadata for specific port *** */
17699 struct cmd_config_tx_metadata_specific_result {
17700 cmdline_fixed_string_t port;
17701 cmdline_fixed_string_t keyword;
17703 cmdline_fixed_string_t item;
17708 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
17709 __rte_unused struct cmdline *cl,
17710 __rte_unused void *data)
17712 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
17714 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17716 ports[res->port_id].tx_metadata = res->value;
17717 /* Add/remove callback to insert valid metadata in every Tx packet. */
17718 if (ports[res->port_id].tx_metadata)
17719 add_tx_md_callback(res->port_id);
17721 remove_tx_md_callback(res->port_id);
17722 rte_flow_dynf_metadata_register();
17725 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
17726 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
17728 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
17729 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
17730 keyword, "config");
17731 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
17732 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
17734 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
17735 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
17736 item, "tx_metadata");
17737 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
17738 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
17741 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
17742 .f = cmd_config_tx_metadata_specific_parsed,
17744 .help_str = "port config <port_id> tx_metadata <value>",
17746 (void *)&cmd_config_tx_metadata_specific_port,
17747 (void *)&cmd_config_tx_metadata_specific_keyword,
17748 (void *)&cmd_config_tx_metadata_specific_id,
17749 (void *)&cmd_config_tx_metadata_specific_item,
17750 (void *)&cmd_config_tx_metadata_specific_value,
17755 /* *** set dynf *** */
17756 struct cmd_config_tx_dynf_specific_result {
17757 cmdline_fixed_string_t port;
17758 cmdline_fixed_string_t keyword;
17760 cmdline_fixed_string_t item;
17761 cmdline_fixed_string_t name;
17762 cmdline_fixed_string_t value;
17766 cmd_config_dynf_specific_parsed(void *parsed_result,
17767 __rte_unused struct cmdline *cl,
17768 __rte_unused void *data)
17770 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
17771 struct rte_mbuf_dynflag desc_flag;
17773 uint64_t old_port_flags;
17775 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17777 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
17779 if (strlcpy(desc_flag.name, res->name,
17780 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
17781 printf("Flag name too long\n");
17784 desc_flag.flags = 0;
17785 flag = rte_mbuf_dynflag_register(&desc_flag);
17787 printf("Can't register flag\n");
17790 strcpy(dynf_names[flag], desc_flag.name);
17792 old_port_flags = ports[res->port_id].mbuf_dynf;
17793 if (!strcmp(res->value, "set")) {
17794 ports[res->port_id].mbuf_dynf |= 1UL << flag;
17795 if (old_port_flags == 0)
17796 add_tx_dynf_callback(res->port_id);
17798 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
17799 if (ports[res->port_id].mbuf_dynf == 0)
17800 remove_tx_dynf_callback(res->port_id);
17804 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
17805 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17807 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
17808 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17809 keyword, "config");
17810 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
17811 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17813 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
17814 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17816 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
17817 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17819 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
17820 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17821 value, "set#clear");
17823 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
17824 .f = cmd_config_dynf_specific_parsed,
17826 .help_str = "port config <port id> dynf <name> set|clear",
17828 (void *)&cmd_config_tx_dynf_specific_port,
17829 (void *)&cmd_config_tx_dynf_specific_keyword,
17830 (void *)&cmd_config_tx_dynf_specific_port_id,
17831 (void *)&cmd_config_tx_dynf_specific_item,
17832 (void *)&cmd_config_tx_dynf_specific_name,
17833 (void *)&cmd_config_tx_dynf_specific_value,
17838 /* *** display tx_metadata per port configuration *** */
17839 struct cmd_show_tx_metadata_result {
17840 cmdline_fixed_string_t cmd_show;
17841 cmdline_fixed_string_t cmd_port;
17842 cmdline_fixed_string_t cmd_keyword;
17847 cmd_show_tx_metadata_parsed(void *parsed_result,
17848 __rte_unused struct cmdline *cl,
17849 __rte_unused void *data)
17851 struct cmd_show_tx_metadata_result *res = parsed_result;
17853 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17854 printf("invalid port id %u\n", res->cmd_pid);
17857 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
17858 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
17859 ports[res->cmd_pid].tx_metadata);
17863 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
17864 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17866 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
17867 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17869 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
17870 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
17872 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
17873 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17874 cmd_keyword, "tx_metadata");
17876 cmdline_parse_inst_t cmd_show_tx_metadata = {
17877 .f = cmd_show_tx_metadata_parsed,
17879 .help_str = "show port <port_id> tx_metadata",
17881 (void *)&cmd_show_tx_metadata_show,
17882 (void *)&cmd_show_tx_metadata_port,
17883 (void *)&cmd_show_tx_metadata_pid,
17884 (void *)&cmd_show_tx_metadata_keyword,
17889 /* *** show fec capability per port configuration *** */
17890 struct cmd_show_fec_capability_result {
17891 cmdline_fixed_string_t cmd_show;
17892 cmdline_fixed_string_t cmd_port;
17893 cmdline_fixed_string_t cmd_fec;
17894 cmdline_fixed_string_t cmd_keyword;
17899 cmd_show_fec_capability_parsed(void *parsed_result,
17900 __rte_unused struct cmdline *cl,
17901 __rte_unused void *data)
17903 #define FEC_CAP_NUM 2
17904 struct cmd_show_fec_capability_result *res = parsed_result;
17905 struct rte_eth_fec_capa speed_fec_capa[FEC_CAP_NUM];
17906 unsigned int num = FEC_CAP_NUM;
17907 unsigned int ret_num;
17910 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17911 printf("Invalid port id %u\n", res->cmd_pid);
17915 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
17916 if (ret == -ENOTSUP) {
17917 printf("Function not implemented\n");
17919 } else if (ret < 0) {
17920 printf("Get FEC capability failed\n");
17924 ret_num = (unsigned int)ret;
17925 show_fec_capability(ret_num, speed_fec_capa);
17928 cmdline_parse_token_string_t cmd_show_fec_capability_show =
17929 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17931 cmdline_parse_token_string_t cmd_show_fec_capability_port =
17932 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17934 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
17935 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
17937 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
17938 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17940 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
17941 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17942 cmd_keyword, "capabilities");
17944 cmdline_parse_inst_t cmd_show_capability = {
17945 .f = cmd_show_fec_capability_parsed,
17947 .help_str = "show port <port_id> fec capabilities",
17949 (void *)&cmd_show_fec_capability_show,
17950 (void *)&cmd_show_fec_capability_port,
17951 (void *)&cmd_show_fec_capability_pid,
17952 (void *)&cmd_show_fec_capability_fec,
17953 (void *)&cmd_show_fec_capability_keyword,
17958 /* *** show fec mode per port configuration *** */
17959 struct cmd_show_fec_metadata_result {
17960 cmdline_fixed_string_t cmd_show;
17961 cmdline_fixed_string_t cmd_port;
17962 cmdline_fixed_string_t cmd_keyword;
17967 cmd_show_fec_mode_parsed(void *parsed_result,
17968 __rte_unused struct cmdline *cl,
17969 __rte_unused void *data)
17971 #define FEC_NAME_SIZE 16
17972 struct cmd_show_fec_metadata_result *res = parsed_result;
17974 char buf[FEC_NAME_SIZE];
17977 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17978 printf("Invalid port id %u\n", res->cmd_pid);
17981 ret = rte_eth_fec_get(res->cmd_pid, &mode);
17982 if (ret == -ENOTSUP) {
17983 printf("Function not implemented\n");
17985 } else if (ret < 0) {
17986 printf("Get FEC mode failed\n");
17991 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
17992 strlcpy(buf, "off", sizeof(buf));
17994 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17995 strlcpy(buf, "auto", sizeof(buf));
17997 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17998 strlcpy(buf, "baser", sizeof(buf));
18000 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
18001 strlcpy(buf, "rs", sizeof(buf));
18007 printf("%s\n", buf);
18010 cmdline_parse_token_string_t cmd_show_fec_mode_show =
18011 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
18013 cmdline_parse_token_string_t cmd_show_fec_mode_port =
18014 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
18016 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
18017 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
18019 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
18020 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
18021 cmd_keyword, "fec_mode");
18023 cmdline_parse_inst_t cmd_show_fec_mode = {
18024 .f = cmd_show_fec_mode_parsed,
18026 .help_str = "show port <port_id> fec_mode",
18028 (void *)&cmd_show_fec_mode_show,
18029 (void *)&cmd_show_fec_mode_port,
18030 (void *)&cmd_show_fec_mode_pid,
18031 (void *)&cmd_show_fec_mode_keyword,
18036 /* *** set fec mode per port configuration *** */
18037 struct cmd_set_port_fec_mode {
18038 cmdline_fixed_string_t set;
18039 cmdline_fixed_string_t port;
18041 cmdline_fixed_string_t fec_mode;
18042 cmdline_fixed_string_t fec_value;
18045 /* Common CLI fields for set fec mode */
18046 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
18047 TOKEN_STRING_INITIALIZER
18048 (struct cmd_set_port_fec_mode,
18050 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
18051 TOKEN_STRING_INITIALIZER
18052 (struct cmd_set_port_fec_mode,
18054 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
18055 TOKEN_NUM_INITIALIZER
18056 (struct cmd_set_port_fec_mode,
18058 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
18059 TOKEN_STRING_INITIALIZER
18060 (struct cmd_set_port_fec_mode,
18061 fec_mode, "fec_mode");
18062 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
18063 TOKEN_STRING_INITIALIZER
18064 (struct cmd_set_port_fec_mode,
18068 cmd_set_port_fec_mode_parsed(
18069 void *parsed_result,
18070 __rte_unused struct cmdline *cl,
18071 __rte_unused void *data)
18073 struct cmd_set_port_fec_mode *res = parsed_result;
18074 uint16_t port_id = res->port_id;
18078 ret = parse_fec_mode(res->fec_value, &mode);
18080 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
18085 ret = rte_eth_fec_set(port_id, mode);
18086 if (ret == -ENOTSUP) {
18087 printf("Function not implemented\n");
18089 } else if (ret < 0) {
18090 printf("Set FEC mode failed\n");
18095 cmdline_parse_inst_t cmd_set_fec_mode = {
18096 .f = cmd_set_port_fec_mode_parsed,
18098 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
18100 (void *)&cmd_set_port_fec_mode_set,
18101 (void *)&cmd_set_port_fec_mode_port,
18102 (void *)&cmd_set_port_fec_mode_port_id,
18103 (void *)&cmd_set_port_fec_mode_str,
18104 (void *)&cmd_set_port_fec_mode_value,
18109 /* show port supported ptypes */
18111 /* Common result structure for show port ptypes */
18112 struct cmd_show_port_supported_ptypes_result {
18113 cmdline_fixed_string_t show;
18114 cmdline_fixed_string_t port;
18116 cmdline_fixed_string_t ptypes;
18119 /* Common CLI fields for show port ptypes */
18120 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
18121 TOKEN_STRING_INITIALIZER
18122 (struct cmd_show_port_supported_ptypes_result,
18124 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
18125 TOKEN_STRING_INITIALIZER
18126 (struct cmd_show_port_supported_ptypes_result,
18128 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
18129 TOKEN_NUM_INITIALIZER
18130 (struct cmd_show_port_supported_ptypes_result,
18132 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
18133 TOKEN_STRING_INITIALIZER
18134 (struct cmd_show_port_supported_ptypes_result,
18138 cmd_show_port_supported_ptypes_parsed(
18139 void *parsed_result,
18140 __rte_unused struct cmdline *cl,
18141 __rte_unused void *data)
18143 #define RSVD_PTYPE_MASK 0xf0000000
18144 #define MAX_PTYPES_PER_LAYER 16
18145 #define LTYPE_NAMESIZE 32
18146 #define PTYPE_NAMESIZE 256
18147 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
18148 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
18149 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
18150 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
18151 uint16_t port_id = res->port_id;
18154 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
18158 while (ptype_mask != RSVD_PTYPE_MASK) {
18160 switch (ptype_mask) {
18161 case RTE_PTYPE_L2_MASK:
18162 strlcpy(ltype, "L2", sizeof(ltype));
18164 case RTE_PTYPE_L3_MASK:
18165 strlcpy(ltype, "L3", sizeof(ltype));
18167 case RTE_PTYPE_L4_MASK:
18168 strlcpy(ltype, "L4", sizeof(ltype));
18170 case RTE_PTYPE_TUNNEL_MASK:
18171 strlcpy(ltype, "Tunnel", sizeof(ltype));
18173 case RTE_PTYPE_INNER_L2_MASK:
18174 strlcpy(ltype, "Inner L2", sizeof(ltype));
18176 case RTE_PTYPE_INNER_L3_MASK:
18177 strlcpy(ltype, "Inner L3", sizeof(ltype));
18179 case RTE_PTYPE_INNER_L4_MASK:
18180 strlcpy(ltype, "Inner L4", sizeof(ltype));
18186 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
18187 ptype_mask, ptypes,
18188 MAX_PTYPES_PER_LAYER);
18191 printf("Supported %s ptypes:\n", ltype);
18193 printf("%s ptypes unsupported\n", ltype);
18195 for (i = 0; i < ret; ++i) {
18196 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
18197 printf("%s\n", buf);
18204 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
18205 .f = cmd_show_port_supported_ptypes_parsed,
18207 .help_str = "show port <port_id> ptypes",
18209 (void *)&cmd_show_port_supported_ptypes_show,
18210 (void *)&cmd_show_port_supported_ptypes_port,
18211 (void *)&cmd_show_port_supported_ptypes_port_id,
18212 (void *)&cmd_show_port_supported_ptypes_ptypes,
18217 /* *** display rx/tx descriptor status *** */
18218 struct cmd_show_rx_tx_desc_status_result {
18219 cmdline_fixed_string_t cmd_show;
18220 cmdline_fixed_string_t cmd_port;
18221 cmdline_fixed_string_t cmd_keyword;
18222 cmdline_fixed_string_t cmd_desc;
18223 cmdline_fixed_string_t cmd_status;
18230 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
18231 __rte_unused struct cmdline *cl,
18232 __rte_unused void *data)
18234 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
18237 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18238 printf("invalid port id %u\n", res->cmd_pid);
18242 if (!strcmp(res->cmd_keyword, "rxq")) {
18243 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
18246 printf("Invalid queueid = %d\n", res->cmd_qid);
18249 if (rc == RTE_ETH_RX_DESC_AVAIL)
18250 printf("Desc status = AVAILABLE\n");
18251 else if (rc == RTE_ETH_RX_DESC_DONE)
18252 printf("Desc status = DONE\n");
18254 printf("Desc status = UNAVAILABLE\n");
18255 } else if (!strcmp(res->cmd_keyword, "txq")) {
18256 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
18259 printf("Invalid queueid = %d\n", res->cmd_qid);
18262 if (rc == RTE_ETH_TX_DESC_FULL)
18263 printf("Desc status = FULL\n");
18264 else if (rc == RTE_ETH_TX_DESC_DONE)
18265 printf("Desc status = DONE\n");
18267 printf("Desc status = UNAVAILABLE\n");
18271 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
18272 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18274 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
18275 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18277 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
18278 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18280 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
18281 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18282 cmd_keyword, "rxq#txq");
18283 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
18284 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18286 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
18287 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18289 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
18290 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18292 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
18293 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18294 cmd_status, "status");
18295 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
18296 .f = cmd_show_rx_tx_desc_status_parsed,
18298 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
18301 (void *)&cmd_show_rx_tx_desc_status_show,
18302 (void *)&cmd_show_rx_tx_desc_status_port,
18303 (void *)&cmd_show_rx_tx_desc_status_pid,
18304 (void *)&cmd_show_rx_tx_desc_status_keyword,
18305 (void *)&cmd_show_rx_tx_desc_status_qid,
18306 (void *)&cmd_show_rx_tx_desc_status_desc,
18307 (void *)&cmd_show_rx_tx_desc_status_did,
18308 (void *)&cmd_show_rx_tx_desc_status_status,
18313 /* Common result structure for set port ptypes */
18314 struct cmd_set_port_ptypes_result {
18315 cmdline_fixed_string_t set;
18316 cmdline_fixed_string_t port;
18318 cmdline_fixed_string_t ptype_mask;
18322 /* Common CLI fields for set port ptypes */
18323 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
18324 TOKEN_STRING_INITIALIZER
18325 (struct cmd_set_port_ptypes_result,
18327 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
18328 TOKEN_STRING_INITIALIZER
18329 (struct cmd_set_port_ptypes_result,
18331 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
18332 TOKEN_NUM_INITIALIZER
18333 (struct cmd_set_port_ptypes_result,
18335 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
18336 TOKEN_STRING_INITIALIZER
18337 (struct cmd_set_port_ptypes_result,
18338 ptype_mask, "ptype_mask");
18339 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
18340 TOKEN_NUM_INITIALIZER
18341 (struct cmd_set_port_ptypes_result,
18345 cmd_set_port_ptypes_parsed(
18346 void *parsed_result,
18347 __rte_unused struct cmdline *cl,
18348 __rte_unused void *data)
18350 struct cmd_set_port_ptypes_result *res = parsed_result;
18351 #define PTYPE_NAMESIZE 256
18352 char ptype_name[PTYPE_NAMESIZE];
18353 uint16_t port_id = res->port_id;
18354 uint32_t ptype_mask = res->mask;
18357 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
18360 printf("Port %d doesn't support any ptypes.\n", port_id);
18364 uint32_t ptypes[ret];
18366 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
18368 printf("Unable to set requested ptypes for Port %d\n", port_id);
18372 printf("Successfully set following ptypes for Port %d\n", port_id);
18373 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
18374 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
18375 printf("%s\n", ptype_name);
18378 clear_ptypes = false;
18381 cmdline_parse_inst_t cmd_set_port_ptypes = {
18382 .f = cmd_set_port_ptypes_parsed,
18384 .help_str = "set port <port_id> ptype_mask <mask>",
18386 (void *)&cmd_set_port_ptypes_set,
18387 (void *)&cmd_set_port_ptypes_port,
18388 (void *)&cmd_set_port_ptypes_port_id,
18389 (void *)&cmd_set_port_ptypes_mask_str,
18390 (void *)&cmd_set_port_ptypes_mask_u32,
18395 /* *** display mac addresses added to a port *** */
18396 struct cmd_showport_macs_result {
18397 cmdline_fixed_string_t cmd_show;
18398 cmdline_fixed_string_t cmd_port;
18399 cmdline_fixed_string_t cmd_keyword;
18404 cmd_showport_macs_parsed(void *parsed_result,
18405 __rte_unused struct cmdline *cl,
18406 __rte_unused void *data)
18408 struct cmd_showport_macs_result *res = parsed_result;
18410 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
18413 if (!strcmp(res->cmd_keyword, "macs"))
18414 show_macs(res->cmd_pid);
18415 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
18416 show_mcast_macs(res->cmd_pid);
18419 cmdline_parse_token_string_t cmd_showport_macs_show =
18420 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
18422 cmdline_parse_token_string_t cmd_showport_macs_port =
18423 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
18425 cmdline_parse_token_num_t cmd_showport_macs_pid =
18426 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
18428 cmdline_parse_token_string_t cmd_showport_macs_keyword =
18429 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
18430 cmd_keyword, "macs#mcast_macs");
18432 cmdline_parse_inst_t cmd_showport_macs = {
18433 .f = cmd_showport_macs_parsed,
18435 .help_str = "show port <port_id> macs|mcast_macs",
18437 (void *)&cmd_showport_macs_show,
18438 (void *)&cmd_showport_macs_port,
18439 (void *)&cmd_showport_macs_pid,
18440 (void *)&cmd_showport_macs_keyword,
18445 /* ******************************************************************************** */
18447 /* list of instructions */
18448 cmdline_parse_ctx_t main_ctx[] = {
18449 (cmdline_parse_inst_t *)&cmd_help_brief,
18450 (cmdline_parse_inst_t *)&cmd_help_long,
18451 (cmdline_parse_inst_t *)&cmd_quit,
18452 (cmdline_parse_inst_t *)&cmd_load_from_file,
18453 (cmdline_parse_inst_t *)&cmd_showport,
18454 (cmdline_parse_inst_t *)&cmd_showqueue,
18455 (cmdline_parse_inst_t *)&cmd_showeeprom,
18456 (cmdline_parse_inst_t *)&cmd_showportall,
18457 (cmdline_parse_inst_t *)&cmd_showdevice,
18458 (cmdline_parse_inst_t *)&cmd_showcfg,
18459 (cmdline_parse_inst_t *)&cmd_showfwdall,
18460 (cmdline_parse_inst_t *)&cmd_start,
18461 (cmdline_parse_inst_t *)&cmd_start_tx_first,
18462 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18463 (cmdline_parse_inst_t *)&cmd_set_link_up,
18464 (cmdline_parse_inst_t *)&cmd_set_link_down,
18465 (cmdline_parse_inst_t *)&cmd_reset,
18466 (cmdline_parse_inst_t *)&cmd_set_numbers,
18467 (cmdline_parse_inst_t *)&cmd_set_log,
18468 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
18469 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
18470 (cmdline_parse_inst_t *)&cmd_set_txpkts,
18471 (cmdline_parse_inst_t *)&cmd_set_txsplit,
18472 (cmdline_parse_inst_t *)&cmd_set_txtimes,
18473 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
18474 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18475 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18476 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18477 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18478 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18479 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18480 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18481 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18482 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
18483 (cmdline_parse_inst_t *)&cmd_set_link_check,
18484 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18485 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
18486 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18487 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
18488 #ifdef RTE_NET_BOND
18489 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18490 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
18491 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18492 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18493 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18494 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
18495 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18496 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18497 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18498 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18499 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18501 (cmdline_parse_inst_t *)&cmd_vlan_offload,
18502 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
18503 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18504 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18505 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18506 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18507 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18508 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18509 (cmdline_parse_inst_t *)&cmd_csum_set,
18510 (cmdline_parse_inst_t *)&cmd_csum_show,
18511 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
18512 (cmdline_parse_inst_t *)&cmd_tso_set,
18513 (cmdline_parse_inst_t *)&cmd_tso_show,
18514 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18515 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18516 (cmdline_parse_inst_t *)&cmd_gro_enable,
18517 (cmdline_parse_inst_t *)&cmd_gro_flush,
18518 (cmdline_parse_inst_t *)&cmd_gro_show,
18519 (cmdline_parse_inst_t *)&cmd_gso_enable,
18520 (cmdline_parse_inst_t *)&cmd_gso_size,
18521 (cmdline_parse_inst_t *)&cmd_gso_show,
18522 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18523 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18524 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18525 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18526 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18527 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18528 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18529 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18530 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
18531 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
18532 (cmdline_parse_inst_t *)&cmd_config_dcb,
18533 (cmdline_parse_inst_t *)&cmd_read_reg,
18534 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
18535 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
18536 (cmdline_parse_inst_t *)&cmd_write_reg,
18537 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18538 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
18539 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18540 (cmdline_parse_inst_t *)&cmd_stop,
18541 (cmdline_parse_inst_t *)&cmd_mac_addr,
18542 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18543 (cmdline_parse_inst_t *)&cmd_set_qmap,
18544 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18545 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
18546 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
18547 (cmdline_parse_inst_t *)&cmd_operate_port,
18548 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
18549 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
18550 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
18551 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
18552 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18553 (cmdline_parse_inst_t *)&cmd_config_speed_all,
18554 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
18555 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
18556 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18557 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
18558 (cmdline_parse_inst_t *)&cmd_config_mtu,
18559 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18560 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
18561 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18562 (cmdline_parse_inst_t *)&cmd_config_rss,
18563 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18564 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18565 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18566 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18567 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
18568 (cmdline_parse_inst_t *)&cmd_showport_reta,
18569 (cmdline_parse_inst_t *)&cmd_showport_macs,
18570 (cmdline_parse_inst_t *)&cmd_config_burst,
18571 (cmdline_parse_inst_t *)&cmd_config_thresh,
18572 (cmdline_parse_inst_t *)&cmd_config_threshold,
18573 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
18574 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
18575 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
18576 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
18577 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
18578 (cmdline_parse_inst_t *)&cmd_global_config,
18579 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
18580 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
18581 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
18582 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
18583 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
18584 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
18585 (cmdline_parse_inst_t *)&cmd_dump,
18586 (cmdline_parse_inst_t *)&cmd_dump_one,
18587 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
18588 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
18589 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
18590 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
18591 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
18592 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
18593 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
18594 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
18595 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
18596 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
18597 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
18598 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
18599 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
18600 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
18601 (cmdline_parse_inst_t *)&cmd_flow,
18602 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
18603 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
18604 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
18605 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
18606 (cmdline_parse_inst_t *)&cmd_create_port_meter,
18607 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
18608 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
18609 (cmdline_parse_inst_t *)&cmd_del_port_meter,
18610 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
18611 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
18612 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
18613 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
18614 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
18615 (cmdline_parse_inst_t *)&cmd_mcast_addr,
18616 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
18617 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
18618 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
18619 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
18620 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
18621 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
18622 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
18623 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
18624 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
18625 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
18626 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
18627 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
18628 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
18629 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
18630 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
18631 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
18632 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
18633 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
18634 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
18635 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
18636 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
18637 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
18638 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
18639 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
18640 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
18641 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
18642 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
18643 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
18644 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
18645 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
18646 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
18647 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18648 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18649 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
18650 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
18651 (cmdline_parse_inst_t *)&cmd_set_vxlan,
18652 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
18653 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18654 (cmdline_parse_inst_t *)&cmd_set_nvgre,
18655 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18656 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
18657 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18658 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
18659 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18660 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18661 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18662 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18663 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18664 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18665 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18666 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18667 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18668 (cmdline_parse_inst_t *)&cmd_ddp_add,
18669 (cmdline_parse_inst_t *)&cmd_ddp_del,
18670 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
18671 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
18672 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
18673 (cmdline_parse_inst_t *)&cmd_clear_input_set,
18674 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
18675 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18676 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
18677 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
18678 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18679 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18680 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18681 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18683 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18684 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18685 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18686 (cmdline_parse_inst_t *)&cmd_queue_region,
18687 (cmdline_parse_inst_t *)&cmd_region_flowtype,
18688 (cmdline_parse_inst_t *)&cmd_user_priority_region,
18689 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
18690 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18691 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18692 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18693 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18694 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18695 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18696 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18697 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18698 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18699 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18700 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18701 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18702 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18703 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18704 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
18705 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18706 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18707 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18708 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18709 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18710 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18711 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18712 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18713 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18714 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18715 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18716 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18717 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18718 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18719 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18720 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
18721 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
18722 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
18724 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
18725 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
18727 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
18728 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
18729 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
18730 (cmdline_parse_inst_t *)&cmd_set_raw,
18731 (cmdline_parse_inst_t *)&cmd_show_set_raw,
18732 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
18733 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
18734 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
18735 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
18736 (cmdline_parse_inst_t *)&cmd_show_capability,
18740 /* read cmdline commands from file */
18742 cmdline_read_from_file(const char *filename)
18744 struct cmdline *cl;
18746 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
18748 printf("Failed to create file based cmdline context: %s\n",
18753 cmdline_interact(cl);
18758 printf("Read CLI commands from %s\n", filename);
18761 /* prompt function, called from main on MAIN lcore */
18765 /* initialize non-constant commands */
18766 cmd_set_fwd_mode_init();
18767 cmd_set_fwd_retry_mode_init();
18769 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
18770 if (testpmd_cl == NULL)
18772 cmdline_interact(testpmd_cl);
18773 cmdline_stdin_exit(testpmd_cl);
18779 if (testpmd_cl != NULL)
18780 cmdline_quit(testpmd_cl);
18784 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18786 if (id == (portid_t)RTE_PORT_ALL) {
18789 RTE_ETH_FOREACH_DEV(pid) {
18790 /* check if need_reconfig has been set to 1 */
18791 if (ports[pid].need_reconfig == 0)
18792 ports[pid].need_reconfig = dev;
18793 /* check if need_reconfig_queues has been set to 1 */
18794 if (ports[pid].need_reconfig_queues == 0)
18795 ports[pid].need_reconfig_queues = queue;
18797 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18798 /* check if need_reconfig has been set to 1 */
18799 if (ports[id].need_reconfig == 0)
18800 ports[id].need_reconfig = dev;
18801 /* check if need_reconfig_queues has been set to 1 */
18802 if (ports[id].need_reconfig_queues == 0)
18803 ports[id].need_reconfig_queues = queue;